FS/XFS testing framework
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH 4/4] generic: test that renaming into a directory fails with EDQUOT
Date: Fri, 15 Apr 2022 03:13:38 +0800	[thread overview]
Message-ID: <20220414191338.tc7vrhxfqlkml4fu@zlang-mailbox> (raw)
In-Reply-To: <20220412175827.GI16799@magnolia>

On Tue, Apr 12, 2022 at 10:58:27AM -0700, Darrick J. Wong wrote:
> On Wed, Apr 13, 2022 at 01:29:30AM +0800, Zorro Lang wrote:
> > On Mon, Apr 11, 2022 at 03:54:54PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <djwong@kernel.org>
> > > 
> > > Add a regression test to make sure that unprivileged userspace renaming
> > > within a directory fails with EDQUOT when the directory quota limits have
> > > been exceeded.
> > > 
> > > Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> > > ---
> > >  tests/generic/833     |   71 +++++++++++++++++++++++++++++++++++++++++++++++++
> > >  tests/generic/833.out |    3 ++
> > >  2 files changed, 74 insertions(+)
> > >  create mode 100755 tests/generic/833
> > >  create mode 100644 tests/generic/833.out
> > > 
> > > 
> > > diff --git a/tests/generic/833 b/tests/generic/833
> > > new file mode 100755
> > > index 00000000..a1b3cbc0
> > > --- /dev/null
> > > +++ b/tests/generic/833
> > > @@ -0,0 +1,71 @@
> > > +#! /bin/bash
> > > +# SPDX-License-Identifier: GPL-2.0
> > > +# Copyright (c) 2022 Oracle.  All Rights Reserved.
> > > +#
> > > +# FS QA Test No. 833
> > > +#
> > > +# Ensure that unprivileged userspace hits EDQUOT while moving files into a
> > > +# directory when the directory's quota limits have been exceeded.
> > > +#
> > > +# Regression test for commit:
> > > +#
> > > +# 41667260bc84 ("xfs: reserve quota for target dir expansion when renaming files")
> > > +#
> > > +. ./common/preamble
> > > +_begin_fstest auto quick quota
> > > +
> > > +# Import common functions.
> > > +. ./common/filter
> > > +. ./common/quota
> > > +
> > > +# real QA test starts here
> > > +
> > > +# Modify as appropriate.
> > > +_supported_fs generic
> > > +_require_quota
> > > +_require_user
> > > +_require_scratch
> > > +
> > > +_scratch_mkfs > "$seqres.full" 2>&1
> > > +_qmount_option usrquota
> > > +_qmount
> > > +
> > > +blocksize=$(_get_block_size $SCRATCH_MNT)
> > > +scratchdir=$SCRATCH_MNT/dir
> > > +scratchfile=$SCRATCH_MNT/file
> > > +stagedir=$SCRATCH_MNT/staging
> > > +mkdir $scratchdir $stagedir
> > > +touch $scratchfile
> > > +
> > > +# Create a 2-block directory for our 1-block quota limit
> > > +total_size=$((blocksize * 2))
> > > +dirents=$((total_size / 255))
> > > +
> > > +for ((i = 0; i < dirents; i++)); do
> > > +	name=$(printf "x%0254d" $i)
> > > +	ln $scratchfile $scratchdir/$name
> > > +done
> > > +
> > > +# Set a low quota hardlimit for an unprivileged uid and chown the files to it
> > > +echo "set up quota" >> $seqres.full
> > > +setquota -u $qa_user 0 "$((blocksize / 1024))" 0 0 $SCRATCH_MNT
> > > +chown $qa_user $scratchdir $scratchfile
> > > +repquota -upn $SCRATCH_MNT >> $seqres.full
> > > +
> > > +# Fail at renaming into the directory as qa_user to ensure quota enforcement
> > > +# works
> > > +chmod a+rwx $stagedir
> > > +echo "fail quota" >> $seqres.full
> > > +for ((i = 0; i < dirents; i++)); do
> > > +	name=$(printf "y%0254d" $i)
> > > +	ln $scratchfile $stagedir/$name
> > > +	su - "$qa_user" -c "mv $stagedir/$name $scratchdir/$name" 2>&1 | \
> > 
> > Same as [PATCH 3/4], do we need "--login"?
> > Oh, I just found there's only one case generic/128 use this option too. Anyway I
> > have no reason to object it, just speak out for review:)
> 
> <nod> I have the same response as the previous patch. ;)

Same as [PATCH 3/4], we'll help to deal with the "-".

Reviewed-by: Zorro Lang <zlang@redhat.com>

> 
> --D
> 
> > Thanks,
> > Zorro
> > 
> > > +		_filter_scratch | sed -e 's/y[0-9]*/yXXX/g'
> > > +	test "${PIPESTATUS[0]}" -ne 0 && break
> > > +done
> > > +repquota -upn $SCRATCH_MNT >> $seqres.full
> > > +
> > > +# success, all done
> > > +echo Silence is golden
> > > +status=0
> > > +exit
> > > diff --git a/tests/generic/833.out b/tests/generic/833.out
> > > new file mode 100644
> > > index 00000000..d100fa07
> > > --- /dev/null
> > > +++ b/tests/generic/833.out
> > > @@ -0,0 +1,3 @@
> > > +QA output created by 833
> > > +mv: cannot move 'SCRATCH_MNT/staging/yXXX' to 'SCRATCH_MNT/dir/yXXX': Disk quota exceeded
> > > +Silence is golden
> > > 
> > 
> 


      reply	other threads:[~2022-04-14 19:13 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 22:54 [PATCHSET 0/4] fstests: new tests for kernel 5.18 Darrick J. Wong
2022-04-11 22:54 ` [PATCH 1/4] xfs: make sure syncfs(2) passes back super_operations.sync_fs errors Darrick J. Wong
2022-04-12  9:37   ` Zorro Lang
2022-04-12 17:28     ` Darrick J. Wong
2022-04-14 14:43       ` Zorro Lang
2022-04-14 15:42         ` Darrick J. Wong
2022-04-14 18:58           ` Zorro Lang
2022-04-11 22:54 ` [PATCH 2/4] generic: ensure we drop suid after fallocate Darrick J. Wong
2022-04-12 11:52   ` Zorro Lang
2022-04-13  7:58     ` Amir Goldstein
2022-04-13 15:44       ` Zorro Lang
2022-04-14 15:50         ` Darrick J. Wong
2022-04-14 19:10           ` Zorro Lang
2022-04-15 13:42             ` Amir Goldstein
2022-04-16 14:01               ` Zorro Lang
2022-04-16 17:30                 ` Amir Goldstein
2022-04-17 15:40               ` Eryu Guan
2022-04-19 17:18                 ` Darrick J. Wong
2022-04-15  8:54           ` Amir Goldstein
2022-04-11 22:54 ` [PATCH 3/4] generic: test that linking into a directory fails with EDQUOT Darrick J. Wong
2022-04-12 17:17   ` Zorro Lang
2022-04-12 17:52     ` Darrick J. Wong
2022-04-14 19:12       ` Zorro Lang
2022-04-11 22:54 ` [PATCH 4/4] generic: test that renaming " Darrick J. Wong
2022-04-12 17:29   ` Zorro Lang
2022-04-12 17:58     ` Darrick J. Wong
2022-04-14 19:13       ` Zorro Lang [this message]

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=20220414191338.tc7vrhxfqlkml4fu@zlang-mailbox \
    --to=zlang@redhat.com \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox