Linux block layer
 help / color / mirror / Atom feed
From: Li Lingfeng <lilingfeng3@huawei.com>
To: Li Wang <li.wang@windriver.com>, <axboe@kernel.dk>,
	<linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] block: fix ioctl return error with GENHD_FL_NO_PART
Date: Tue, 17 Oct 2023 16:58:15 +0800	[thread overview]
Message-ID: <907c4906-3595-aa6d-8cba-5daa7133b17f@huawei.com> (raw)
In-Reply-To: <20231017080900.842241-1-li.wang@windriver.com>

I don't think so.

GENHD_FL_NO_PART means "partition support is disabled". If users try to 
add or resize partition on the disk with this flag, kernel should remind 
them that the parameter of device is wrong.
So I think it's appropriate to return -EINVAL.

Thanks.

在 2023/10/17 16:09, Li Wang 写道:
> GENHD_FL_NO_PART means no device(-ENXIO), not parameter error(-EINVAL).
>
> test case with parted command:
> @dd if=/dev/zero of=./blk-file bs=1M count=200
> @losetup /dev/loop0 ./blk-file
> @parted -s /dev/loop0 mklabel MSDOS
> Error: Partition(s) 1, ..., 64 on /dev/loop0 have been written,
> but we have been unable to inform the kernel of the change,
> probably because it/they are in use. As a result,
> the old partition(s) will remain in use. You should reboot now
> before making further changes.
> @echo $?
> 1
>
> Fixes: 1a721de8489f ("block: don't add or resize partition on the disk with GENHD_FL_NO_PART")
> Signed-off-by: Li Wang <li.wang@windriver.com>
> ---
>   block/ioctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/ioctl.c b/block/ioctl.c
> index d5f5cd61efd7..701c64cd67e8 100644
> --- a/block/ioctl.c
> +++ b/block/ioctl.c
> @@ -21,7 +21,7 @@ static int blkpg_do_ioctl(struct block_device *bdev,
>   	long long start, length;
>   
>   	if (disk->flags & GENHD_FL_NO_PART)
> -		return -EINVAL;
> +		return -ENXIO;
>   	if (!capable(CAP_SYS_ADMIN))
>   		return -EACCES;
>   	if (copy_from_user(&p, upart, sizeof(struct blkpg_partition)))

  reply	other threads:[~2023-10-17  8:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-17  8:09 [PATCH] block: fix ioctl return error with GENHD_FL_NO_PART Li Wang
2023-10-17  8:58 ` Li Lingfeng [this message]
2023-10-17  9:26   ` Wang, Li
2023-10-17 11:21     ` Li Lingfeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=907c4906-3595-aa6d-8cba-5daa7133b17f@huawei.com \
    --to=lilingfeng3@huawei.com \
    --cc=axboe@kernel.dk \
    --cc=li.wang@windriver.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox