All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v4 1/5] syscalls/quotactl01: Add Q_GETNEXTQUOTA test
Date: Wed, 20 Nov 2019 16:12:44 +0100	[thread overview]
Message-ID: <20191120151244.GA28197@dell5510> (raw)
In-Reply-To: <1574241216-15168-2-git-send-email-xuyang2018.jy@cn.fujitsu.com>

Hi Jan, Cyril, 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>
Reviewed-by: Petr Vorel <pvorel@suse.cz>

LGTM, with 2 questions.

>  #ifndef LAPI_QUOTACTL_H__
>  # define LAPI_QUOTACTL_H__

> +#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/).

> +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;
> +};

...
> +++ 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
BTW correct formatting is
/*
 *
 */
Not
/*
*
*/
I'll change it during merge (nit, the code is what matters, not formatting, of course).

...
> +static int getnextquota_nsup;
...
>  static void setup(void)
>  {
>  	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).

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

  reply	other threads:[~2019-11-20 15:12 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-20  9:13 [LTP] [PATCH v4 0/5] optimize quotactl test code Yang Xu
2019-11-20  9:13 ` [LTP] [PATCH v4 1/5] syscalls/quotactl01: Add Q_GETNEXTQUOTA test Yang Xu
2019-11-20 15:12   ` Petr Vorel [this message]
2019-11-20 15:16     ` Petr Vorel
2019-11-21  3:37       ` Yang Xu
2019-11-21  5:10         ` Petr Vorel
2019-11-21  7:07           ` Yang Xu
2019-11-21  8:21             ` Petr Vorel
2019-11-21  9:01               ` Yang Xu
2019-11-21  2:29     ` Yang Xu
2019-11-21  5:45       ` Petr Vorel
2019-11-21  7:45         ` Yang Xu
2019-11-21  8:32           ` Petr Vorel
2019-11-21  8:38             ` Yang Xu
2019-11-21  9:01     ` Jan Stancek
2019-11-21 10:30       ` Petr Vorel
2019-11-21 11:08         ` Jan Stancek
2019-11-21 15:19           ` Petr Vorel
2019-11-20  9:13 ` [LTP] [PATCH v4 2/5] syscalls/quotactl02: Add Q_XGETQSTATV test and group quota tests Yang Xu
2019-11-20  9:13 ` [LTP] [PATCH v4 3/5] syscalls/quotactl04: add project quota test for non-xfs filesystem Yang Xu
2019-11-20  9:13 ` [LTP] [PATCH v4 4/5] syscalls/quotactl05: add project quota test on xfs filesystem Yang Xu
2019-11-20  9:13 ` [LTP] [PATCH v4 5/5] syscalls/quotactl06: Add new error testcase Yang Xu
2019-11-21 17:01 ` [LTP] [PATCH v4 0/5] optimize quotactl test code Petr Vorel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191120151244.GA28197@dell5510 \
    --to=pvorel@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.