]> git.baikalelectronics.ru Git - kernel.git/commit
dm table: fix iterate_devices based device capability checks
authorJeffle Xu <jefflexu@linux.alibaba.com>
Tue, 2 Feb 2021 03:35:28 +0000 (11:35 +0800)
committerMike Snitzer <snitzer@redhat.com>
Tue, 9 Feb 2021 13:45:25 +0000 (08:45 -0500)
commit3460575b13e8a01a65ab3263628727eb6f5db1e4
tree925f525a4dfaac836d462759646c3ccf5de4e73c
parent5a4d54384302bd282198507ae2c2d0740bdd19fc
dm table: fix iterate_devices based device capability checks

According to the definition of dm_iterate_devices_fn:
 * This function must iterate through each section of device used by the
 * target until it encounters a non-zero return code, which it then returns.
 * Returns zero if no callout returned non-zero.

For some target type (e.g. dm-stripe), one call of iterate_devices() may
iterate multiple underlying devices internally, in which case a non-zero
return code returned by iterate_devices_callout_fn will stop the iteration
in advance. No iterate_devices_callout_fn should return non-zero unless
device iteration should stop.

Rename dm_table_requires_stable_pages() to dm_table_any_dev_attr() and
elevate it for reuse to stop iterating (and return non-zero) on the
first device that causes iterate_devices_callout_fn to return non-zero.
Use dm_table_any_dev_attr() to properly iterate through devices.

Rename device_is_nonrot() to device_is_rotational() and invert logic
accordingly to fix improper disposition.

Fixes: 0af311677e21 ("dm table: clear add_random unless all devices have it set")
Fixes: 9c9257971b9a ("dm table: propagate non rotational flag")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-table.c