All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
Cc: dsterba@suse.com, linux-btrfs@vger.kernel.org,
	anand.jain@oracle.com, wqu@suse.com,
	Marcos Paulo de Souza <mpdesouza@suse.com>
Subject: Re: [PATCH] btrfs-progs: qgroup: Check for ENOTCONN error on create/assign/limit
Date: Wed, 27 Nov 2019 12:30:38 +0800	[thread overview]
Message-ID: <0d82cb5f-9d01-0e3a-26bb-33019d8a9e65@gmx.com> (raw)
In-Reply-To: <20191127034851.13482-1-marcos.souza.org@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2206 bytes --]



On 2019/11/27 上午11:48, Marcos Paulo de Souza wrote:
> From: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> Current btrfs code returns ENOTCONN when the user tries to create a
> qgroup on a subvolume without quota enabled. In order to present a
> meaningful message to the user, we now handle ENOTCONN showing
> the message "quota not enabled".
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Don't forget the original -EINVAL.

So it needs to cover both -EINVAL (for older kernel) and -ENOTCONN (for
newer kernel).

Thanks,
Qu

> ---
>  This patch survived a full btrfs-progs tests run
> 
>  cmds/qgroup.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/cmds/qgroup.c b/cmds/qgroup.c
> index ba81052a..6bfb4949 100644
> --- a/cmds/qgroup.c
> +++ b/cmds/qgroup.c
> @@ -98,7 +98,9 @@ static int _cmd_qgroup_assign(const struct cmd_struct *cmd, int assign,
>  
>  	ret = ioctl(fd, BTRFS_IOC_QGROUP_ASSIGN, &args);
>  	if (ret < 0) {
> -		error("unable to assign quota group: %m");
> +		error("unable to assign quota group: %s",
> +				errno == ENOTCONN ? "quota not enabled"
> +						: strerror(errno));
>  		close_file_or_dir(fd, dirstream);
>  		return 1;
>  	}
> @@ -152,8 +154,10 @@ static int _cmd_qgroup_create(int create, int argc, char **argv)
>  	ret = ioctl(fd, BTRFS_IOC_QGROUP_CREATE, &args);
>  	close_file_or_dir(fd, dirstream);
>  	if (ret < 0) {
> -		error("unable to %s quota group: %m",
> -			create ? "create":"destroy");
> +		error("unable to %s quota group: %s",
> +			create ? "create":"destroy",
> +				errno == ENOTCONN ? "quota not enabled"
> +						: strerror(errno));
>  		return 1;
>  	}
>  	return 0;
> @@ -447,7 +451,10 @@ static int cmd_qgroup_limit(const struct cmd_struct *cmd, int argc, char **argv)
>  	ret = ioctl(fd, BTRFS_IOC_QGROUP_LIMIT, &args);
>  	close_file_or_dir(fd, dirstream);
>  	if (ret < 0) {
> -		error("unable to limit requested quota group: %m");
> +		error("unable to limit requested quota group: %s",
> +				errno == ENOTCONN ? "quota not enabled"
> +						: strerror(errno));
> +
>  		return 1;
>  	}
>  	return 0;
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2019-11-27  4:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-27  3:48 [PATCH] btrfs-progs: qgroup: Check for ENOTCONN error on create/assign/limit Marcos Paulo de Souza
2019-11-27  4:30 ` Qu Wenruo [this message]
2019-11-28 11:08   ` David Sterba
2019-11-28 12:39     ` Qu Wenruo

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=0d82cb5f-9d01-0e3a-26bb-33019d8a9e65@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=anand.jain@oracle.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=marcos.souza.org@gmail.com \
    --cc=mpdesouza@suse.com \
    --cc=wqu@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.