* [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
@ 2024-01-18 13:04 Li Lingfeng
2024-01-18 15:20 ` Jens Axboe
2024-01-20 1:08 ` Jens Axboe
0 siblings, 2 replies; 4+ messages in thread
From: Li Lingfeng @ 2024-01-18 13:04 UTC (permalink / raw)
To: allison.karlitskaya, hch, axboe, yukuai1
Cc: linux-kernel, linux-block, houtao1, yi.zhang, yangerkun,
lilingfeng
From: Li Lingfeng <lilingfeng3@huawei.com>
Commit 1a721de8489f ("block: don't add or resize partition on the disk
with GENHD_FL_NO_PART") prevented all operations about partitions on disks
with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless.
However, it changed error code in some scenarios. So move checking
GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact.
Fixes: 1a721de8489f ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART")
Reported-by: Allison Karlitskaya <allison.karlitskaya@redhat.com>
Closes: https://lore.kernel.org/all/CAOYeF9VsmqKMcQjo1k6YkGNujwN-nzfxY17N3F-CMikE1tYp+w@mail.gmail.com/
Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
---
block/ioctl.c | 2 --
block/partitions/core.c | 5 +++++
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/ioctl.c b/block/ioctl.c
index 9c73a763ef88..438f79c564cf 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -20,8 +20,6 @@ static int blkpg_do_ioctl(struct block_device *bdev,
struct blkpg_partition p;
sector_t start, length;
- if (disk->flags & GENHD_FL_NO_PART)
- return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))
diff --git a/block/partitions/core.c b/block/partitions/core.c
index e6ac73617f3e..8bc68e8acafd 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -439,6 +439,11 @@ int bdev_add_partition(struct gendisk *disk, int partno, sector_t start,
goto out;
}
+ if (disk->flags & GENHD_FL_NO_PART) {
+ ret = -EINVAL;
+ goto out;
+ }
+
if (partition_overlaps(disk, start, length, -1)) {
ret = -EBUSY;
goto out;
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
2024-01-18 13:04 [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition() Li Lingfeng
@ 2024-01-18 15:20 ` Jens Axboe
2024-01-19 1:27 ` Yu Kuai
2024-01-20 1:08 ` Jens Axboe
1 sibling, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2024-01-18 15:20 UTC (permalink / raw)
To: Li Lingfeng, allison.karlitskaya, hch, yukuai1
Cc: linux-kernel, linux-block, houtao1, yi.zhang, yangerkun, Yu Kuai
On 1/18/24 6:04 AM, Li Lingfeng wrote:
> From: Li Lingfeng <lilingfeng3@huawei.com>
>
> Commit 1a721de8489f ("block: don't add or resize partition on the disk
> with GENHD_FL_NO_PART") prevented all operations about partitions on disks
> with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless.
> However, it changed error code in some scenarios. So move checking
> GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact.
This looks fine, but it's identical to the one sent out by Yu two days
ago. Hmm? Who's the proper author?
Adding Yu.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
2024-01-18 15:20 ` Jens Axboe
@ 2024-01-19 1:27 ` Yu Kuai
0 siblings, 0 replies; 4+ messages in thread
From: Yu Kuai @ 2024-01-19 1:27 UTC (permalink / raw)
To: Jens Axboe, Li Lingfeng, allison.karlitskaya, hch, yukuai1
Cc: linux-kernel, linux-block, houtao1, yi.zhang, yangerkun,
yukuai (C)
Hi,
在 2024/01/18 23:20, Jens Axboe 写道:
> On 1/18/24 6:04 AM, Li Lingfeng wrote:
>> From: Li Lingfeng <lilingfeng3@huawei.com>
>>
>> Commit 1a721de8489f ("block: don't add or resize partition on the disk
>> with GENHD_FL_NO_PART") prevented all operations about partitions on disks
>> with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless.
>> However, it changed error code in some scenarios. So move checking
>> GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact.
>
> This looks fine, but it's identical to the one sent out by Yu two days
> ago. Hmm? Who's the proper author?
Lingfeng is my collegue and I told him that he should send a fix for his
formal patch. Sorry for the confusion :)
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
>
> Adding Yu.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
2024-01-18 13:04 [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition() Li Lingfeng
2024-01-18 15:20 ` Jens Axboe
@ 2024-01-20 1:08 ` Jens Axboe
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2024-01-20 1:08 UTC (permalink / raw)
To: allison.karlitskaya, hch, yukuai1, Li Lingfeng
Cc: linux-kernel, linux-block, houtao1, yi.zhang, yangerkun
On Thu, 18 Jan 2024 21:04:01 +0800, Li Lingfeng wrote:
> Commit 1a721de8489f ("block: don't add or resize partition on the disk
> with GENHD_FL_NO_PART") prevented all operations about partitions on disks
> with GENHD_FL_NO_PART in blkpg_do_ioctl() since they are meaningless.
> However, it changed error code in some scenarios. So move checking
> GENHD_FL_NO_PART to bdev_add_partition() to eliminate impact.
>
>
> [...]
Applied, thanks!
[1/1] block: Move checking GENHD_FL_NO_PART to bdev_add_partition()
commit: 6a1cf2468a9ba1f56de7478ee6ad0d54e0aa821a
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-20 1:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-18 13:04 [PATCH] block: Move checking GENHD_FL_NO_PART to bdev_add_partition() Li Lingfeng
2024-01-18 15:20 ` Jens Axboe
2024-01-19 1:27 ` Yu Kuai
2024-01-20 1:08 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox