All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2 0/6] optimize quotactl test code
@ 2019-10-23  9:00 Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
                   ` (5 more replies)
  0 siblings, 6 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

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

-- 
2.18.0




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  2019-10-31 14:02   ` Petr Vorel
  2019-10-23  9:00 ` [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4 Yang Xu
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

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

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 .../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(-)

diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index bcb1b842c..b0be525d6 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -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
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index 7e74840e4..0593b965f 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -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
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index 32a281482..cf73231a9 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -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
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  2019-10-31 15:26   ` Petr Vorel
  2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

We 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.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/configure.ac b/configure.ac
index 3785dff63..5e741af08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
 
diff --git a/m4/ltp-xfs_quota.m4 b/m4/ltp-xfs_quota.m4
deleted file mode 100644
index 60a4b5633..000000000
--- a/m4/ltp-xfs_quota.m4
+++ /dev/null
@@ -1,23 +0,0 @@
-dnl SPDX-License-Identifier: GPL-2.0-or-later
-dnl Copyright (c) 2013 Fujitsu Ltd.
-dnl Author: DAN LI <li.dan@cn.fujitsu.com>
-
-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
-])
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index 0593b965f..021833411 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -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
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
index cf73231a9..434fefe2a 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl03.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -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
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4 Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  2019-10-24  8:25   ` Jan Kara
  2019-10-31 14:31   ` Petr Vorel
  2019-10-23  9:00 ` [LTP] [PATCH v2 4/6] syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test Yang Xu
                   ` (2 subsequent siblings)
  5 siblings, 2 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 include/lapi/quotactl.h                       | 23 ++---
 m4/ltp-quota.m4                               | 36 +-------
 .../kernel/syscalls/quotactl/quotactl01.c     | 86 ++++++++++++-------
 3 files changed, 67 insertions(+), 78 deletions(-)

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index 729472f69..99f4e5fc5 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -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 <yangx.jy@cn.fujitsu.com>
- *
- * 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 <xuyang2018.jy@cn.jujitsu.com>
  */
 
 #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__ */
diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
index c5e233ca1..964c34925 100644
--- a/m4/ltp-quota.m4
+++ b/m4/ltp-quota.m4
@@ -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 ltp@lists.linux.it))
-	fi
-
-fi
+AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
 ])
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index b0be525d6..af78646e4 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -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 <yangx.jy@cn.fujitsu.com>
 *
 * 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;
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 4/6] syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
                   ` (2 preceding siblings ...)
  2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
  2019-10-23  9:00 ` [LTP] [PATCH v2 6/6] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
  5 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

Q_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.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 include/lapi/quotactl.h                       |   8 +
 m4/ltp-quota.m4                               |   2 +
 .../kernel/syscalls/quotactl/quotactl02.c     | 200 +++++++++++++++---
 3 files changed, 182 insertions(+), 28 deletions(-)

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index 99f4e5fc5..f1e404256 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -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
diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
index 964c34925..688c7c5f7 100644
--- a/m4/ltp-quota.m4
+++ b/m4/ltp-quota.m4
@@ -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>])
+
 ])
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index 021833411..da431a41d 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2013 Fujitsu Ltd.
+ * Copyright (c) 2016-2019 FUJITSU LIMITED. All rights reserved
  * Author: DAN LI <li.dan@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
  */
 
 /*
@@ -9,12 +10,32 @@
  *
  * Description:
  * This testcase checks basic flags of quotactl(2) for an XFS file system:
- * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status.
- * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status.
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for user.
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for user.
  * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
- *    limits.
+ *    limits for user.
  * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
- *    quota limits.
+ *    quota limits Cgreater than or equal to ID for user.
+ * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for user.
+ * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for user.
+ * 7) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for group.
+ * 8) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for group.
+ * 9) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits for group.
+ * 10) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits for group.
+ * 11) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for group.
+ * 12) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for group.
+ * 13)quotactl(2) succeeds to turn off xfs_quota and use Q_XQUOTARM to free
+ *    disk space taken by disk quotas.
  */
 #define _GNU_SOURCE
 #include <errno.h>
@@ -27,16 +48,25 @@
 
 #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_qoff(int, char *, int);
+static void check_qon(int, char *, int);
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qoffv(int, char *, int);
+static void check_qonv(int, char *, int);
+#endif
+
 static void check_qlim(int, char *);
+static void check_qrm(int, char *);
 
 static uint32_t test_id;
 static struct fs_disk_quota set_dquota = {
 	.d_rtb_softlimit = 1000,
 	.d_fieldmask = FS_DQ_RTBSOFT
 };
-static uint32_t qflag = XFS_QUOTA_UDQ_ENFD;
+static uint32_t qflagu = XFS_QUOTA_UDQ_ENFD;
+static uint32_t qflagg = XFS_QUOTA_GDQ_ENFD;
+static uint32_t qflag_acct = XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_GDQ_ACCT;
 static const char mntpoint[] = "mnt_point";
 
 static struct t_case {
@@ -44,32 +74,78 @@ static struct t_case {
 	void *addr;
 	void (*func_check)();
 	int check_subcmd;
+	int flag;
 	char *des;
 } tcases[] = {
-	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflag, check_qoff, Q_XGETQSTAT,
-	"turn off xfs quota and get xfs quota off status"},
-	{QCMD(Q_XQUOTAON, USRQUOTA), &qflag, check_qon, Q_XGETQSTAT,
-	"turn on xfs quota and get xfs quota on status"},
-	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETQUOTA,
-	"Q_XGETQUOTA"},
-	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETNEXTQUOTA,
-	"Q_XGETNEXTQUOTA"},
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflagu, check_qoff,
+	QCMD(Q_XGETQSTAT, USRQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for user"},
+
+	{QCMD(Q_XQUOTAON, USRQUOTA), &qflagu, check_qon,
+	QCMD(Q_XGETQSTAT, USRQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for user"},
+
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, USRQUOTA), 0,
+	"Q_XGETQUOTA for user"},
+
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, USRQUOTA), 0,
+	"Q_XGETNEXTQUOTA for user"},
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflagu, check_qoffv,
+	QCMD(Q_XGETQSTATV, USRQUOTA), 1,
+	"turn off xfs quota and get xfs quota off statv for user"},
+
+	{QCMD(Q_XQUOTAON, USRQUOTA), &qflagu, check_qonv,
+	QCMD(Q_XGETQSTATV, USRQUOTA), 1,
+	"turn on xfs quota and get xfs quota on statv for user"},
+#endif
+
+	{QCMD(Q_XQUOTAOFF, GRPQUOTA), &qflagg, check_qoff,
+	QCMD(Q_XGETQSTAT, GRPQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for group"},
+
+	{QCMD(Q_XQUOTAON, GRPQUOTA), &qflagg, check_qon,
+	QCMD(Q_XGETQSTAT, GRPQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for group"},
+
+	{QCMD(Q_XSETQLIM, GRPQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, GRPQUOTA), 0,
+	"Q_XGETQUOTA for group"},
+
+	{QCMD(Q_XSETQLIM, GRPQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, GRPQUOTA), 0,
+	"Q_XGETNEXTQUOTA for group"},
+
+#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"},
+
+	{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
+
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflag_acct, check_qrm, Q_XQUOTARM, 1,
+	"turn off xfs quota and free disk spaces taken by disk quotas"},
 };
 
-static void check_qoff(int subcmd, char *desp)
+static void check_qoff(int subcmd, char *desp, int flag)
 {
 	int res;
 	struct fs_quota_stat res_qstat;
 
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
-	               test_id, (void*) &res_qstat);
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
 	if (res == -1) {
 		tst_res(TFAIL | TERRNO,
 			"quotactl() failed to get xfs quota off status");
 		return;
 	}
 
-	if (res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD) {
+	if (res_qstat.qs_flags & flag) {
 		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
 		return;
 	}
@@ -77,20 +153,43 @@ static void check_qoff(int subcmd, char *desp)
 	tst_res(TPASS, "quoactl() succeeded to %s", desp);
 }
 
-static void check_qon(int subcmd, char *desp)
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qoffv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1,
+	};
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off stav");
+		return;
+	}
+
+	if (res_qstatv.qs_flags & flag) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+#endif
+
+static void check_qon(int subcmd, char *desp, int flag)
 {
 	int res;
 	struct fs_quota_stat res_qstat;
 
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
-	               test_id, (void*) &res_qstat);
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
 	if (res == -1) {
 		tst_res(TFAIL | TERRNO,
 			"quotactl() failed to get xfs quota on status");
 		return;
 	}
 
-	if (!(res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)) {
+	if (!(res_qstat.qs_flags & flag)) {
 		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
 		return;
 	}
@@ -98,6 +197,30 @@ static void check_qon(int subcmd, char *desp)
 	tst_res(TPASS, "quoactl() succeeded to %s", desp);
 }
 
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qonv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1
+	};
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on statv");
+		return;
+	}
+
+	if (!(res_qstatv.qs_flags & flag)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+#endif
+
 static void check_qlim(int subcmd, char *desp)
 {
 	int res;
@@ -105,8 +228,7 @@ static void check_qlim(int subcmd, char *desp)
 
 	res_dquota.d_rtb_softlimit = 0;
 
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
-	               test_id, (void*) &res_dquota);
+	res = quotactl(subcmd, tst_device->dev,	test_id, (void *) &res_dquota);
 	if (res == -1) {
 		if (errno == EINVAL) {
 			tst_brk(TCONF | TERRNO,
@@ -134,6 +256,25 @@ static void check_qlim(int subcmd, char *desp)
 		"quota limits", desp);
 }
 
+static void check_qrm(int subcmd, char *desp)
+{
+	int res;
+
+	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
+			test_id, (void *) &qflag_acct);
+	if (res == -1) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"Q_XQUOTARM wasn't supported in quotactl()");
+		}
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to free disk spaces taken by disk quotas");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
 static void setup(void)
 {
 	test_id = geteuid();
@@ -149,7 +290,10 @@ static void verify_quota(unsigned int n)
 		return;
 	}
 
