All of lore.kernel.org
 help / color / mirror / Atom feed
From: "libaokun (A)" <libaokun1@huawei.com>
To: Amir Goldstein <amir73il@gmail.com>
Cc: fstests <fstests@vger.kernel.org>, Zorro Lang <zlang@redhat.com>,
	Eryu Guan <guaneryu@gmail.com>,
	Zhihao Cheng <chengzhihao1@huawei.com>, <yukuai3@huawei.com>,
	Baokun Li <libaokun1@huawei.com>
Subject: Re: [RFC v3] common: xfstests support overlay+tmpfs
Date: Tue, 10 May 2022 20:05:12 +0800	[thread overview]
Message-ID: <1aa6663e-1c1d-3659-231d-29c6d4e448c9@huawei.com> (raw)
In-Reply-To: <CAOQ4uxhTzqvuD5=5c4O_fhzV9CrHSpipegjUiETgCbNTkdvpvA@mail.gmail.com>

在 2022/5/10 15:51, Amir Goldstein 写道:
> On Tue, May 10, 2022 at 4:50 AM Baokun Li <libaokun1@huawei.com> wrote:
>> The local.config of overlay+tmpfs is as follows:
>> ```local.config.example
>> export FSTYP=tmpfs
>> export TEST_DEV=tmpfs_test
>> export TEST_DIR=/tmp/test
>> export SCRATCH_DEV=tmpfs_scratch
>> export SCRATCH_MNT=/tmp/scratch
>> ```
>>
>> Run `./check -overlay tests` to execute test case on overlay+tmpfs.
>>
>> Signed-off-by: Baokun Li <libaokun1@huawei.com>
>> ---
>> V1->V2:
>>          Fix the bug in version V1 and fix the issue in cycle_mount.
>> V2->V3:
>>          Merge two patches into one completed patch.
>>
>> V1: https://patchwork.kernel.org/project/fstests/patch/20220424063751.1067376-1-libaokun1@huawei.com/
>> V2: https://patchwork.kernel.org/project/fstests/cover/20220507094524.949615-1-libaokun1@huawei.com/
>>
>>   common/config  | 12 ++++++------
>>   common/overlay |  2 +-
>>   common/rc      | 31 ++++++++++++++++++++++++-------
>>   3 files changed, 31 insertions(+), 14 deletions(-)
>>
>> diff --git a/common/config b/common/config
>> index 1033b890..d5953176 100644
>> --- a/common/config
>> +++ b/common/config
>> @@ -610,15 +610,15 @@ _overlay_config_override()
>>          [ ! -d "$TEST_DEV" ] || export OVL_BASE_TEST_DIR="$TEST_DEV"
>>          [ ! -d "$SCRATCH_DEV" ] || export OVL_BASE_SCRATCH_MNT="$SCRATCH_DEV"
>>
>> +       # Config file may specify base fs type, but we obay -overlay flag
>> +       [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
>> +       export FSTYP=overlay
>> +
>>          # 2. SCRATCH/TEST_DEV point to the base fs partitions.  In this case,
>>          #    the new OVL_BASE_SCRATCH/TEST_DEV/MNT vars are set to the values
>>          #    of the configured base fs and SCRATCH/TEST_DEV vars are set to the
>>          #    overlayfs base and mount dirs inside base fs mount.
>> -       [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || return 0
>> -
>> -       # Config file may specify base fs type, but we obay -overlay flag
>> -       [ "$FSTYP" == overlay ] || export OVL_BASE_FSTYP="$FSTYP"
>> -       export FSTYP=overlay
>> +       [ -b "$TEST_DEV" ] || [ -c "$TEST_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
>>
>>          # Store original base fs vars
>>          export OVL_BASE_TEST_DEV="$TEST_DEV"
>> @@ -634,7 +634,7 @@ _overlay_config_override()
>>          export TEST_DIR="$OVL_BASE_TEST_DIR/$OVL_MNT"
>>          export MOUNT_OPTIONS="$OVERLAY_MOUNT_OPTIONS"
>>
>> -       [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || return 0
>> +       [ -b "$SCRATCH_DEV" ] || [ -c "$SCRATCH_DEV" ] || [ "$OVL_BASE_FSTYP" == tmpfs ] || return 0
>>
>>          # Store original base fs vars
>>          export OVL_BASE_SCRATCH_DEV="$SCRATCH_DEV"
>> diff --git a/common/overlay b/common/overlay
>> index fff67ba1..c4e7ee58 100644
>> --- a/common/overlay
>> +++ b/common/overlay
>> @@ -81,7 +81,7 @@ _overlay_base_mount()
>>                  return 1
>>          fi
>>
>> -       _mount $* $dev $mnt
>> +       _mount -t $OVL_BASE_FSTYP $* $dev $mnt
>>          _idmapped_mount $dev $mnt
>>   }
>>
>> diff --git a/common/rc b/common/rc
>> index 553ae350..ca465438 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -410,10 +410,19 @@ _scratch_cycle_mount()
>>   {
>>       local opts="$1"
>>
>> -    if [ "$FSTYP" = tmpfs ]; then
>> -       _scratch_remount "$opts"
>> -       return
>> -    fi
>> +       case "$FSTYP" in
>> +       tmpfs)
>> +               _scratch_remount "$opts"
>> +               return
>> +               ;;
>> +       overlay)
>> +               if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
>> +                       _scratch_remount "$opts"
>
> That doesn't look right.
> _scrtach_cycle_mount is important for several overlay tests and there
> is no reason to
> skip it if base fs is tmpfs.
> What you need to do is cycle mount the overlay without cycle mounting
> the base fs.
> You could do something like this:
>
>    local unmounted
> ...
>
>    overlay)
>                 if [ "$OVL_BASE_FSTYP" = tmpfs ]; then
>                           $UMOUNT_PROG $SCRATCH_MNT
>                           unmounted=true
>                 fi
>                 ;;
>     esac
> ...
>      [ "$unmounted" = true ] || _scratch_unmount
>      _try_scratch_mount "$opts" || _fail "cycle mount failed"
> }
>
> There are some overlay tests that open code this pattern like overlay/077:
>
> # Remove the lower directory and mount overlay again to create
> # a "former merge dir"
> $UMOUNT_PROG $SCRATCH_MNT
> rm -rf $lowerdir/former
> _scratch_mount
>
> So _scratch_mount is expected to work just fine when base fs is already mounted
> assuming that _check_mounted_on works correctly with tmpfs.
>
> Thanks,
> Amir.
> .

Thank you very much for your advice.

I will send a patch V4 with the changes suggested by you.

-- 
With Best Regards,
Baokun Li

.




  reply	other threads:[~2022-05-10 12:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-10  2:04 [RFC v3] common: xfstests support overlay+tmpfs Baokun Li
2022-05-10  7:51 ` Amir Goldstein
2022-05-10 12:05   ` libaokun (A) [this message]
2022-05-10 12:12     ` Amir Goldstein
2022-05-10 12:22       ` libaokun (A)

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=1aa6663e-1c1d-3659-231d-29c6d4e448c9@huawei.com \
    --to=libaokun1@huawei.com \
    --cc=amir73il@gmail.com \
    --cc=chengzhihao1@huawei.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=yukuai3@huawei.com \
    --cc=zlang@redhat.com \
    /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.