syscalls/quotactl07: add regresstion test for Q_XQTUOTARM
PATCH 1/1 syscalls/quotactl07: add regresstion test for Q_XQTUOTARM
This is a regresstion test to check Q_XQUOTARM whether has quota flags check.
--- include/lapi/quotactl.h | 4 + runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl07.c | 89 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl07.c
include/lapi/quotactl.h +4 -0
@@ -59,6 +59,10 @@ struct fs_quota_statv {# define PRJQUOTA 2#endif +#ifndef Q_XQUOTARM +# define Q_XQUOTARM XQM_CMD(6) +#endif +#ifndef Q_XGETQSTATV # define Q_XGETQSTATV XQM_CMD(8)#endif
runtest/syscalls +1 -0
@@ -958,6 +958,7 @@ quotactl03 quotactl03 quotactl04 quotactl04 quotactl05 quotactl05 quotactl06 quotactl06 +quotactl07 quotactl07 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
@@ -4,3 +4,4 @@ /quotactl04 /quotactl05 /quotactl06 +/quotactl07
testcases/kernel/syscalls/quotactl/quotactl07.c new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH 1/1 syscalls/quotactl07: add regresstion test for Q_XQTUOTARM
Hi Yang,
Quoted 85 lines · Yang Xu
This is a regresstion test to check
Q_XQUOTARMwhether has quota flags check.Signed-off-by Yang Xu <[email protected]>--- include/lapi/quotactl.h | 4 + runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl07.c | 89 +++++++++++++++++++ 4 files changed, 95 insertions(+)create mode 100644
testcases/kernel/syscalls/quotactl/quotactl07.cinclude/lapi/quotactl.h +4
-0@@ -59,6 +59,10 @@ struct fs_quota_statv {# define PRJQUOTA 2#endif +#ifndef Q_XQUOTARM +# define Q_XQUOTARM XQM_CMD(6) +#endif +#ifndef Q_XGETQSTATV # define Q_XGETQSTATV XQM_CMD(8)#endif runtest/syscalls +1
-0@@ -958,6 +958,7 @@ quotactl03 quotactl03 quotactl04 quotactl04 quotactl05 quotactl05 quotactl06 quotactl06 +quotactl07 quotactl07 read01 read01 read02 read02testcases/kernel/syscalls/quotactl/.gitignore +1
-0@@ -4,3 +4,4 @@ /quotactl04 /quotactl05 /quotactl06 +/quotactl07testcases/kernel/syscalls/quotactl/quotactl07.c new file +31
-0@@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This is a regresstion test for kernel commit 3dd4d40b4208 +* ("xfs: Sanity check flags of Q_XQUOTARM call"). +*/ + +#include "config.h" +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <sys/quota.h> +#include "lapi/quotactl.h" +#include "tst_test.h" + +#ifdef HAVE_XFS_XQM_H +# include <xfs/xqm.h> + +#define MNTPOINT "mntpoint" + +static uint32_t qflag_acct =XFS_QUOTA_UDQ_ACCT ; +static int test_id; +static int xquotarm_nsup; +static unsigned int valid_type =1 ; +static unsigned int invalid_type =9 ; + +static void verify_quota (void ) +{ +if (xquotarm_nsup) {
testcases/kernel/syscalls/quotactl/quotactl07.c line 41
Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +10
-0+tst_res (TCONF , +"current system doesn't support Q_XQUOTARM, skip it" ); +return ; + } + +SAFE_MOUNT (tst_device->dev,MNTPOINT , tst_device->fs_type,0 ,"quota" ); + +TEST (quotactl (QCMD (Q_XQUOTAOFF ,USRQUOTA ), tst_device->dev, test_id, (void *)&qflag_acct)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"quotactl with Q_XQUOTAOFF failed" );
Is it possible to git rid of Q_XQUOTAOFF and call Q_XQUOTARM with invalid_type directly?
testcases/kernel/syscalls/quotactl/quotactl07.c line 54
Quoted 13 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +13
-0+ +TEST (quotactl (QCMD (Q_XQUOTARM ,USRQUOTA ), tst_device->dev, test_id, (void *)&invalid_type)); +if (TST_ERR ==EINVAL ) +tst_res (TPASS ,"Q_XQUOTARM has quota type check" ); +else +tst_res (TFAIL ,"Q_XQUOTARM doesn't have quota type check" ); + +SAFE_UMOUNT (MNTPOINT ); +} + +static void setup (void ) +{ + test_id =geteuid ();
Is test_id necessary?? It seems to be ignored by both Q_XQUOTAOFF and Q_XQUOTARM.
testcases/kernel/syscalls/quotactl/quotactl07.c line 64
Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +10
-0+ +SAFE_MOUNT (tst_device->dev,MNTPOINT , tst_device->fs_type,0 ,"quota" ); + +TEST (quotactl (QCMD (Q_XQUOTAOFF ,USRQUOTA ), tst_device->dev, test_id, (void *)&qflag_acct)); +if (TST_RET ==-1 ) +tst_brk (TBROK |TTERRNO ,"quotactl with Q_XQUOTAOFF failed" ); + +TEST (quotactl (QCMD (Q_XQUOTARM ,USRQUOTA ), tst_device->dev, test_id, (void *)&valid_type)); +if (TST_ERR ==EINVAL ) + xquotarm_nsup =1 ;
Is xquotarm_nsup variable duplicated? it seems simpler to report TCONF here.
testcases/kernel/syscalls/quotactl/quotactl07.c line 66
Quoted 2 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +2
-0+ +SAFE_UMOUNT (MNTPOINT );
Why do you need to mount and then umount?
Could we call Q_XQUOTAON if you have to turn on usrquota again?
Best Regards,
Xiao Yang
Quoted 23 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +23
-0+} + +static const char *kconfigs[] = { +"CONFIG_XFS_QUOTA" , +NULL +}; + +static struct tst_test test = { + .setup = setup, + .needs_root =1 , + .needs_kconfigs = kconfigs, + .test_all = verify_quota, + .format_device =1 , + .dev_fs_type ="xfs" , + .mntpoint =MNTPOINT , + .tags = (const struct tst_tag []) { + {"linux-git" ,"3dd4d40b4208" }, + {} + } +}; +#else +TST_TEST_TCONF ("System doesn't have <xfs/xqm.h>" ); +#endif
PATCH 1/1 syscalls/quotactl07: add regresstion test for Q_XQTUOTARM
Hi Xiao
Quoted 94 lines · Xiao Yang
Hi Yang,
Quoted 91 lines · Yang Xu
This is a regresstion test to check
Q_XQUOTARM? whether has quota flags check.Signed-off-by Yang Xu <[email protected]>---
? include/lapi/quotactl.h?????????????????????? |? 4 + ? runtest/syscalls????????????????????????????? |? 1 + ? testcases/kernel/syscalls/quotactl/.gitignore |? 1 + ? .../kernel/syscalls/quotactl/quotactl07.c???? | 89 +++++++++++++++++++? 4 files changed, 95 insertions(+)
? create mode 100644testcases/kernel/syscalls/quotactl/quotactl07.cinclude/lapi/quotactl.h +0
-0@@ -59,6 +59,10 @@ struct fs_quota_statv {? # define PRJQUOTA 2
? #endifinclude/lapi/quotactl.h +4
-0+#ifndef Q_XQUOTARM +# define Q_XQUOTARM XQM_CMD(6) +#endif +? #ifndef
Q_XGETQSTATV
? # defineQ_XGETQSTATVXQM_CMD(8)
? #endifruntest/syscalls +0
-0@@ -958,6 +958,7 @@ quotactl03 quotactl03? quotactl04 quotactl04
? quotactl05 quotactl05
? quotactl06 quotactl06
+quotactl07 quotactl07
? read01 read01
? read02 read02testcases/kernel/syscalls/quotactl/.gitignore +0
-0@@ -4,3 +4,4 @@? /quotactl04
? /quotactl05
? /quotactl06testcases/kernel/syscalls/quotactl/.gitignore +1
-0+/quotactl07testcases/kernel/syscalls/quotactl/quotactl07.c new file +37
-0@@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This is a regresstion test for kernel commit 3dd4d40b4208 +* ("xfs: Sanity check flags of Q_XQUOTARM call"). +*/ + +#include "config.h" +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <sys/quota.h> +#include "lapi/quotactl.h" +#include "tst_test.h" + +#ifdef HAVE_XFS_XQM_H +# include <xfs/xqm.h> + +#define MNTPOINT ??? "mntpoint" + +static uint32_t qflag_acct =XFS_QUOTA_UDQ_ACCT ; +static int test_id; +static int xquotarm_nsup; +static unsigned int valid_type =1 ; +static unsigned int invalid_type =9 ; + +static void verify_quota (void ) +{ +??? if (xquotarm_nsup) { +??????? tst_res(TCONF, +??????????? "current system doesn't support Q_XQUOTARM, skip it"); +??????? return; +??? } + +??? SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0,
Quoted 8 lines
Quoted 6 lines
"quota");
+
+???TEST(quotactl(QCMD(Q_XQUOTAOFF, USRQUOTA), tst_device->dev, test_id, (void *)&qflag_acct));
+??? if (TST_RET== -1)
+???????tst_brk(TBROK | TTERRNO, "quotactl with Q_XQUOTAOFF failed");Is it possible to git rid of
Q_XQUOTAOFFand callQ_XQUOTARMwithinvalid_typedirectly?
From man-pages, before we use Q_XQUOTARM , quotas must have already
been turned off. If we don't use turnoff, it will report EINVAL but not we wanted "EINVAL". as below:
-------------------------------------------------------
fs/xfs/xfs_quotaops.c +9 -4
@@ -164,8 +164,10 @@ xfs_quota_enable(if (sb_rdonly (sb))return -EROFS ; -if (!XFS_IS_QUOTA_RUNNING (mp)) +if (!XFS_IS_QUOTA_RUNNING (mp)) { +printk ("xuyang quota is no running\n" );return -ENOSYS ; + }return xfs_qm_scall_quotaon (mp,xfs_quota_flags (uflags)); }
@@ -198,12 +200,15 @@ xfs_fs_rm_xquota(if (sb_rdonly (sb))return -EROFS ; -if (XFS_IS_QUOTA_ON (mp)) +if (XFS_IS_QUOTA_ON (mp)) { +printk ("xuyang rm quota\n" );return -EINVAL ; + } -if (uflags & ~(FS_USER_QUOTA |FS_GROUP_QUOTA |FS_PROJ_QUOTA )) +if (uflags & ~(FS_USER_QUOTA |FS_GROUP_QUOTA |FS_PROJ_QUOTA )) { +printk ("xuyang flag check\n" );return -EINVAL ; - + }if (uflags &FS_USER_QUOTA ) flags |=XFS_DQ_USER ;if (uflags &FS_GROUP_QUOTA )
-------------------------------------------------------
it will report "xuyang rm quota" because quota acct is on.
So I think it is impossible except we mount without quota option. But it is meaningless(without quota feature to use Q_XQUOTARM). I prefer to use my old way. What do you think about it?
Quoted 9 lines
Quoted 9 lines
+
+???TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, test_id, (void *)&invalid_type));
+??? if (TST_ERR== EINVAL)
+???????tst_res(TPASS, "Q_XQUOTARM has quota type check"); +??? else
+???????tst_res(TFAIL, "Q_XQUOTARM doesn't have quota type check"); +
+???SAFE_UMOUNT(MNTPOINT);
Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl07.c
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +5
-0+} + +static void setup (void ) +{ +??? test_id = geteuid();Is
test_idnecessary?? It seems to be ignored by bothQ_XQUOTAOFFandQ_XQUOTARM.
It is unnecessary. From man-pages or kernel source code, this id argument is ingored. I will use 0 instead of it.
Quoted 16 lines
Quoted 14 lines
+
+???SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota");
+
+???TEST(quotactl(QCMD(Q_XQUOTAOFF, USRQUOTA), tst_device->dev, test_id, (void *)&qflag_acct));
+??? if (TST_RET== -1)
+???????tst_brk(TBROK | TTERRNO, "quotactl with Q_XQUOTAOFF failed"); +
+???TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, test_id, (void *)&valid_type));
+??? if (TST_ERR== EINVAL)
+???????xquotarm_nsup= 1;Is
xquotarm_nsupvariable duplicated? it seems simpler to report TCONF here.
Yes. I will report TCONF here. Also, I will add SAFE_UMOUNT when we use Q_XQUOTAOFF failed.
Quoted 7 lines
Quoted 2 lines
+
+???SAFE_UMOUNT(MNTPOINT);Why do you need to mount and then umount?
Could we call
Q_XQUOTAONif you have to turn on usrquota again?
At the beginning , I also want to use Q_XQUOTAON to turn on usrquota again. But from kernel code, when we call Q_XQUOTAON, it will use XFS_IS_QUOTA_RUNNING macro to check whether there have quota acct. If not, it will report ENOSYS. So, I give up using Q_XQUOTAON and use mount/umount.
Thanks
Yang Xu
Quoted 31 lines
Best Regards,
Xiao Yang
Quoted 23 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +23
-0+} + +static const char *kconfigs[] = { +??? "CONFIG_XFS_QUOTA", +??? NULL +}; + +static struct tst_test test = { +??? .setup = setup, +??? .needs_root = 1, +??? .needs_kconfigs = kconfigs, +??? .test_all = verify_quota, +??? .format_device = 1, +??? .dev_fs_type = "xfs", +??? .mntpoint = MNTPOINT, +??? .tags = (const struct tst_tag[]) { +??????? {"linux-git", "3dd4d40b4208"}, +??????? {} +??? } +}; +#else +??? TST_TEST_TCONF("System doesn't have <xfs/xqm.h>"); +#endif
PATCH 1/1 syscalls/quotactl07: add regresstion test for Q_XQTUOTARM
Quoted 150 lines · Yang Xu
Hi Xiao
Quoted 95 lines · Xiao Yang
Hi Yang,
Quoted 92 lines · Yang Xu
This is a regresstion test to check
Q_XQUOTARM? whether has quota flags check.Signed-off-by Yang Xu <[email protected]>---
? include/lapi/quotactl.h?????????????????????? |? 4 + ? runtest/syscalls????????????????????????????? |? 1 + ? testcases/kernel/syscalls/quotactl/.gitignore |? 1 + ? .../kernel/syscalls/quotactl/quotactl07.c???? | 89+++++++++++++++++++
? 4 files changed, 95 insertions(+)
? create mode 100644testcases/kernel/syscalls/quotactl/quotactl07.cinclude/lapi/quotactl.h +0
-0@@ -59,6 +59,10 @@ struct fs_quota_statv {? # define PRJQUOTA 2
? #endifinclude/lapi/quotactl.h +4
-0+#ifndef Q_XQUOTARM +# define Q_XQUOTARM XQM_CMD(6) +#endif +? #ifndef
Q_XGETQSTATV
? # defineQ_XGETQSTATVXQM_CMD(8)
? #endifruntest/syscalls +0
-0@@ -958,6 +958,7 @@ quotactl03 quotactl03? quotactl04 quotactl04
? quotactl05 quotactl05
? quotactl06 quotactl06
+quotactl07 quotactl07
? read01 read01
? read02 read02testcases/kernel/syscalls/quotactl/.gitignore +0
-0@@ -4,3 +4,4 @@? /quotactl04
? /quotactl05
? /quotactl06testcases/kernel/syscalls/quotactl/.gitignore +1
-0+/quotactl07testcases/kernel/syscalls/quotactl/quotactl07.c new file +37
-0@@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This is a regresstion test for kernel commit 3dd4d40b4208 +* ("xfs: Sanity check flags of Q_XQUOTARM call"). +*/ + +#include "config.h" +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <sys/quota.h> +#include "lapi/quotactl.h" +#include "tst_test.h" + +#ifdef HAVE_XFS_XQM_H +# include <xfs/xqm.h> + +#define MNTPOINT ??? "mntpoint" + +static uint32_t qflag_acct =XFS_QUOTA_UDQ_ACCT ; +static int test_id; +static int xquotarm_nsup; +static unsigned int valid_type =1 ; +static unsigned int invalid_type =9 ; + +static void verify_quota (void ) +{ +??? if (xquotarm_nsup) { +??????? tst_res(TCONF, +??????????? "current system doesn't support Q_XQUOTARM, skip it"); +??????? return; +??? } + +??? SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0,Quoted 8 lines
Quoted 6 lines
"quota");
+
+???TEST(quotactl(QCMD(Q_XQUOTAOFF, USRQUOTA), tst_device->dev, test_id, (void *)&qflag_acct));
+??? if (TST_RET== -1)
+???????tst_brk(TBROK | TTERRNO, "quotactl with Q_XQUOTAOFF failed");Is it possible to git rid of
Q_XQUOTAOFFand callQ_XQUOTARMwithinvalid_typedirectly?From man-pages, before we use
Q_XQUOTARM, quotas must have already been turned off. If we don't use turnoff, it will report EINVAL but not we wanted "EINVAL".? as below:
-------------------------------------------------------fs/xfs/xfs_quotaops.c +9
-5@@ -164,8 +164,10 @@ xfs_quota_enable( ??????? if (sb_rdonly(sb)) ??????????????? return -EROFS; -?????? if (!XFS_IS_QUOTA_RUNNING(mp)) +?????? if (!XFS_IS_QUOTA_RUNNING(mp)) { +?????????????? printk("xuyang quota is no running\n"); ??????????????? return -ENOSYS; +?????? } ??????? return xfs_qm_scall_quotaon(mp, xfs_quota_flags(uflags)); ?}@@ -198,12 +200,15 @@ xfs_fs_rm_xquota( ??????? if (sb_rdonly(sb)) ??????????????? return -EROFS; -?????? if (XFS_IS_QUOTA_ON(mp)) +?????? if (XFS_IS_QUOTA_ON(mp)) { +?????????????? printk("xuyang rm quota\n"); ??????????????? return -EINVAL; +?????? } -?????? if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA)) +?????? if (uflags & ~(FS_USER_QUOTA | FS_GROUP_QUOTA | FS_PROJ_QUOTA)) { +?????????????? printk("xuyang flag check\n"); ??????????????? return -EINVAL; - +?????? } ??????? if (uflags & FS_USER_QUOTA) ??????????????? flags |= XFS_DQ_USER; ??????? if (uflags & FS_GROUP_QUOTA) -------------------------------------------------------it will report "xuyang rm quota" because quota acct is on.
Quoted 3 lines
So I think it is impossible except we mount without quota option. But it is
meaningless(without quota feature to use Q_XQUOTARM). I prefer to use my old way. What do you think about it?
Hi Xu,
Sorry for the late reply.? It seems that you understood what I mean.
e.g. Make setup stage do mount and Q_XQUOTAOFF and then only call
Q_XQUOTARM in verify_quota() as you v2 patch does.
Thanks,
Xiao Yang
Quoted 86 lines
Quoted 11 lines
Quoted 11 lines
+
+???TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, test_id, (void *)&invalid_type));
+??? if (TST_ERR== EINVAL)
+???????tst_res(TPASS, "Q_XQUOTARM has quota type check"); +??? else
+???????tst_res(TFAIL, "Q_XQUOTARM doesn't have quota type check"); +
+???SAFE_UMOUNT(MNTPOINT);Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl07.c
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +5
-0+} + +static void setup (void ) +{ +??? test_id = geteuid();Is
test_idnecessary?? It seems to be ignored by bothQ_XQUOTAOFFandQ_XQUOTARM.It is unnecessary.? From man-pages or kernel source code, this id argument is ingored. I will use 0 instead of it.
Quoted 16 lines
Quoted 14 lines
+
+???SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, "quota");
+
+???TEST(quotactl(QCMD(Q_XQUOTAOFF, USRQUOTA), tst_device->dev, test_id, (void *)&qflag_acct));
+??? if (TST_RET== -1)
+???????tst_brk(TBROK | TTERRNO, "quotactl with Q_XQUOTAOFF failed"); +
+???TEST(quotactl(QCMD(Q_XQUOTARM, USRQUOTA), tst_device->dev, test_id, (void *)&valid_type));
+??? if (TST_ERR== EINVAL)
+???????xquotarm_nsup= 1;Is
xquotarm_nsupvariable duplicated? it seems simpler to report TCONF here.Yes. I will report TCONF here. Also, I will add
SAFE_UMOUNTwhen we useQ_XQUOTAOFFfailed.Quoted 7 lines
Quoted 2 lines
+
+???SAFE_UMOUNT(MNTPOINT);Why do you need to mount and then umount?
Could we call
Q_XQUOTAONif you have to turn on usrquota again?At the beginning , I also want to use
Q_XQUOTAONto turn on usrquota again. But from kernel code, when we callQ_XQUOTAON, it will useXFS_IS_QUOTA_RUNNINGmacro to check whether there have quota acct. If not, it will report ENOSYS. So, I give up usingQ_XQUOTAONand use mount/umount.Thanks
Yang XuQuoted 31 lines
Best Regards,
Xiao Yang
Quoted 23 lines
testcases/kernel/syscalls/quotactl/quotactl07.c new file +23
-0+} + +static const char *kconfigs[] = { +??? "CONFIG_XFS_QUOTA", +??? NULL +}; + +static struct tst_test test = { +??? .setup = setup, +??? .needs_root = 1, +??? .needs_kconfigs = kconfigs, +??? .test_all = verify_quota, +??? .format_device = 1, +??? .dev_fs_type = "xfs", +??? .mntpoint = MNTPOINT, +??? .tags = (const struct tst_tag[]) { +??????? {"linux-git", "3dd4d40b4208"}, +??????? {} +??? } +}; +#else +??? TST_TEST_TCONF("System doesn't have <xfs/xqm.h>"); +#endif