-	tc->func_check(tc->check_subcmd, tc->des);
+	if (tc->flag)
+		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
+	else
+		tc->func_check(tc->check_subcmd, tc->des);
 }
 
 static const char *kconfigs[] = {
@@ -166,7 +310,7 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.dev_fs_type = "xfs",
 	.mntpoint = mntpoint,
-	.mnt_data = "usrquota",
+	.mnt_data = "usrquota,grpquota",
 	.setup = setup,
 };
 #else
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
                   ` (3 preceding siblings ...)
  2019-10-23  9:00 ` [LTP] [PATCH v2 4/6] syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  2019-10-24  8:14   ` Jan Kara
  2019-10-23  9:00 ` [LTP] [PATCH v2 6/6] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

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 together

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Suggested-by: Jan Kara <jack@suse.cz>
---
 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

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index f1e404256..309806fc0 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -10,6 +10,10 @@
 
 #include <linux/quota.h>
 
+# ifndef PRJQUOTA
+#  define PRJQUOTA 2
+# endif
+
 # ifndef Q_XQUOTARM
 #  define Q_XQUOTARM XQM_CMD(6)
 # endif
diff --git a/runtest/syscalls b/runtest/syscalls
index 12d3e0d3b..c30e9e620 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64
 quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
+quotactl04 quotactl04
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index b0ef075e7..1db7c5d98 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -1,3 +1,4 @@
 /quotactl01
 /quotactl02
 /quotactl03
+/quotactl04
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
new file mode 100644
index 000000000..c169b8b13
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * 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 update quota usages with Q_SYNC flag for project.
+ * 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.
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include "config.h"
+#include <sys/quota.h>
+#include "lapi/quotactl.h"
+#include "tst_test.h"
+
+#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"},
+
+	{QCMD(Q_SYNC, PRJQUOTA), &test_id, &res_dq,
+	NULL, NULL, 0, "update quota usages 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,
+};
+
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 6/6] syscalls/quotactl05: add project quota test for xfs filesystem
  2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
                   ` (4 preceding siblings ...)
  2019-10-23  9:00 ` [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
@ 2019-10-23  9:00 ` Yang Xu
  5 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-23  9:00 UTC (permalink / raw)
  To: ltp

This 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.").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/runtest/syscalls b/runtest/syscalls
index c30e9e620..f2c7b0daf 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -954,6 +954,7 @@ quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
+quotactl05 quotactl05
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index 1db7c5d98..6fe62fbf7 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -2,3 +2,4 @@
 /quotactl02
 /quotactl03
 /quotactl04
+/quotactl05
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
new file mode 100644
index 000000000..7f62c3b8c
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -0,0 +1,276 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * Test Name: quotactl05
+ *
+ * Description:
+ * This testcase checks basic flags of quotactl(2) for project on an XFS file
+ * system:
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for project
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for project.
+ * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits for project.
+ * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits Cgreater than or equal to ID for project.
+ * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for project.
+ * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for project.
+ * 7)quotactl(2) succeeds to turn off xfs_quota and use Q_XQUOTARM to free
+ *    disk space taken by disk quotas.
+ */
+#define _GNU_SOURCE
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/quota.h>
+#include "config.h"
+#include "tst_test.h"
+#include "lapi/quotactl.h"
+
+#if defined(HAVE_XFS_XQM_H)
+#include <xfs/xqm.h>
+static void check_qoff(int, char *, int);
+static void check_qon(int, char *, int);
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qoffv(int, char *, int);
+static void check_qonv(int, char *, int);
+#endif
+
+static void check_qlim(int, char *);
+static void check_qrm(int, char *);
+
+static uint32_t test_id;
+static struct fs_disk_quota set_dquota = {
+	.d_rtb_softlimit = 1000,
+	.d_fieldmask = FS_DQ_RTBSOFT
+};
+static uint32_t qflag = XFS_QUOTA_PDQ_ENFD;
+static uint32_t qflag_acct = XFS_QUOTA_PDQ_ACCT | XFS_QUOTA_UDQ_ACCT | XFS_QUOTA_GDQ_ACCT;
+static const char mntpoint[] = "mnt_point";
+
+static struct t_case {
+	int cmd;
+	void *addr;
+	void (*func_check)();
+	int check_subcmd;
+	int flag;
+	char *des;
+} tcases[] = {
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflag, check_qoff, Q_XGETQSTAT, 1,
+	"turn off xfs quota and get xfs quota off status for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflag, check_qon, Q_XGETQSTAT, 1,
+	"turn on xfs quota and get xfs quota on status for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim, Q_XGETQUOTA, 0,
+	"Q_XGETQUOTA for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim, Q_XGETNEXTQUOTA, 0,
+	"Q_XGETNEXTQUOTA for project"},
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflag, check_qoffv, Q_XGETQSTATV, 1,
+	"turn off xfs quota and get xfs quota off statv for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflag, check_qonv, Q_XGETQSTATV, 1,
+	"turn on xfs quota and get xfs quota on statv for project"},
+#endif
+
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflag_acct, check_qrm, Q_XQUOTARM, 1,
+	"turn off xfs quota and free disk spaces taken by disk quotas"},
+};
+
+static void check_qoff(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_stat res_qstat;
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+			test_id, (void *) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off status");
+		return;
+	}
+
+	if (res_qstat.qs_flags & flag) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qoffv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1,
+	};
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+			test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off stav");
+		return;
+	}
+
+	if (res_qstatv.qs_flags & flag) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+#endif
+
+static void check_qon(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_stat res_qstat;
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+		test_id, (void *) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on status");
+		return;
+	}
+
+	if (!(res_qstat.qs_flags & flag)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+static void check_qonv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1
+	};
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+		test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on statv");
+		return;
+	}
+
+	if (!(res_qstatv.qs_flags & flag)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+#endif
+
+static void check_qlim(int subcmd, char *desp)
+{
+	int res;
+	static struct fs_disk_quota res_dquota;
+
+	res_dquota.d_rtb_softlimit = 0;
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+			test_id, (void *) &res_dquota);
+	if (res == -1) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"%s wasn't supported in quotactl()", desp);
+		}
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs disk quota limits");
+		return;
+	}
+
+	if (res_dquota.d_id != test_id) {
+		tst_res(TFAIL, "quotactl() got unexpected user id %u,"
+			" expected %u", res_dquota.d_id, test_id);
+		return;
+	}
+
+	if (res_dquota.d_rtb_hardlimit != set_dquota.d_rtb_hardlimit) {
+		tst_res(TFAIL, "quotactl() got unexpected rtb soft limit %llu,"
+			" expected %llu", res_dquota.d_rtb_hardlimit,
+			set_dquota.d_rtb_hardlimit);
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to set and use %s to get xfs disk "
+		"quota limits", desp);
+}
+
+static void check_qrm(int subcmd, char *desp)
+{
+	int res;
+
+	res = quotactl(QCMD(subcmd, PRJQUOTA), tst_device->dev,
+			test_id, (void *) &qflag_acct);
+	if (res == -1) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"Q_XQUOTARM wasn't supported in quotactl()");
+		}
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to free disk spaces taken by disk quotas");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+static void setup(void)
+{
+	test_id = geteuid();
+}
+
+static void verify_quota(unsigned int n)
+{
+	struct t_case *tc = &tcases[n];
+
+	TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+		return;
+	}
+
+	if (tc->flag)
+		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
+	else
+		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,
+	.dev_fs_type = "xfs",
+	.mntpoint = mntpoint,
+	.mnt_data = "prjquota",
+	.setup = setup,
+};
+#else
+	TST_TEST_TCONF("This system didn't have <xfs/xqm.h>");
+#endif
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2019-10-23  9:00 ` [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
@ 2019-10-24  8:14   ` Jan Kara
  2019-10-24  9:55     ` Yang Xu
  0 siblings, 1 reply; 37+ messages in thread
From: Jan Kara @ 2019-10-24  8:14 UTC (permalink / raw)
  To: ltp

On Wed 23-10-19 17:00:30, Yang Xu wrote:
> 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 together
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> Suggested-by: Jan Kara <jack@suse.cz>
>
...
> @@ -0,0 +1,159 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + *
> + * 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 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).

> + * 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

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
@ 2019-10-24  8:25   ` Jan Kara
  2019-10-25  8:49     ` Yang Xu
  2019-10-31 14:10     ` Petr Vorel
  2019-10-31 14:31   ` Petr Vorel
  1 sibling, 2 replies; 37+ messages in thread
From: Jan Kara @ 2019-10-24  8:25 UTC (permalink / raw)
  To: ltp

On Wed 23-10-19 17:00:28, Yang Xu wrote:
> 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.
> 
> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>

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

> ---
>  include/lapi/quotactl.h                       | 23 ++---
>  m4/ltp-quota.m4                               | 36 +-------
>  .../kernel/syscalls/quotactl/quotactl01.c     | 86 ++++++++++++-------
>  3 files changed, 67 insertions(+), 78 deletions(-)
> 
> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
> index 729472f69..99f4e5fc5 100644
> --- a/include/lapi/quotactl.h
> +++ b/include/lapi/quotactl.h
> @@ -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 <yangx.jy@cn.fujitsu.com>
> - *
> - * 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 <xuyang2018.jy@cn.jujitsu.com>
>   */
>  
>  #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__ */
> diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
> index c5e233ca1..964c34925 100644
> --- a/m4/ltp-quota.m4
> +++ b/m4/ltp-quota.m4
> @@ -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 ltp@lists.linux.it))
> -	fi
> -
> -fi
> +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
>  ])
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
> index b0be525d6..af78646e4 100644
> --- a/testcases/kernel/syscalls/quotactl/quotactl01.c
> +++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
> @@ -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 <yangx.jy@cn.fujitsu.com>
>  *
>  * 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;
> -- 
> 2.18.0
> 
> 
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2019-10-24  8:14   ` Jan Kara
@ 2019-10-24  9:55     ` Yang Xu
  0 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-24  9:55 UTC (permalink / raw)
  To: ltp


on 2019/10/24 16:14, Jan Kara wrote:

> On Wed 23-10-19 17:00:30, Yang Xu wrote:
>> 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 together
>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> Suggested-by: Jan Kara <jack@suse.cz>
>>
> ...
>> @@ -0,0 +1,159 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
>> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> + *
>> + * 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 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).

I have no objection about removint Q_SYNC.

>
>> + * 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>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-24  8:25   ` Jan Kara
@ 2019-10-25  8:49     ` Yang Xu
  2019-10-31 14:10     ` Petr Vorel
  1 sibling, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-10-25  8:49 UTC (permalink / raw)
  To: ltp



on 2019/10/24 16:25, Jan Kara wrote:
> On Wed 23-10-19 17:00:28, Yang Xu wrote:
>> 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.
>>
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> 
> 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.

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.
> 
> 								Honza
> 
>> ---
>>   include/lapi/quotactl.h                       | 23 ++---
>>   m4/ltp-quota.m4                               | 36 +-------
>>   .../kernel/syscalls/quotactl/quotactl01.c     | 86 ++++++++++++-------
>>   3 files changed, 67 insertions(+), 78 deletions(-)
>>
>> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
>> index 729472f69..99f4e5fc5 100644
>> --- a/include/lapi/quotactl.h
>> +++ b/include/lapi/quotactl.h
>> @@ -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 <yangx.jy@cn.fujitsu.com>
>> - *
>> - * 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 <xuyang2018.jy@cn.jujitsu.com>
>>    */
>>   
>>   #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__ */
>> diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
>> index c5e233ca1..964c34925 100644
>> --- a/m4/ltp-quota.m4
>> +++ b/m4/ltp-quota.m4
>> @@ -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 ltp@lists.linux.it))
>> -	fi
>> -
>> -fi
>> +AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
>>   ])
>> diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
>> index b0be525d6..af78646e4 100644
>> --- a/testcases/kernel/syscalls/quotactl/quotactl01.c
>> +++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
>> @@ -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 <yangx.jy@cn.fujitsu.com>
>>   *
>>   * 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;
>> -- 
>> 2.18.0
>>
>>
>>



^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4
  2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
@ 2019-10-31 14:02   ` Petr Vorel
  0 siblings, 0 replies; 37+ messages in thread
From: Petr Vorel @ 2019-10-31 14:02 UTC (permalink / raw)
  To: ltp

Hi Xu,

> 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.
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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-24  8:25   ` Jan Kara
  2019-10-25  8:49     ` Yang Xu
@ 2019-10-31 14:10     ` Petr Vorel
  1 sibling, 0 replies; 37+ messages in thread
From: Petr Vorel @ 2019-10-31 14:10 UTC (permalink / raw)
  To: ltp

Hi Jan,

> On Wed 23-10-19 17:00:28, Yang Xu wrote:
> > 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.

> > Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>

> 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.

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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
  2019-10-24  8:25   ` Jan Kara
@ 2019-10-31 14:31   ` Petr Vorel
  2019-11-01 12:44     ` Yang Xu
  1 sibling, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-10-31 14:31 UTC (permalink / raw)
  To: ltp

Hi Xu,

> 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.

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  include/lapi/quotactl.h                       | 23 ++---
>  m4/ltp-quota.m4                               | 36 +-------
>  .../kernel/syscalls/quotactl/quotactl01.c     | 86 ++++++++++++-------
>  3 files changed, 67 insertions(+), 78 deletions(-)

> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
...
>  #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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP]  [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4
  2019-10-23  9:00 ` [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4 Yang Xu
@ 2019-10-31 15:26   ` Petr Vorel
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
  0 siblings, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-10-31 15:26 UTC (permalink / raw)
  To: ltp

Hi Xu,

> We 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.

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>

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/

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-10-31 14:31   ` Petr Vorel
@ 2019-11-01 12:44     ` Yang Xu
  0 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:44 UTC (permalink / raw)
  To: ltp


on 2019/10/31 22:31, Petr Vorel wrote:

> Hi Xu,
>
>> 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.
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>> ---
>>   include/lapi/quotactl.h                       | 23 ++---
>>   m4/ltp-quota.m4                               | 36 +-------
>>   .../kernel/syscalls/quotactl/quotactl01.c     | 86 ++++++++++++-------
>>   3 files changed, 67 insertions(+), 78 deletions(-)
>> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
> ...
>>   #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

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.

[1]https://travis-ci.org/xuyang0410/ltp/builds/605963472?utm_medium=notification&utm_source=github_status

Thanks
Yang Xu

>
> => 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
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191101/06f679de/attachment.htm>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 0/5] optimize quotactl test code
  2019-10-31 15:26   ` Petr Vorel
@ 2019-11-01 12:55     ` Yang Xu
  2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
                         ` (5 more replies)
  0 siblings, 6 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

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

-- 
2.18.0




^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
@ 2019-11-01 12:55       ` Yang Xu
  2019-11-15 15:51         ` Petr Vorel
  2019-11-15 16:48         ` Petr Vorel
  2019-11-01 12:55       ` [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test Yang Xu
                         ` (4 subsequent siblings)
  5 siblings, 2 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

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.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/configure.ac b/configure.ac
index 62c5a0bb4..31999cd7a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index 729472f69..afce865bc 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -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 <yangx.jy@cn.fujitsu.com>
- *
- * 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 <xuyang2018.jy@cn.jujitsu.com>
  */
 
 #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__ */
diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
new file mode 100644
index 000000000..e8d08c6b7
--- /dev/null
+++ b/m4/ltp-quota.m4
@@ -0,0 +1,7 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2019 Fujitsu Ltd.
+dnl Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+
+AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[
+AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
+])
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index 2f563515d..7dda58417 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -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 <yangx.jy@cn.fujitsu.com>
 *
 * 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 "config.h"
@@ -36,11 +40,13 @@
 #include <string.h>
 #include <unistd.h>
 #include <stdio.h>
-#include <sys/quota.h>
+#include "lapi/quotactl.h"
 
 #include "tst_test.h"
 
-#define QFMT_VFS_V0	2
+#ifndef QFMT_VFS_V0
+# define QFMT_VFS_V0	2
+#endif
 #define USRPATH MNTPOINT "/aquota.user"
 #define GRPPATH MNTPOINT "/aquota.group"
 #define FMTID	QFMT_VFS_V0
@@ -61,6 +67,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;
@@ -94,6 +104,12 @@ static struct tcase {
 	{QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq,
 	NULL, NULL, 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),
+	"get next disk quota limit for user"},
+#endif
+
 	{QCMD(Q_QUOTAOFF, USRQUOTA), &test_id, USRPATH,
 	NULL, NULL, 0, "turn off quota for user"},
 
@@ -120,6 +136,12 @@ static struct tcase {
 	{QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq,
 	NULL, NULL, 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),
+	"get next disk quota limit for group"},
+#endif
+
 	{QCMD(Q_QUOTAOFF, GRPQUOTA), &test_id, GRPPATH,
 	NULL, NULL, 0, "turn off quota for group"}
 };
@@ -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");
+		return;
+	}
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
 		return;
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
  2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
@ 2019-11-01 12:55       ` Yang Xu
  2019-11-15 17:41         ` Petr Vorel
  2019-11-01 12:55       ` [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
                         ` (3 subsequent siblings)
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

Q_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).

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index afce865bc..787f4691e 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -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
diff --git a/m4/ltp-quota.m4 b/m4/ltp-quota.m4
index e8d08c6b7..bcdff7041 100644
--- a/m4/ltp-quota.m4
+++ b/m4/ltp-quota.m4
@@ -4,4 +4,5 @@ dnl Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
 
 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>])
 ])
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index edba84391..a3703d79b 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
- * Copyright (c) 2013 Fujitsu Ltd.
+ * Copyright (c) 2013-2019 FUJITSU LIMITED. All rights reserved
  * Author: DAN LI <li.dan@cn.fujitsu.com>
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
  */
 
 /*
@@ -9,132 +10,98 @@
  *
  * Description:
  * This testcase checks basic flags of quotactl(2) for an XFS file system:
- * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status.
- * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status.
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for user.
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for usr.
  * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
- *    limits.
+ *    limits for user.
  * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
- *    quota limits.
+ *    quota limits greater than or equal to ID for user.
+ * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for user.
+ * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for user.
+ * 7) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for group.
+ * 8) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for group.
+ * 9) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits for group.
+ * 10)quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits for group.
+ * 11)quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for group.
+ * 12)quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for group.
  */
-#define _GNU_SOURCE
-#include "config.h"
-#include <errno.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sys/quota.h>
 
-#include "tst_test.h"
-#include "lapi/quotactl.h"
+#include "quotactl02.h"
 
 #ifdef 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 *);
-
-static uint32_t test_id;
-static struct fs_disk_quota set_dquota = {
-	.d_rtb_softlimit = 1000,
-	.d_fieldmask = FS_DQ_RTBSOFT
-};
-static uint32_t qflag = XFS_QUOTA_UDQ_ENFD;
-static const char mntpoint[] = "mnt_point";
+static uint32_t qflagu = XFS_QUOTA_UDQ_ENFD;
+static uint32_t qflagg = XFS_QUOTA_GDQ_ENFD;
 
 static struct t_case {
 	int cmd;
 	void *addr;
 	void (*func_check)();
 	int check_subcmd;
+	int flag;
 	char *des;
 } tcases[] = {
-	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflag, check_qoff, Q_XGETQSTAT,
-	"turn off xfs quota and get xfs quota off status"},
-	{QCMD(Q_XQUOTAON, USRQUOTA), &qflag, check_qon, Q_XGETQSTAT,
-	"turn on xfs quota and get xfs quota on status"},
-	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETQUOTA,
-	"Q_XGETQUOTA"},
-	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETNEXTQUOTA,
-	"Q_XGETNEXTQUOTA"},
-};
-
-static void check_qoff(int subcmd, char *desp)
-{
-	int res;
-	struct fs_quota_stat res_qstat;
-
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev, test_id,
-		       (void *) &res_qstat);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota off status");
-		return;
-	}
-
-	if (res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD) {
-		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
-		return;
-	}
-
-	tst_res(TPASS, "quoactl() succeeded to %s", desp);
-}
-
-static void check_qon(int subcmd, char *desp)
-{
-	int res;
-	struct fs_quota_stat res_qstat;
-
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
-		       test_id, (void *) &res_qstat);
-	if (res == -1) {
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs quota on status");
-		return;
-	}
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflagu, check_qoff,
+	QCMD(Q_XGETQSTAT, USRQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for user"},
+
+	{QCMD(Q_XQUOTAON, USRQUOTA), &qflagu, check_qon,
+	QCMD(Q_XGETQSTAT, USRQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for user"},
+
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, USRQUOTA), 0,
+	"Q_XGETQUOTA for user"},
+
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, USRQUOTA), 0,
+	"Q_XGETNEXTQUOTA for user"},
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflagu, check_qoffv,
+	QCMD(Q_XGETQSTATV, USRQUOTA), 1,
+	"turn off xfs quota and get xfs quota off statv for user"},
+
+	{QCMD(Q_XQUOTAON, USRQUOTA), &qflagu, check_qonv,
+	QCMD(Q_XGETQSTATV, USRQUOTA), 1,
+	"turn on xfs quota and get xfs quota on statv for user"},
+#endif
 
-	if (!(res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)) {
-		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
-		return;
-	}
+	{QCMD(Q_XQUOTAOFF, GRPQUOTA), &qflagg, check_qoff,
+	QCMD(Q_XGETQSTAT, GRPQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for group"},
 
-	tst_res(TPASS, "quoactl() succeeded to %s", desp);
-}
+	{QCMD(Q_XQUOTAON, GRPQUOTA), &qflagg, check_qon,
+	QCMD(Q_XGETQSTAT, GRPQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for group"},
 
-static void check_qlim(int subcmd, char *desp)
-{
-	int res;
-	static struct fs_disk_quota res_dquota;
-
-	res_dquota.d_rtb_softlimit = 0;
-
-	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
-		       test_id, (void *) &res_dquota);
-	if (res == -1) {
-		if (errno == EINVAL) {
-			tst_brk(TCONF | TERRNO,
-				"%s wasn't supported in quotactl()", desp);
-		}
-		tst_res(TFAIL | TERRNO,
-			"quotactl() failed to get xfs disk quota limits");
-		return;
-	}
+	{QCMD(Q_XSETQLIM, GRPQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, GRPQUOTA), 0,
+	"Q_XGETQUOTA for group"},
 
-	if (res_dquota.d_id != test_id) {
-		tst_res(TFAIL, "quotactl() got unexpected user id %u, expected %u",
-				res_dquota.d_id, test_id);
-		return;
-	}
+	{QCMD(Q_XSETQLIM, GRPQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, GRPQUOTA), 0,
+	"Q_XGETNEXTQUOTA for group"},
 
-	if (res_dquota.d_rtb_hardlimit != set_dquota.d_rtb_hardlimit) {
-		tst_res(TFAIL, "quotactl() got unexpected rtb soft limit %llu, expected %llu",
-				res_dquota.d_rtb_hardlimit,
-			set_dquota.d_rtb_hardlimit);
-		return;
-	}
+#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
+};
 
 static void setup(void)
 {
@@ -151,14 +118,12 @@ static void verify_quota(unsigned int n)
 		return;
 	}
 
-	tc->func_check(tc->check_subcmd, tc->des);
+	if (tc->flag)
+		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
+	else
+		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,
@@ -168,7 +133,7 @@ static struct tst_test test = {
 	.mount_device = 1,
 	.dev_fs_type = "xfs",
 	.mntpoint = mntpoint,
-	.mnt_data = "usrquota",
+	.mnt_data = "usrquota,grpquota",
 	.setup = setup,
 };
 #else
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.h b/testcases/kernel/syscalls/quotactl/quotactl02.h
new file mode 100644
index 000000000..c96cdc3e4
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.h
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ */
+
+#ifndef QUOTACTL02_H
+#define QUOTACTL02_H
+
+#define _GNU_SOURCE
+#include "config.h"
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include "tst_test.h"
+#include "lapi/quotactl.h"
+
+#ifdef HAVE_XFS_XQM_H
+# include <xfs/xqm.h>
+
+static struct fs_disk_quota set_dquota = {
+	.d_rtb_softlimit = 1000,
+	.d_fieldmask = FS_DQ_RTBSOFT
+};
+static uint32_t test_id;
+static const char mntpoint[] = "mnt_point";
+static const char *kconfigs[] = {
+	"CONFIG_XFS_QUOTA",
+	NULL
+};
+void check_qoff(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_stat res_qstat;
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off status");
+		return;
+	}
+
+	if (res_qstat.qs_flags & flag) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+void check_qon(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_stat res_qstat;
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on status");
+		return;
+	}
+
+	if (!(res_qstat.qs_flags & flag)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+void check_qoffv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1,
+	};
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off stav");
+		return;
+	}
+
+	if (res_qstatv.qs_flags & flag) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+
+void check_qonv(int subcmd, char *desp, int flag)
+{
+	int res;
+	struct fs_quota_statv res_qstatv = {
+		.qs_version = FS_QSTATV_VERSION1
+	};
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_qstatv);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on statv");
+		return;
+	}
+
+	if (!(res_qstatv.qs_flags & flag)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
+#endif
+
+void check_qlim(int subcmd, char *desp)
+{
+	int res;
+	static struct fs_disk_quota res_dquota;
+
+	res_dquota.d_rtb_softlimit = 0;
+
+	res = quotactl(subcmd, tst_device->dev, test_id, (void *) &res_dquota);
+	if (res == -1) {
+		if (errno == EINVAL) {
+			tst_res(TCONF,
+				"%s wasn't supported in quotactl()", desp);
+		} else {
+			tst_res(TFAIL | TERRNO,
+				"quotactl() failed to get xfs disk quota limits");
+		}
+		return;
+	}
+
+	if (res_dquota.d_id != test_id) {
+		tst_res(TFAIL, "quotactl() got unexpected user id %u, expected %u",
+			res_dquota.d_id, test_id);
+		return;
+	}
+
+	if (res_dquota.d_rtb_hardlimit != set_dquota.d_rtb_hardlimit) {
+		tst_res(TFAIL, "quotactl() got unexpected rtb soft limit %llu, expected %llu",
+				res_dquota.d_rtb_hardlimit, set_dquota.d_rtb_hardlimit);
+		return;
+	}
+
+	tst_res(TPASS, "quoactl() succeeded to set and use %s to get xfs disk quota limits",
+			desp);
+}
+#endif//HAVE_XFS_XQM_H
+#endif
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
  2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
  2019-11-01 12:55       ` [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test Yang Xu
@ 2019-11-01 12:55       ` Yang Xu
  2022-03-15 17:19         ` Petr Vorel
  2019-11-01 12:55       ` [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
                         ` (2 subsequent siblings)
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

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 together

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
index 787f4691e..b9ab54483 100644
--- a/include/lapi/quotactl.h
+++ b/include/lapi/quotactl.h
@@ -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
diff --git a/runtest/syscalls b/runtest/syscalls
index 12d3e0d3b..c30e9e620 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64
 quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
+quotactl04 quotactl04
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index b0ef075e7..1db7c5d98 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -1,3 +1,4 @@
 /quotactl01
 /quotactl02
 /quotactl03
+/quotactl04
diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
new file mode 100644
index 000000000..25ab016cf
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * 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,
+};
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
                         ` (2 preceding siblings ...)
  2019-11-01 12:55       ` [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
@ 2019-11-01 12:55       ` Yang Xu
  2019-11-01 12:55       ` [LTP] [PATCH v3 5/5] syscalls/quotactl06: Add new testcase Yang Xu
  2019-11-12  8:05       ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
  5 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

This 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.").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/runtest/syscalls b/runtest/syscalls
index c30e9e620..f2c7b0daf 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -954,6 +954,7 @@ quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
+quotactl05 quotactl05
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index 1db7c5d98..9621e7717 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -2,3 +2,5 @@
 /quotactl02
 /quotactl03
 /quotactl04
+/quotactl05
+
diff --git a/testcases/kernel/syscalls/quotactl/quotactl05.c b/testcases/kernel/syscalls/quotactl/quotactl05.c
new file mode 100644
index 000000000..2c4f49f7c
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl05.c
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * Test Name: quotactl05
+ *
+ * Description:
+ * This testcase checks basic flags of quotactl(2) for project on an XFS file
+ * system:
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status
+ *    for project.
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status
+ *    for project.
+ * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits for project.
+ * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits Cgreater than or equal to ID for project.
+ * 5) quotactl(2) succeeds to turn off xfs quota and get xfs quota off statv
+ *    for project.
+ * 6) quotactl(2) succeeds to turn on xfs quota and get xfs quota on statv
+ *    for project.
+ */
+#include "quotactl02.h"
+#if defined(HAVE_XFS_XQM_H)
+
+static uint32_t qflagp = XFS_QUOTA_PDQ_ENFD;
+static struct t_case {
+	int cmd;
+	void *addr;
+	void (*func_check)();
+	int check_subcmd;
+	int flag;
+	char *des;
+} tcases[] = {
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflagp, check_qoff,
+	QCMD(Q_XGETQSTAT, PRJQUOTA), 1,
+	"turn off xfs quota and get xfs quota off status for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflagp, check_qon,
+	QCMD(Q_XGETQSTAT, PRJQUOTA), 1,
+	"turn on xfs quota and get xfs quota on status for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETQUOTA, PRJQUOTA), 0,
+	"Q_XGETQUOTA for project"},
+
+	{QCMD(Q_XSETQLIM, PRJQUOTA), &set_dquota, check_qlim,
+	QCMD(Q_XGETNEXTQUOTA, PRJQUOTA), 0,
+	"Q_XGETNEXTQUOTA for project"},
+
+#if defined(HAVE_STRUCT_FS_QUOTA_STATV)
+	{QCMD(Q_XQUOTAOFF, PRJQUOTA), &qflagp, check_qoffv,
+	QCMD(Q_XGETQSTATV, PRJQUOTA), 1,
+	"turn off xfs quota and get xfs quota off statv for project"},
+
+	{QCMD(Q_XQUOTAON, PRJQUOTA), &qflagp, check_qonv,
+	QCMD(Q_XGETQSTATV, PRJQUOTA), 1,
+	"turn on xfs quota and get xfs quota on statv for project"},
+#endif
+};
+
+static void setup(void)
+{
+	test_id = geteuid();
+}
+
+static void verify_quota(unsigned int n)
+{
+	struct t_case *tc = &tcases[n];
+
+	TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+	if (TST_RET == -1) {
+		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+		return;
+	}
+
+	if (tc->flag)
+		tc->func_check(tc->check_subcmd, tc->des, *(int *)(tc->addr));
+	else
+		tc->func_check(tc->check_subcmd, tc->des);
+}
+
+static struct tst_test test = {
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.needs_kconfigs = kconfigs,
+	.test = verify_quota,
+	.tcnt = ARRAY_SIZE(tcases),
+	.mount_device = 1,
+	.dev_fs_type = "xfs",
+	.mntpoint = mntpoint,
+	.mnt_data = "prjquota",
+	.setup = setup,
+};
+
+#else
+	TST_TEST_TCONF("This system didn't have <xfs/xqm.h>");
+#endif
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 5/5] syscalls/quotactl06: Add new testcase
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
                         ` (3 preceding siblings ...)
  2019-11-01 12:55       ` [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
@ 2019-11-01 12:55       ` Yang Xu
  2019-11-12  8:05       ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
  5 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-01 12:55 UTC (permalink / raw)
  To: ltp

Check various errnos for the quotactl().

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
 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

diff --git a/runtest/syscalls b/runtest/syscalls
index f2c7b0daf..93b7a3f78 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -955,6 +955,7 @@ quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
 quotactl05 quotactl05
+quotactl06 quotactl06
 
 read01 read01
 read02 read02
diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
index 9621e7717..b9a015654 100644
--- a/testcases/kernel/syscalls/quotactl/.gitignore
+++ b/testcases/kernel/syscalls/quotactl/.gitignore
@@ -3,4 +3,5 @@
 /quotactl03
 /quotactl04
 /quotactl05
+/quotactl06
 
diff --git a/testcases/kernel/syscalls/quotactl/quotactl06.c b/testcases/kernel/syscalls/quotactl/quotactl06.c
new file mode 100644
index 000000000..9c98bfde7
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl06.c
@@ -0,0 +1,183 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
+ * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
+ *
+ * Tests basic error handling of the quotactl syscall.
+ * Description:
+ * 1) quotactl fails with EACCES when cmd is Q_QUOTAON and addr
+ * existed but not a regular file.
+ * 2) quotaclt fails with ENOENT when the file specified by special
+ * or addr does not exist.
+ * 3) quotactl fails with EBUSTY when  cmd is Q_QUOTAON and another
+ * Q_QUOTAON had already been performed.
+ * 4) quotactl fails with EFAULT when addr or special is invalid.
+ * 5) quotactl fails with EINVAL when cmd or type is invalid.
+ * 6) quotactl fails with ENOTBLK when special is not a block device.
+ * 7) quotactl fails with ESRCH when no disk quota is found for the
+ * indicated user and quotas have not been turned on for this fs.
+ * 8) quotactl fails with ESRCH when cmd is Q_QUOTAON, but the quota
+ * format was not found.
+ * 9) quotactl fails with ESRCH when cmd is Q_GETNEXTQUOTA, but there
+ * is no ID greater than or equal to id that has an active quota.
+ * 10) quotactl fails with ERANGE when cmd is Q_SETQUOTA, but the
+ * specified limits are out of the range allowed by the quota format.
+ * 11) quotactl fails with EPERM when the caller lacked the required
+ * privilege (CAP_SYS_ADMIN) for the specified operation.
+ */
+#include <errno.h>
+#include <sys/quota.h>
+#include "tst_test.h"
+#include "lapi/quotactl.h"
+#include "tst_capability.h"
+
+#define OPTION_INVALID 999
+#define QFMT_VFS_V0     2
+#define USRPATH MNTPOINT "/aquota.user"
+#define FMTID QFMT_VFS_V0
+
+#define MNTPOINT "mntpoint"
+#define TESTDIR1 MNTPOINT "/testdir1"
+#define TESTDIR2 MNTPOINT "/testdir2"
+
+static int32_t fmt_id = FMTID;
+static int32_t fmt_invalid = 999;
+static int test_invalid;
+static int test_id;
+static struct dqblk set_dq = {
+	.dqb_bsoftlimit = 100,
+	.dqb_valid = QIF_BLIMITS
+};
+
+static struct dqblk set_dqmax = {
+	.dqb_bsoftlimit = 0x7fffffffffffffffLL,  /* 2^63-1 */
+	.dqb_valid = QIF_BLIMITS
+};
+
+struct tst_cap dropadmin = {
+	.action = TST_CAP_DROP,
+	.id = CAP_SYS_ADMIN,
+	.name = "CAP_SYS_ADMIN",
+};
+
+struct tst_cap needadmin = {
+	.action = TST_CAP_REQ,
+	.id = CAP_SYS_ADMIN,
+	.name = "CAP_SYS_ADMIN",
+};
+
+static struct tcase {
+	int cmd;
+	int *id;
+	void *addr;
+	int exp_err;
+	int on_flag;
+} tcases[] = {
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, TESTDIR1, EACCES, 0 },
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, TESTDIR2, ENOENT, 0},
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH, EBUSY, 1},
+	{QCMD(Q_SETQUOTA, USRQUOTA), &fmt_id, NULL, EFAULT, 1},
+	{QCMD(OPTION_INVALID, USRQUOTA), &fmt_id, USRPATH, EINVAL, 0},
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH, ENOTBLK, 0},
+	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq, ESRCH, 0},
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_invalid, USRPATH, ESRCH, 0},
+	{QCMD(Q_GETNEXTQUOTA, USRQUOTA), &test_invalid, USRPATH, ESRCH, 0},
+	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dqmax, ERANGE, 1},
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH, EPERM, 0},
+};
+
+static void verify_quotactl(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	int quota_on = 0;
+	int drop_flag = 0;
+
+	if (!tc->addr)
+		tc->addr = tst_get_bad_addr(NULL);
+	if (tc->on_flag) {
+		TEST(quotactl(QCMD(Q_QUOTAON, USRQUOTA), tst_device->dev, FMTID, USRPATH));
+		if (TST_RET == -1)
+			tst_brk(TBROK,
+				"quotactl with Q_QUOTAON returned %ld", TST_RET);
+		quota_on = 1;
+	}
+
+	if (tc->exp_err == EPERM) {
+		tst_cap_action(&dropadmin);
+		drop_flag = 1;
+	}
+
+	if (tc->exp_err == ENOTBLK)
+		TEST(quotactl(tc->cmd, "/dev/null", *tc->id, tc->addr));
+	else
+		TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));
+	if (TST_RET == -1) {
+		if (tc->exp_err == TST_ERR) {
+			tst_res(TPASS | TTERRNO,
+				"quotactl failed as expected");
+		} else if (*tc->id == test_invalid && tc->exp_err == EINVAL) {
+			tst_res(TFAIL,
+				"quotactl Q_GETNEXTQUOTA option is not supported.");
+		} else {
+			tst_res(TFAIL | TTERRNO,
+				"quotactl failed unexpectedly; expected %s, but got",
+				tst_strerrno(tc->exp_err));
+		}
+	} else {
+		tst_res(TFAIL, "quotactl returned wrong value: %ld", TST_RET);
+	}
+
+	if (quota_on) {
+		TEST(quotactl(QCMD(Q_QUOTAOFF, USRQUOTA), tst_device->dev, FMTID, USRPATH));
+		if (TST_RET == -1)
+			tst_brk(TBROK,
+				"quotactl with Q_QUOTAOFF returned %ld", TST_RET);
+		quota_on = 0;
+	}
+
+	if (drop_flag) {
+		tst_cap_action(&needadmin);
+		drop_flag = 0;
+	}
+}
+
+static void setup(void)
+{
+	const char *const cmd[] = {"quotacheck", "-uF", "vfsv0", MNTPOINT, NULL};
+	int ret;
+
+	ret = tst_run_cmd(cmd, NULL, NULL, 1);
+	switch (ret) {
+	case 0:
+		break;
+	case 255:
+		tst_brk(TBROK, "quotacheck binary not installed");
+		break;
+	default:
+		tst_brk(TBROK, "quotacheck exited with %i", ret);
+	}
+
+	if (access(USRPATH, F_OK) == -1)
+		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
+
+	SAFE_MKDIR(TESTDIR1, 0666);
+	test_id = geteuid();
+	test_invalid = test_id + 1;
+}
+
+static const char *kconfigs[] = {
+	"CONFIG_QFMT_V2",
+	NULL
+};
+
+static struct tst_test test = {
+	.setup = setup,
+	.needs_kconfigs = kconfigs,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_quotactl,
+	.dev_fs_type = "ext4",
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.mnt_data = "usrquota",
+	.needs_root = 1,
+};
-- 
2.18.0




