optimize quotactl test code
v2 cover optimize quotactl test code
I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.
------------v1->v2:
for quotactl02.c, add group quota test and add Q_XQUTOARM test
add quotactl04.c and add quota05.c to test project quota.
------------
Yang Xu (6):
syscalls/quotactl: Don't use ltp-quota.m4 m4/ltp-xfs_quota.m4: Remove useless ltp?xfs_quota.m4 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test syscalls/quotactl04: add project quota test for non-xfs filesystem syscalls/quotactl05: add project quota test for xfs filesystem
configure.ac | 2 +- include/lapi/quotactl.h | 35 ++- m4/ltp-quota.m4 | 36 +-- m4/ltp-xfs_quota.m4 | 23 -- runtest/syscalls | 2 + testcases/kernel/syscalls/quotactl/.gitignore | 2 + .../kernel/syscalls/quotactl/quotactl01.c | 133 +++++---- .../kernel/syscalls/quotactl/quotactl02.c | 218 +++++++++++--- .../kernel/syscalls/quotactl/quotactl03.c | 22 +- .../kernel/syscalls/quotactl/quotactl04.c | 159 ++++++++++ .../kernel/syscalls/quotactl/quotactl05.c | 276 ++++++++++++++++++ 11 files changed, 727 insertions(+), 181 deletions(-) delete mode 100644 m4/ltp-xfs_quota.m4 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c
Signature · 1 line
2.18.0
PATCH v2 1/6 syscalls/quotactl: Don't use ltp-quota.m4
Current quotactl01.c has logic problem. There is no relation between Q_GETINFO and quota format. The format should depend on quotacheck -F and kernel config such as CONFIG_QFMT_V1 or CONFIG_QFMT_V2(most linux distributions use the v2).
Q_GETINFO cmd was introduced since Linux 2.4.22, we don't need to check it now. Also, specfiy quota format to QFMT_VFS_V0 by quotacheck -F and check CONFIG_QFMT_V2 in kernel config to avoid issue such as#189[1]. So in quotactl01.c, we don't need to use the macro of ltp-quota.m4. In quotactl0[2-3].c, we don't need to check very basic header <sys/quota.h> (it was introdued in glibc since 1997). Remove quota version macro.
Don't remove ltp-quota.m4 because I will rewrite it to detect if_nextdqblk struct for Q_GETNEXTQUOTA cmd on the coming patch.
[1]https://github.com/linux-test-project/ltp/issues/189
--- .../kernel/syscalls/quotactl/quotactl01.c | 47 +++++++------------ .../kernel/syscalls/quotactl/quotactl02.c | 8 +--- .../kernel/syscalls/quotactl/quotactl03.c | 9 ++-- 3 files changed, 22 insertions(+), 42 deletions(-)
testcases/kernel/syscalls/quotactl/quotactl01.c +17 -30
@@ -39,26 +39,12 @@#include "tst_test.h" -#if defined(HAVE_QUOTAV2 ) || defined(HAVE_QUOTAV1 )# include <sys/quota.h> -# if defined(HAVE_QUOTAV2 ) -# define _LINUX_QUOTA_VERSION 2 -# ifndef QFMT_VFS_V0 -# define QFMT_VFS_V0 2 -# endif +# define QFMT_VFS_V0 2# define USRPATH MNTPOINT "/aquota.user"# define GRPPATH MNTPOINT "/aquota.group"# define FMTID QFMT_VFS_V0 -# else -# define _LINUX_QUOTA_VERSION 1 -# ifndef QFMT_VFS_OLD -# define QFMT_VFS_OLD 1 -# endif -# define USRPATH MNTPOINT "/quota.user" -# define GRPPATH MNTPOINT "/quota.group" -# define FMTID QFMT_VFS_OLD -# endif # define MNTPOINT "mntpoint"
@@ -69,14 +55,13 @@ static struct dqblk set_dq = { .dqb_valid = QIF_BLIMITS };static struct dqblk res_dq; -# if defined(HAVE_QUOTAV2 ) +static struct dqinfo set_qf = { .dqi_bgrace =80 , .dqi_valid =IIF_BGRACE };static struct dqinfo res_qf;static int32_t fmt_buf; -# endif static struct tcase { int cmd;
@@ -96,7 +81,7 @@ static struct tcase { {QCMD (Q_GETQUOTA ,USRQUOTA ), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user"}, -# if defined(HAVE_QUOTAV2) + {QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf, NULL, NULL, 0, "set information about quotafile for user"},
@@ -107,7 +92,7 @@ static struct tcase { {QCMD (Q_GETFMT ,USRQUOTA ), &test_id, &fmt_buf, &fmt_id, &fmt_buf,sizeof (fmt_buf), "get quota format for user"}, -# endif + {QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq, NULL, NULL, 0, "update quota usages for user"},
@@ -123,7 +108,7 @@ static struct tcase { {QCMD (Q_GETQUOTA ,GRPQUOTA ), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit,sizeof (res_dq.dqb_bsoftlimit), "set disk quota limit for group"}, -# if defined(HAVE_QUOTAV2) + {QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf, NULL, NULL, 0, "set information about quotafile for group"},
@@ -133,7 +118,7 @@ static struct tcase { {QCMD (Q_GETFMT ,GRPQUOTA ), &test_id, &fmt_buf, &fmt_id, &fmt_buf, sizeof(fmt_buf), "get quota format for group"}, -# endif + {QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq, NULL, NULL, 0, "update quota usages for group"},
@@ -143,22 +128,21 @@ static struct tcase {static void setup (void ) { -const char *const cmd[] = {"quotacheck" ,"-ug" ,MNTPOINT ,NULL }; +const char *const cmd[] = {"quotacheck" ,"-ugF" ,"vfsv0" ,MNTPOINT ,NULL };int ret; - ret =tst_run_cmd (cmd,NULL ,NULL ,1 );switch (ret) { +case 0 : +break ;case 255 : -tst_brk (TCONF ,"quotacheck binary not installed" ); +tst_brk (TBROK ,"quotacheck binary not installed" ); +break ;default :tst_brk (TBROK ,"quotacheck exited with %i" , ret); -case 0 : -break ; } test_id =geteuid (); -if (access (USRPATH ,F_OK ) ==-1 )tst_brk (TFAIL |TERRNO ,"user quotafile didn't exist" );
@@ -190,9 +174,15 @@ static void verify_quota(unsigned int n)tst_res (TPASS ,"quotactl succeeded to %s" , tc->des); } +static const char *kconfigs[] = { +"CONFIG_QFMT_V2" , +NULL +}; +static struct tst_test test = { .needs_tmpdir =1 , .needs_root =1 , + .needs_kconfigs = kconfigs, .test = verify_quota, .tcnt =ARRAY_SIZE (tcases), .mount_device =1 ,
@@ -202,6 +192,3 @@ static struct tst_test test = { .setup = setup, }; -#else -TST_TEST_TCONF ("This system didn't support quota" ); -#endif
testcases/kernel/syscalls/quotactl/quotactl02.c +2 -6
@@ -23,10 +23,6 @@#include <sys/quota.h> #include "config.h" -#if defined(HAVE_QUOTAV2 ) || defined(HAVE_QUOTAV1 ) -# include <sys/quota.h> -#endif -#if defined(HAVE_XFS_QUOTA )# include <xfs/xqm.h> #endif
@@ -34,7 +30,7 @@#include "tst_test.h" #include "lapi/quotactl.h" -#if defined(HAVE_XFS_QUOTA ) && (defined(HAVE_QUOTAV2 ) || defined(HAVE_QUOTAV1 )) +#if defined(HAVE_XFS_QUOTA )static void check_qoff (int ,char *);static void check_qon (int ,char *);static void check_qlim (int ,char *);
@@ -172,5 +168,5 @@ static struct tst_test test = { .setup = setup, };#else -TST_TEST_TCONF ("This system didn't support quota or xfs quota" ); +TST_TEST_TCONF ("This system didn't support xfs quota" );#endif
testcases/kernel/syscalls/quotactl/quotactl03.c +3 -6
@@ -29,10 +29,7 @@#include <stdio.h> #include <sys/quota.h> #include "config.h" - -#if defined(HAVE_QUOTAV2 ) || defined(HAVE_QUOTAV1 ) -# include <sys/quota.h> -#endif +#include <sys/quota.h> #if defined(HAVE_XFS_QUOTA )# include <xfs/xqm.h>
@@ -41,7 +38,7 @@#include "tst_test.h" #include "lapi/quotactl.h" -#if defined(HAVE_XFS_QUOTA ) && (defined(HAVE_QUOTAV2 ) || defined(HAVE_QUOTAV1 )) +#if defined(HAVE_XFS_QUOTA )static const char mntpoint[] ="mnt_point" ;static uint32_t test_id =0xfffffffc ;
@@ -84,5 +81,5 @@ static struct tst_test test = { };#else -TST_TEST_TCONF ("This system didn't support quota or xfs quota" ); +TST_TEST_TCONF ("This system didn't support xfs quota" );#endif
Signature · 1 line
2.18.0
PATCH v2 1/6 syscalls/quotactl: Don't use ltp-quota.m4
Hi Xu,
Quoted 12 lines
Current
quotactl01.chas logic problem. There is no relation betweenQ_GETINFOand quota format. The format should depend on quotacheck -F and kernel config such asCONFIG_QFMT_V1orCONFIG_QFMT_V2(most linux distributions use the v2).
Q_GETINFOcmd was introduced since Linux 2.4.22, we don't need to check it now. Also, specfiy quota format toQFMT_VFS_V0by quotacheck -F and checkCONFIG_QFMT_V2in kernel config to avoid issue such as#189[1]. So inquotactl01.c, we don't need to use the macro of ltp-quota.m4. In quotactl0[2-3].c, we don't need to check very basic header <sys/quota.h> (it was introdued in glibc since 1997). Remove quota version macro.
Quoted 2 lines
Don't remove ltp-quota.m4 because I will rewrite it to detect
if_nextdqblkstruct forQ_GETNEXTQUOTAcmd on the coming patch.
I'm going to merge 1st and 2nd commit as these are obviously ok. With one change: I'll remove ltp-quota.m4, I see no problem to remove it in 1st commit and later introduce different macro with the same name.
Kind regards,
Petr
PATCH v2 2/6 m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4
In reply to Yang XuWe can detect <xfs/xqm.h> in configure.ac instead of using ltp-xfs_quota.m4. Also we should need to check CONFIG_XFS_QUOTA whether enable in kernel config.
--- configure.ac | 2 +- m4/ltp-xfs_quota.m4 | 23 ------------------- .../kernel/syscalls/quotactl/quotactl02.c | 16 +++++++------ .../kernel/syscalls/quotactl/quotactl03.c | 17 +++++++------- 4 files changed, 19 insertions(+), 39 deletions(-) delete mode 100644 m4/ltp-xfs_quota.m4
configure.ac +1 -1
@@ -62,6 +62,7 @@ AC_CHECK_HEADERS([ \ sys/ustat.h \ sys/utsname.h \ sys/xattr.h \ + xfs/xqm.h \ ]) AC_CHECK_FUNCS([ \
@@ -257,7 +258,6 @@ LTP_CHECK_TIMERFD test "x$with_tirpc" = xyes && LTP_CHECK_TIRPC LTP_CHECK_TPACKET_V3 LTP_CHECK_UNAME_DOMAINNAME -LTP_CHECK_XFS_QUOTACTL LTP_CHECK_X_TABLES LTP_DETECT_HOST_CPU
m4/ltp-xfs_quota.m4 deleted +0 -23
@@ -1,23 +0,0 @@ -dnl SPDX-License-Identifier: GPL-2.0-or-later -dnl Copyright (c) 2013 Fujitsu Ltd. -dnl Author: DAN LI <[email protected]> - -AC_DEFUN([LTP_CHECK_XFS_QUOTACTL],[ - AC_MSG_CHECKING([for XFS quota (xfs/xqm.h)]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _GNU_SOURCE -#include <xfs/xqm.h> -#include <sys/quota.h> -int main(void) { - struct fs_quota_stat qstat; - return quotactl(QCMD(Q_XGETQSTAT, USRQUOTA), "/dev/null", geteuid(), - (caddr_t) &qstat); -}])],[has_xfs_quota="yes"]) - -if test "x$has_xfs_quota" = xyes; then - AC_DEFINE(HAVE_XFS_QUOTA,1,[Define to 1 if you have xfs quota]) - AC_MSG_RESULT(yes) -else - AC_MSG_RESULT(no) -fi -])
testcases/kernel/syscalls/quotactl/quotactl02.c +9 -7
@@ -22,15 +22,11 @@#include <stdio.h> #include <sys/quota.h> #include "config.h" - -#if defined(HAVE_XFS_QUOTA ) -# include <xfs/xqm.h> -#endif -#include "tst_test.h" #include "lapi/quotactl.h" -#if defined(HAVE_XFS_QUOTA ) +#if defined(HAVE_XFS_XQM_H ) +#include <xfs/xqm.h> static void check_qoff (int ,char *);static void check_qon (int ,char *);static void check_qlim (int ,char *);
@@ -156,9 +152,15 @@ static void verify_quota(unsigned int n) tc->func_check (tc->check_subcmd, tc->des); } +static const char *kconfigs[] = { +"CONFIG_XFS_QUOTA" , +NULL +}; +static struct tst_test test = { .needs_tmpdir =1 , .needs_root =1 , + .needs_kconfigs = kconfigs, .test = verify_quota, .tcnt =ARRAY_SIZE (tcases), .mount_device =1 ,
@@ -168,5 +170,5 @@ static struct tst_test test = { .setup = setup, };#else -TST_TEST_TCONF ("This system didn't support xfs quota" ); +TST_TEST_TCONF ("This system didn't have <xfs/xqm.h>" );#endif
testcases/kernel/syscalls/quotactl/quotactl03.c +9 -8
@@ -30,16 +30,11 @@#include <sys/quota.h> #include "config.h" #include <sys/quota.h> - -#if defined(HAVE_XFS_QUOTA ) -# include <xfs/xqm.h> -#endif -#include "tst_test.h" #include "lapi/quotactl.h" -#if defined(HAVE_XFS_QUOTA ) - +#if defined(HAVE_XFS_XQM_H ) +#include <xfs/xqm.h> static const char mntpoint[] ="mnt_point" ;static uint32_t test_id =0xfffffffc ;
@@ -70,9 +65,15 @@ static void verify_quota(void) } } +static const char *kconfigs[] = { +"CONFIG_XFS_QUOTA" , +NULL +}; +static struct tst_test test = { .needs_tmpdir =1 , .needs_root =1 , + .needs_kconfigs = kconfigs, .test_all = verify_quota, .mount_device =1 , .dev_fs_type ="xfs" ,
@@ -81,5 +82,5 @@ static struct tst_test test = { };#else -TST_TEST_TCONF ("This system didn't support xfs quota" ); +TST_TEST_TCONF ("This system didn't have <xfs/xqm.h>" );#endif
Signature · 1 line
2.18.0
PATCH v2 2/6 m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4
Hi Xu,
Quoted 5 lines
We can detect <
xfs/xqm.h> in configure.ac instead of using ltp-xfs_quota.m4. Also we should need to checkCONFIG_XFS_QUOTAwhether enable in kernel config.Signed-off-by Yang Xu <[email protected]>
Merge these 2 commits with minor changes.
Could you please send new version, where you rebase the rest of this patchset, fix issue including <linux/quota.h> with <sys/quota.h> causing failure on centos6 [1] remove Q_SYNC from quotactl04.c [2] and add quotactl06 [3].
Thanks a lot!
Kind regards,
Petr
[1] https://patchwork.ozlabs.org/patch/1181923/#2292956
[2] https://patchwork.ozlabs.org/patch/1181925/#2287412
[3] https://patchwork.ozlabs.org/patch/1185189/
v3 cover optimize quotactl test code
I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.
------------v2->v3:
1.for quotactl02.c, add group quota test
2.add quotactl04.c and add quota05.c to test project quota.
3.add quotactl06.c to test error
4. fix build erro on centos6
ps:don't test Q_XQUOTARM in quotactl02,04 because cycle running will
report ENOSYS (quota feture has been off). I will introduce a
new test to test it and also a regression test for commit[1]. [1]https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/commit/?h=for-next&id=3dd4d40b420846dd35869ccc8f8627feef2cff32 [2]https://travis-ci.org/xuyang0410/ltp/builds/605963472?utm_medium=notification&utm_source=github_status
------------
Yang Xu (5):
syscalls/quotactl01.c: Add Q_GETNEXQUOTA test syscalls/quotactl02.c: Add Q_XGETQSTATV test syscalls/quotactl04: add project quota test for non-xfs filesystem syscalls/quotactl05: add project quota test for xfs filesystem syscalls/quotactl06: Add new testcase
configure.ac | 1 + include/lapi/quotactl.h | 34 +-- m4/ltp-quota.m4 | 8 + runtest/syscalls | 3 + testcases/kernel/syscalls/quotactl/.gitignore | 4 + .../kernel/syscalls/quotactl/quotactl01.c | 53 +++-- .../kernel/syscalls/quotactl/quotactl02.c | 193 +++++++----------- .../kernel/syscalls/quotactl/quotactl02.h | 152 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl04.c | 155 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl05.c | 99 +++++++++ .../kernel/syscalls/quotactl/quotactl06.c | 183 +++++++++++++++++ 11 files changed, 745 insertions(+), 140 deletions(-) create mode 100644 m4/ltp-quota.m4 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl02.h create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c create mode 100644 testcases/kernel/syscalls/quotactl/quotactl06.c
Signature · 1 line
2.18.0
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Q_GETNEXTQUOTA was introduced since linux 4.6, this operation is the same as Q_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.
--- configure.ac | 1 + include/lapi/quotactl.h | 26 +++++---- m4/ltp-quota.m4 | 7 +++ .../kernel/syscalls/quotactl/quotactl01.c | 53 ++++++++++++++----- 4 files changed, 61 insertions(+), 26 deletions(-) create mode 100644 m4/ltp-quota.m4
configure.ac +1 -0
@@ -248,6 +248,7 @@ AC_DEFINE_UNQUOTED(NUMA_ERROR_MSG, ["$numa_error_msg"], [Error message when no N LTP_CHECK_SYSCALL_PERF_EVENT_OPEN +LTP_CHECK_SYSCALL_QUOTACTL LTP_CHECK_SYSCALL_SIGNALFD LTP_CHECK_SYSCALL_UTIMENSAT LTP_CHECK_TASKSTATS
include/lapi/quotactl.h +12 -14
@@ -1,26 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Fujitsu Ltd. +* Copyright (c) 2017-2019 Fujitsu Ltd. * Author: Xiao Yang <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* Author: Yang Xu <[email protected]> */ #ifndef LAPI_QUOTACTL_H__ # define LAPI_QUOTACTL_H__ +#ifdef HAVE_STRUCT_IF_NEXTDQBLK +# include <linux/quota.h> +#endif +#include <sys/quota.h> +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif +# ifndef Q_GETNEXTQUOTA +# define Q_GETNEXTQUOTA 0x800009/* get disk limits and usage >= ID */ +# endif +#endif /* LAPI_QUOTACTL_H__ */
m4/ltp-quota.m4 new file +7 -0
@@ -0,0 +1,7 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Fujitsu Ltd. +dnl Author: Yang Xu <[email protected]> + +AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) +])
testcases/kernel/syscalls/quotactl/quotactl01.c +41 -12
104 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 5 lines
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>
LGTM, minor note below.
Quoted 1 line
include/lapi/quotactl.h +0
-0
...
include/lapi/quotactl.h line 12
Quoted 5 lines
#ifndef
LAPI_QUOTACTL_H__# define LAPI_QUOTACTL_H__include/lapi/quotactl.h +2
-0+#ifdef HAVE_STRUCT_IF_NEXTDQBLK +# include <linux/quota.h>
You test <linux/quota.h> in LTP_CHECK_SYSCALL_QUOTACTL (indirectly via AC_CHECK_TYPES, but that should be ok)
Quoted 3 lines
include/lapi/quotactl.h +3
-0+#endif +#include <sys/quota.h> +
...
include/lapi/quotactl.h static void verify_quota(unsigned int n) · line 186
Quoted 11 lines
include/lapi/quotactl.h +5
-0@@ -155,8 +177,15 @@ static void verify_quota(unsigned int n) res_dq.dqb_bsoftlimit =0 ; res_qf.dqi_igrace =0 ; fmt_buf =0 ; +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) + res_ndq.dqb_id =-1 ; +#endif TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_ERR ==EINVAL ) { +tst_res (TCONF ,"Current system doesn't support this cmd" );
nit: cmd? Maybe something like "quotactl() syscall does not support this command" or "quotactl() syscall does not support to %s", tc->des
to follow other messages. I'd actually prefer to have some macro, which prints QCMD flags, but that's a detail which we can ignore.
include/lapi/quotactl.h static void verify_quota(unsigned int n) · line 191
Quoted 5 lines
include/lapi/quotactl.h +2
-0+return ; + }if (TST_RET ==-1 ) {tst_res (TFAIL |TTERRNO ,"quotactl failed to %s" , tc->des);return ;
Kind regards,
Petr
Xu
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 7 lines
Quoted 6 lines
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>
Thanks for your review.
Quoted 3 lines
include/lapi/quotactl.h line 12
Quoted 2 lines
include/lapi/quotactl.h +2
-0+#ifdef HAVE_STRUCT_IF_NEXTDQBLK +# include <linux/quota.h> You test <
linux/quota.h> inLTP_CHECK_SYSCALL_QUOTACTL(indirectly viaAC_CHECK_TYPES, but that should be ok)
...
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl01.c static void verify_quota(unsigned int n) · line 186
Quoted 3 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +2
-0TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_ERR ==EINVAL ) { +tst_res (TCONF ,"Current system doesn't support this cmd" );nit: cmd? Maybe something like "
quotactl()syscall does not support this command"
or "quotactl()syscall does not support to %s",tc->desto follow other messages. I'd actually prefer to have some macro, which prints QCMD flags, but that's a detail which we can >ignore.
I think we can add some info before each run (such as prctl02.c and copy_file_range02.c, make error cases more clear ), as below:
tst_res(TINFO, "Test #%d: %s", n, tc->tname); // this tname is a QCMD_string
Quoted 2 lines
Kind regards,
Petr
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Hi Xu,
Quoted 7 lines
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl01.c static void verify_quota(unsigned int n) · line 186
Quoted 3 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +2
-0TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_ERR ==EINVAL ) { +tst_res (TCONF ,"Current system doesn't support this cmd" );nit: cmd? Maybe something like "
quotactl()syscall does not support this command"
or "quotactl()syscall does not support to %s",tc->desto follow other messages. I'd actually prefer to have some macro, which prints QCMD flags, but that's a detail which we can >ignore.I think we can add some info before each run (such as
prctl02.candcopy_file_range02.c, make error cases more clear ), as below:tst_res(TINFO, "Test #%d: %s", n, tc->tname); // this tname is a QCMD_string
+1. It could use similar approach as it's in testcases/kernel/syscalls/mbind/mbind01.c
#define POLICY_DESC(x) .policy = x, .desc = #x #define POLICY_DESC_TEXT(x, y) .policy = x, .desc = #x" ("y")"
static struct test_case tcase[] = {
{
POLICY_DESC(MPOL_DEFAULT),
...
},
{
POLICY_DESC_TEXT(MPOL_DEFAULT, "target exists"),But I'd prefer to have it as a separate patch after v4 of this patchset is merged. I'd prefer to finish v4 (I've already fixed small formatting things, I can fix the rest of needed things myself).
Kind regards,
Petr
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 22 lines · Petr Vorel
Hi Xu,
Quoted 7 lines
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl01.c static void verify_quota(unsigned int n) · line 186
Quoted 3 lines
TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));testcases/kernel/syscalls/quotactl/quotactl01.c +2
-0+if (TST_ERR ==EINVAL ) { +tst_res (TCONF ,"Current system doesn't support this cmd" );nit: cmd? Maybe something like "
quotactl()syscall does not support this command"
or "quotactl()syscall does not support to %s",tc->desto follow other messages. I'd actually prefer to have some macro, which prints QCMD flags, but that's a detail which we can >ignore.I think we can add some info before each run (such as
prctl02.candcopy_file_range02.c, make error cases more clear ), as below:tst_res(TINFO, "Test #%d: %s", n, tc->tname); // this tname is a QCMD_string+1. It could use similar approach as it's in
testcases/kernel/syscalls/mbind/mbind01.c#define
POLICY_DESC(x).policy = x, .desc = #x #definePOLICY_DESC_TEXT(x, y).policy = x, .desc = #x" ("y")"static struct test_case tcase[] = { { POLICY_DESC(MPOL_DEFAULT), ... }, { POLICY_DESC_TEXT(MPOL_DEFAULT, "target exists"),
Quoted 3 lines
But I'd prefer to have it as a separate patch after v4 of this patchset is merged. I'd prefer to finish v4 (I've already fixed small formatting things, I can fix the rest of needed things myself).
Hi Petr
?Using a macro is a better way.
Thanks
Yang Xu
Quoted 5 lines
Kind regards,
Petr
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191121/19ca1160/attachment.htm>
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
In reply to Yang XuSubject: [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test => s/Q_GETNEXQUOTA/Q_GETNEXTQUOTA/ :)
Generally there are more typos in docs and formatting issues. As these are just a small details, I usually fix them during merge, but copy paste on constants is you friend.
Kind regards,
Petr
Xu
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Hi Petr
I will check it and correct them.
Quoted 6 lines
Subject: Re: [PATCH v3 1/5]
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtestSubject: [PATCH v3 1/5]
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtest => s/Q_GETNEXQUOTA/Q_GETNEXTQUOTA/ :) Generally there are more typos in docs and >formatting ?issues. As these are just a small details, I usually fix them during merge, but copy paste on constants is you friend.Kind regards,
Petr
PATCH v3 1/5 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Hi Xu,
Quoted 2 lines
Hi Petr
I will check it and correct them.
No need to send a new patchset just for this, I'll fix that during merge.
Quoted 3 lines
Quoted 3 lines
Subject: Re: [PATCH v3 1/5]
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtestSubject: [PATCH v3 1/5]
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtest => s/Q_GETNEXQUOTA/Q_GETNEXTQUOTA/ :) Generally there are more typos in docs and >formatting ?issues. As these are just a small details, I usually fix them during merge, but copy paste on constants is you friend.
Kind regards,
Petr
PATCH v3 2/5 syscalls/quotactl02.c: Add Q_XGETQSTATV test
In reply to Yang XuQ_XGETQSTATV returns XFS filesystem-specific quota information in the fs_quota_statv pointed to by addr. The qs_version field of the structure should be filled with the version of the structure supported by the caller (for now, only FS_QSTAT_VERSION1 is supported).
--- include/lapi/quotactl.h | 4 + m4/ltp-quota.m4 | 1 + .../kernel/syscalls/quotactl/quotactl02.c | 193 +++++++----------- .../kernel/syscalls/quotactl/quotactl02.h | 152 ++++++++++++++ 4 files changed, 236 insertions(+), 114 deletions(-) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl02.h
include/lapi/quotactl.h +4 -0
@@ -13,6 +13,10 @@#endif #include <sys/quota.h> +# ifndef Q_XGETQSTATV +# define Q_XGETQSTATV XQM_CMD(8) +# endif +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif
m4/ltp-quota.m4 +1 -0
@@ -4,4 +4,5 @@ dnl Author: Yang Xu <[email protected]> AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) +AC_CHECK_TYPES([struct fs_quota_statv],,,[#include <xfs/xqm.h>]) ])
testcases/kernel/syscalls/quotactl/quotactl02.c +79 -114
239 lines not on this page · raw message
testcases/kernel/syscalls/quotactl/quotactl02.h new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v3 2/5 syscalls/quotactl02.c: Add Q_XGETQSTATV test
Hi Xu,
Quoted 4 lines
Q_XGETQSTATVreturns XFS filesystem-specific quota information in thefs_quota_statvpointed to by addr. Theqs_versionfield of the structure should be filled with the version of the structure supported by the caller (for now, onlyFS_QSTAT_VERSION1is supported).
nit: one would think you add 1 test case. But you added 8 test cases, all of them are XFS related, but only 4 related to Q_XGETQSTATV.
Quoted 1 line
Signed-off-by Yang Xu <[email protected]>
Nice work, thanks!
Nit: I'd just extract quotactl02.h later in the commit, where
the code needs to be reused (i.e. in 0cc1dc512 ("syscalls/quotactl05: add project quota test for xfs filesystem")) or at least mention why you do it now.
...
Quoted 1 line
+++
b/testcases/kernel/syscalls/quotactl/quotactl02.c
...
testcases/kernel/syscalls/quotactl/quotactl02.c line 104
Quoted 13 lines
testcases/kernel/syscalls/quotactl/quotactl02.c +9
-3+#if defined(HAVE_STRUCT_FS_QUOTA_STATV) + {QCMD(Q_XQUOTAOFF, GRPQUOTA), &qflagg, check_qoffv, + QCMD(Q_XGETQSTATV, GRPQUOTA), 1, + "turn off xfs quota and get xfs quota off statv for group"}, -tst_res (TPASS ,"quoactl() succeeded to set and use %s to get xfs disk quota limits" , - desp); -} + {QCMD(Q_XQUOTAON, GRPQUOTA), &qflagg, check_qonv, + QCMD(Q_XGETQSTATV, GRPQUOTA), 1, + "turn on xfs quota and get xfs quota on statv for group"}, +#endif +};
Hm, we don't report some TCONF: Q_XGETQSTATV not supported. But that's probably not important.
...
Kind regards,
Petr
Xu
PATCH v3 2/5 syscalls/quotactl02.c: Add Q_XGETQSTATV test
Quoted 7 lines
Hi Xu,
Quoted 4 lines
Q_XGETQSTATVreturns XFS filesystem-specific quota information in thefs_quota_statvpointed to by addr. Theqs_versionfield of the structure should be filled with the version of the structure supported by the caller (for now, onlyFS_QSTAT_VERSION1is supported).nit: one would think you add 1 test case. But you added 8 test cases, all of them are XFS related, but only 4 related to
Q_XGETQSTATV.
For user quota, I add 2 test cases to use Q_XGETQSTATV to get status for Q_XQUOTAOFF and Q_XQUOTAOFF .
Also, I add group quota for this case as quotactl01.c. so I add 8 (2+6) test cases. I will update group coverage in commit info.
Ps: I want to use Q_XGETQSTAT to test Q_XQUOTAOFF, Q_XGETQSTATV to test Q_XQUOTAON. So it can be only 8 test cases. But Q_XGETQSTATV is introduced since v3.12-rc1 commit[1]. We should use a pair (on,off )to test Q_XGETQSTATV.
Quoted 2 lines
Quoted 1 line
Signed-off-by Yang Xu <[email protected]>
Thanks for your review.
Quoted 1 line
Quoted 1 line
Nit: I'd just extract
quotactl02.hlater in the commit, where the code needs to be reused (i.e. in0cc1dc512("syscalls/quotactl05: add project quota test for xfs filesystem")) or at least mention why you do it now.
I will mention it in commit info.
Quoted 7 lines
Quoted 1 line
+++
b/testcases/kernel/syscalls/quotactl/quotactl02.c...
Quoted 4 lines
testcases/kernel/syscalls/quotactl/quotactl02.c +4
-0+#if defined(HAVE_STRUCT_FS_QUOTA_STATV) + {QCMD(Q_XQUOTAOFF, GRPQUOTA), &qflagg, check_qoffv, + QCMD(Q_XGETQSTATV, GRPQUOTA), 1, + "turn off xfs quota and get xfs quota off statv for group"},
Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl02.c
Quoted 6 lines
testcases/kernel/syscalls/quotactl/quotactl02.c +3
-3-tst_res (TPASS ,"quoactl() succeeded to set and use %s to get xfs disk quota limits" , - desp); -} + {QCMD (Q_XQUOTAON ,GRPQUOTA ), &qflagg, check_qonv, +QCMD (Q_XGETQSTATV ,GRPQUOTA ),1 , + "turn on xfs quota and get xfs quota on statv for group"}, #endif };Hm, we don't report some TCONF:
Q_XGETQSTATVnot supported. But that's probably not important
This cmd was introduced since 2013, I think we should check it. Also, if we
Use a new kernel but boot with a older kernel header, HAVE_STRUCT_FS_QUOTA_STATV may be undefined.
But in kernel, it is implemented. So I think we may define a fs_quota_statv struct in ltp, so we can detect whether Q_XGETQSTAT is implemented. What do you think about it?
Quoted 3 lines
...
Kind regards,
Petr
PATCH v3 2/5 syscalls/quotactl02.c: Add Q_XGETQSTATV test
Hi Xu,
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Q_XGETQSTATVreturns XFS filesystem-specific quota information in thefs_quota_statvpointed to by addr. Theqs_versionfield of the structure should be filled with the version of the structure supported by the caller (for now, onlyFS_QSTAT_VERSION1is supported).
Quoted 8 lines
Quoted 1 line
nit: one would think you add 1 test case. But you added 8 test cases, all of them are XFS related, but only 4 related to
Q_XGETQSTATV.For user quota, I add 2 test cases to use
Q_XGETQSTATVto get status forQ_XQUOTAOFFandQ_XQUOTAOFF.
Also, I add group quota for this case asquotactl01.c. so I add 8 (2+6) test cases. I will update group coverage in commit info.Ps: I want to use
Q_XGETQSTATto testQ_XQUOTAOFF,Q_XGETQSTATVto testQ_XQUOTAON. So it can be only 8 test cases. ButQ_XGETQSTATVis introduced since v3.12-rc1 commit[1]. We should use a pair (on,off )to testQ_XGETQSTATV.
Thanks for info.
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Yang Xu <[email protected]>Thanks for your review.
Quoted 1 line
Quoted 1 line
Nit: I'd just extract
quotactl02.hlater in the commit, where the code needs to be reused (i.e. in0cc1dc512("syscalls/quotactl05: add project quota test for xfs filesystem")) or at least mention why you do it now.I will mention it in commit info.
OK, I'll review the rest of v3 and wait for v4.
Quoted 15 lines
Quoted 7 lines
Quoted 1 line
+++
b/testcases/kernel/syscalls/quotactl/quotactl02.c...
Quoted 4 lines
testcases/kernel/syscalls/quotactl/quotactl02.c +4
-0+#if defined(HAVE_STRUCT_FS_QUOTA_STATV) + {QCMD(Q_XQUOTAOFF, GRPQUOTA), &qflagg, check_qoffv, + QCMD(Q_XGETQSTATV, GRPQUOTA), 1, + "turn off xfs quota and get xfs quota off statv for group"},Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl02.c
Quoted 6 lines
testcases/kernel/syscalls/quotactl/quotactl02.c +3
-3-tst_res (TPASS ,"quoactl() succeeded to set and use %s to get xfs disk quota limits" , - desp); -} + {QCMD (Q_XQUOTAON ,GRPQUOTA ), &qflagg, check_qonv, +QCMD (Q_XGETQSTATV ,GRPQUOTA ),1 , + "turn on xfs quota and get xfs quota on statv for group"}, #endif };Hm, we don't report some TCONF:
Q_XGETQSTATVnot supported. But that's probably not important
Quoted 4 lines
This cmd was introduced since 2013, I think we should check it. Also, if we
Use a new kernel but boot with a older kernel header,HAVE_STRUCT_FS_QUOTA_STATVmay be undefined.
But in kernel, it is implemented. So I think we may define afs_quota_statvstruct in ltp, so we can detect whetherQ_XGETQSTATis implemented. What do you think about it?
+1, IMHO this makes sense.
Kind regards,
Petr
PATCH v3 3/5 syscalls/quotactl04: add project quota test for non-xfs filesystem
In reply to Yang XuThis is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota
2)on old kernel, kernel doesn't permit mount both prjquota and grpquota together
--- include/lapi/quotactl.h | 4 + runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl04.c | 155 ++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c
include/lapi/quotactl.h +4 -0
@@ -13,6 +13,10 @@#endif #include <sys/quota.h> +#ifndef PRJQUOTA +# define PRJQUOTA 2 +#endif +# ifndef Q_XGETQSTATV # define Q_XGETQSTATV XQM_CMD(8)# endif
runtest/syscalls +1 -0
@@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64 quotactl01 quotactl01 quotactl02 quotactl02 quotactl03 quotactl03 +quotactl04 quotactl04 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
@@ -1,3 +1,4 @@ /quotactl01 /quotactl02 /quotactl03 +/quotactl04
testcases/kernel/syscalls/quotactl/quotactl04.c new file +155 -0
155 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem
Hi Xu,
Quoted 4 lines
This is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota
...
testcases/kernel/syscalls/quotactl/quotactl04.c line 147
Quoted 1 line
testcases/kernel/syscalls/quotactl/quotactl04.c new file +1
-0+ .min_kver = "4.10", /* commit 689c958cbe6b (ext4: add project quota support) */
commit 689c958cbe6b is from v4.5-rc1. But you use Q_GETNEXTQUOTA, which is from 926132c0257a ("quota: add new quotactl Q_GETNEXTQUOTA") from v4.6-rc1.
Others looks to me quite old (before UAPI split in v3.7-rc1.
Thus it could be .min_kver = "v4.5" for the rest (unless there is some other dependency). Or am I missing something? But maybe we just don't care.
Kind regards,
Petr
Quoted 208 lines
2)on old kernel, kernel doesn't permit mount both prjquota and grpquota together
Signed-off-by Yang Xu <[email protected]>--- include/lapi/quotactl.h | 4 + runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl04.c | 155 ++++++++++++++++++ 4 files changed, 161 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.cinclude/lapi/quotactl.h +4
-0@@ -13,6 +13,10 @@#endif #include <sys/quota.h> +#ifndef PRJQUOTA +# define PRJQUOTA 2 +#endif +# ifndef Q_XGETQSTATV # define Q_XGETQSTATV XQM_CMD(8)# endif runtest/syscalls +1
-0@@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64 quotactl01 quotactl01 quotactl02 quotactl02 quotactl03 quotactl03 +quotactl04 quotactl04 read01 read01 read02 read02testcases/kernel/syscalls/quotactl/.gitignore +1
-0@@ -1,3 +1,4 @@ /quotactl01 /quotactl02 /quotactl03 +/quotactl04testcases/kernel/syscalls/quotactl/quotactl04.c new file +155
-0@@ -0,0 +1,155 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This testcase checks the basic flag of quotactl(2) for project quota on +* non-XFS filesystems. +* +* 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project. +* 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag +* for project. +* 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag +* for project. +* 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO +* flag for project. +* 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO +* flag for project. +* 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project. +* 7) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTQUOTA flag for project. +* 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project. +*/ + +#include <errno.h> +#include <string.h> +#include <unistd.h> +#include <stdio.h> +#include <sys/stat.h> +#include "config.h" +#include "lapi/quotactl.h" +#include "tst_test.h" + +#ifndef QFMT_VFS_V1 +# define QFMT_VFS_V1 4 +#endif +#define FMTID QFMT_VFS_V1 +#define MNTPOINT "mntpoint" +static int32_t fmt_id =FMTID ; +static int test_id, mount_flag; +static struct dqblk set_dq = { + .dqb_bsoftlimit =100 , + .dqb_valid =QIF_BLIMITS +}; +static struct dqblk res_dq; +static struct dqinfo set_qf = { + .dqi_bgrace =80 , + .dqi_valid =IIF_BGRACE +}; + +static struct dqinfo res_qf; +static int32_t fmt_buf; + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) +static struct if_nextdqblk res_ndq; +#endif + +static struct tcase { +int cmd; +int *id; +void *addr; +void *set_data; +void *res_data; +int sz; +char *des; +} tcases[] = { + {QCMD (Q_QUOTAON ,PRJQUOTA ), &fmt_id,NULL , +NULL ,NULL ,0 ,"turn on quota for project" }, + + {QCMD (Q_SETQUOTA ,PRJQUOTA ), &test_id, &set_dq, +NULL ,NULL ,0 ,"set disk quota limit for project" }, + + {QCMD (Q_GETQUOTA ,PRJQUOTA ), &test_id, &res_dq, + &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, +sizeof (res_dq.dqb_bsoftlimit),"get disk quota limit for project" }, + + {QCMD (Q_SETINFO ,PRJQUOTA ), &test_id, &set_qf, +NULL ,NULL ,0 ,"set information about quotafile for project" }, + + {QCMD (Q_GETINFO ,PRJQUOTA ), &test_id, &res_qf, + &set_qf.dqi_bgrace, &res_qf.dqi_bgrace,sizeof (res_qf.dqi_bgrace), +"get information about quotafile for project" }, + + {QCMD (Q_GETFMT ,PRJQUOTA ), &test_id, &fmt_buf, + &fmt_id, &fmt_buf,sizeof (fmt_buf), +"get quota format for project" }, + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK) + {QCMD (Q_GETNEXTQUOTA ,PRJQUOTA ), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id,sizeof (res_ndq.dqb_id), +"get next disk quota limit for project" }, +#endif + + {QCMD (Q_QUOTAOFF ,PRJQUOTA ), &test_id,NULL , +NULL ,NULL ,0 ,"turn off quota for project" }, + +}; + +static void setup (void ) +{ +const char *const extra_opts[] = {"-O quota,project" ,NULL }; + + test_id =geteuid (); +SAFE_MKFS (tst_device->dev, tst_device->fs_type,NULL , extra_opts); +SAFE_MOUNT (tst_device->dev,MNTPOINT , tst_device->fs_type,0 ,"quota" ); + mount_flag =1 ; +} + +static void cleanup (void ) +{ +if (mount_flag &&tst_umount (MNTPOINT )) +tst_res (TWARN |TERRNO ,"umount(%s)" ,MNTPOINT ); +} + +static void verify_quota (unsigned int n) +{ +struct tcase *tc = &tcases[n]; + + res_dq.dqb_bsoftlimit =0 ; + res_qf.dqi_igrace =0 ; + fmt_buf =0 ; + +TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_RET ==-1 ) { +tst_res (TFAIL |TTERRNO ,"quotactl failed to %s" , tc->des); +return ; + } + +if (memcmp (tc->res_data, tc->set_data, tc->sz)) { +tst_res (TFAIL ,"quotactl failed to %s" , tc->des); +tst_res_hexd (TINFO , tc->res_data, tc->sz,"retval: " ); +tst_res_hexd (TINFO , tc->set_data, tc->sz,"expected: " ); +return ; + } + +tst_res (TPASS ,"quotactl succeeded to %s" , tc->des); +} + +static const char *kconfigs[] = { +"CONFIG_QFMT_V2" , +NULL +}; + +static struct tst_test test = { + .needs_tmpdir =1 , + .needs_root =1 , + .needs_kconfigs = kconfigs, + .min_kver ="4.10" ,/* commit 689c958cbe6b (ext4: add project quota support) */ + .test = verify_quota, + .tcnt =ARRAY_SIZE (tcases), + .setup = setup, + .cleanup = cleanup, + .needs_device =1 , + .dev_fs_type ="ext4" , + .mntpoint =MNTPOINT , +};
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem
Hi Petr
Quoted 10 lines
Hi Xu,
Quoted 4 lines
Quoted 4 lines
This is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota...
Quoted 1 line
Quoted 1 line
+ .min_kver = "4.10", /* commit
689c958cbe6b(ext4: add project quota support) */commit
689c958cbe6bis from v4.5-rc1. But you useQ_GETNEXTQUOTA, which is from926132c0257a("quota: add new quotactlQ_GETNEXTQUOTA") from v4.6-rc1.
Oh, I remember I use the following command to search linux tag git tag --contains 689c958
v4.10
v4.10-rc1
v4.10-rc2
...
v4.5-rc1
I forgot to see the last v4.5-rc1. Sorry.
Quoted 5 lines
Others looks to me quite old (before UAPI split in v3.7-rc1.
Thus it could be .min_kver = "v4.5" for the rest (unless there is some other dependency). Or am I missing something? But maybe we just don't care.
I think we should fix this. I will send patch to fix these two problems.
Best Regards
Yang Xu
Quoted 4 lines
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 4/5 syscalls/quotactl05: add project quota test for xfs filesystem
In reply to Yang XuThis is a variant about quotactl02. It is used to test project quota. I split it into a new case instead of adding it in quotaclt02 because kernel doesn't permit mount both group and project quota before commit d892d5864f02 ("xfs: Start using pquotaino from the superblock.").
--- runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 2 + .../kernel/syscalls/quotactl/quotactl05.c | 99 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c
runtest/syscalls +1 -0
@@ -954,6 +954,7 @@ quotactl01 quotactl01 quotactl02 quotactl02 quotactl03 quotactl03 quotactl04 quotactl04 +quotactl05 quotactl05 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +2 -0
@@ -2,3 +2,5 @@ /quotactl02 /quotactl03 /quotactl04 +/quotactl05 +
testcases/kernel/syscalls/quotactl/quotactl05.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v3 5/5 syscalls/quotactl06: Add new testcase
In reply to Yang XuCheck various errnos for the quotactl().
--- runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl06.c | 183 ++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl06.c
runtest/syscalls +1 -0
@@ -955,6 +955,7 @@ quotactl02 quotactl02 quotactl03 quotactl03 quotactl04 quotactl04 quotactl05 quotactl05 +quotactl06 quotactl06 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
@@ -3,4 +3,5 @@ /quotactl03 /quotactl04 /quotactl05 +/quotactl06
testcases/kernel/syscalls/quotactl/quotactl06.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.18.0
v3 cover optimize quotactl test code
In reply to Yang XuHi All
ping.
Quoted 36 lines
I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.
------------
v2->v3:
1.forquotactl02.c, add group quota test
2.addquotactl04.cand addquota05.cto test project quota.
3.addquotactl06.cto test error
4. fix build erro on centos6
ps:don't testQ_XQUOTARMin quotactl02,04 because cycle running will
report ENOSYS (quota feture has been off). I will introduce a
new test to test it and also a regression test for commit[1]. [1]https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/commit/?h=for-next&id=3dd4d40b420846dd35869ccc8f8627feef2cff32 [2]https://travis-ci.org/xuyang0410/ltp/builds/605963472?utm_medium=notification&utm_source=github_status
------------Yang Xu (5):
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtestsyscalls/quotactl02.c: AddQ_XGETQSTATVtest syscalls/quotactl04: add project quota test for non-xfs filesystem syscalls/quotactl05: add project quota test for xfs filesystem syscalls/quotactl06: Add new testcaseconfigure.ac | 1 + include/lapi/quotactl.h | 34 +-- m4/ltp-quota.m4 | 8 + runtest/syscalls | 3 + testcases/kernel/syscalls/quotactl/.gitignore | 4 + .../kernel/syscalls/quotactl/quotactl01.c | 53 +++-- .../kernel/syscalls/quotactl/quotactl02.c | 193 +++++++----------- .../kernel/syscalls/quotactl/quotactl02.h | 152 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl04.c | 155 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl05.c | 99 +++++++++ .../kernel/syscalls/quotactl/quotactl06.c | 183 +++++++++++++++++ 11 files changed, 745 insertions(+), 140 deletions(-)
Quoted 6 lines
create mode 100644 m4/ltp-quota.m4
create mode 100644testcases/kernel/syscalls/quotactl/quotactl02.hcreate mode 100644testcases/kernel/syscalls/quotactl/quotactl04.ccreate mode 100644testcases/kernel/syscalls/quotactl/quotactl05.ccreate mode 100644testcases/kernel/syscalls/quotactl/quotactl06.c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191112/93f0dbfc/attachment.htm>
v3 cover optimize quotactl test code
Hi
Does anyone have some comments for this patch set?
Quoted 44 lines
Hi All
ping.Quoted 42 lines
I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.
------------
v2->v3:
1.forquotactl02.c, add group quota test
2.addquotactl04.cand addquota05.cto test project quota.
3.addquotactl06.cto test error
4. fix build erro on centos6
ps:don't testQ_XQUOTARMin quotactl02,04 because cycle running will
report ENOSYS (quota feture has been off). I will introduce a
new test to test it and also a regression test for commit[1]. [1]https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/commit/?h=for-next&id=3dd4d40b420846dd35869ccc8f8627feef2cff32 [2]https://travis-ci.org/xuyang0410/ltp/builds/605963472?utm_medium=notification&utm_source=github_status
------------Yang Xu (5):
syscalls/quotactl01.c: AddQ_GETNEXQUOTAtestsyscalls/quotactl02.c: AddQ_XGETQSTATVtest syscalls/quotactl04: add project quota test for non-xfs filesystem syscalls/quotactl05: add project quota test for xfs filesystem syscalls/quotactl06: Add new testcaseconfigure.ac | 1 + include/lapi/quotactl.h | 34 +-- m4/ltp-quota.m4 | 8 + runtest/syscalls | 3 + testcases/kernel/syscalls/quotactl/.gitignore | 4 + .../kernel/syscalls/quotactl/quotactl01.c | 53 +++-- .../kernel/syscalls/quotactl/quotactl02.c | 193 +++++++----------- .../kernel/syscalls/quotactl/quotactl02.h | 152 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl04.c | 155 ++++++++++++++ .../kernel/syscalls/quotactl/quotactl05.c | 99 +++++++++ .../kernel/syscalls/quotactl/quotactl06.c | 183 +++++++++++++++++ 11 files changed, 745 insertions(+), 140 deletions(-)create mode 100644 m4/ltp-quota.m4
create mode 100644testcases/kernel/syscalls/quotactl/quotactl02.hcreate mode 100644testcases/kernel/syscalls/quotactl/quotactl04.ccreate mode 100644testcases/kernel/syscalls/quotactl/quotactl05.ccreate mode 100644testcases/kernel/syscalls/quotactl/quotactl06.c
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191115/7541d7ae/attachment.htm>
v3 cover optimize quotactl test code
Hi Xu,
Quoted 2 lines
Hi
Does anyone have some comments for this patch set?
Sorry, I've been busy with other things, but it's on my todo list.
Kind regards,
Petr
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
In reply to Yang XuQ_GETNEXTQUOTA was introduced since linux 4.6, this operation is the same as Q_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.
--- include/lapi/quotactl.h | 23 ++--- m4/ltp-quota.m4 | 36 +------- .../kernel/syscalls/quotactl/quotactl01.c | 86 ++++++++++++------- 3 files changed, 67 insertions(+), 78 deletions(-)
include/lapi/quotactl.h +9 -14
@@ -1,26 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Fujitsu Ltd. +* Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved. * Author: Xiao Yang <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* Author: Yang Xu <[email protected]> */ #ifndef LAPI_QUOTACTL_H__ # define LAPI_QUOTACTL_H__ +#include <linux/quota.h> +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif +# ifndef Q_GETNEXTQUOTA +# define Q_GETNEXTQUOTA 0x800009/* get disk limits and usage >= ID */ +# endif +#endif /* LAPI_QUOTACTL_H__ */
m4/ltp-quota.m4 +2 -34
@@ -1,39 +1,7 @@ dnl SPDX-License-Identifier: GPL-2.0-or-later dnl Copyright (c) Cisco Systems, Inc, 2008 +dnl Copyright (c) 2019 Fujitsu Ltd. AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 2 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETINFO, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav2="yes"]) - -if test "x$has_quotav2" = xyes; then - AC_DEFINE(HAVE_QUOTAV2,1,[Define to 1 if you have quota v2]) -else - - # got quota v1? - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 1 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETQUOTA, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav1="yes"]) - - if test "x$has_quotav1" = xyes; then - AC_DEFINE(HAVE_QUOTAV1,1,[Define to 1 if you have quota v1]) - else - AC_MSG_WARN(Couldn't determine quota version (please submit config.log and manpage to [email protected])) - fi - -fi +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) ])
testcases/kernel/syscalls/quotactl/quotactl01.c +56 -30
167 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 5 lines · Yang Xu
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>
I was thinking about how much these tests are actually needed. The thing is that fstests have also quota tests. And as part of these tests we do run e.g. repquota(8) and verify its output and that uses Q_GETNEXTQUOTA inside. So Q_GETNEXTQUOTA gets testing as part of fstests. On the other hand fstests are focused on testing the general quota functionality as user would use it so we don't really try to make sure all quotactl calls are covered. So there's still some value in low level testing of each quotactl like you do here.
Honza
Quoted 274 lines
--- include/lapi/quotactl.h | 23 ++--- m4/ltp-quota.m4 | 36 +------- .../kernel/syscalls/quotactl/quotactl01.c | 86 ++++++++++++------- 3 files changed, 67 insertions(+), 78 deletions(-)include/lapi/quotactl.h +9
-14@@ -1,26 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Fujitsu Ltd. +* Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved. * Author: Xiao Yang <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* Author: Yang Xu <[email protected]> */ #ifndef LAPI_QUOTACTL_H__ # define LAPI_QUOTACTL_H__ +#include <linux/quota.h> +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif +# ifndef Q_GETNEXTQUOTA +# define Q_GETNEXTQUOTA 0x800009/* get disk limits and usage >= ID */ +# endif +#endif /* LAPI_QUOTACTL_H__ */ m4/ltp-quota.m4 +2
-34@@ -1,39 +1,7 @@ dnl SPDX-License-Identifier: GPL-2.0-or-later dnl Copyright (c) Cisco Systems, Inc, 2008 +dnl Copyright (c) 2019 Fujitsu Ltd. AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 2 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETINFO, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav2="yes"]) - -if test "x$has_quotav2" = xyes; then - AC_DEFINE(HAVE_QUOTAV2,1,[Define to 1 if you have quota v2]) -else - - # got quota v1? - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 1 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETQUOTA, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav1="yes"]) - - if test "x$has_quotav1" = xyes; then - AC_DEFINE(HAVE_QUOTAV1,1,[Define to 1 if you have quota v1]) - else - AC_MSG_WARN(Couldn't determine quota version (please submit config.log and manpage to [email protected])) - fi - -fi +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) ])testcases/kernel/syscalls/quotactl/quotactl01.c +56
-30@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) Crackerjack Project., 2007 -* Copyright (c) 2016 Fujitsu Ltd. +* Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved * Author: Xiao Yang <[email protected]> * * This testcase checks the basic flag of quotactl(2) for non-XFS filesystems: @@ -16,19 +16,23 @@* flag for user. * 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for user. * 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for user. -* 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user. -* 9) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group. -* 10) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag +* 8) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTSTAT flag for user. +* 9) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user. +* 10) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group. +* 11) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag * for group. -* 11) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag +* 12) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag * for group. -* 12) quotactl(2) succeeds to set information about quotafile with Q_SETINFO +* 13) quotactl(2) succeeds to set information about quotafile with Q_SETINFO * flag for group. -* 13) quotactl(2) succeeds to get information about quotafile with Q_GETINFO +* 14) quotactl(2) succeeds to get information about quotafile with Q_GETINFO * flag for group. -* 14) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group. -* 15) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group. -* 16) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group. +* 15) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group. +* 16) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group. +* 17) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTSTAT flag for group. +* 18) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group. */ #include <errno.h> @@ -36,10 +40,9 @@#include <unistd.h> #include <stdio.h> #include "config.h" - +#include <sys/quota.h> #include "tst_test.h" - -# include <sys/quota.h> +#include "lapi/quotactl.h" # define QFMT_VFS_V0 2# define USRPATH MNTPOINT "/aquota.user"@@ -63,6 +66,10 @@ static struct dqinfo set_qf = {static struct dqinfo res_qf;static int32_t fmt_buf; +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) +static struct if_nextdqblk res_ndq; +#endif + static struct tcase { int cmd; int *id;@@ -70,60 +77,73 @@ static struct tcase {void *set_data;void *res_data;int sz; +int nflag;char *des; } tcases[] = { {QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH, - NULL, NULL, 0, "turn on quota for user"}, + NULL, NULL, 0, 0, "turn on quota for user"}, {QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, - NULL, NULL, 0, "set disk quota limit for user"}, + NULL, NULL, 0, 0, "set disk quota limit for user"}, {QCMD(Q_GETQUOTA, USRQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, - sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user"}, + sizeof(res_dq.dqb_bsoftlimit), 0, "get disk quota limit for user"}, {QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf, - NULL, NULL, 0, "set information about quotafile for user"}, + NULL, NULL, 0, 0, "set information about quotafile for user"}, {QCMD(Q_GETINFO, USRQUOTA), &test_id, &res_qf, - &set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + &set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), 0, "get information about quotafile for user"}, {QCMD(Q_GETFMT, USRQUOTA), &test_id, &fmt_buf, - &fmt_id, &fmt_buf, sizeof(fmt_buf), + &fmt_id, &fmt_buf, sizeof(fmt_buf), 0, "get quota format for user"}, {QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq, - NULL, NULL, 0, "update quota usages for user"}, + NULL, NULL, 0, 0, "update quota usages for user"}, + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK) + {QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), 1, + "get next disk quota limit for user"}, +#endif {QCMD(Q_QUOTAOFF, USRQUOTA), &test_id, USRPATH, - NULL, NULL, 0, "turn off quota for user"}, + NULL, NULL, 0, 0, "turn off quota for user"}, {QCMD(Q_QUOTAON, GRPQUOTA), &fmt_id, GRPPATH, - NULL, NULL, 0, "turn on quota for group"}, + NULL, NULL, 0, 0, "turn on quota for group"}, {QCMD(Q_SETQUOTA, GRPQUOTA), &test_id, &set_dq, - NULL, NULL, 0, "set disk quota limit for group"}, + NULL, NULL, 0, 0, "set disk quota limit for group"}, {QCMD(Q_GETQUOTA, GRPQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, - &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), + &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), 0, "set disk quota limit for group"}, {QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf, - NULL, NULL, 0, "set information about quotafile for group"}, + NULL, NULL, 0, 0, "set information about quotafile for group"}, {QCMD(Q_GETINFO, GRPQUOTA), &test_id, &res_qf, &set_qf.dqi_bgrace, - &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), 0, "get information about quotafile for group"}, {QCMD(Q_GETFMT, GRPQUOTA), &test_id, &fmt_buf, - &fmt_id, &fmt_buf, sizeof(fmt_buf), "get quota format for group"}, + &fmt_id, &fmt_buf, sizeof(fmt_buf), 0, "get quota format for group"}, {QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq, - NULL, NULL, 0, "update quota usages for group"}, + NULL, NULL, 0, 0, "update quota usages for group"}, + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK) + {QCMD(Q_GETNEXTQUOTA, GRPQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), 1, + "get next disk quota limit for group"}, +#endif {QCMD(Q_QUOTAOFF, GRPQUOTA), &test_id, GRPPATH, - NULL, NULL, 0, "turn off quota for group"} + NULL, NULL, 0, 0, "turn off quota for group"} }; static void setup(void)@@ -156,9 +176,15 @@ static void verify_quota(unsigned int n) res_dq.dqb_bsoftlimit =0 ; res_qf.dqi_igrace =0 ; +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) + res_ndq.dqb_id =-1 ; +#endif fmt_buf =0 ; -TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_ERR ==ENOSYS && tc->nflag) { +tst_res (TCONF ,"Current system doesn't support Q_GETNEXTQUOTA, it needs kernel>=4.6!" ); +return ; + }if (TST_RET ==-1 ) {tst_res (TFAIL |TTERRNO ,"quotactl failed to %s" , tc->des);return ;Signature · 1 line
2.18.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 7 lines · Jan Kara
Quoted 5 lines · Yang Xu
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>
Quoted 8 lines
I was thinking about how much these tests are actually needed. The thing is that fstests have also quota tests. And as part of these tests we do run e.g. repquota(8) and verify its output and that uses
Q_GETNEXTQUOTAinside. SoQ_GETNEXTQUOTAgets testing as part of fstests. On the other hand fstests are focused on testing the general quota functionality as user would use it so we don't really try to make sure all quotactl calls are covered. So there's still some value in low level testing of each quotactl like you do here.
IMO, fstests tests quota more deeply and it coverS more user scenes(also
some regresstion tests). But in ltp, in syscalls/quotactl, I try my
best to test various subcmds (it may stay in API level but not actual quota actions) and three quota types(user,group,project).
In addition, I am writing quotactl error tests as man-pages mentioned.
Quoted 277 lines
Honza
Quoted 274 lines
--- include/lapi/quotactl.h | 23 ++--- m4/ltp-quota.m4 | 36 +------- .../kernel/syscalls/quotactl/quotactl01.c | 86 ++++++++++++------- 3 files changed, 67 insertions(+), 78 deletions(-)include/lapi/quotactl.h +9
-14@@ -1,26 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* -* Copyright (c) 2017 Fujitsu Ltd. +* Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved. * Author: Xiao Yang <[email protected]> -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. +* Author: Yang Xu <[email protected]> */ #ifndef LAPI_QUOTACTL_H__ # define LAPI_QUOTACTL_H__ +#include <linux/quota.h> +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif +# ifndef Q_GETNEXTQUOTA +# define Q_GETNEXTQUOTA 0x800009/* get disk limits and usage >= ID */ +# endif +#endif /* LAPI_QUOTACTL_H__ */ m4/ltp-quota.m4 +2
-34@@ -1,39 +1,7 @@ dnl SPDX-License-Identifier: GPL-2.0-or-later dnl Copyright (c) Cisco Systems, Inc, 2008 +dnl Copyright (c) 2019 Fujitsu Ltd. AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 2 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETINFO, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav2="yes"]) - -if test "x$has_quotav2" = xyes; then - AC_DEFINE(HAVE_QUOTAV2,1,[Define to 1 if you have quota v2]) -else - - # got quota v1? - AC_LINK_IFELSE([AC_LANG_SOURCE([ -#define _LINUX_QUOTA_VERSION 1 -#include <sys/types.h> -#include <sys/quota.h> -#include <unistd.h> -int main(void) { - struct dqblk dq; - return quotactl(QCMD(Q_GETQUOTA, USRQUOTA), (const char *) "/dev/null", - geteuid(), (caddr_t) &dq); -}])],[has_quotav1="yes"]) - - if test "x$has_quotav1" = xyes; then - AC_DEFINE(HAVE_QUOTAV1,1,[Define to 1 if you have quota v1]) - else - AC_MSG_WARN(Couldn't determine quota version (please submit config.log and manpage to [email protected])) - fi - -fi +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) ])testcases/kernel/syscalls/quotactl/quotactl01.c +56
-30@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) Crackerjack Project., 2007 -* Copyright (c) 2016 Fujitsu Ltd. +* Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved * Author: Xiao Yang <[email protected]> * * This testcase checks the basic flag of quotactl(2) for non-XFS filesystems: @@ -16,19 +16,23 @@* flag for user. * 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for user. * 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for user. -* 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user. -* 9) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group. -* 10) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag +* 8) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTSTAT flag for user. +* 9) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user. +* 10) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group. +* 11) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag * for group. -* 11) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag +* 12) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag * for group. -* 12) quotactl(2) succeeds to set information about quotafile with Q_SETINFO +* 13) quotactl(2) succeeds to set information about quotafile with Q_SETINFO * flag for group. -* 13) quotactl(2) succeeds to get information about quotafile with Q_GETINFO +* 14) quotactl(2) succeeds to get information about quotafile with Q_GETINFO * flag for group. -* 14) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group. -* 15) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group. -* 16) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group. +* 15) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group. +* 16) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group. +* 17) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTSTAT flag for group. +* 18) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group. */ #include <errno.h> @@ -36,10 +40,9 @@#include <unistd.h> #include <stdio.h> #include "config.h" - +#include <sys/quota.h> #include "tst_test.h" - -# include <sys/quota.h> +#include "lapi/quotactl.h" # define QFMT_VFS_V0 2# define USRPATH MNTPOINT "/aquota.user"@@ -63,6 +66,10 @@ static struct dqinfo set_qf = {static struct dqinfo res_qf;static int32_t fmt_buf; +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) +static struct if_nextdqblk res_ndq; +#endif + static struct tcase { int cmd; int *id;@@ -70,60 +77,73 @@ static struct tcase {void *set_data;void *res_data;int sz; +int nflag;char *des; } tcases[] = { {QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH, - NULL, NULL, 0, "turn on quota for user"}, + NULL, NULL, 0, 0, "turn on quota for user"}, {QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, - NULL, NULL, 0, "set disk quota limit for user"}, + NULL, NULL, 0, 0, "set disk quota limit for user"}, {QCMD(Q_GETQUOTA, USRQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit, - sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user"}, + sizeof(res_dq.dqb_bsoftlimit), 0, "get disk quota limit for user"}, {QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf, - NULL, NULL, 0, "set information about quotafile for user"}, + NULL, NULL, 0, 0, "set information about quotafile for user"}, {QCMD(Q_GETINFO, USRQUOTA), &test_id, &res_qf, - &set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + &set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), 0, "get information about quotafile for user"}, {QCMD(Q_GETFMT, USRQUOTA), &test_id, &fmt_buf, - &fmt_id, &fmt_buf, sizeof(fmt_buf), + &fmt_id, &fmt_buf, sizeof(fmt_buf), 0, "get quota format for user"}, {QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq, - NULL, NULL, 0, "update quota usages for user"}, + NULL, NULL, 0, 0, "update quota usages for user"}, + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK) + {QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), 1, + "get next disk quota limit for user"}, +#endif {QCMD(Q_QUOTAOFF, USRQUOTA), &test_id, USRPATH, - NULL, NULL, 0, "turn off quota for user"}, + NULL, NULL, 0, 0, "turn off quota for user"}, {QCMD(Q_QUOTAON, GRPQUOTA), &fmt_id, GRPPATH, - NULL, NULL, 0, "turn on quota for group"}, + NULL, NULL, 0, 0, "turn on quota for group"}, {QCMD(Q_SETQUOTA, GRPQUOTA), &test_id, &set_dq, - NULL, NULL, 0, "set disk quota limit for group"}, + NULL, NULL, 0, 0, "set disk quota limit for group"}, {QCMD(Q_GETQUOTA, GRPQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit, - &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), + &res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit), 0, "set disk quota limit for group"}, {QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf, - NULL, NULL, 0, "set information about quotafile for group"}, + NULL, NULL, 0, 0, "set information about quotafile for group"}, {QCMD(Q_GETINFO, GRPQUOTA), &test_id, &res_qf, &set_qf.dqi_bgrace, - &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), + &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace), 0, "get information about quotafile for group"}, {QCMD(Q_GETFMT, GRPQUOTA), &test_id, &fmt_buf, - &fmt_id, &fmt_buf, sizeof(fmt_buf), "get quota format for group"}, + &fmt_id, &fmt_buf, sizeof(fmt_buf), 0, "get quota format for group"}, {QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq, - NULL, NULL, 0, "update quota usages for group"}, + NULL, NULL, 0, 0, "update quota usages for group"}, + +#if defined(HAVE_STRUCT_IF_NEXTDQBLK) + {QCMD(Q_GETNEXTQUOTA, GRPQUOTA), &test_id, &res_ndq, + &test_id, &res_ndq.dqb_id, sizeof(res_ndq.dqb_id), 1, + "get next disk quota limit for group"}, +#endif {QCMD(Q_QUOTAOFF, GRPQUOTA), &test_id, GRPPATH, - NULL, NULL, 0, "turn off quota for group"} + NULL, NULL, 0, 0, "turn off quota for group"} }; static void setup(void)@@ -156,9 +176,15 @@ static void verify_quota(unsigned int n) res_dq.dqb_bsoftlimit =0 ; res_qf.dqi_igrace =0 ; +#if defined(HAVE_STRUCT_IF_NEXTDQBLK ) + res_ndq.dqb_id =-1 ; +#endif fmt_buf =0 ; -TEST (quotactl (tc->cmd, tst_device->dev, *tc->id, tc->addr)); +if (TST_ERR ==ENOSYS && tc->nflag) { +tst_res (TCONF ,"Current system doesn't support Q_GETNEXTQUOTA, it needs kernel>=4.6!" ); +return ; + }if (TST_RET ==-1 ) {tst_res (TFAIL |TTERRNO ,"quotactl failed to %s" , tc->des);return ;Signature · 1 line
2.18.0
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
In reply to Jan KaraHi Jan,
Quoted 7 lines · Yang Xu
Quoted 5 lines
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>
Quoted 8 lines
I was thinking about how much these tests are actually needed. The thing is that fstests have also quota tests. And as part of these tests we do run e.g. repquota(8) and verify its output and that uses
Q_GETNEXTQUOTAinside. SoQ_GETNEXTQUOTAgets testing as part of fstests. On the other hand fstests are focused on testing the general quota functionality as user would use it so we don't really try to make sure all quotactl calls are covered. So there's still some value in low level testing of each quotactl like you do here.
Agree that testing quotactl as syscall in LTP makes sense (unlike testing filesystem features or performance, that was the reason why we deleted "New ext4 features" tests).
Thank you for the review!
Kind regards,
Petr
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
In reply to Yang XuHi Xu,
Quoted 12 lines
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>--- include/lapi/quotactl.h | 23 ++--- m4/ltp-quota.m4 | 36 +------- .../kernel/syscalls/quotactl/quotactl01.c | 86 ++++++++++++------- 3 files changed, 67 insertions(+), 78 deletions(-)include/lapi/quotactl.h +0
-0
...
Quoted 4 lines
#ifndef
LAPI_QUOTACTL_H__# define LAPI_QUOTACTL_H__+#include <
linux/quota.h>
I'd prefer to add autotools check for <linux/quota.h configure.ac (I guess we ignore include/config.h.default atm).
But, more important, I'd prefer to include <sys/quota.h> here as well:
#ifdef HAVE_LINUX_QUOTA_H
# include <linux/quota.h> #else # include <sys/quota.h> #endif
=> move it from quotactl0*.c (there is not yet agreement to include headers in lapi files, but later lapi files does it).
The reason is that old distros fail when both headers are included at the same time (probably <linux/quota.h> got fixed later, maybe there is an workaround, but the easiest way is to handle this in header anyway).
Kind regards,
Petr
[1] https://travis-ci.org/pevik/ltp/jobs/605507690
[2] https://api.travis-ci.org/v3/job/605507690/log.txt
PATCH v2 3/6 syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
Quoted 19 lines · Petr Vorel
Hi Xu,
Quoted 10 lines
Q_GETNEXTQUOTAwas introduced since linux 4.6, this operation is the same asQ_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.Signed-off-by Yang Xu <[email protected]>--- include/lapi/quotactl.h | 23 ++--- m4/ltp-quota.m4 | 36 +------- .../kernel/syscalls/quotactl/quotactl01.c | 86 ++++++++++++------- 3 files changed, 67 insertions(+), 78 deletions(-)include/lapi/quotactl.h +0
-0...
Quoted 3 lines
#ifndef
LAPI_QUOTACTL_H__# define LAPI_QUOTACTL_H__ +#include <linux/quota.h>I'd prefer to add autotools check for <
linux/quota.hconfigure.ac (I guess we ignoreinclude/config.h.defaultatm).
Quoted 7 lines
But, more important, I'd prefer to include <
sys/quota.h> here as well:#ifdef
HAVE_LINUX_QUOTA_H# include <linux/quota.h> #else # include <sys/quota.h> #endif
Hi Petr
It still has problems that sys/quota.h has some struct defintion as struct dqblk ,struct dqinfo. Also, now linux/quota.h doesn't have quotactl function declaration.
I think we can use HAVE_STRUCT_IF_NEXTDQBLK macro in lapi/quotactl.h to decide whether include <linux/quota.h> because I add <linux/quota.h> for finding struct if_netxdqblk defintion.
ps: In my ltp fork, it passed.
Thanks
Yang Xu
Quoted 8 lines
=> move it from quotactl0*.c (there is not yet agreement to include headers in lapi files, but later lapi files does it).
The reason is that old distros fail when both headers are included at the same time (probably <
linux/quota.h> got fixed later, maybe there is an workaround, but the easiest way is to handle this in header anyway).
Quoted 7 lines
Kind regards,
Petr[1] https://travis-ci.org/pevik/ltp/jobs/605507690
[2] https://api.travis-ci.org/v3/job/605507690/log.txt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191101/06f679de/attachment.htm>
PATCH v2 4/6 syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test
In reply to Yang XuQ_XGETQSTATV returns XFS filesystem-specific quota information in the fs_quota_statv pointed to by addr. The qs_version field of the structure should be filled with the version of the structure supported by the caller (for now, only FS_QSTAT_VERSION1 is supported).
Q_XQUOTARM free the disk space taken by disk quotas and quotas must have already been turned off.
Also increase coverage to test group quota.
--- include/lapi/quotactl.h | 8 + m4/ltp-quota.m4 | 2 + .../kernel/syscalls/quotactl/quotactl02.c | 200 +++++++++++++++--- 3 files changed, 182 insertions(+), 28 deletions(-)
include/lapi/quotactl.h +8 -0
@@ -10,6 +10,14 @@#include <linux/quota.h> +# ifndef Q_XQUOTARM +# define Q_XQUOTARM XQM_CMD(6) +# endif + +# ifndef Q_XGETQSTATV +# define Q_XGETQSTATV XQM_CMD(8) +# endif +# ifndef Q_XGETNEXTQUOTA # define Q_XGETNEXTQUOTA XQM_CMD(9)# endif
m4/ltp-quota.m4 +2 -0
@@ -4,4 +4,6 @@ dnl Copyright (c) 2019 Fujitsu Ltd. AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[ AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>]) +AC_CHECK_TYPES([struct fs_quota_statv],,,[#include <xfs/xqm.h>]) + ])
testcases/kernel/syscalls/quotactl/quotactl02.c +172 -28
293 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v2 5/6 syscalls/quotactl04: add project quota test for non-xfs filesystem
In reply to Yang XuThis is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota
2)on old kernel, kernel doesn't permit mount both prjquota and grpquota together
--- include/lapi/quotactl.h | 4 + runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl04.c | 159 ++++++++++++++++++ 4 files changed, 165 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c
include/lapi/quotactl.h +4 -0
@@ -10,6 +10,10 @@#include <linux/quota.h> +# ifndef PRJQUOTA +# define PRJQUOTA 2 +# endif +# ifndef Q_XQUOTARM # define Q_XQUOTARM XQM_CMD(6)# endif
runtest/syscalls +1 -0
@@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64 quotactl01 quotactl01 quotactl02 quotactl02 quotactl03 quotactl03 +quotactl04 quotactl04 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
@@ -1,3 +1,4 @@ /quotactl01 /quotactl02 /quotactl03 +/quotactl04
testcases/kernel/syscalls/quotactl/quotactl04.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v2 5/6 syscalls/quotactl04: add project quota test for non-xfs filesystem
Quoted 9 lines · Yang Xu
This is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota
2)on old kernel, kernel doesn't permit mount both prjquota and grpquota togetherSigned-off-by Yang Xu <[email protected]>Suggested-by Jan Kara <[email protected]>
...
Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +9
-0@@ -0,0 +1,159 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This testcase checks the basic flag of quotactl(2) for project quota on +* non-XFS filesystems. +* +* 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project.
testcases/kernel/syscalls/quotactl/quotactl04.c line 19
Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +10
-0+* 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag +* for project. +* 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag +* for project. +* 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO +* flag for project. +* 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO +* flag for project. +* 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project. +* 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for project.
Testing Q_SYNC is mostly pointless for project quota as it will just do nothing (the quota changes are journalled).
testcases/kernel/syscalls/quotactl/quotactl04.c line 23
Quoted 4 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +4
-0+* 8) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTQUOTA flag for project. +* 9) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project. +*/
Otherwise the set of checks looks sensible to do basic sanity check of quotactl(2) syscall.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
PATCH v2 5/6 syscalls/quotactl04: add project quota test for non-xfs filesystem
Quoted 25 lines · Jan Kara
Quoted 9 lines · Yang Xu
This is a variant about quotactl01. It is used to test project quota. I split it into a new case instead of adding it in quotaclt01 because two points:
1)before linux 4.10, ext4 doesn't support project quota
2)on old kernel, kernel doesn't permit mount both prjquota and grpquota togetherSigned-off-by Yang Xu <[email protected]>Suggested-by Jan Kara <[email protected]>...
Quoted 14 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +13
-0@@ -0,0 +1,159 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 FUJITSU LIMITED. All rights reserved. +* Author: Yang Xu <[email protected]> +* +* This testcase checks the basic flag of quotactl(2) for project quota on +* non-XFS filesystems. +* +* 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for project. +* 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag +* for project. +* 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag +* for project.
Quoted 8 lines
testcases/kernel/syscalls/quotactl/quotactl04.c line 19
Quoted 6 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +6
-0+* 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO +* flag for project. +* 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO +* flag for project. +* 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for project. +* 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for project. Testing
Q_SYNCis mostly pointless for project quota as it will just do nothing (the quota changes are journalled).
I have no objection about removint Q_SYNC.
Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl04.c line 23
Quoted 5 lines
testcases/kernel/syscalls/quotactl/quotactl04.c new file +4
-0+* 8) quotactl(2) succeeds to get disk quota limit greater than or equal to +* ID with Q_GETNEXTQUOTA flag for project. +* 9) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for project. +*/ Otherwise the set of checks looks sensible to do basic sanity check of quotactl(2) syscall.
Honza
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191024/35c20053/attachment.htm>
PATCH v2 6/6 syscalls/quotactl05: add project quota test for xfs filesystem
In reply to Yang XuThis is a variant about quotactl02. It is used to test project quota. I split it into a new case instead of adding it in quotaclt02 because kernel doesn't permit mount both group and project quota before commit d892d5864f02 ("xfs: Start using pquotaino from the superblock.").
--- runtest/syscalls | 1 + testcases/kernel/syscalls/quotactl/.gitignore | 1 + .../kernel/syscalls/quotactl/quotactl05.c | 276 ++++++++++++++++++ 3 files changed, 278 insertions(+) create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c
runtest/syscalls +1 -0
@@ -954,6 +954,7 @@ quotactl01 quotactl01 quotactl02 quotactl02 quotactl03 quotactl03 quotactl04 quotactl04 +quotactl05 quotactl05 read01 read01 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
@@ -2,3 +2,4 @@ /quotactl02 /quotactl03 /quotactl04 +/quotactl05
testcases/kernel/syscalls/quotactl/quotactl05.c new file +276 -0
276 lines not on this page · raw message
Signature · 1 line
2.18.0