Skip to contentSkip to conversation

optimize quotactl test code

PATCH New Yang Xu 3 participants 23 messages Nov 20, 2019 – Nov 21, 2019

lore
Share & tools
lore

Yang Xu

author
#0 lore raw

v4 cover optimize quotactl test code

I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.

------------
v3->v4
check some new features(such as Q_GETNETXSTAT,Q_XGETNEXTSTAT,Q_XGETQSTATV) whether supported in setup by using ltp customized struct
------------
Yang Xu (5):
syscalls/quotactl01: Add Q_GETNEXTQUOTA test syscalls/quotactl02: Add Q_XGETQSTATV test and group quota tests syscalls/quotactl04: add project quota test for non-xfs filesystem syscalls/quotactl05: add project quota test on xfs filesystem syscalls/quotactl06: Add new error testcase

 configure.ac                                  |   1 +
 include/lapi/quotactl.h                       |  80 +++++--
 m4/ltp-quota.m4                               |   8 +
 runtest/syscalls                              |   3 +
 testcases/kernel/syscalls/quotactl/.gitignore |   3 +
 .../kernel/syscalls/quotactl/quotactl01.c     | 107 ++++++---
 .../kernel/syscalls/quotactl/quotactl02.c     | 222 ++++++++----------
 .../kernel/syscalls/quotactl/quotactl02.h     | 167 +++++++++++++
 .../kernel/syscalls/quotactl/quotactl04.c     | 162 +++++++++++++
 .../kernel/syscalls/quotactl/quotactl05.c     | 118 ++++++++++
 .../kernel/syscalls/quotactl/quotactl06.c     | 196 ++++++++++++++++
 11 files changed, 906 insertions(+), 161 deletions(-)
 create mode 100644 m4/ltp-quota.m4
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl02.h
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl06.c
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Q_GETNEXTQUOTA was introduced since linux 4.6, this operation is the same as Q_GETQUOTA, but it returns quota information for the next ID greater than or equal to id that has a quota set.

---
 configure.ac                                  |   1 +
 include/lapi/quotactl.h                       |  43 ++++---
 m4/ltp-quota.m4                               |   7 ++
 .../kernel/syscalls/quotactl/quotactl01.c     | 107 +++++++++++++-----
 4 files changed, 115 insertions(+), 43 deletions(-)
 create mode 100644 m4/ltp-quota.m4