^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 0/5] optimize quotactl test code
  2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
                         ` (4 preceding siblings ...)
  2019-11-01 12:55       ` [LTP] [PATCH v3 5/5] syscalls/quotactl06: Add new testcase Yang Xu
@ 2019-11-12  8:05       ` Yang Xu
  2019-11-15  9:02         ` Yang Xu
  5 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-11-12  8:05 UTC (permalink / raw)
  To: ltp

Hi All

ping.

> 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
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191112/93f0dbfc/attachment.htm>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 0/5] optimize quotactl test code
  2019-11-12  8:05       ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
@ 2019-11-15  9:02         ` Yang Xu
  2019-11-15  9:25           ` Petr Vorel
  0 siblings, 1 reply; 37+ messages in thread
From: Yang Xu @ 2019-11-15  9:02 UTC (permalink / raw)
  To: ltp

Hi
Does anyone have some comments for this patch set?

> Hi All
> ping.
>> 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
>>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191115/7541d7ae/attachment.htm>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 0/5] optimize quotactl test code
  2019-11-15  9:02         ` Yang Xu
@ 2019-11-15  9:25           ` Petr Vorel
  0 siblings, 0 replies; 37+ messages in thread
From: Petr Vorel @ 2019-11-15  9:25 UTC (permalink / raw)
  To: ltp

