From: Bruce Ashfield <bruce.ashfi...@gmail.com> Signed-off-by: Bruce Ashfield <bruce.ashfi...@gmail.com> --- ...partitions-if-GD_SUPPRESS_PART_SCAN-.patch | 43 +++++++++ ...-support-partitions-without-scanning.patch | 87 +++++++++++++++++++ meta/recipes-kernel/linux/linux-yocto_5.15.bb | 4 + 3 files changed, 134 insertions(+) create mode 100644 meta/recipes-kernel/linux/files/0001-block-don-t-add-partitions-if-GD_SUPPRESS_PART_SCAN-.patch create mode 100644 meta/recipes-kernel/linux/files/0001-block-loop-support-partitions-without-scanning.patch
diff --git a/meta/recipes-kernel/linux/files/0001-block-don-t-add-partitions-if-GD_SUPPRESS_PART_SCAN-.patch b/meta/recipes-kernel/linux/files/0001-block-don-t-add-partitions-if-GD_SUPPRESS_PART_SCAN-.patch new file mode 100644 index 0000000000..cde4f317e9 --- /dev/null +++ b/meta/recipes-kernel/linux/files/0001-block-don-t-add-partitions-if-GD_SUPPRESS_PART_SCAN-.patch @@ -0,0 +1,43 @@ +From 748008e1da926a814cc0a054c81ca614408b1b0c Mon Sep 17 00:00:00 2001 +From: Ming Lei <ming....@redhat.com> +Date: Tue, 23 Aug 2022 18:38:19 +0800 +Subject: [PATCH] block: don't add partitions if GD_SUPPRESS_PART_SCAN is set + +Commit b9684a71fca7 ("block, loop: support partitions without scanning") +adds GD_SUPPRESS_PART_SCAN for replacing part function of +GENHD_FL_NO_PART. But looks blk_add_partitions() is missed, since +loop doesn't want to add partitions if GENHD_FL_NO_PART was set. +And it causes regression on libblockdev (as called from udisks) which +operates with the LO_FLAGS_PARTSCAN. + +Fixes the issue by not adding partitions if GD_SUPPRESS_PART_SCAN is +set. + +Upstream-Status: Backport [748008e1da926a814cc0a054c81ca614408b1b0c] + +Fixes: b9684a71fca7 ("block, loop: support partitions without scanning") +Signed-off-by: Ming Lei <ming....@redhat.com> +Reviewed-by: Christoph Hellwig <h...@lst.de> +Link: https://lore.kernel.org/r/20220823103819.395776-1-ming....@redhat.com +Signed-off-by: Jens Axboe <ax...@kernel.dk> +--- + block/partitions/core.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/block/partitions/core.c b/block/partitions/core.c +index fc1d70384825..b8112f52d388 100644 +--- a/block/partitions/core.c ++++ b/block/partitions/core.c +@@ -596,6 +596,9 @@ static int blk_add_partitions(struct gendisk *disk) + if (disk->flags & GENHD_FL_NO_PART) + return 0; + ++ if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state)) ++ return 0; ++ + state = check_partition(disk); + if (!state) + return 0; +-- +2.39.2 + diff --git a/meta/recipes-kernel/linux/files/0001-block-loop-support-partitions-without-scanning.patch b/meta/recipes-kernel/linux/files/0001-block-loop-support-partitions-without-scanning.patch new file mode 100644 index 0000000000..9522c2d2cc --- /dev/null +++ b/meta/recipes-kernel/linux/files/0001-block-loop-support-partitions-without-scanning.patch @@ -0,0 +1,87 @@ +From ea6bf87558eb534ded532cfa622b575c1f39e3d6 Mon Sep 17 00:00:00 2001 +From: Christoph Hellwig <h...@lst.de> +Date: Fri, 27 May 2022 07:58:06 +0200 +Subject: [PATCH] block, loop: support partitions without scanning + +Historically we did distinguish between a flag that surpressed partition +scanning, and a combinations of the minors variable and another flag if +any partitions were supported. This was generally confusing and doesn't +make much sense, but some corner case uses of the loop driver actually +do want to support manually added partitions on a device that does not +actively scan for partitions. To make things worsee the loop driver +also wants to dynamically toggle the scanning for partitions on a live +gendisk, which makes the disk->flags updates non-atomic. + +Introduce a new GD_SUPPRESS_PART_SCAN bit in disk->state that disables +just scanning for partitions, and toggle that instead of GENHD_FL_NO_PART +in the loop driver. + +Upstream-Status: Backport [b9684a71fca793213378dd410cd11675d973eaa1] + +Fixes: 1ebe2e5f9d68 ("block: remove GENHD_FL_EXT_DEVT") +Reported-by: Ming Lei <ming....@redhat.com> +Signed-off-by: Christoph Hellwig <h...@lst.de> +Reviewed-by: Ming Lei <ming....@redhat.com> +Link: https://lore.kernel.org/r/20220527055806.1972352-1-...@lst.de +Signed-off-by: Jens Axboe <ax...@kernel.dk> +Signed-off-by: Bruce Ashfield <bruce.ashfi...@gmail.com> +--- + drivers/block/loop.c | 8 ++++---- + include/linux/blkdev.h | 1 + + 2 files changed, 5 insertions(+), 4 deletions(-) + +diff --git a/drivers/block/loop.c b/drivers/block/loop.c +index 4769caab9ff9..a76302450c46 100644 +--- a/drivers/block/loop.c ++++ b/drivers/block/loop.c +@@ -1332,7 +1332,7 @@ static int loop_configure(struct loop_device *lo, fmode_t mode, + lo->lo_flags |= LO_FLAGS_PARTSCAN; + partscan = lo->lo_flags & LO_FLAGS_PARTSCAN; + if (partscan) +- lo->lo_disk->flags &= ~GENHD_FL_NO_PART; ++ clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); + + /* enable and uncork uevent now that we are done */ + dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 0); +@@ -1481,7 +1481,7 @@ static int __loop_clr_fd(struct loop_device *lo, bool release) + mutex_lock(&lo->lo_mutex); + lo->lo_flags = 0; + if (!part_shift) +- lo->lo_disk->flags |= GENHD_FL_NO_PART; ++ set_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); + lo->lo_state = Lo_unbound; + mutex_unlock(&lo->lo_mutex); + +@@ -1598,7 +1598,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) + + if (!err && (lo->lo_flags & LO_FLAGS_PARTSCAN) && + !(prev_lo_flags & LO_FLAGS_PARTSCAN)) { +- lo->lo_disk->flags &= ~GENHD_FL_NO_PART; ++ clear_bit(GD_SUPPRESS_PART_SCAN, &lo->lo_disk->state); + partscan = true; + } + out_unlock: +@@ -2428,7 +2428,7 @@ static int loop_add(int i) + * userspace tools. Parameters like this in general should be avoided. + */ + if (!part_shift) +- disk->flags |= GENHD_FL_NO_PART; ++ set_bit(GD_SUPPRESS_PART_SCAN, &disk->state); + disk->flags |= GENHD_FL_EXT_DEVT; + atomic_set(&lo->lo_refcnt, 0); + mutex_init(&lo->lo_mutex); +diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h +index 905844172cfd..15815f1ced9e 100644 +--- a/include/linux/blkdev.h ++++ b/include/linux/blkdev.h +@@ -813,6 +813,7 @@ static inline unsigned int blk_queue_depth(struct request_queue *q) + */ + #define BLK_DEFAULT_SG_TIMEOUT (60 * HZ) + #define BLK_MIN_SG_TIMEOUT (7 * HZ) ++#define GD_SUPPRESS_PART_SCAN 5 + + struct rq_map_data { + struct page **pages; +-- +2.39.2 + diff --git a/meta/recipes-kernel/linux/linux-yocto_5.15.bb b/meta/recipes-kernel/linux/linux-yocto_5.15.bb index 1c6b3d1112..17d36524f7 100644 --- a/meta/recipes-kernel/linux/linux-yocto_5.15.bb +++ b/meta/recipes-kernel/linux/linux-yocto_5.15.bb @@ -38,6 +38,10 @@ KBRANCH:class-devupstream = "v5.15/base" SRC_URI = "git://git.yoctoproject.org/linux-yocto.git;name=machine;branch=${KBRANCH}; \ git://git.yoctoproject.org/yocto-kernel-cache;type=kmeta;name=meta;branch=yocto-5.15;destsuffix=${KMETA}" +SRC_URI += "file://0001-block-don-t-add-partitions-if-GD_SUPPRESS_PART_SCAN-.patch" +SRC_URI += "file://0001-block-loop-support-partitions-without-scanning.patch" + + LIC_FILES_CHKSUM = "file://COPYING;md5=6bc538ed5bd9a7fc9398086aedcd7e46" LINUX_VERSION ?= "5.15.149" -- 2.39.2
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#196820): https://lists.openembedded.org/g/openembedded-core/message/196820 Mute This Topic: https://lists.openembedded.org/mt/104794844/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-