public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] dm table: fix iterate_devices based device capability checks" failed to apply to 4.4-stable tree
@ 2021-03-01 13:44 gregkh
  2021-03-05  6:30 ` [PATCH 4.4.y 0/2] dm: device capability check fixes Jeffle Xu
  0 siblings, 1 reply; 9+ messages in thread
From: gregkh @ 2021-03-01 13:44 UTC (permalink / raw)
  To: jefflexu, snitzer; +Cc: stable


The patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From a4c8dd9c2d0987cf542a2a0c42684c9c6d78a04e Mon Sep 17 00:00:00 2001
From: Jeffle Xu <jefflexu@linux.alibaba.com>
Date: Tue, 2 Feb 2021 11:35:28 +0800
Subject: [PATCH] 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: c3c4555edd10 ("dm table: clear add_random unless all devices have it set")
Fixes: 4693c9668fdc ("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>

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 4acf2342f7ad..3e211e64f348 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1295,6 +1295,46 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
 	return &t->targets[(KEYS_PER_NODE * n) + k];
 }
 
+/*
+ * type->iterate_devices() should be called when the sanity check needs to
+ * iterate and check all underlying data devices. iterate_devices() will
+ * iterate all underlying data devices until it encounters a non-zero return
+ * code, returned by whether the input iterate_devices_callout_fn, or
+ * iterate_devices() itself internally.
+ *
+ * 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.
+ *
+ * Cases requiring _any_ underlying device supporting some kind of attribute,
+ * should use the iteration structure like dm_table_any_dev_attr(), or call
+ * it directly. @func should handle semantics of positive examples, e.g.
+ * capable of something.
+ *
+ * Cases requiring _all_ underlying devices supporting some kind of attribute,
+ * should use the iteration structure like dm_table_supports_nowait() or
+ * dm_table_supports_discards(). Or introduce dm_table_all_devs_attr() that
+ * uses an @anti_func that handle semantics of counter examples, e.g. not
+ * capable of something. So: return !dm_table_any_dev_attr(t, anti_func);
+ */
+static bool dm_table_any_dev_attr(struct dm_table *t,
+				  iterate_devices_callout_fn func)
+{
+	struct dm_target *ti;
+	unsigned int i;
+
+	for (i = 0; i < dm_table_get_num_targets(t); i++) {
+		ti = dm_table_get_target(t, i);
+
+		if (ti->type->iterate_devices &&
+		    ti->type->iterate_devices(ti, func, NULL))
+			return true;
+        }
+
+	return false;
+}
+
 static int count_device(struct dm_target *ti, struct dm_dev *dev,
 			sector_t start, sector_t len, void *data)
 {
@@ -1595,12 +1635,12 @@ static int dm_table_supports_dax_write_cache(struct dm_table *t)
 	return false;
 }
 
-static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev,
-			    sector_t start, sector_t len, void *data)
+static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev,
+				sector_t start, sector_t len, void *data)
 {
 	struct request_queue *q = bdev_get_queue(dev->bdev);
 
-	return q && blk_queue_nonrot(q);
+	return q && !blk_queue_nonrot(q);
 }
 
 static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
@@ -1611,23 +1651,6 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
 	return q && !blk_queue_add_random(q);
 }
 
-static bool dm_table_all_devices_attribute(struct dm_table *t,
-					   iterate_devices_callout_fn func)
-{
-	struct dm_target *ti;
-	unsigned i;
-
-	for (i = 0; i < dm_table_get_num_targets(t); i++) {
-		ti = dm_table_get_target(t, i);
-
-		if (!ti->type->iterate_devices ||
-		    !ti->type->iterate_devices(ti, func, NULL))
-			return false;
-	}
-
-	return true;
-}
-
 static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
 					 sector_t start, sector_t len, void *data)
 {
@@ -1779,27 +1802,6 @@ static int device_requires_stable_pages(struct dm_target *ti,
 	return q && blk_queue_stable_writes(q);
 }
 
-/*
- * If any underlying device requires stable pages, a table must require
- * them as well.  Only targets that support iterate_devices are considered:
- * don't want error, zero, etc to require stable pages.
- */
-static bool dm_table_requires_stable_pages(struct dm_table *t)
-{
-	struct dm_target *ti;
-	unsigned i;
-
-	for (i = 0; i < dm_table_get_num_targets(t); i++) {
-		ti = dm_table_get_target(t, i);
-
-		if (ti->type->iterate_devices &&
-		    ti->type->iterate_devices(ti, device_requires_stable_pages, NULL))
-			return true;
-	}
-
-	return false;
-}
-
 void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 			       struct queue_limits *limits)
 {
@@ -1849,10 +1851,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 		dax_write_cache(t->md->dax_dev, true);
 
 	/* Ensure that all underlying devices are non-rotational. */
-	if (dm_table_all_devices_attribute(t, device_is_nonrot))
-		blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
-	else
+	if (dm_table_any_dev_attr(t, device_is_rotational))
 		blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
+	else
+		blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
 
 	if (!dm_table_supports_write_same(t))
 		q->limits.max_write_same_sectors = 0;
@@ -1864,8 +1866,11 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	/*
 	 * Some devices don't use blk_integrity but still want stable pages
 	 * because they do their own checksumming.
+	 * If any underlying device requires stable pages, a table must require
+	 * them as well.  Only targets that support iterate_devices are considered:
+	 * don't want error, zero, etc to require stable pages.
 	 */
-	if (dm_table_requires_stable_pages(t))
+	if (dm_table_any_dev_attr(t, device_requires_stable_pages))
 		blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q);
 	else
 		blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, q);
@@ -1876,7 +1881,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	 * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not
 	 * have it set.
 	 */
-	if (blk_queue_add_random(q) && dm_table_all_devices_attribute(t, device_is_not_random))
+	if (blk_queue_add_random(q) && dm_table_any_dev_attr(t, device_is_not_random))
 		blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
 
 	/*


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4.4.y 0/2] dm: device capability check fixes
  2021-03-01 13:44 FAILED: patch "[PATCH] dm table: fix iterate_devices based device capability checks" failed to apply to 4.4-stable tree gregkh
@ 2021-03-05  6:30 ` Jeffle Xu
  2021-03-05  6:30   ` [PATCH 4.4.y 1/2] dm table: fix iterate_devices based device capability checks Jeffle Xu
                     ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jeffle Xu @ 2021-03-05  6:30 UTC (permalink / raw)
  To: gregkh, sashal; +Cc: stable, jefflexu, snitzer

- patch 1 is from upstream
- patch 2 is to fix the code specific to 4.4 (has been removed in upstream)

Jeffle Xu (2):
  dm table: fix iterate_devices based device capability checks
  dm table: fix no_sg_merge iterate_devices based device capability
    checks

 drivers/md/dm-table.c | 83 +++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 30 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 4.4.y 1/2] dm table: fix iterate_devices based device capability checks
  2021-03-05  6:30 ` [PATCH 4.4.y 0/2] dm: device capability check fixes Jeffle Xu
