From 3d460ec444940d50f4d87d023a660df31d7963bc Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Mon, 9 Jun 2025 20:58:41 +0900 Subject: [PATCH 1/5] adding ci files --- .github/workflows/kernel_build.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/kernel_build.yml diff --git a/.github/workflows/kernel_build.yml b/.github/workflows/kernel_build.yml new file mode 100644 index 0000000000000..cd0f9d145429c --- /dev/null +++ b/.github/workflows/kernel_build.yml @@ -0,0 +1,28 @@ +name: blktests-ci + +on: + pull_request: + +jobs: + build-kernel: + runs-on: ubuntu-latest + steps: + - name: Configure git + run: | + git config --global --add safe.directory '*' + - name: Checkout git + run: | + sudo apt-get install -y libelf-dev + mkdir -p linux + cd linux + git init + git remote add origin https://github.com/${{ github.repository }} + git fetch origin --depth=5 ${{ github.event.pull_request.head.sha }} + git reset --hard ${{ github.event.pull_request.head.sha }} + git log -1 + - name: Build kernel + run: | + cd linux + make defconfig + make -j 8 + From e673bea844e9ee2a89b53416c3e9b4184cfd0bd1 Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 5 Jun 2025 15:08:54 +0000 Subject: [PATCH 2/5] md/raid0: set chunk_sectors limit Currently we use min io size as the chunk size when deciding on the atomic write size limits - see blk_stack_atomic_writes_head(). The limits min_io_size is not a reliable value to store the chunk size, as this may be mutated by the block stacking code. Such an example would be for the min io size less than the physical block size, and the min io size is raised to the physical block size - see blk_stack_limits(). The block stacking limits will rely on chunk_sectors in future, so set this value (to the chunk size). Signed-off-by: John Garry --- drivers/md/raid0.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index d8f639f4ae123..cbe2a9054cb91 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -384,6 +384,7 @@ static int raid0_set_limits(struct mddev *mddev) lim.max_write_zeroes_sectors = mddev->chunk_sectors; lim.io_min = mddev->chunk_sectors << 9; lim.io_opt = lim.io_min * mddev->raid_disks; + lim.chunk_sectors = mddev->chunk_sectors; lim.features |= BLK_FEAT_ATOMIC_WRITES; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) From 10beabf175c1eedf658932b0d44573bbd4946082 Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 5 Jun 2025 15:08:55 +0000 Subject: [PATCH 3/5] md/raid10: set chunk_sectors limit Same as done for raid0, set chunk_sectors limit to appropriately set the atomic write size limit. Signed-off-by: John Garry --- drivers/md/raid10.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index b74780af4c220..97065bb26f430 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4004,6 +4004,7 @@ static int raid10_set_queue_limits(struct mddev *mddev) md_init_stacking_limits(&lim); lim.max_write_zeroes_sectors = 0; lim.io_min = mddev->chunk_sectors << 9; + lim.chunk_sectors = mddev->chunk_sectors; lim.io_opt = lim.io_min * raid10_nr_stripes(conf); lim.features |= BLK_FEAT_ATOMIC_WRITES; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); From 5f756cafdac53827db891d2919ebaccbe4c554ee Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 5 Jun 2025 15:08:56 +0000 Subject: [PATCH 4/5] dm-stripe: limit chunk_sectors to the stripe size Currently we use min io size as the chunk size when deciding on the limit of atomic write size. Using min io size is not reliable, as this may be mutated when stacking the bottom device limits. The block stacking limits will rely on chunk_sectors in future, so set this value (to the chunk size). Introduce a flag - DM_TARGET_STRIPED - and check this in dm_set_device_limits() when setting this limit. Signed-off-by: John Garry --- drivers/md/dm-stripe.c | 3 ++- drivers/md/dm-table.c | 4 ++++ include/linux/device-mapper.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index a7dc04bd55e5c..c30df6715149f 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c @@ -466,7 +466,8 @@ static struct target_type stripe_target = { .name = "striped", .version = {1, 7, 0}, .features = DM_TARGET_PASSES_INTEGRITY | DM_TARGET_NOWAIT | - DM_TARGET_ATOMIC_WRITES | DM_TARGET_PASSES_CRYPTO, + DM_TARGET_ATOMIC_WRITES | DM_TARGET_PASSES_CRYPTO | + DM_TARGET_STRIPED, .module = THIS_MODULE, .ctr = stripe_ctr, .dtr = stripe_dtr, diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 24a857ff6d0b1..4f1f7173740c2 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -430,6 +430,10 @@ static int dm_set_device_limits(struct dm_target *ti, struct dm_dev *dev, return 0; } + /* For striped types, limit the chunk_sectors to the chunk size */ + if (dm_target_supports_striped(ti->type)) + limits->chunk_sectors = len >> SECTOR_SHIFT; + mutex_lock(&q->limits_lock); /* * BLK_FEAT_ATOMIC_WRITES is not inherited from the bottom device in diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index cb95951547abe..a863523b69eee 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -309,6 +309,9 @@ struct target_type { #define DM_TARGET_ATOMIC_WRITES 0x00000400 #define dm_target_supports_atomic_writes(type) ((type)->features & DM_TARGET_ATOMIC_WRITES) +#define DM_TARGET_STRIPED 0x00000800 +#define dm_target_supports_striped(type) ((type)->features & DM_TARGET_STRIPED) + struct dm_target { struct dm_table *table; struct target_type *type; From 6317ab9a3770003047b166cc4c4f59900501cc0c Mon Sep 17 00:00:00 2001 From: John Garry Date: Thu, 5 Jun 2025 15:08:57 +0000 Subject: [PATCH 5/5] block: use chunk_sectors when evaluating stacked atomic write limits The atomic write unit max is limited by any stack device stripe size. It is required that the atomic write unit is a power-of-2 factor of the stripe size. Currently we use io_min limit to hold the stripe size, and check for a io_min <= SECTOR_SIZE when deciding if we have a striped stacked device. Nilay reports that this causes a problem when the physical block size is greater than SECTOR_SIZE [0]. Furthermore, io_min may be mutated when stacking devices, and this makes it a poor candidate to hold the stripe size. Such an example would be when the io_min is less than the physical block size. Use chunk_sectors to hold the stripe size, which is more appropriate. [0] https://lore.kernel.org/linux-block/888f3b1d-7817-4007-b3b3-1a2ea04df771@linux.ibm.com/T/#mecca17129f72811137d3c2f1e477634e77f06781 Signed-off-by: John Garry --- block/blk-settings.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index a000daafbfb48..5b0f1a854e815 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -594,11 +594,13 @@ static bool blk_stack_atomic_writes_boundary_head(struct queue_limits *t, static bool blk_stack_atomic_writes_head(struct queue_limits *t, struct queue_limits *b) { + unsigned int chunk_size = t->chunk_sectors << SECTOR_SHIFT; + if (b->atomic_write_hw_boundary && !blk_stack_atomic_writes_boundary_head(t, b)) return false; - if (t->io_min <= SECTOR_SIZE) { + if (!t->chunk_sectors) { /* No chunk sectors, so use bottom device values directly */ t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max; t->atomic_write_hw_unit_min = b->atomic_write_hw_unit_min; @@ -617,12 +619,12 @@ static bool blk_stack_atomic_writes_head(struct queue_limits *t, * aligned with both limits, i.e. 8K in this example. */ t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max; - while (t->io_min % t->atomic_write_hw_unit_max) + while (chunk_size % t->atomic_write_hw_unit_max) t->atomic_write_hw_unit_max /= 2; t->atomic_write_hw_unit_min = min(b->atomic_write_hw_unit_min, t->atomic_write_hw_unit_max); - t->atomic_write_hw_max = min(b->atomic_write_hw_max, t->io_min); + t->atomic_write_hw_max = min(b->atomic_write_hw_max, chunk_size); return true; }