[dm-devel] [PATCH] block: fix incorrect branching in blk_max_size_offset() [was: Re: [git pull] device mapper fixes for 5.10-rc7]

Mike Snitzer snitzer at redhat.com
Fri Dec 4 22:37:42 UTC 2020


On Fri, Dec 04 2020 at  4:35P -0500,
pr-tracker-bot at kernel.org <pr-tracker-bot at kernel.org> wrote:

> The pull request you sent on Fri, 4 Dec 2020 16:05:21 -0500:
> 
> > git://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git tags/for-5.10/dm-fixes
> 
> has been merged into torvalds/linux.git:
> https://git.kernel.org/torvalds/c/b3298500b23f0b53a8d81e0d5ad98a29db71f4f0
> 
> Thank you!

Hi Linus,

This is _really_ embarrassing; but I screwed up the branching at the top
of blk_max_size_offset(), here is the fix:

From: Mike Snitzer <snitzer at redhat.com>
Date: Fri, 4 Dec 2020 17:21:03 -0500
Subject: [PATCH] block: fix incorrect branching in blk_max_size_offset()

If non-zero 'chunk_sectors' is passed in to blk_max_size_offset() that
override will be incorrectly ignored.

Old blk_max_size_offset() branching, prior to commit 3ee16db390b4,
must be used only if passed 'chunk_sectors' override is zero.

Fixes: 3ee16db390b4 ("dm: fix IO splitting")
Cc: stable at vger.kernel.org # 5.9
Reported-by: John Dorminy <jdorminy at redhat.com>
Signed-off-by: Mike Snitzer <snitzer at redhat.com>
---
 include/linux/blkdev.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 24ae504cf77d..033eb5f73b65 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1076,10 +1076,12 @@ static inline unsigned int blk_max_size_offset(struct request_queue *q,
 					       sector_t offset,
 					       unsigned int chunk_sectors)
 {
-	if (!chunk_sectors && q->limits.chunk_sectors)
-		chunk_sectors = q->limits.chunk_sectors;
-	else
-		return q->limits.max_sectors;
+	if (!chunk_sectors) {
+		if (q->limits.chunk_sectors)
+			chunk_sectors = q->limits.chunk_sectors;
+		else
+			return q->limits.max_sectors;
+	}
 
 	if (likely(is_power_of_2(chunk_sectors)))
 		chunk_sectors -= offset & (chunk_sectors - 1);
-- 
2.15.0




More information about the dm-devel mailing list