Patch "block: Ensure start sector is aligned for stacking atomic writes" has been added to the 6.13-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    block: Ensure start sector is aligned for stacking atomic writes

to the 6.13-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     block-ensure-start-sector-is-aligned-for-stacking-at.patch
and it can be found in the queue-6.13 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9a06d32f15f12533880be740db62aefdb36467cb
Author: John Garry <john.g.garry@xxxxxxxxxx>
Date:   Thu Jan 9 11:39:59 2025 +0000

    block: Ensure start sector is aligned for stacking atomic writes
    
    [ Upstream commit 6564862d646e7d630929ba1ff330740bb215bdac ]
    
    For stacking atomic writes, ensure that the start sector is aligned with
    the device atomic write unit min and any boundary. Otherwise, we may
    permit misaligned atomic writes.
    
    Rework bdev_can_atomic_write() into a common helper to resuse the
    alignment check. There also use atomic_write_hw_unit_min, which is more
    proper (than atomic_write_unit_min).
    
    Fixes: d7f36dc446e89 ("block: Support atomic writes limits for stacked devices")
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx>
    Reviewed-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20250109114000.2299896-2-john.g.garry@xxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-settings.c b/block/blk-settings.c
index b017637d9e735..64f2e67238d77 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -608,7 +608,7 @@ static bool blk_stack_atomic_writes_head(struct queue_limits *t,
 }
 
 static void blk_stack_atomic_writes_limits(struct queue_limits *t,
-				struct queue_limits *b)
+				struct queue_limits *b, sector_t start)
 {
 	if (!(t->features & BLK_FEAT_ATOMIC_WRITES_STACKED))
 		goto unsupported;
@@ -616,6 +616,9 @@ static void blk_stack_atomic_writes_limits(struct queue_limits *t,
 	if (!b->atomic_write_unit_min)
 		goto unsupported;
 
+	if (!blk_atomic_write_start_sect_aligned(start, b))
+		goto unsupported;
+
 	/*
 	 * If atomic_write_hw_max is set, we have already stacked 1x bottom
 	 * device, so check for compliance.
@@ -798,7 +801,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
 		t->zone_write_granularity = 0;
 		t->max_zone_append_sectors = 0;
 	}
-	blk_stack_atomic_writes_limits(t, b);
+	blk_stack_atomic_writes_limits(t, b, start);
 
 	return ret;
 }
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e0ce4d6913cde..495813277597f 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1701,6 +1701,15 @@ struct io_comp_batch {
 	void (*complete)(struct io_comp_batch *);
 };
 
+static inline bool blk_atomic_write_start_sect_aligned(sector_t sector,
+						struct queue_limits *limits)
+{
+	unsigned int alignment = max(limits->atomic_write_hw_unit_min,
+				limits->atomic_write_hw_boundary);
+
+	return IS_ALIGNED(sector, alignment >> SECTOR_SHIFT);
+}
+
 static inline bool bdev_can_atomic_write(struct block_device *bdev)
 {
 	struct request_queue *bd_queue = bdev->bd_queue;
@@ -1709,15 +1718,9 @@ static inline bool bdev_can_atomic_write(struct block_device *bdev)
 	if (!limits->atomic_write_unit_min)
 		return false;
 
-	if (bdev_is_partition(bdev)) {
-		sector_t bd_start_sect = bdev->bd_start_sect;
-		unsigned int alignment =
-			max(limits->atomic_write_unit_min,
-			    limits->atomic_write_hw_boundary);
-
-		if (!IS_ALIGNED(bd_start_sect, alignment >> SECTOR_SHIFT))
-			return false;
-	}
+	if (bdev_is_partition(bdev))
+		return blk_atomic_write_start_sect_aligned(bdev->bd_start_sect,
+							limits);
 
 	return true;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux