linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: Jerry Snitselaar <jerry.snitselaar@oracle.com>
Cc: linux-btrfs@vger.kernel.org, chris.mason@fusionio.com,
	dsterba@suse.cz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: return EPERM in btrfs_rm_device()
Date: Sat, 2 Mar 2013 20:04:04 +0200	[thread overview]
Message-ID: <20130302180404.GA1991@zambezi.lan> (raw)
In-Reply-To: <1362208439-19245-1-git-send-email-jerry.snitselaar@oracle.com>

On Sat, Mar 02, 2013 at 12:13:59AM -0700, Jerry Snitselaar wrote:
> Currently there are error paths in btrfs_rm_device() where EINVAL is
> returned telling the user they passed an invalid argument even though
> they passed a valid device. Change to return EPERM instead as the
> operation is not permitted.
> 
> Signed-off-by: Jerry Snitselaar <jerry.snitselaar@oracle.com>
> ---
>  fs/btrfs/volumes.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index 5cbb7f4..3e1586c 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -1392,14 +1392,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
>  	if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices <= 4) {
>  		printk(KERN_ERR "btrfs: unable to go below four devices "
>  		       "on raid10\n");
> -		ret = -EINVAL;
> +		ret = -EPERM;
>  		goto out;
>  	}
>  
>  	if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices <= 2) {
>  		printk(KERN_ERR "btrfs: unable to go below two "
>  		       "devices on raid1\n");
> -		ret = -EINVAL;
> +		ret = -EPERM;
>  		goto out;
>  	}
>  
> @@ -1449,14 +1449,14 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
>  
>  	if (device->is_tgtdev_for_dev_replace) {
>  		pr_err("btrfs: unable to remove the dev_replace target dev\n");
> -		ret = -EINVAL;
> +		ret = -EPERM;
>  		goto error_brelse;
>  	}
>  
>  	if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) {
>  		printk(KERN_ERR "btrfs: unable to remove the only writeable "
>  		       "device\n");
> -		ret = -EINVAL;
> +		ret = -EPERM;

I don't think returning EPERM in these cases is any better than EINVAL.
FWIW, many other btrfs ioctls, especially balance, suffer from this as
well.  What we really need is some kind of error message delivery
system, but that's not going to happen any time soon...

Thanks,

		Ilya

      reply	other threads:[~2013-03-02 18:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-02  7:13 [PATCH] btrfs: return EPERM in btrfs_rm_device() Jerry Snitselaar
2013-03-02 18:04 ` Ilya Dryomov [this message]

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=20130302180404.GA1991@zambezi.lan \
    --to=idryomov@gmail.com \
    --cc=chris.mason@fusionio.com \
    --cc=dsterba@suse.cz \
    --cc=jerry.snitselaar@oracle.com \
    --cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).