From patchwork Tue May 28 15:17:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10965209 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C77E92A for ; Tue, 28 May 2019 15:17:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D71E28421 for ; Tue, 28 May 2019 15:17:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3B79D28893; Tue, 28 May 2019 15:17:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11F8627FB1 for ; Tue, 28 May 2019 15:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727794AbfE1PRd (ORCPT ); Tue, 28 May 2019 11:17:33 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33663 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfE1PRd (ORCPT ); Tue, 28 May 2019 11:17:33 -0400 Received: by mail-wr1-f67.google.com with SMTP id d9so20689109wrx.0; Tue, 28 May 2019 08:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=D2tiTFln/if3GrLE8MLMPVx2reMyc0yTmj93edCCdaY=; b=FFdXFRA2xxNNzhGAFQtq/vPXXSDotclvP/U6tkeJ3QiT8SislSK0qq6jvWx5ek1hid o4xi5xf9EjtbD94T/u/gr/XELUA18K0JXvboh/AWma3JiRUbW0cWBt/rcnoBSAelkqj9 SWJ8zUR8wbUZwXP4VWV+RHC5Ff+WiVMqKZYN4iXYras5dFrH43cLC97lLL6rVFObx+HC 1Gynb7Vtt28mXZ4UmrloAl3wHkJD+bO8JrppnAyeqOcyQ/L7pHnt3qnRBKNK4g/BjIA+ 4KvV798h46Jj5qTgikqqudFkyW8Ve9l3Xvfmfp9+KKEJD2paM6FwqG2CnjMU2w2008lP ahoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=D2tiTFln/if3GrLE8MLMPVx2reMyc0yTmj93edCCdaY=; b=hZqRVgZMKrdM8NDzOX6uuR8iJVZGE1n1uMxenoSL+jmm+HDUD3t/vJlqxzfcdoRO1+ yGffrkil4UQBnh/9I6j5VTnD4z95SCG0AIj0ukqaOKaQ+g9fy0ReiNnkRg3DHbD1NTAc MTJu88u7tzS9J09oqwY+zazR9MB0QYG6sQZhoLsfbYz6NbHMhcJ/ZTtf1dszerkR1LgE LnqPBkqi5mmIKLn/jQxW9F9zbo76S1mNTA2m8Lj//N5kKGW0bhvpWzL3iiCj8sYWd8nR c3MDvcYr4K8r0tTaGICIuXGQ4sJ33t5xLP7wuf/mAHW6MZ+QKLP7eKKDqo20+/w36K6M RpQw== X-Gm-Message-State: APjAAAW0cQfJjJYBM4v2AGQ2MhuTa79dflDNtpjNPglzRhEdmJvncB1u EQMdDLxd8oyP9W2a+vCl6umxbW+I X-Google-Smtp-Source: APXvYqzfErGiBzi/PiL9uCsQjDzUB+k2U80Irh7x4LAFoSgST9MjZziT+htATg9tPkiKoaxdbtBCHg== X-Received: by 2002:adf:e404:: with SMTP id g4mr39160723wrm.161.1559056651907; Tue, 28 May 2019 08:17:31 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id z65sm5017010wme.37.2019.05.28.08.17.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 08:17:31 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: zhangyi , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v3 1/4] fstests: define constants for fsck exit codes Date: Tue, 28 May 2019 18:17:20 +0300 Message-Id: <20190528151723.12525-2-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528151723.12525-1-amir73il@gmail.com> References: <20190528151723.12525-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Define the constants for hard coded values used in _repair_scratch_fs() to check fsck exit code. Suggested-by: zhangyi (F) Signed-off-by: Amir Goldstein Reviewed-by: zhangyi (F) --- common/config | 11 +++++++++++ common/rc | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/common/config b/common/config index 364432bb..bd64be62 100644 --- a/common/config +++ b/common/config @@ -69,6 +69,17 @@ export OVL_WORK="ovl-work" # overlay mount point parent must be the base fs root export OVL_MNT="ovl-mnt" +# From e2fsprogs/e2fsck/e2fsck.h: +# Exit code used by fsck-type programs +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 + export PWD=`pwd` #export DEBUG=${DEBUG:=...} # arbitrary CFLAGS really. export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a} diff --git a/common/rc b/common/rc index e78e0920..cedc1cfa 100644 --- a/common/rc +++ b/common/rc @@ -1116,7 +1116,7 @@ _repair_scratch_fs() fsck -t $FSTYP -y $SCRATCH_DEV 2>&1 local res=$? case $res in - 0|1|2) + $FSCK_OK|$FSCK_NONDESTRUCT|$FSCK_REBOOT) res=0 ;; *) From patchwork Tue May 28 15:17:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10965213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E01F15E6 for ; Tue, 28 May 2019 15:17:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DDD1284B3 for ; Tue, 28 May 2019 15:17:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 118EF28305; Tue, 28 May 2019 15:17:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 820B928606 for ; Tue, 28 May 2019 15:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727829AbfE1PRg (ORCPT ); Tue, 28 May 2019 11:17:36 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:53040 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbfE1PRf (ORCPT ); Tue, 28 May 2019 11:17:35 -0400 Received: by mail-wm1-f67.google.com with SMTP id y3so3397723wmm.2; Tue, 28 May 2019 08:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AgFYfL9iguIZiE1nP0hatiHAbHNWsO2s/qiB0KNMhuc=; b=nrkdSd/dMUa6S5Yc4AZaFY92y+WN8Ncz5ctWVlk2PRw+wBcYL8NFqgX5zFfk3jsNNN 89IzxqWgPGQyIziLE+cU1FvGZ+ghyzMA1Dv680I+j+K29RBTZ8R5j5UhrNIdIhXcYMnF uyfBT2o2Y+oI48MDIxMfBe+Jby/R8F0CDZNdULBnq/AfUNA+M80GasJo75yvGRPPUHRZ hxNBNLliSoaIWV/sq7AvA776xy6nY3rp7VZMUk9mt/XlLtU8x0+agRzlw6VJw3lm6u1J VOd3xLUm4on95FEECPE9QUd4OVo/rM2Tsh0SnGS0EZ1qWOqBGS3IXo63JM0CU/KEcFus cHFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AgFYfL9iguIZiE1nP0hatiHAbHNWsO2s/qiB0KNMhuc=; b=SmN5yrdF9rXySbD6CPkSf6NuNFKuAJpWfcwiPMQfh36mX41IQckJT//dmG654FWwcy YttvcbTeQWpneQQbqcbEl6/9tFHN3rEShJkhLrh2yiIC2AhVjAqrCH4TFDpY2rbRfHtE nmxnxvng802qizMmGS+bbpSx6ury2EpwtmDMsTV5sksSNGNpl2TNzmA4987AtcU7P7YN GYNy8lI+fXnnsjcKhm/8231hPQZPWmL3E6r/NeZX2wFE62QdXQqT+uH5orXO2LZI+hzu c9Sc+e3azzEumxu0hV6hQaAIvcHLEXXfSJcHPpXfXr6aySNXWU1meDpNpznenclPO2Fv WXnw== X-Gm-Message-State: APjAAAWSF8D0zRWm7VfJc4iLCGymJJt5AUb1y1XzqgKul/97YRj9KYat WnF6Hnbmm/78sBaDsjnvl/o= X-Google-Smtp-Source: APXvYqyluOCHPetznwr36Ep4Eu0VYZXoZ/iPcvEXCI+0o9t/cIbUam3JlkA5TanaAqwU3PghhPC4PA== X-Received: by 2002:a1c:d182:: with SMTP id i124mr3658637wmg.102.1559056653441; Tue, 28 May 2019 08:17:33 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id z65sm5017010wme.37.2019.05.28.08.17.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 08:17:32 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: zhangyi , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v3 2/4] overlay: fix _repair_scratch_fs Date: Tue, 28 May 2019 18:17:21 +0300 Message-Id: <20190528151723.12525-3-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528151723.12525-1-amir73il@gmail.com> References: <20190528151723.12525-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP _repair_scratch_fs did not do the right thing for overlay. Implement and call _repair_overlay_scratch_fs to repair overlay filesystem and then fall through to repair base filesystem. The only tests currentrly calling _repair_scratch_fs on a ./check -overlay run are generic/330 generic/332 in case the base fs supports reflink. The rest of the tests calling _repair_scratch_fs require that $SCRATCH_DEV is a block device. Suggested-by: zhangyi (F) Signed-off-by: Amir Goldstein Reviewed-by: zhangyi (F) --- common/overlay | 17 +++++++++++++++++ common/rc | 13 +++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/common/overlay b/common/overlay index b526f24d..a71c2035 100644 --- a/common/overlay +++ b/common/overlay @@ -320,3 +320,20 @@ _check_overlay_scratch_fs() "$OVL_BASE_SCRATCH_DEV" "$OVL_BASE_SCRATCH_MNT" \ $OVL_BASE_MOUNT_OPTIONS $SELINUX_MOUNT_OPTIONS } + +_repair_overlay_scratch_fs() +{ + _overlay_fsck_dirs $OVL_BASE_SCRATCH_MNT/$OVL_LOWER \ + $OVL_BASE_SCRATCH_MNT/$OVL_UPPER \ + $OVL_BASE_SCRATCH_MNT/$OVL_WORK -y + local res=$? + case $res in + $FSCK_OK|$FSCK_NONDESTRUCT) + res=0 + ;; + *) + _dump_err2 "fsck.overlay failed, err=$res" + ;; + esac + return $res +} diff --git a/common/rc b/common/rc index cedc1cfa..d0aa36a0 100644 --- a/common/rc +++ b/common/rc @@ -1112,8 +1112,17 @@ _repair_scratch_fs() return $res ;; *) - # Let's hope fsck -y suffices... - fsck -t $FSTYP -y $SCRATCH_DEV 2>&1 + local dev=$SCRATCH_DEV + local fstyp=$FSTYP + if [ $FSTYP = "overlay" -a -n "$OVL_BASE_SCRATCH_DEV" ]; then + _repair_overlay_scratch_fs + # Fall through to repair base fs + dev=$OVL_BASE_SCRATCH_DEV + fstyp=$OVL_BASE_FSTYP + $UMOUNT_PROG $OVL_BASE_SCRATCH_MNT + fi + # Let's hope fsck -y suffices... + fsck -t $fstyp -y $dev 2>&1 local res=$? case $res in $FSCK_OK|$FSCK_NONDESTRUCT|$FSCK_REBOOT) From patchwork Tue May 28 15:17:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10965217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B340F92A for ; Tue, 28 May 2019 15:17:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2FD1284B3 for ; Tue, 28 May 2019 15:17:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9745428305; Tue, 28 May 2019 15:17:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD2C228610 for ; Tue, 28 May 2019 15:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727842AbfE1PRj (ORCPT ); Tue, 28 May 2019 11:17:39 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36935 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfE1PRj (ORCPT ); Tue, 28 May 2019 11:17:39 -0400 Received: by mail-wm1-f67.google.com with SMTP id 7so3312767wmo.2; Tue, 28 May 2019 08:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NZDmQWSWY+QNvcHKSmDZzQOfUj5wyT2MFLcttqkfnI4=; b=kStFgdg7fcNh6K1K3o48KaDCjHGD+SEV05lNCztag9Zs9POMWvrwQ1gLlE6PhNT6ow UcG5Ue3SnYtiThuvQ1wJTCjS8RJnitUFTc1++aeo0rY47bn1oMguLqeZpc6tnxwGooxQ j7ObC6nJS2cwqcdTGEvVQjyjS4zun912NiaE+QCb1I1dwaA62WYcJcR2Gt7EpglPOGBs s5/Hm8jLsxOUC4Z8zDojHWMx9TXqgXQyAf9OhYeFVLNtdMehQhZqw1W6q17eYvF9Ckpc ZVRlAGYGH8MEdl61sy51DeZjHbOhwf7PcrRwB+qhAZP2qtV7hh+8TJ4pMNyYs20oZMAo b2og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NZDmQWSWY+QNvcHKSmDZzQOfUj5wyT2MFLcttqkfnI4=; b=pUiPHor4v6B+i+fmHjBLaraoQeOOSnMaTG9gJjfVPNzoG6EDdnyvXKUcoybEDJHUAi 79SR74531XtWfRY3hmdkB+gwrPJcZ0zy1aBqaGiUdirzvNkZrr5RrVrboe+7+Jl76Fos jHfFQ/keSEizgcAWfAoN+xUcA3hq3uszzYWgD0hkQVixwlF53yF6iozsrTgGh8vDUWGn HHSTG/ieGgRS7EcCONWuzsVGl+ZLCOlJ3d+3+hBpX9mmpgdyZw1aO4w16gFlYPhVhX50 tIUWZBz61Sm+kcFswtoZvzdGe/ULSwsfuXNqsz+NQhZCDeowZLrBsbyyTyLxIbWLI2mH JC6g== X-Gm-Message-State: APjAAAXLgfSNzjJ7U+0IdS8oFOKQyZIAlnrN78X/HdjfBh1qLrJzFNM/ 4+jaoAWgVS0T//Az8mvkDcQ= X-Google-Smtp-Source: APXvYqwfq6T28wCX61EylVszSoNQfy6detawklstr1rYEKHsI7rY3sRWbTKD/ZVHTvEoRFDWNcshvQ== X-Received: by 2002:a05:600c:23ce:: with SMTP id p14mr3397005wmb.36.1559056654929; Tue, 28 May 2019 08:17:34 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id z65sm5017010wme.37.2019.05.28.08.17.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 08:17:34 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: zhangyi , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v3 3/4] overlay: correct fsck.overlay exit code Date: Tue, 28 May 2019 18:17:22 +0300 Message-Id: <20190528151723.12525-4-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528151723.12525-1-amir73il@gmail.com> References: <20190528151723.12525-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "zhangyi (F)" 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. [amir] rename helper to _overlay_fsck_expect, split define of FSCK_* to a seprate path. Signed-off-by: zhangyi (F) Signed-off-by: Amir Goldstein Reviewed-by: zhangyi (F) --- common/overlay | 19 +++++++++++++++++++ tests/overlay/045 | 27 +++++++++------------------ tests/overlay/046 | 36 ++++++++++++------------------------ tests/overlay/056 | 9 +++------ 4 files changed, 43 insertions(+), 48 deletions(-) diff --git a/common/overlay b/common/overlay index a71c2035..53e35caf 100644 --- a/common/overlay +++ b/common/overlay @@ -193,6 +193,25 @@ _overlay_fsck_dirs() -o workdir=$workdir $* } +# Run fsck and check for expected return value +_overlay_fsck_expect() +{ + # 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" +} + _overlay_check_dirs() { local lowerdir=$1 diff --git a/tests/overlay/045 b/tests/overlay/045 index acc70871..6b5e8ae4 100755 --- a/tests/overlay/045 +++ b/tests/overlay/045 @@ -96,8 +96,7 @@ echo "+ Orphan whiteout" make_test_dirs make_whiteout $lowerdir/foo $upperdir/{foo,bar} -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p ls $lowerdir ls $upperdir @@ -107,8 +106,7 @@ make_test_dirs touch $lowerdir2/{foo,bar} make_whiteout $upperdir/foo $lowerdir/bar -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK "$lowerdir:$lowerdir2" $upperdir $workdir -p check_whiteout $upperdir/foo $lowerdir/bar # Test orphan whiteout in opaque directory, should remove @@ -119,8 +117,7 @@ touch $lowerdir/testdir/foo make_opaque_dir $upperdir/testdir make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p ls $upperdir/testdir # Test orphan whiteout whose parent path is not an merged directory, @@ -135,8 +132,7 @@ make_whiteout $lowerdir/testdir2 make_opaque_dir $lowerdir/testdir3 make_whiteout $upperdir/{testdir1/foo,/testdir2/foo,testdir3/foo,testdir4/foo} -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 || echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT "$lowerdir:$lowerdir2" $upperdir $workdir -p ls $upperdir/testdir1 ls $upperdir/testdir2 ls $upperdir/testdir3 @@ -150,8 +146,7 @@ touch $lowerdir/testdir/foo make_redirect_dir $upperdir/testdir "origin" make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p ls $upperdir/testdir # Test valid whiteout in redirect directory cover file in lower @@ -163,8 +158,7 @@ touch $lowerdir/origin/foo make_redirect_dir $upperdir/testdir "origin" make_whiteout $upperdir/testdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_whiteout $upperdir/testdir/foo # Test valid whiteout covering lower target whose parent directory @@ -177,8 +171,7 @@ make_redirect_dir $lowerdir/testdir "origin" mkdir -p $upperdir/testdir/subdir make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p \ - >> $seqres.full 2>&1 || echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK "$lowerdir:$lowerdir2" $upperdir $workdir -p check_whiteout $upperdir/testdir/subdir/foo # Test invalid whiteout in opaque subdirectory in a redirect directory, @@ -191,8 +184,7 @@ make_redirect_dir $upperdir/testdir "origin" make_opaque_dir $upperdir/testdir/subdir make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p ls $upperdir/testdir/subdir # Test valid whiteout in reidrect subdirectory in a opaque directory @@ -205,8 +197,7 @@ make_opaque_dir $upperdir/testdir make_redirect_dir $upperdir/testdir/subdir "/origin" make_whiteout $upperdir/testdir/subdir/foo -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_whiteout $upperdir/testdir/subdir/foo # success, all done diff --git a/tests/overlay/046 b/tests/overlay/046 index 6338a383..4a9ee68f 100755 --- a/tests/overlay/046 +++ b/tests/overlay/046 @@ -121,8 +121,7 @@ echo "+ Invalid redirect" make_test_dirs make_redirect_dir $upperdir/testdir "invalid" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_no_redirect $upperdir/testdir # Test invalid redirect xattr point to a file origin, should remove @@ -131,8 +130,7 @@ make_test_dirs touch $lowerdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_no_redirect $upperdir/testdir # Test valid redirect xattr point to a directory origin in the same directory, @@ -143,8 +141,7 @@ mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir "origin" # Test valid redirect xattr point to a directory origin in different directories @@ -155,8 +152,7 @@ mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir1/testdir2 "/origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir1/testdir2 "/origin" # Test valid redirect xattr but missing whiteout to cover lower target, @@ -166,8 +162,7 @@ make_test_dirs mkdir $lowerdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir "origin" check_whiteout $upperdir/origin @@ -178,8 +173,7 @@ mkdir $lowerdir/{testdir1,testdir2} make_redirect_dir $upperdir/testdir1 "testdir2" make_redirect_dir $upperdir/testdir2 "testdir1" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir1 "testdir2" check_redirect $upperdir/testdir2 "testdir1" @@ -191,8 +185,7 @@ mkdir $lowerdir/testdir make_redirect_dir $upperdir/testdir "invalid" # Question get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -y check_no_redirect $upperdir/testdir check_opaque $upperdir/testdir @@ -205,12 +198,10 @@ make_redirect_dir $lowerdir/testdir1 "origin" make_redirect_dir $lowerdir/testdir2 "origin" make_redirect_dir $upperdir/testdir3 "origin" -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -p >> \ - $seqres.full 2>&1 && echo "fsck should fail" +_overlay_fsck_expect $FSCK_UNCORRECTED "$lowerdir:$lowerdir2" $upperdir $workdir -p # Question get yes answer: Duplicate redirect directory, remove xattr ? -_overlay_fsck_dirs "$lowerdir:$lowerdir2" $upperdir $workdir -y >> \ - $seqres.full 2>&1 || echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT "$lowerdir:$lowerdir2" $upperdir $workdir -y redirect_1=`check_redirect $lowerdir/testdir1 "origin" 2>/dev/null` redirect_2=`check_redirect $lowerdir/testdir2 "origin" 2>/dev/null` [[ $redirect_1 == $redirect_2 ]] && echo "Redirect xattr incorrect" @@ -223,12 +214,10 @@ make_test_dirs mkdir $lowerdir/origin $upperdir/origin make_redirect_dir $upperdir/testdir "origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 && \ - echo "fsck should fail" +_overlay_fsck_expect $FSCK_UNCORRECTED $lowerdir $upperdir $workdir -p # Question get yes answer: Duplicate redirect directory, remove xattr ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -y check_no_redirect $upperdir/testdir # Test duplicate redirect xattr with lower same name directory exists, @@ -240,8 +229,7 @@ make_redirect_dir $upperdir/testdir "invalid" # Question one get yes answer: Duplicate redirect directory, remove xattr? # Question two get yes answer: Should set opaque dir ? -_overlay_fsck_dirs $lowerdir $upperdir $workdir -y >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -y check_no_redirect $upperdir/testdir check_opaque $upperdir/testdir diff --git a/tests/overlay/056 b/tests/overlay/056 index 44ffb54a..dc7b98cb 100755 --- a/tests/overlay/056 +++ b/tests/overlay/056 @@ -96,8 +96,7 @@ $UMOUNT_PROG $SCRATCH_MNT remove_impure $upperdir/testdir1 remove_impure $upperdir/testdir2 -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_impure $upperdir/testdir1 check_impure $upperdir/testdir2 @@ -108,8 +107,7 @@ make_test_dirs mkdir $lowerdir/origin make_redirect_dir $upperdir/testdir/subdir "/origin" -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_impure $upperdir/testdir # Test missing impure xattr in directory which has merge directories, @@ -118,8 +116,7 @@ echo "+ Missing impure(3)" make_test_dirs mkdir $lowerdir/testdir $upperdir/testdir -_overlay_fsck_dirs $lowerdir $upperdir $workdir -p >> $seqres.full 2>&1 || \ - echo "fsck should not fail" +_overlay_fsck_expect $FSCK_NONDESTRUCT $lowerdir $upperdir $workdir -p check_impure $upperdir # success, all done From patchwork Tue May 28 15:17:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10965215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9B6915E6 for ; Tue, 28 May 2019 15:17:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAB2C28606 for ; Tue, 28 May 2019 15:17:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BEFBA28714; Tue, 28 May 2019 15:17:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50AD5284F9 for ; Tue, 28 May 2019 15:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbfE1PRj (ORCPT ); Tue, 28 May 2019 11:17:39 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:44875 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbfE1PRi (ORCPT ); Tue, 28 May 2019 11:17:38 -0400 Received: by mail-wr1-f67.google.com with SMTP id w13so12306696wru.11; Tue, 28 May 2019 08:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4Lg0K0q8VReszXMeOvyTdpLQyUXLxJAiBvY9d4NKRqQ=; b=pxqRKt7YOONRzl8/jtjQiWihKpEd2TpjXgtXBfLkXppF/fTdpl/0rpNeeZSaGj/zO5 ekPbGmIeLR1HD2oNFDp13oLaih+dJ73NUN8faXhr2EwSMOsqR8YFCjDflcY/L1vpw0nO V9BDA01DlTmud1o9Zgkr1FblQlzyTfPl/oDbYw0dUL4pKDrnuZx14O947A9mg+554zY3 RkiqOaPFZ4jieU07TamFnOXE8ENhEuNyYpwL399e3xWfkY+NuDSABNDFtirlT23ZMmAp akW1f6TE1fJukXEEUNqSnQcoHX2vZ/l4q8Q7jkH7HZK4lcVeoZELj/Cdsce+oVEKgr0k T4pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4Lg0K0q8VReszXMeOvyTdpLQyUXLxJAiBvY9d4NKRqQ=; b=JhvquEFwjnx1fYFe8A2Sfd1YZ8kFjB8rmNbEfpHJCfR1OmHAgW3JyIAiv+E/OM/XzQ 9oNUMYl4ORuAueswkJuqYiAeA6z/3msW7PTJFyiZ8V+fTgDXviGsH4Jh2Yrnp+62t/F6 EgWiRHtCyxD/xErk4tqHlLNFKPSGZFklfq5F5uYIOG8v3J8I0gZue13OldkgiqkDiFhi BZXq/06gUI/ldr3teMHuf2Aw9QTZJAz+QvQkgF9ej3ZM5USp0IJ2HfeGIO9LnRU/SkvL YstHcvYkRy/E0+8xv6thbiHw83fMAYrGnjb/RjBe1CsXMpp+Bbfg0G4vfXtloh1SmUu/ fBbw== X-Gm-Message-State: APjAAAWJeoT+WEwa2mF72wjzw1R/wIXp3IV3IDCUqsNjvqy66fxGm1iD oT6w2T5akXKvGaqt8BG3oAj16lYD X-Google-Smtp-Source: APXvYqwzRLG91zNR5ThmrPSX2M4AzfrpQB2OMwzlkbahiGrfL9r5Jre6/NImMBVfZPPtE8dPIR46GA== X-Received: by 2002:adf:f292:: with SMTP id k18mr52692440wro.321.1559056656524; Tue, 28 May 2019 08:17:36 -0700 (PDT) Received: from amir-ThinkPad-T480.ctera.local (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id z65sm5017010wme.37.2019.05.28.08.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 May 2019 08:17:35 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: zhangyi , Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH v3 4/4] overlay: fix exit code for some fsck.overlay valid cases Date: Tue, 28 May 2019 18:17:23 +0300 Message-Id: <20190528151723.12525-5-amir73il@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190528151723.12525-1-amir73il@gmail.com> References: <20190528151723.12525-1-amir73il@gmail.com> Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "zhangyi (F)" Some valid test cases about fsck.overlay may be not valid enough now, they lose the impure xattr on the parent directory of the simluated redirect directory, and lose the whiteout which use to cover the origin lower object. Then fsck.overlay will fix these two inconsistency which are not those test cases want to cover, thus it will lead to fsck.overlay return FSCK_NONDESTRUCT instead of FSCK_OK. Fix these by complement the missing overlay related features. Signed-off-by: zhangyi (F) --- tests/overlay/045 | 19 ++++++++++++++++--- tests/overlay/046 | 13 +++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tests/overlay/045 b/tests/overlay/045 index 6b5e8ae4..34b7ce4c 100755 --- a/tests/overlay/045 +++ b/tests/overlay/045 @@ -37,6 +37,7 @@ _require_attrs _require_command "$FSCK_OVERLAY_PROG" fsck.overlay OVL_XATTR_OPAQUE_VAL=y +OVL_XATTR_IMPURE_VAL=y # remove all files from previous tests _scratch_mkfs @@ -69,6 +70,15 @@ make_opaque_dir() $SETFATTR_PROG -n $OVL_XATTR_OPAQUE -v $OVL_XATTR_OPAQUE_VAL $target } +# Create impure directories +make_impure_dir() +{ + for dir in $*; do + mkdir -p $dir + $SETFATTR_PROG -n $OVL_XATTR_IMPURE -v $OVL_XATTR_IMPURE_VAL $dir + done +} + # Create a redirect directory make_redirect_dir() { @@ -155,8 +165,9 @@ echo "+ Valid whiteout(2)" make_test_dirs mkdir $lowerdir/origin touch $lowerdir/origin/foo +make_impure_dir $upperdir make_redirect_dir $upperdir/testdir "origin" -make_whiteout $upperdir/testdir/foo +make_whiteout $upperdir/origin $upperdir/testdir/foo _overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_whiteout $upperdir/testdir/foo @@ -169,7 +180,8 @@ mkdir -p $lowerdir2/origin/subdir touch $lowerdir2/origin/subdir/foo make_redirect_dir $lowerdir/testdir "origin" mkdir -p $upperdir/testdir/subdir -make_whiteout $upperdir/testdir/subdir/foo +make_whiteout $lowerdir/origin $upperdir/testdir/subdir/foo +make_impure_dir $upperdir/testdir $upperdir _overlay_fsck_expect $FSCK_OK "$lowerdir:$lowerdir2" $upperdir $workdir -p check_whiteout $upperdir/testdir/subdir/foo @@ -195,7 +207,8 @@ mkdir $lowerdir/origin touch $lowerdir/origin/foo make_opaque_dir $upperdir/testdir make_redirect_dir $upperdir/testdir/subdir "/origin" -make_whiteout $upperdir/testdir/subdir/foo +make_whiteout $upperdir/origin $upperdir/testdir/subdir/foo +make_impure_dir $upperdir/testdir _overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_whiteout $upperdir/testdir/subdir/foo diff --git a/tests/overlay/046 b/tests/overlay/046 index 4a9ee68f..36c74207 100755 --- a/tests/overlay/046 +++ b/tests/overlay/046 @@ -40,6 +40,16 @@ _require_command "$FSCK_OVERLAY_PROG" fsck.overlay _scratch_mkfs OVL_XATTR_OPAQUE_VAL=y +OVL_XATTR_IMPURE_VAL=y + +# Create impure directories +make_impure_dir() +{ + for dir in $*; do + mkdir -p $dir + $SETFATTR_PROG -n $OVL_XATTR_IMPURE -v $OVL_XATTR_IMPURE_VAL $dir + done +} # Create a redirect directory make_redirect_dir() @@ -140,6 +150,7 @@ make_test_dirs mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir "origin" +make_impure_dir $upperdir _overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir "origin" @@ -151,6 +162,7 @@ make_test_dirs mkdir $lowerdir/origin make_whiteout $upperdir/origin make_redirect_dir $upperdir/testdir1/testdir2 "/origin" +make_impure_dir $upperdir/testdir1 _overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir1/testdir2 "/origin" @@ -172,6 +184,7 @@ make_test_dirs mkdir $lowerdir/{testdir1,testdir2} make_redirect_dir $upperdir/testdir1 "testdir2" make_redirect_dir $upperdir/testdir2 "testdir1" +make_impure_dir $upperdir _overlay_fsck_expect $FSCK_OK $lowerdir $upperdir $workdir -p check_redirect $upperdir/testdir1 "testdir2"