All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amir Goldstein <amir73il@gmail.com>
To: "zhangyi (F)" <yi.zhang@huawei.com>
Cc: fstests <fstests@vger.kernel.org>, Eryu Guan <guaneryu@gmail.com>,
	Miklos Szeredi <miklos@szeredi.hu>, Miao Xie <miaoxie@huawei.com>
Subject: Re: [PATCH v2 1/4] overlay: correct fsck.overlay exit code
Date: Tue, 16 Oct 2018 12:45:18 +0300	[thread overview]
Message-ID: <CAOQ4uxh8YWXprDPp1H6Si+L1QXBwcTp1+P78MqYZD5wMzuJopg@mail.gmail.com> (raw)
In-Reply-To: <20181016074559.24728-2-yi.zhang@huawei.com>

On Tue, Oct 16, 2018 at 10:32 AM zhangyi (F) <yi.zhang@huawei.com> wrote:
>
> fsck.overlay should return correct exit code to show the file system
> status after fsck, instead of return 0 means consistency and !0 means
> inconsistency or something bad happened.
>
> Fix the following three exit code after running fsck.overlay:
>
> - Return FSCK_OK if the input file system is consistent,
> - Return FSCK_NONDESTRUCT if the file system inconsistent errors
>   corrected,
> - Return FSCK_UNCORRECTED if the file system still have inconsistent
>   errors.
>
> This patch also add a helper function to run fsck.overlay and check
> the return value is expected or not.
>
> Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
> ---
>  common/overlay    | 29 +++++++++++++++++++++++++++++
>  tests/overlay/045 | 27 +++++++++------------------
>  tests/overlay/046 | 36 ++++++++++++------------------------
>  tests/overlay/056 |  9 +++------
>  4 files changed, 53 insertions(+), 48 deletions(-)
>
> diff --git a/common/overlay b/common/overlay
> index b526f24..4cc2829 100644
> --- a/common/overlay
> +++ b/common/overlay
> @@ -12,6 +12,16 @@ export OVL_XATTR_NLINK="trusted.overlay.nlink"
>  export OVL_XATTR_UPPER="trusted.overlay.upper"
>  export OVL_XATTR_METACOPY="trusted.overlay.metacopy"
>
> +# Export exit code used by fsck.overlay program
> +export FSCK_OK=0
> +export FSCK_NONDESTRUCT=1
> +export FSCK_REBOOT=2
> +export FSCK_UNCORRECTED=4
> +export FSCK_ERROR=8
> +export FSCK_USAGE=16
> +export FSCK_CANCELED=32
> +export FSCK_LIBRARY=128
> +
>  # helper function to do the actual overlayfs mount operation
>  _overlay_mount_dirs()
>  {
> @@ -193,6 +203,25 @@ _overlay_fsck_dirs()
>                            -o workdir=$workdir $*
>  }
>
> +# Run fsck and check the return value
> +_run_check_fsck()
> +{
> +       # The first arguments is the expected fsck program exit code, the
> +       # remaining arguments are the input parameters of the fsck program.
> +       local expect_ret=$1
> +       local lowerdir=$2
> +       local upperdir=$3
> +       local workdir=$4
> +       shift 4
> +
> +       _overlay_fsck_dirs $lowerdir $upperdir $workdir $* >> \
> +                       $seqres.full 2>&1
> +       fsck_ret=$?
> +
> +       [[ "$fsck_ret" == "$expect_ret" ]] || \
> +               echo "fsck return unexpected value:$expect_ret,$fsck_ret"
> +}

Looks good.

Please consider the name _overlay_repair_dirs() with reference to
_repair_scratch_fs(), which is used for roughly the same purpose.

BTW, the tests generic/330 generic/332 when run with -overlay
over xfs with reflink support seem to call _repair_scratch_fs() which does:
        # Let's hope fsck -y suffices...
        fsck -t $FSTYP -y $SCRATCH_DEV 2>&1
        local res=$?
        case $res in
        0|1|2)
                res=0
                ;;
        *)
                _dump_err2 "fsck.$FSTYP failed, err=$res"

How come fsck.overlay is not complaining about missing arguments??

The rest of the generic tests that call _repair_scratch_fs() have
_require_dm_target() which _require_block_device(), so don't run with overlay.

If you do sort this out and add overlay support to
_repair_scratch_fs() its probably
worth replacing 0|1|2) with FSCK_ constants.

Thanks,
Amir.

  reply	other threads:[~2018-10-16 17:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16  7:45 [PATCH v2 0/4] overlay: enhance fsck.overlay test cases zhangyi (F)
2018-10-16  7:45 ` [PATCH v2 1/4] overlay: correct fsck.overlay exit code zhangyi (F)
2018-10-16  9:45   ` Amir Goldstein [this message]
2018-10-18  2:37     ` zhangyi (F)
2018-10-18  4:37       ` Amir Goldstein
2018-10-18 16:22         ` zhangyi
2018-10-18  4:54   ` Amir Goldstein
2018-10-16  7:45 ` [PATCH v2 2/4] overlay: fix exit code for some fsck.overlay valid cases zhangyi (F)
2018-10-16  9:26   ` Amir Goldstein
2018-10-18  3:42     ` zhangyi (F)
2018-10-18  4:44       ` Amir Goldstein
2018-10-19 12:36         ` zhangyi (F)
2018-10-19 14:00           ` Amir Goldstein
2018-10-16  7:45 ` [PATCH v2 3/4] overlay: add fsck.overlay stress test zhangyi (F)
2018-10-16 10:07   ` Amir Goldstein
2018-10-18  3:48     ` zhangyi (F)
2018-10-16  7:45 ` [PATCH v2 4/4] overlay: add fsck.overlay exception tests zhangyi (F)
2018-10-16 13:29   ` Amir Goldstein
2018-10-16  9:27 ` [PATCH v2 0/4] overlay: enhance fsck.overlay test cases Amir Goldstein
2018-10-16 12:39   ` Amir Goldstein
2018-10-18  3:50     ` zhangyi (F)

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=CAOQ4uxh8YWXprDPp1H6Si+L1QXBwcTp1+P78MqYZD5wMzuJopg@mail.gmail.com \
    --to=amir73il@gmail.com \
    --cc=fstests@vger.kernel.org \
    --cc=guaneryu@gmail.com \
    --cc=miaoxie@huawei.com \
    --cc=miklos@szeredi.hu \
    --cc=yi.zhang@huawei.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.