Hi Xu,
> 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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
@ 2019-11-15 15:51         ` Petr Vorel
  2019-11-18  6:42           ` Xu, Yang
  2019-11-15 16:48         ` Petr Vorel
  1 sibling, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-11-15 15:51 UTC (permalink / raw)
  To: ltp

> 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.

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
LGTM, minor note below.

> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
...
>  #ifndef LAPI_QUOTACTL_H__
>  # define LAPI_QUOTACTL_H__

> +#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)
> +#endif
> +#include <sys/quota.h>
> +

...
> @@ -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.

> +		return;
> +	}
>  	if (TST_RET == -1) {
>  		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
>  		return;

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
  2019-11-15 15:51         ` Petr Vorel
@ 2019-11-15 16:48         ` Petr Vorel
  2019-11-18  6:18           ` Xu, Yang
  1 sibling, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-11-15 16:48 UTC (permalink / raw)
  To: ltp

Subject: [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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test
  2019-11-01 12:55       ` [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test Yang Xu
@ 2019-11-15 17:41         ` Petr Vorel
  2019-11-18  7:59           ` Xu, Yang
  0 siblings, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-11-15 17:41 UTC (permalink / raw)
  To: ltp

Hi Xu,

> Q_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).
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.

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
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.

...
> +++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
...
> +#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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-15 16:48         ` Petr Vorel
@ 2019-11-18  6:18           ` Xu, Yang
  2019-11-18  6:24             ` Petr Vorel
  0 siblings, 1 reply; 37+ messages in thread
From: Xu, Yang @ 2019-11-18  6:18 UTC (permalink / raw)
  To: ltp

Hi Petr
 I will check it and correct them.
>Subject: Re: [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
>
>Subject: [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





^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-18  6:18           ` Xu, Yang
@ 2019-11-18  6:24             ` Petr Vorel
  0 siblings, 0 replies; 37+ messages in thread
From: Petr Vorel @ 2019-11-18  6:24 UTC (permalink / raw)
  To: ltp

Hi Xu,

> 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.

> >Subject: Re: [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test

> >Subject: [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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-15 15:51         ` Petr Vorel
@ 2019-11-18  6:42           ` Xu, Yang
  2019-11-20 17:09             ` Petr Vorel
  0 siblings, 1 reply; 37+ messages in thread
From: Xu, Yang @ 2019-11-18  6:42 UTC (permalink / raw)
  To: ltp


>> 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.
>
>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>Reviewed-by: Petr Vorel <pvorel@suse.cz> LGTM, minor note below.
Thanks for your review.

>> +#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)
...
>>  	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.
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
>Kind regards,
>Petr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test
  2019-11-15 17:41         ` Petr Vorel
@ 2019-11-18  7:59           ` Xu, Yang
  2019-11-18  8:25             ` Petr Vorel
  0 siblings, 1 reply; 37+ messages in thread
From: Xu, Yang @ 2019-11-18  7:59 UTC (permalink / raw)
  To: ltp


>Hi Xu,
> >Q_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).
>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.

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5d5e3d57605e77708685e8d20a40fe86891db299

>> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
>Reviewed-by: Petr Vorel <pvorel@suse.cz> Nice work, thanks!
Thanks for your review.

>>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.
I will mention it in commit info.
>> +++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
>...
>> +#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
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?

>...
>Kind regards,
>Petr





^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test
  2019-11-18  7:59           ` Xu, Yang
@ 2019-11-18  8:25             ` Petr Vorel
  0 siblings, 0 replies; 37+ messages in thread
From: Petr Vorel @ 2019-11-18  8:25 UTC (permalink / raw)
  To: ltp

Hi Xu,

> > >Q_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).
> >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.

> [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5d5e3d57605e77708685e8d20a40fe86891db299
Thanks for info.

> >> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> >Reviewed-by: Petr Vorel <pvorel@suse.cz> Nice work, thanks!
> Thanks for your review.

> >>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.
> I will mention it in commit info.
OK, I'll review the rest of v3 and wait for v4.

> >> +++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
> >...
> >> +#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
> 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?
+1, IMHO this makes sense.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-18  6:42           ` Xu, Yang
@ 2019-11-20 17:09             ` Petr Vorel
  2019-11-21  3:59               ` Yang Xu
  0 siblings, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2019-11-20 17:09 UTC (permalink / raw)
  To: ltp

Hi Xu,

> >>  	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.
> 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

+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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test
  2019-11-20 17:09             ` Petr Vorel
@ 2019-11-21  3:59               ` Yang Xu
  0 siblings, 0 replies; 37+ messages in thread
From: Yang Xu @ 2019-11-21  3:59 UTC (permalink / raw)
  To: ltp


on 2019/11/21 1:09, Petr Vorel wrote:

> Hi Xu,
>
>>>>   	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.
>> 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
> +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).

Hi Petr

 ?Using a macro is a better way.

Thanks
Yang Xu

>
> Kind regards,
> Petr
>
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linux.it/pipermail/ltp/attachments/20191121/19ca1160/attachment.htm>

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2019-11-01 12:55       ` [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
@ 2022-03-15 17:19         ` Petr Vorel
  2022-03-16  2:00           ` xuyang2018.jy
  0 siblings, 1 reply; 37+ messages in thread
From: Petr Vorel @ 2022-03-15 17:19 UTC (permalink / raw)
  To: Yang Xu; +Cc: ltp

Hi 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
...
> +	.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

> 2)on old kernel, kernel doesn't permit mount both prjquota and grpquota together

> Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> ---
>  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

> diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
> index 787f4691e..b9ab54483 100644
> --- a/include/lapi/quotactl.h
> +++ b/include/lapi/quotactl.h
> @@ -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
> diff --git a/runtest/syscalls b/runtest/syscalls
> index 12d3e0d3b..c30e9e620 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -953,6 +953,7 @@ pwritev202_64 pwritev202_64
>  quotactl01 quotactl01
>  quotactl02 quotactl02
>  quotactl03 quotactl03
> +quotactl04 quotactl04

>  read01 read01
>  read02 read02
> diff --git a/testcases/kernel/syscalls/quotactl/.gitignore b/testcases/kernel/syscalls/quotactl/.gitignore
> index b0ef075e7..1db7c5d98 100644
> --- a/testcases/kernel/syscalls/quotactl/.gitignore
> +++ b/testcases/kernel/syscalls/quotactl/.gitignore
> @@ -1,3 +1,4 @@
>  /quotactl01
>  /quotactl02
>  /quotactl03
> +/quotactl04
> diff --git a/testcases/kernel/syscalls/quotactl/quotactl04.c b/testcases/kernel/syscalls/quotactl/quotactl04.c
> new file mode 100644
> index 000000000..25ab016cf
> --- /dev/null
> +++ b/testcases/kernel/syscalls/quotactl/quotactl04.c
> @@ -0,0 +1,155 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2019 FUJITSU LIMITED. All rights reserved.
> + * Author: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
> + *
> + * 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,
> +};

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem
  2022-03-15 17:19         ` Petr Vorel
@ 2022-03-16  2:00           ` xuyang2018.jy
  0 siblings, 0 replies; 37+ messages in thread
From: xuyang2018.jy @ 2022-03-16  2:00 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi Petr
> Hi 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
> ...
>> >  +	.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.
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.
>
> 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
>
> Kind regards,
> Petr
>

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2022-03-16  2:00 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-23  9:00 [LTP] [PATCH v2 0/6] optimize quotactl test code Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 1/6] syscalls/quotactl: Don't use ltp-quota.m4 Yang Xu
2019-10-31 14:02   ` Petr Vorel
2019-10-23  9:00 ` [LTP] [PATCH v2 2/6] m4/ltp-xfs_quota.m4: Remove useless ltp—xfs_quota.m4 Yang Xu
2019-10-31 15:26   ` Petr Vorel
2019-11-01 12:55     ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
2019-11-01 12:55       ` [LTP] [PATCH v3 1/5] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
2019-11-15 15:51         ` Petr Vorel
2019-11-18  6:42           ` Xu, Yang
2019-11-20 17:09             ` Petr Vorel
2019-11-21  3:59               ` Yang Xu
2019-11-15 16:48         ` Petr Vorel
2019-11-18  6:18           ` Xu, Yang
2019-11-18  6:24             ` Petr Vorel
2019-11-01 12:55       ` [LTP] [PATCH v3 2/5] syscalls/quotactl02.c: Add Q_XGETQSTATV test Yang Xu
2019-11-15 17:41         ` Petr Vorel
2019-11-18  7:59           ` Xu, Yang
2019-11-18  8:25             ` Petr Vorel
2019-11-01 12:55       ` [LTP] [PATCH v3 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
2022-03-15 17:19         ` Petr Vorel
2022-03-16  2:00           ` xuyang2018.jy
2019-11-01 12:55       ` [LTP] [PATCH v3 4/5] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu
2019-11-01 12:55       ` [LTP] [PATCH v3 5/5] syscalls/quotactl06: Add new testcase Yang Xu
2019-11-12  8:05       ` [LTP] [PATCH v3 0/5] optimize quotactl test code Yang Xu
2019-11-15  9:02         ` Yang Xu
2019-11-15  9:25           ` Petr Vorel
2019-10-23  9:00 ` [LTP] [PATCH v2 3/6] syscalls/quotactl01.c: Add Q_GETNEXQUOTA test Yang Xu
2019-10-24  8:25   ` Jan Kara
2019-10-25  8:49     ` Yang Xu
2019-10-31 14:10     ` Petr Vorel
2019-10-31 14:31   ` Petr Vorel
2019-11-01 12:44     ` Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 4/6] syscalls/quotactl02.c: Add Q_XGETQSTATV and Q_XQUOTARM test Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 5/6] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
2019-10-24  8:14   ` Jan Kara
2019-10-24  9:55     ` Yang Xu
2019-10-23  9:00 ` [LTP] [PATCH v2 6/6] syscalls/quotactl05: add project quota test for xfs filesystem Yang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.