configure.ac +1 -0
index c8c0db2dc..50d14967d 100644
@@ -251,6 +251,7 @@ AC_DEFINE_UNQUOTED(NUMA_ERROR_MSG, ["$numa_error_msg"], [Error message when no N
 
 
 LTP_CHECK_SYSCALL_PERF_EVENT_OPEN
+LTP_CHECK_SYSCALL_QUOTACTL
 LTP_CHECK_SYSCALL_SIGNALFD
 LTP_CHECK_SYSCALL_UTIMENSAT
 LTP_CHECK_TASKSTATS
include/lapi/quotactl.h +29 -14

55 lines not on this page · raw message

m4/ltp-quota.m4 new file +7 -0
new file mode 100644
index 000000000..e8d08c6b7
@@ -0,0 +1,7 @@
+dnl SPDX-License-Identifier: GPL-2.0-or-later
+dnl Copyright (c) 2019 Fujitsu Ltd.
+dnl Author: Yang Xu <[email protected]>
+
+AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[
+AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
+])
testcases/kernel/syscalls/quotactl/quotactl01.c +78 -29

203 lines not on this page · raw message

Signature · 1 line
2.18.0
#2 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Jan, Cyril, Xu,

Quoted 5 lines

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.

LGTM, with 2 questions.

include/lapi/quotactl.h line 17

Quoted 10 lines

#ifndef LAPI_QUOTACTL_H__

 # define LAPI_QUOTACTL_H__
include/lapi/quotactl.h +7 -0
+#include <sys/quota.h>
+
+#ifdef HAVE_STRUCT_IF_NEXTDQBLK
+# include <linux/quota.h>
+#else
+# ifdef HAVE_LINUX_TYPES_H
+# include <linux/types.h>

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed? __u64 can be uint64_t etc (as it's also visible in struct dqblk in <sys/quota.h> in various libc headers).
We used this approach for /usr/include/linux/bpf.h and for fanotify fixes for musl (testcases/kernel/syscalls/fanotify/fanotify.h).

So unless you're against this approach here I'll change it before merge (and add this info to next version of library API writing guidelines patch
https://patchwork.ozlabs.org/patch/1166786/).

Quoted 12 lines
include/lapi/quotactl.h +12 -0
+struct if_nextdqblk {
+	__u64 dqb_bhardlimit;
+	__u64 dqb_bsoftlimit;
+	__u64 dqb_curspace;
+	__u64 dqb_ihardlimit;
+	__u64 dqb_isoftlimit;
+	__u64 dqb_curinodes;
+	__u64 dqb_btime;
+	__u64 dqb_itime;
+	__u32 dqb_valid;
+	__u32 dqb_id;
+};

...

testcases/kernel/syscalls/quotactl/quotactl01.c line 4

Quoted 7 lines

+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c

testcases/kernel/syscalls/quotactl/quotactl01.c +1 -1
@@ -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

BTW correct formatting is
/*
*
*/
Not
/*
*
*/
I'll change it during merge (nit, the code is what matters, not formatting, of course).

...

Quoted 1 line
testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
+static int getnextquota_nsup;

...

testcases/kernel/syscalls/quotactl/quotactl01.c static struct tcase { · line 167

Quoted 5 lines

static void setup(void)
{

testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
 	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
 	int ret;
+	getnextquota_nsup = 0;

This is not needed (getnextquota_nsup is static and it's called just once, I'll remove it before merge).

testcases/kernel/syscalls/quotactl/quotactl01.c static void setup(void) · line 189

Quoted 10 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +4 -0
 	ret = tst_run_cmd(cmd, NULL, NULL, 1);
 	switch (ret) {
@@ -146,6 +183,11 @@ static void setup(void)
 
 	if (access(GRPPATH, F_OK) == -1)
 		tst_brk(TFAIL | TERRNO, "group quotafile didn't exist");
+
+	TEST(quotactl(QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev,
+		test_id, (void *) &res_ndq));
+	if (TST_ERR == EINVAL || TST_ERR == ENOSYS)

Does EINVAL really mans not supported? Shouldn't be just for ENOSYS

testcases/kernel/syscalls/quotactl/quotactl01.c static void setup(void) · line 191

Quoted 2 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
+		getnextquota_nsup = 1;
 }

Looking at kernel sources - this does not look as not supported, but rather a failure (we might want to add some test for EINVAL):

	if (!qid_has_mapping(sb->s_user_ns, qid))
		return -EINVAL;

kernel fs/quota/quota.c
/*
* Return quota for next active quota >= this id, if any exists,
* otherwise return -ENOENT via ->get_nextdqblk
*/
static int quota_getnextquota(struct super_block *sb, int type, qid_t id,
void __user *addr)

{
	struct kqid qid;
	struct qc_dqblk fdq;
	struct if_nextdqblk idq;
	int ret;

	if (!sb->s_qcop->get_nextdqblk)
		return -ENOSYS;
	qid = make_kqid(current_user_ns(), type, id);
	if (!qid_has_mapping(sb->s_user_ns, qid))
		return -EINVAL;
	ret = sb->s_qcop->get_nextdqblk(sb, &qid, &fdq);
	if (ret)
		return ret;
	/* struct if_nextdqblk is a superset of struct if_dqblk */
	copy_to_if_dqblk((struct if_dqblk *)&idq, &fdq);
	idq.dqb_id = from_kqid(current_user_ns(), qid);
	if (copy_to_user(addr, &idq, sizeof(idq)))
		return -EFAULT;
	return 0;
}

Kind regards,
Petr

#3 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Jan, Cyril, Xu,

Quoted 11 lines

include/lapi/quotactl.h line 17

Quoted 5 lines
include/lapi/quotactl.h +5 -0
+#ifdef HAVE_STRUCT_IF_NEXTDQBLK
+# include <linux/quota.h>
+#else
+# ifdef HAVE_LINUX_TYPES_H
+# include <linux/types.h>

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed? __u64 can be uint64_t etc (as it's also visible in struct dqblk in <sys/quota.h> in various libc headers).
We used this approach for /usr/include/linux/bpf.h and for fanotify fixes for musl (testcases/kernel/syscalls/fanotify/fanotify.h).

Quoted 3 lines

So unless you're against this approach here I'll change it before merge (and add this info to next version of library API writing guidelines patch
https://patchwork.ozlabs.org/patch/1166786/).

+ general question: do we want always test against kernel headers or libc headers? Libc is often outdated, so mostly it'd be our fallback to be tested. Ideally both kernel and libc header should be tested, but that's not easily achievable.

Kind regards,
Petr

author
#4 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Quoted 15 lines · Petr Vorel

Hi Jan, Cyril, Xu,

Quoted 5 lines

include/lapi/quotactl.h line 17

Quoted 5 lines
include/lapi/quotactl.h +5 -0
+#ifdef HAVE_STRUCT_IF_NEXTDQBLK
+# include <linux/quota.h>
+#else
+# ifdef HAVE_LINUX_TYPES_H
+# include <linux/types.h>
Quoted 8 lines

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed? __u64 can be uint64_t etc (as it's also visible in struct dqblk in <sys/quota.h> in various libc headers).
We used this approach for /usr/include/linux/bpf.h and for fanotify fixes for musl (testcases/kernel/syscalls/fanotify/fanotify.h).
So unless you're against this approach here I'll change it before merge (and add this info to next version of library API writing guidelines patch
https://patchwork.ozlabs.org/patch/1166786/).

Quoted 4 lines

+ general question: do we want always test against kernel headers or libc headers? Libc is often outdated, so mostly it'd be our fallback to be tested. Ideally both kernel and libc header should be tested, but that's not easily achievable.

IMHO, We often test libc and it usually includes kernel headers ie. <sys/quota.h> <sys/prctl.h>. I perfet to check one except that glibc and kernel they have themselves implementation . If the struct or variable is not defined, we can define it in ltp lapi headers. Then we can avoid build error and increase coverage(because kernel may implement it).

Quoted 4 lines

Kind regards,
Petr

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

#5 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Xu,

Quoted 10 lines
Quoted 4 lines

+ general question: do we want always test against kernel headers or libc headers? Libc is often outdated, so mostly it'd be our fallback to be tested. Ideally both kernel and libc header should be tested, but that's not easily achievable.

IMHO, We often test libc and it usually includes kernel headers ie. <sys/quota.h> <sys/prctl.h>. I perfet to check one except that glibc and kernel they have themselves implementation . If the struct or variable is not defined, we can define it in ltp lapi headers. Then we can avoid build error and increase coverage(because kernel may implement it).

Yep. I'm ok with using libc headers (increased coverage), but we need good checks anyway for other libc (at least for musl; bionic also like glibc uses internally kernel headers, uclibc-ng usually embeds kernel header parts and strives to be glibc compatible anyway).

Kind regards,
Petr

author
#6 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Quoted 11 lines · Petr Vorel

Hi Xu,

Quoted 9 lines
Quoted 4 lines

+ general question: do we want always test against kernel headers or libc headers? Libc is often outdated, so mostly it'd be our fallback to be tested. Ideally both kernel and libc header should be tested, but that's not easily achievable.

IMHO, We often test libc and it usually includes kernel headers ie. <sys/quota.h> <sys/prctl.h>. I perfet to check one except that glibc and kernel they have themselves implementation . If the struct or variable is not defined, we can define it in ltp lapi headers. Then we can avoid build error and increase coverage(because kernel may implement it).

Quoted 4 lines

Yep. I'm ok with using libc headers (increased coverage), but we need good checks anyway for other libc (at least for musl; bionic also like glibc uses internally kernel headers, uclibc-ng usually embeds kernel header parts and strives to be glibc compatible anyway).

Hi Petr

Yes. I check <sys/quota.h> and <sys/prctl.h> on musl libc[1] and they don't include linux header files. So I think checking both kernel and libc headers on other libc(musl,bionic) is meaningful.

ps: If our travis-ci has a target with musl, I think it will be better. I don't know whether possible.

[1]http://git.musl-libc.org/cgit/musl/tree/include/sys/quota.h

Thanks
Yang Xu

Quoted 5 lines

Kind regards,
Petr

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

#7 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Xu,

Quoted 2 lines

Yes. I check <sys/quota.h> and <sys/prctl.h> on musl libc[1] and they don't include linux header files. So I think checking both kernel and libc headers on other libc(musl,bionic) is meaningful.

But in single C file we decide only on one of these two.
It's a similar problem as testing raw syscall or libc wrapper (which we already solved with .test_variants).
NOTE: Bionic has generate it's headers from linux headers.

Quoted 1 line

ps: If our travis-ci has a target with musl, I think it will be better. I don't know whether possible.

It's here. But it requires some more fixes (in a meantime files are deleted), so I'll post it once it's everything fixed
https://github.com/pevik/ltp/commits/travis/musl
https://travis-ci.org/pevik/ltp/builds/614575796

There is also CI on LTP on all glibc/uclibc-ng/musl in Buildroot
http://autobuild.buildroot.net/index.php?reason=ltp-testsuite-20190930

+ There are other CI based on yocto/openembedded on glibc/uclibc-ng/musl

Quoted 1 line

[1]http://git.musl-libc.org/cgit/musl/tree/include/sys/quota.h

Kind regards,
Petr

author
#8 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Quoted 8 lines · Petr Vorel

Hi Xu,

Quoted 2 lines

Yes. I check <sys/quota.h> and <sys/prctl.h> on musl libc[1] and they don't include linux header files. So I think checking both kernel and libc headers on other libc(musl,bionic) is meaningful.

But in single C file we decide only on one of these two.
It's a similar problem as testing raw syscall or libc wrapper (which we already solved with .test_variants).
NOTE: Bionic has generate it's headers from linux headers.

I see.

Thanks again for reminding Bionic like glibc uses linux headers.

Quoted 11 lines
Quoted 2 lines

ps: If our travis-ci has a target with musl, I think it will be better. I don't know whether possible.

It's here. But it requires some more fixes (in a meantime files are deleted), so I'll post it once it's everything fixed
https://github.com/pevik/ltp/commits/travis/musl
https://travis-ci.org/pevik/ltp/builds/614575796

There is also CI on LTP on all glibc/uclibc-ng/musl in Buildroot
http://autobuild.buildroot.net/index.php?reason=ltp-testsuite-20190930

+ There are other CI based on yocto/openembedded on glibc/uclibc-ng/musl

It is so cool.? And I think I? can move your musl patches to my ltp fork, so that I can also test them on musl when I contribute my patches to ltp.

ps: I also think we should not block this patchset.

Quoted 6 lines
Quoted 2 lines

[1]http://git.musl-libc.org/cgit/musl/tree/include/sys/quota.h

Kind regards,
Petr

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

author
#9 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

In reply to Petr Vorel
Quoted 25 lines · Petr Vorel

Hi Jan, Cyril, Xu,

Quoted 4 lines

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.

LGTM, with 2 questions.

include/lapi/quotactl.h line 17

Quoted 9 lines
  #ifndef LAPI_QUOTACTL_H__
  # define LAPI_QUOTACTL_H__
include/lapi/quotactl.h +7 -0
+#include <sys/quota.h>
+
+#ifdef HAVE_STRUCT_IF_NEXTDQBLK
+# include <linux/quota.h>
+#else
+# ifdef HAVE_LINUX_TYPES_H
+# include <linux/types.h>

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed? __u64 can be uint64_t etc (as it's also visible in struct dqblk in <sys/quota.h> in various libc headers).
We used this approach for /usr/include/linux/bpf.h and for fanotify fixes for musl (testcases/kernel/syscalls/fanotify/fanotify.h).

Quoted 3 lines

So unless you're against this approach here I'll change it before merge (and add this info to next version of library API writing guidelines patch
https://patchwork.ozlabs.org/patch/1166786/).

I have no objection about using uint64_t becuase Q_GETNEXTQUOTA man-pages also uses it. I used struct if_nextdqblk as same as <linux/quota.h> defined. But I don't know why we can't use <linux/type.h> in lapi/quotactl.h and I also use it in lapi/seccomp.h. IMHO, they affected nothing. Or, they have some redefined errors or not having this headers files in special linux distribution.

Quoted 32 lines
Quoted 12 lines
include/lapi/quotactl.h +12 -0
+struct if_nextdqblk {
+	__u64 dqb_bhardlimit;
+	__u64 dqb_bsoftlimit;
+	__u64 dqb_curspace;
+	__u64 dqb_ihardlimit;
+	__u64 dqb_isoftlimit;
+	__u64 dqb_curinodes;
+	__u64 dqb_btime;
+	__u64 dqb_itime;
+	__u32 dqb_valid;
+	__u32 dqb_id;
+};

...

testcases/kernel/syscalls/quotactl/quotactl01.c line 4

Quoted 7 lines

+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c

testcases/kernel/syscalls/quotactl/quotactl01.c +1 -1
@@ -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

BTW correct formatting is
/*
*
*/
Not
/*
*
*/
I'll change it during merge (nit, the code is what matters, not formatting, of course).

...

testcases/kernel/syscalls/quotactl/quotactl01.c static struct dqinfo set_qf = { · line 69

Quoted 1 line
testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
+static int getnextquota_nsup;
Quoted 8 lines

...

testcases/kernel/syscalls/quotactl/quotactl01.c static struct tcase { · line 167

Quoted 5 lines
  static void setup(void)
  {
  	const char *const cmd[] = {"quotacheck", "-ugF", "vfsv0", MNTPOINT, NULL};
  	int ret;
testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
+	getnextquota_nsup = 0;

This is not needed (getnextquota_nsup is static and it's called just once, I'll remove it before merge).

Yes.

Quoted 11 lines

testcases/kernel/syscalls/quotactl/quotactl01.c static void setup(void) · line 188

Quoted 10 lines
  	ret = tst_run_cmd(cmd, NULL, NULL, 1);
  	switch (ret) {
testcases/kernel/syscalls/quotactl/quotactl01.c +4 -0
@@ -146,6 +183,11 @@ static void setup(void)
  	if (access(GRPPATH, F_OK) == -1)
  		tst_brk(TFAIL | TERRNO, "group quotafile didn't exist");
+
+	TEST(quotactl(QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev,
+		test_id, (void *) &res_ndq));
+	if (TST_ERR == EINVAL || TST_ERR == ENOSYS)

Does EINVAL really mans not supported? Shouldn't be just for ENOSYS.

EINVAL can mean non-supported? by using correct argument.

Quoted 27 lines

testcases/kernel/syscalls/quotactl/quotactl01.c static void setup(void) · line 191

Quoted 2 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +1 -0
+		getnextquota_nsup = 1;
  }

Looking at kernel sources - this does not look as not supported, but rather a failure (we might want to add some test for EINVAL):

	if (!qid_has_mapping(sb->s_user_ns, qid))
		return -EINVAL;

kernel fs/quota/quota.c
/*
* Return quota for next active quota >= this id, if any exists,
* otherwise return -ENOENT via ->get_nextdqblk
*/
static int quota_getnextquota(struct super_block *sb, int type, qid_t id,
void __user *addr)

{
	struct kqid qid;
	struct qc_dqblk fdq;
	struct if_nextdqblk idq;
	int ret;

	if (!sb->s_qcop->get_nextdqblk)
		return -ENOSYS;
	qid = make_kqid(current_user_ns(), type, id);
	if (!qid_has_mapping(sb->s_user_ns, qid))
		return -EINVAL;
	ret = sb->s_qcop->get_nextdqblk(sb, &qid, &fdq);
	if (ret)
Quoted 8 lines
		return ret;
	/* struct if_nextdqblk is a superset of struct if_dqblk */
	copy_to_if_dqblk((struct if_dqblk *)&idq, &fdq);
	idq.dqb_id = from_kqid(current_user_ns(), qid);
	if (copy_to_user(addr, &idq, sizeof(idq)))
		return -EFAULT;
	return 0;
}

Hi Petr

look do_quotactl function in fs/quota/quota.c.

static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id,
?????????????????????? void __user *addr, const struct path *path)
{

??? switch (cmd) {
??????? case Q_QUOTAON:
??????????????? return quota_quotaon(sb, type, id, path); ??????? case Q_QUOTAOFF:
??????????????? return quota_quotaoff(sb, type); ??????? case Q_GETFMT:
??????????????? return quota_getfmt(sb, type, addr); ??????? case Q_GETINFO:
??? ??? ......

??? ???? default:
??????????????? return -EINVAL;
??????? }
}

So if it doesn't have Q_GETNEXTQUOTA cmd, it should report EINVAL(we use correct argument and correct environment, so there is no failure).

Quoted 4 lines

Kind regards,
Petr

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

#10 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Xu,

Quoted 6 lines
Quoted 5 lines

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed? __u64 can be uint64_t etc (as it's also visible in struct dqblk in <sys/quota.h> in various libc headers).
We used this approach for /usr/include/linux/bpf.h and for fanotify fixes for musl (testcases/kernel/syscalls/fanotify/fanotify.h).

Quoted 8 lines
Quoted 3 lines

So unless you're against this approach here I'll change it before merge (and add this info to next version of library API writing guidelines patch
https://patchwork.ozlabs.org/patch/1166786/).

I have no objection about using uint64_t becuase Q_GETNEXTQUOTA man-pages also uses it. I used struct if_nextdqblk as same as <linux/quota.h> defined. But I don't know why we can't use <linux/type.h> in lapi/quotactl.h and I also use it in lapi/seccomp.h. IMHO, they affected nothing. Or, they have some redefined errors or not having this headers files in special linux distribution.

Based on Jan's comment [1], maybe he meant it specifically for __kernel_fsid_t in fanotify.h, not as a general approach. __kernel_fsid_t is more complicated than uint64_t. That's why I'm asking whether there is a general approach we want to take.

Quoted 23 lines
Quoted 4 lines

testcases/kernel/syscalls/quotactl/quotactl01.c static void setup(void) · line 189

Quoted 3 lines
testcases/kernel/syscalls/quotactl/quotactl01.c +3 -0
+	TEST(quotactl(QCMD(Q_GETNEXTQUOTA, USRQUOTA), tst_device->dev,
+		test_id, (void *) &res_ndq));
+	if (TST_ERR == EINVAL || TST_ERR == ENOSYS)

Does EINVAL really mans not supported? Shouldn't be just for ENOSYS.

EINVAL can mean non-supported? by using correct argument.

look do_quotactl function in fs/quota/quota.c.

static int do_quotactl(struct super_block *sb, int type, int cmd, qid_t id, ?????????????????????? void __user *addr, const struct path *path) {

??? switch (cmd) {
??????? case Q_QUOTAON:
??????????????? return quota_quotaon(sb, type, id, path); ??????? case Q_QUOTAOFF:
??????????????? return quota_quotaoff(sb, type); ??????? case Q_GETFMT:
??????????????? return quota_getfmt(sb, type, addr); ??????? case Q_GETINFO:
??? ??? ......

Quoted 6 lines

??? ???? default:
??????????????? return -EINVAL;
??????? }
}

So if it doesn't have Q_GETNEXTQUOTA cmd, it should report EINVAL(we use correct argument and correct environment, so there is no failure).

OK, you're right, thanks for info :).

Kind regards,
Petr

[1] https://patchwork.ozlabs.org/patch/1178182/#2281586

author
#11 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Quoted 4 lines · Petr Vorel

Based on Jan's comment [1], maybe he meant it specifically for __kernel_fsid_t in fanotify.h, not as a general approach. __kernel_fsid_t is more complicated than uint64_t. That's why I'm asking whether there is a general approach we want to take.

Hi Petr

I see. Now, I think we should avoid to use <linux/types.h>?? because on musl? libc doesn't have it.

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

on myself.

Thanks
Yang Xu

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

#12 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Xu,

Quoted 1 line

I see. Now, I think we should avoid to use <linux/types.h>?? because on musl? libc doesn't have it.

IMHO <linux/types.h> are always installed from kernel, not from libc (packaged result of make headers_install run from kernel sources).

Quoted 1 line

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

Hm, that what I said: using kernel headers is imho easier that using libc headers (fewer problems with compatibility).
Anyway, I don't want to block this patchset.
We can always merge it as it is and sort/fix this problem later.

Kind regards,
Petr

author
#13 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Quoted 5 lines · Petr Vorel

Hi Xu,

Quoted 1 line

I see. Now, I think we should avoid to use <linux/types.h>?? because on musl? libc doesn't have it.

IMHO <linux/types.h> are always installed from kernel, not from libc (packaged result of make headers_install run from kernel sources).

Oh, you are right. For this case, using <linux/types.h> is right that we don't have situation such as fanotify .

Quoted 6 lines
Quoted 2 lines

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

Hm, that what I said: using kernel headers is imho easier that using libc headers (fewer problems with compatibility).
Anyway, I don't want to block this patchset.
We can always merge it as it is and sort/fix this problem later.

Yes. kernel header is more eaiser that libc. Thanks.

Quoted 5 lines

Kind regards,
Petr

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

#14 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

In reply to Petr Vorel

----- Original Message -----

Quoted 2 lines

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed?

Yes, we generally try to avoid including kernel headers. Our style-guide says "Don't use +linux/+ headers if at all possible". uapi on older distros was more prone to cause LTP build errors.

#15 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Jan, Li,

Quoted 7 lines

----- Original Message -----

Quoted 2 lines

@Jan, @Cyril: Do we want to generally avoid loading <linux/types.h> if not really needed?

Yes, we generally try to avoid including kernel headers. Our style-guide says "Don't use +linux/+ headers if at all possible". uapi on older distros was more prone to cause LTP build errors.

Thank you for pointing out docs, I completely forgot on this page. BTW it needs some update (examples use old API, linux_syscall_numbers.h). Also not sure if everything else still applies (4. Call APIs that don't require freeing up resources on failure first, 2. Sort headers).

Quoted 1 line
Quoted 1 line

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

Jan, are you aware of this problem?
Xu, I'm not sure if you're talking about uint64_t problematic in <linux/types.h> (as you mention kernel) or problem in glibc <sys/types.h> / <stdint.h> / <inttypes.h>? We have lots of code which is using some of these 3 libc headers, does it fail on 2.6.32?

Does anybody compile for 2.6.32?
I know we want to keep support for 2.6.x (we had some discussion in the past). Than it'd be good to have travis build for kernel 2.6.x.

Back to patchset. I suggest to merge it as it is and I'll prepare patches, which use <sys/types.h> in our tests.

Kind regards,
Petr

#16 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

----- Original Message -----

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

Jan, are you aware of this problem?

I'm not, it should be defined in stdint.h.

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.10 (Santiago)
# grep uint64_t -r /usr/include/ | grep stdint
/usr/include/stdint.h:typedef unsigned long int	uint64_t;
Quoted 9 lines

Xu, I'm not sure if you're talking about uint64_t problematic in <linux/types.h>
(as you mention kernel) or problem in glibc <sys/types.h> / <stdint.h> / <inttypes.h>?
We have lots of code which is using some of these 3 libc headers, does it fail
on 2.6.32?

Does anybody compile for 2.6.32?

[CC Li]
I think RH still does compile latest for regression tests. RHEL6 will be in sustaining for couple more years.

#17 lore raw

PATCH v4 1/5 syscalls/quotactl01: Add Q_GETNEXTQUOTA test

Hi Jan,

Quoted 21 lines

----- Original Message -----

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Also ,If we use uint64_t, they still failed on 2.6.32-754.el6.x86_64 with undefined . Or, we should use TST_ABI to define uint64_t them

Jan, are you aware of this problem?

I'm not, it should be defined in stdint.h.

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.10 (Santiago)
# grep uint64_t -r /usr/include/ | grep stdint
/usr/include/stdint.h:typedef unsigned long int	uint64_t;
Quoted 7 lines

Xu, I'm not sure if you're talking about uint64_t problematic in <linux/types.h>
(as you mention kernel) or problem in glibc <sys/types.h> / <stdint.h> / <inttypes.h>?
We have lots of code which is using some of these 3 libc headers, does it fail
on 2.6.32?

Quoted 5 lines
Quoted 1 line

Does anybody compile for 2.6.32?

[CC Li]
I think RH still does compile latest for regression tests. RHEL6 will be in sustaining for couple more years.

Thanks for info. Sorry I forgot, we have CentOS 6.10 in travis, that should be enough for testing build in old toolchain.

author
#18 lore raw

PATCH v4 2/5 syscalls/quotactl02: Add Q_XGETQSTATV test and group quota tests

In reply to Yang 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).

Also, cover group quota like quotactl01.c.

Move common code to quota02.h, so we can use it for comming quotactl05.c to test project quota on xfs filesystem.

---
 include/lapi/quotactl.h                       |  33 +++
 m4/ltp-quota.m4                               |   1 +
 .../kernel/syscalls/quotactl/quotactl02.c     | 222 ++++++++----------
 .../kernel/syscalls/quotactl/quotactl02.h     | 167 +++++++++++++
 4 files changed, 305 insertions(+), 118 deletions(-)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl02.h
include/lapi/quotactl.h +33 -0
index 5c49cedce..808d044ff 100644
@@ -30,6 +30,39 @@ struct if_nextdqblk {
 #endif
 #endif
 
+#ifndef HAVE_STRUCT_FS_QUOTA_STATV
+# ifdef HAVE_LINUX_TYPES_H
+# include <linux/types.h>
+struct fs_qfilestatv {
+	__u64           qfs_ino;
+	__u64           qfs_nblks;
+	__u32           qfs_nextents;
+	__u32           qfs_pad;
+};
+
+struct fs_quota_statv {
+	__s8                    qs_version;
+	__u8                    qs_pad1;
+	__u16                   qs_flags;
+	__u32                   qs_incoredqs;
+	struct fs_qfilestatv    qs_uquota;
+	struct fs_qfilestatv    qs_gquota;
+	struct fs_qfilestatv    qs_pquota;
+	__s32                   qs_btimelimit;
+	__s32                   qs_itimelimit;
+	__s32                   qs_rtbtimelimit;
+	__u16                   qs_bwarnlimit;
+	__u16                   qs_iwarnlimit;
+	__u64                   qs_pad2[8];
+};
+#define FS_QSTATV_VERSION1 1
+#endif
+#endif
+
+# ifndef Q_XGETQSTATV
+#  define Q_XGETQSTATV XQM_CMD(8)
+# endif
+
 # ifndef Q_XGETNEXTQUOTA
 #  define Q_XGETNEXTQUOTA XQM_CMD(9)
 # endif
m4/ltp-quota.m4 +1 -0
index e8d08c6b7..bcdff7041 100644
@@ -4,4 +4,5 @@ dnl Author: Yang Xu <[email protected]>
 
 AC_DEFUN([LTP_CHECK_SYSCALL_QUOTACTL],[
 AC_CHECK_TYPES([struct if_nextdqblk],,,[#include <linux/quota.h>])
+AC_CHECK_TYPES([struct fs_quota_statv],,,[#include <xfs/xqm.h>])
 ])
testcases/kernel/syscalls/quotactl/quotactl02.c +104 -118

274 lines not on this page · raw message

testcases/kernel/syscalls/quotactl/quotactl02.h new file +167 -0

167 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#19 lore raw

PATCH v4 3/5 syscalls/quotactl04: add project quota test for non-xfs filesystem

In reply to Yang Xu

This is a variant about quotactl01.c and used to test project quota. I split it into a new case instead of adding it in quotaclt01.c because two points:
1)Before linux 4.10, ext4 doesn't support project quota.
2)On old kernel, kernel doesn't permit mount both prjquota and grpquota together.

---
 include/lapi/quotactl.h                       |   4 +
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/quotactl/.gitignore |   1 +
 .../kernel/syscalls/quotactl/quotactl04.c     | 162 ++++++++++++++++++
 4 files changed, 168 insertions(+)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl04.c
include/lapi/quotactl.h +4 -0
index 808d044ff..8d559af51 100644
@@ -59,6 +59,10 @@ struct fs_quota_statv {
 #endif
 #endif
 
+#ifndef PRJQUOTA
+# define PRJQUOTA 2
+#endif
+
 # ifndef Q_XGETQSTATV
 #  define Q_XGETQSTATV XQM_CMD(8)
 # endif
runtest/syscalls +1 -0
index fee91f909..078143b13 100644
@@ -954,6 +954,7 @@ pwritev202_64 pwritev202_64
 quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
+quotactl04 quotactl04
 
 read01 read01
 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
index b0ef075e7..1db7c5d98 100644
@@ -1,3 +1,4 @@
 /quotactl01
 /quotactl02
 /quotactl03
+/quotactl04
testcases/kernel/syscalls/quotactl/quotactl04.c new file +162 -0

162 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#20 lore raw

PATCH v4 4/5 syscalls/quotactl05: add project quota test on xfs filesystem

In reply to Yang Xu

This is a variant about quotactl02.c and used to test project quota. I split it into a new case instead of adding it in quotaclt02.c because kernel doesn't permit mount both group and project quota before commit d892d5864f02 ("xfs: Start using pquotaino from the superblock.").

---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/quotactl/.gitignore |   1 +
 .../kernel/syscalls/quotactl/quotactl05.c     | 118 ++++++++++++++++++
 3 files changed, 120 insertions(+)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl05.c
runtest/syscalls +1 -0
index 078143b13..b6bf67c38 100644
@@ -955,6 +955,7 @@ quotactl01 quotactl01
 quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
+quotactl05 quotactl05
 
 read01 read01
 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
index 1db7c5d98..6fe62fbf7 100644
@@ -2,3 +2,4 @@
 /quotactl02
 /quotactl03
 /quotactl04
+/quotactl05
testcases/kernel/syscalls/quotactl/quotactl05.c new file +118 -0

118 lines not on this page · raw message

Signature · 1 line
2.18.0
author
#21 lore raw

PATCH v4 5/5 syscalls/quotactl06: Add new error testcase

In reply to Yang Xu
---
 runtest/syscalls                              |   1 +
 testcases/kernel/syscalls/quotactl/.gitignore |   1 +
 .../kernel/syscalls/quotactl/quotactl06.c     | 196 ++++++++++++++++++
 3 files changed, 198 insertions(+)
 create mode 100644 testcases/kernel/syscalls/quotactl/quotactl06.c
runtest/syscalls +1 -0
index b6bf67c38..9bbde8c41 100644
@@ -956,6 +956,7 @@ quotactl02 quotactl02
 quotactl03 quotactl03
 quotactl04 quotactl04
 quotactl05 quotactl05
+quotactl06 quotactl06
 
 read01 read01
 read02 read02
testcases/kernel/syscalls/quotactl/.gitignore +1 -0
index 6fe62fbf7..12896d6ad 100644
@@ -3,3 +3,4 @@
 /quotactl03
 /quotactl04
 /quotactl05
+/quotactl06
testcases/kernel/syscalls/quotactl/quotactl06.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
2.18.0
#22 lore raw

v4 cover optimize quotactl test code

In reply to Yang Xu

Hi Xu,

Quoted 2 lines

I cleanup the quotactl code and add project quota test for quotactl. Thanks to Jan Kara with support about quota.

Whole patchset merged, following with changes for and quotactl.h seccomp.h to use libc headers.
Thanks for your work!

Kind regards,
Petr