@ 2021-03-05  6:30   ` Jeffle Xu
  2021-03-05  6:30   ` [PATCH 4.4.y 2/2] dm table: fix no_sg_merge " Jeffle Xu
  2021-03-05  6:47   ` [PATCH 4.4.y 0/2] dm: device capability check fixes Greg KH
  2 siblings, 0 replies; 9+ messages in thread
From: Jeffle Xu @ 2021-03-05  6:30 UTC (permalink / raw)
  To: gregkh, sashal; +Cc: stable, jefflexu, snitzer

commit a4c8dd9c2d0987cf542a2a0c42684c9c6d78a04e upstream.

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: c3c4555edd10 ("dm table: clear add_random unless all devices have it set")
Fixes: 4693c9668fdc ("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>
[jeffle: no stable writes]
---
 drivers/md/dm-table.c | 71 ++++++++++++++++++++++++++++---------------
 1 file changed, 47 insertions(+), 24 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index a5a6c7f073af..6580de65b81d 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1210,6 +1210,46 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
 	return &t->targets[(KEYS_PER_NODE * n) + k];
 }
 
+/*
+ * type->iterate_devices() should be called when the sanity check needs to
+ * iterate and check all underlying data devices. iterate_devices() will
+ * iterate all underlying data devices until it encounters a non-zero return
+ * code, returned by whether the input iterate_devices_callout_fn, or
+ * iterate_devices() itself internally.
+ *
+ * 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.
+ *
+ * Cases requiring _any_ underlying device supporting some kind of attribute,
+ * should use the iteration structure like dm_table_any_dev_attr(), or call
+ * it directly. @func should handle semantics of positive examples, e.g.
+ * capable of something.
+ *
+ * Cases requiring _all_ underlying devices supporting some kind of attribute,
+ * should use the iteration structure like dm_table_supports_nowait() or
+ * dm_table_supports_discards(). Or introduce dm_table_all_devs_attr() that
+ * uses an @anti_func that handle semantics of counter examples, e.g. not
+ * capable of something. So: return !dm_table_any_dev_attr(t, anti_func);
+ */
+static bool dm_table_any_dev_attr(struct dm_table *t,
+				  iterate_devices_callout_fn func)
+{
+	struct dm_target *ti;
+	unsigned int i;
+
+	for (i = 0; i < dm_table_get_num_targets(t); i++) {
+		ti = dm_table_get_target(t, i);
+
+		if (ti->type->iterate_devices &&
+		    ti->type->iterate_devices(ti, func, NULL))
+			return true;
+        }
+
+	return false;
+}
+
 static int count_device(struct dm_target *ti, struct dm_dev *dev,
 			sector_t start, sector_t len, void *data)
 {
@@ -1380,12 +1420,12 @@ static bool dm_table_discard_zeroes_data(struct dm_table *t)
 	return true;
 }
 
-static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev,
-			    sector_t start, sector_t len, void *data)
+static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev,
+				sector_t start, sector_t len, void *data)
 {
 	struct request_queue *q = bdev_get_queue(dev->bdev);
 
-	return q && blk_queue_nonrot(q);
+	return q && !blk_queue_nonrot(q);
 }
 
 static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
@@ -1404,23 +1444,6 @@ static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev,
 	return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
 }
 
-static bool dm_table_all_devices_attribute(struct dm_table *t,
-					   iterate_devices_callout_fn func)
-{
-	struct dm_target *ti;
-	unsigned i = 0;
-
-	while (i < dm_table_get_num_targets(t)) {
-		ti = dm_table_get_target(t, i++);
-
-		if (!ti->type->iterate_devices ||
-		    !ti->type->iterate_devices(ti, func, NULL))
-			return false;
-	}
-
-	return true;
-}
-
 static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
 					 sector_t start, sector_t len, void *data)
 {
@@ -1511,10 +1534,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 		q->limits.discard_zeroes_data = 0;
 
 	/* Ensure that all underlying devices are non-rotational. */
-	if (dm_table_all_devices_attribute(t, device_is_nonrot))
-		queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
-	else
+	if (dm_table_any_dev_attr(t, device_is_rotational))
 		queue_flag_clear_unlocked(QUEUE_FLAG_NONROT, q);
+	else
+		queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
 
 	if (!dm_table_supports_write_same(t))
 		q->limits.max_write_same_sectors = 0;
@@ -1532,7 +1555,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	 * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not
 	 * have it set.
 	 */
-	if (blk_queue_add_random(q) && dm_table_all_devices_attribute(t, device_is_not_random))
+	if (blk_queue_add_random(q) && dm_table_any_dev_attr(t, device_is_not_random))
 		queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, q);
 
 	/*
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4.4.y 2/2] dm table: fix no_sg_merge iterate_devices based device capability checks
  2021-03-05  6:30 ` [PATCH 4.4.y 0/2] dm: device capability check fixes Jeffle Xu
  2021-03-05  6:30   ` [PATCH 4.4.y 1/2] dm table: fix iterate_devices based device capability checks Jeffle Xu
@ 2021-03-05  6:30   ` Jeffle Xu
  2021-03-05  6:46     ` Greg KH
  2021-03-08  3:21     ` JeffleXu
  2021-03-05  6:47   ` [PATCH 4.4.y 0/2] dm: device capability check fixes Greg KH
  2 siblings, 2 replies; 9+ messages in thread
From: Jeffle Xu @ 2021-03-05  6:30 UTC (permalink / raw)
  To: gregkh, sashal; +Cc: stable, jefflexu, snitzer

Similar to commit a4c8dd9c2d09 ("dm table: fix iterate_devices based
device capability checks"), fix NO_SG_MERGE capability check and invert
logic of the corresponding iterate_devices_callout_fn so that all
devices' NO_SG_MERGE capabilities are properly checked.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Fixes: 200612ec33e5 ("dm table: propagate QUEUE_FLAG_NO_SG_MERGE")
---
 drivers/md/dm-table.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 6580de65b81d..7ee520d4d216 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1436,12 +1436,12 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
 	return q && !blk_queue_add_random(q);
 }
 
-static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev,
-				   sector_t start, sector_t len, void *data)
+static int queue_no_sg_merge(struct dm_target *ti, struct dm_dev *dev,
+			     sector_t start, sector_t len, void *data)
 {
 	struct request_queue *q = bdev_get_queue(dev->bdev);
 
-	return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
+	return q && test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
 }
 
 static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
@@ -1542,10 +1542,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
 	if (!dm_table_supports_write_same(t))
 		q->limits.max_write_same_sectors = 0;
 
-	if (dm_table_all_devices_attribute(t, queue_supports_sg_merge))
-		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
-	else
+	if (dm_table_any_dev_attr(t, queue_no_sg_merge))
 		queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
+	else
+		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
 
 	dm_table_verify_integrity(t);
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH 4.4.y 2/2] dm table: fix no_sg_merge iterate_devices based device capability checks
  2021-03-05  6:30   ` [PATCH 4.4.y 2/2] dm table: fix no_sg_merge " Jeffle Xu
@ 2021-03-05  6:46     ` Greg KH
  2021-03-05  7:00       ` JeffleXu
  2021-03-08  3:21     ` JeffleXu
  1 sibling, 1 reply; 9+ messages in thread
From: Greg KH @ 2021-03-05  6:46 UTC (permalink / raw)
  To: Jeffle Xu; +Cc: sashal, stable, snitzer

On Fri, Mar 05, 2021 at 02:30:51PM +0800, Jeffle Xu wrote:
> Similar to commit a4c8dd9c2d09 ("dm table: fix iterate_devices based
> device capability checks"), fix NO_SG_MERGE capability check and invert
> logic of the corresponding iterate_devices_callout_fn so that all
> devices' NO_SG_MERGE capabilities are properly checked.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> Fixes: 200612ec33e5 ("dm table: propagate QUEUE_FLAG_NO_SG_MERGE")
> ---
>  drivers/md/dm-table.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

What is the git commit id of this patch in Linus's tree?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4.4.y 0/2] dm: device capability check fixes
  2021-03-05  6:30 ` [PATCH 4.4.y 0/2] dm: device capability check fixes Jeffle Xu
  2021-03-05  6:30   ` [PATCH 4.4.y 1/2] dm table: fix iterate_devices based device capability checks Jeffle Xu
  2021-03-05  6:30   ` [PATCH 4.4.y 2/2] dm table: fix no_sg_merge " Jeffle Xu
@ 2021-03-05  6:47   ` Greg KH
  2 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2021-03-05  6:47 UTC (permalink / raw)
  To: Jeffle Xu; +Cc: sashal, stable, snitzer

On Fri, Mar 05, 2021 at 02:30:49PM +0800, Jeffle Xu wrote:
> - patch 1 is from upstream
> - patch 2 is to fix the code specific to 4.4 (has been removed in upstream)
> 
> Jeffle Xu (2):
>   dm table: fix iterate_devices based device capability checks
>   dm table: fix no_sg_merge iterate_devices based device capability
>     checks

Why only 4.4.y for these?  What about all of the missing kernels in the
middle (4.9, 4.14, 4.19, 5.4)?  I can't apply fixes to one older branch
and ignore others, as someone might upgrade and have a regression.

Please provide fixes for those other trees too, and then I will be glad
to merge these.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4.4.y 2/2] dm table: fix no_sg_merge iterate_devices based device capability checks
  2021-03-05  6:46     ` Greg KH
@ 2021-03-05  7:00       ` JeffleXu
  0 siblings, 0 replies; 9+ messages in thread
From: JeffleXu @ 2021-03-05  7:00 UTC (permalink / raw)
  To: Greg KH; +Cc: sashal, stable, snitzer



On 3/5/21 2:46 PM, Greg KH wrote:
> On Fri, Mar 05, 2021 at 02:30:51PM +0800, Jeffle Xu wrote:
>> Similar to commit a4c8dd9c2d09 ("dm table: fix iterate_devices based
>> device capability checks"), fix NO_SG_MERGE capability check and invert
>> logic of the corresponding iterate_devices_callout_fn so that all
>> devices' NO_SG_MERGE capabilities are properly checked.
>>
>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
>> Fixes: 200612ec33e5 ("dm table: propagate QUEUE_FLAG_NO_SG_MERGE")
>> ---
>>  drivers/md/dm-table.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> What is the git commit id of this patch in Linus's tree?
> 
> thanks,
> 
> greg k-h
> 

The code this patch fixes, i.e., commit 200612ec33e5 ("dm table:
propagate QUEUE_FLAG_NO_SG_MERGE"), was removed since commit
2705c93742e9 ("block: kill QUEUE_FLAG_NO_SG_MERGE") in v5.1. Thus the
code base doesn't exist in the latest master branch.

-- 
Thanks,
Jeffle

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4.4.y 2/2] dm table: fix no_sg_merge iterate_devices based device capability checks
  2021-03-05  6:30   ` [PATCH 4.4.y 2/2] dm table: fix no_sg_merge " Jeffle Xu
  2021-03-05  6:46     ` Greg KH
@ 2021-03-08  3:21     ` JeffleXu
  2021-03-08 13:45       ` JeffleXu
  1 sibling, 1 reply; 9+ messages in thread
From: JeffleXu @ 2021-03-08  3:21 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: stable, Greg KH, sashal

Hi, Mike,

Would you please spare some time to review the following patches for
stable tree?

- [1] for 4.4.y
- [2] for 4.9.y
- [3] for 4.14.y
- [4] for 4.19.y

While backporting [5] for stable tree, there's some extra code specific
to stable tree needs to be fixed, see [6] for the background info.

[1] https://www.spinics.net/lists/stable/msg448728.html
[2] https://www.spinics.net/lists/stable/msg448737.html
[3] https://www.spinics.net/lists/stable/msg448740.html
[4] https://www.spinics.net/lists/stable/msg448748.html
[5]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.12-rc2&id=a4c8dd9c2d0987cf542a2a0c42684c9c6d78a04e
[6] https://www.spinics.net/lists/stable/msg448757.html


Thanks,
Jeffle


On 3/5/21 2:30 PM, Jeffle Xu wrote:
> Similar to commit a4c8dd9c2d09 ("dm table: fix iterate_devices based
> device capability checks"), fix NO_SG_MERGE capability check and invert
> logic of the corresponding iterate_devices_callout_fn so that all
> devices' NO_SG_MERGE capabilities are properly checked.
> 
> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
> Fixes: 200612ec33e5 ("dm table: propagate QUEUE_FLAG_NO_SG_MERGE")
> ---
>  drivers/md/dm-table.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
> index 6580de65b81d..7ee520d4d216 100644
> --- a/drivers/md/dm-table.c
> +++ b/drivers/md/dm-table.c
> @@ -1436,12 +1436,12 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
>  	return q && !blk_queue_add_random(q);
>  }
>  
> -static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev,
> -				   sector_t start, sector_t len, void *data)
> +static int queue_no_sg_merge(struct dm_target *ti, struct dm_dev *dev,
> +			     sector_t start, sector_t len, void *data)
>  {
>  	struct request_queue *q = bdev_get_queue(dev->bdev);
>  
> -	return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
> +	return q && test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
>  }
>  
>  static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
> @@ -1542,10 +1542,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
>  	if (!dm_table_supports_write_same(t))
>  		q->limits.max_write_same_sectors = 0;
>  
> -	if (dm_table_all_devices_attribute(t, queue_supports_sg_merge))
> -		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
> -	else
> +	if (dm_table_any_dev_attr(t, queue_no_sg_merge))
>  		queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
> +	else
> +		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
>  
>  	dm_table_verify_integrity(t);
>  
> 

-- 
Thanks,
Jeffle

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 4.4.y 2/2] dm table: fix no_sg_merge iterate_devices based device capability checks
  2021-03-08  3:21     ` JeffleXu
