btrfs-progs: qgroup: Check for ENOTCONN error on create/assign/limit
PATCH 1/1 btrfs-progs: qgroup: Check for ENOTCONN error on create/assign/limit
From: Marcos Paulo de Souza <[email protected]>
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".
---
This patch survived a full btrfs-progs tests run
cmds/qgroup.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
cmds/qgroup.c +11 -4
@@ -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 ;
Signature · 1 line
2.23.0
Quoted 8 lines · Marcos Paulo de Souza
From: Marcos Paulo de Souza <[email protected]>
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 <[email protected]>
Don't forget the original -EINVAL.
So it needs to cover both -EINVAL (for older kernel) and -ENOTCONN (for newer kernel).
Thanks,
Qu
Quoted 47 lines
---
This patch survived a full btrfs-progs tests runcmds/qgroup.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)cmds/qgroup.c +11
-4@@ -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 ;
Quoted 10 lines · Qu Wenruo
Quoted 7 lines · Marcos Paulo de Souza
From: Marcos Paulo de Souza <[email protected]>
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".
Quoted 6 lines
Quoted 1 line
Signed-off-by Marcos Paulo de Souza <[email protected]>Don't forget the original
-EINVAL.So it needs to cover both
-EINVAL(for older kernel) and-ENOTCONN(for newer kernel).
I think for now only ENOTCONN should be interpreted as 'quotas not enabled' as we can be sure it's just that. But EINVAL means 'invalid parameter' and this can be interpreted in that context as if the qgroup ids are wrong etc.
Qu Wenruo
Reviewed-byQuoted 15 lines · David Sterba
Quoted 14 lines · Qu Wenruo
Quoted 8 lines · Marcos Paulo de Souza
From: Marcos Paulo de Souza <[email protected]>
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 <[email protected]>Don't forget the original
-EINVAL.
Quoted 8 lines
Quoted 2 lines
So it needs to cover both
-EINVAL(for older kernel) and-ENOTCONN(for newer kernel).I think for now only ENOTCONN should be interpreted as 'quotas not enabled' as we can be sure it's just that. But EINVAL means 'invalid parameter' and this can be interpreted in that context as if the qgroup ids are wrong etc.
Ah, makes sense.
So no need for a new version.