@ 2021-03-08 13:45       ` JeffleXu
  0 siblings, 0 replies; 9+ messages in thread
From: JeffleXu @ 2021-03-08 13:45 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: stable, Greg KH, sashal



On 3/8/21 11:21 AM, JeffleXu wrote:
> Hi, Mike,
> 
> Would you please spare some time to review the following patches for
> stable tree?
> 
> - [1] for 4.4.y
> - [2] for 4.9.y
> - [3] for 4.14.y
> - [4] for 4.19.y
> 
> While backporting [5] for stable tree, there's some extra code specific
> to stable tree needs to be fixed, see [6] for the background info.
> 
> [1] https://www.spinics.net/lists/stable/msg448728.html
> [2] https://www.spinics.net/lists/stable/msg448737.html
> [3] https://www.spinics.net/lists/stable/msg448740.html
> [4] https://www.spinics.net/lists/stable/msg448748.html
> [5]
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v5.12-rc2&id=a4c8dd9c2d0987cf542a2a0c42684c9c6d78a04e
> [6] https://www.spinics.net/lists/stable/msg448757.html
> 

Sorry, it seems that this patch should not be separated from patch [5],
as the NO_SG_MERGE capability check also calls
dm_table_all_devices_attribute(), which has been removed in patch [5].
It will break the per-patch build-test when leave this patch not applied.

I will send a new version later. Please review on the new version directly.


> 
> 
> On 3/5/21 2:30 PM, Jeffle Xu wrote:
>> Similar to commit a4c8dd9c2d09 ("dm table: fix iterate_devices based
>> device capability checks"), fix NO_SG_MERGE capability check and invert
>> logic of the corresponding iterate_devices_callout_fn so that all
>> devices' NO_SG_MERGE capabilities are properly checked.
>>
>> Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
>> Fixes: 200612ec33e5 ("dm table: propagate QUEUE_FLAG_NO_SG_MERGE")
>> ---
>>  drivers/md/dm-table.c | 12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
>> index 6580de65b81d..7ee520d4d216 100644
>> --- a/drivers/md/dm-table.c
>> +++ b/drivers/md/dm-table.c
>> @@ -1436,12 +1436,12 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev,
>>  	return q && !blk_queue_add_random(q);
>>  }
>>  
>> -static int queue_supports_sg_merge(struct dm_target *ti, struct dm_dev *dev,
>> -				   sector_t start, sector_t len, void *data)
>> +static int queue_no_sg_merge(struct dm_target *ti, struct dm_dev *dev,
>> +			     sector_t start, sector_t len, void *data)
>>  {
>>  	struct request_queue *q = bdev_get_queue(dev->bdev);
>>  
>> -	return q && !test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
>> +	return q && test_bit(QUEUE_FLAG_NO_SG_MERGE, &q->queue_flags);
>>  }
>>  
>>  static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev,
>> @@ -1542,10 +1542,10 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
>>  	if (!dm_table_supports_write_same(t))
>>  		q->limits.max_write_same_sectors = 0;
>>  
>> -	if (dm_table_all_devices_attribute(t, queue_supports_sg_merge))
>> -		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
>> -	else
>> +	if (dm_table_any_dev_attr(t, queue_no_sg_merge))
>>  		queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
>> +	else
>> +		queue_flag_clear_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
>>  
>>  	dm_table_verify_integrity(t);
>>  
>>
> 

-- 
Thanks,
Jeffle

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-03-08 13:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-01 13:44 FAILED: patch "[PATCH] dm table: fix iterate_devices based device capability checks" failed to apply to 4.4-stable tree gregkh
2021-03-05  6:30 ` [PATCH 4.4.y 0/2] dm: device capability check fixes Jeffle Xu
2021-03-05  6:30   ` [PATCH 4.4.y 1/2] dm table: fix iterate_devices based device capability checks Jeffle Xu
2021-03-05  6:30   ` [PATCH 4.4.y 2/2] dm table: fix no_sg_merge " Jeffle Xu
2021-03-05  6:46     ` Greg KH
2021-03-05  7:00       ` JeffleXu
2021-03-08  3:21     ` JeffleXu
2021-03-08 13:45       ` JeffleXu
2021-03-05  6:47   ` [PATCH 4.4.y 0/2] dm: device capability check fixes Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox