From patchwork Wed Jul 12 09:43:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9836391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 336CE602BD for ; Wed, 12 Jul 2017 09:43:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2510228500 for ; Wed, 12 Jul 2017 09:43:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 187EF285ED; Wed, 12 Jul 2017 09:43:17 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 E30F928500 for ; Wed, 12 Jul 2017 09:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755686AbdGLJnP (ORCPT ); Wed, 12 Jul 2017 05:43:15 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34523 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbdGLJnO (ORCPT ); Wed, 12 Jul 2017 05:43:14 -0400 Received: by mail-wr0-f196.google.com with SMTP id k67so4469809wrc.1; Wed, 12 Jul 2017 02:43:13 -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=jmihnNx9a8ngnjGpBVnL5oRbTRd5IDasvbCKgd/5Jpo=; b=YpmnkcMKTBd2KYi+EjOtEsHx6LyLv98Ks4lCqQU1BtJS53VmXiQtX9U1LdfqGEaUUt 8fQd1hq4IrJwsqeBH8AeOBMRA1ADkEyao9mYNta1Rzyc+itNA0nFPgDOOVfe6UMCIsYw bmjxOYPmSrPfaUg9KlbHrXgtJ+cOucWPaLwu38bSK2y7ynKeHqu5wIrxtHXr66DsJwwa v17BGny6NuGAtysec23h+sGPBnrKnbHTEHUDnISw2m9Ys/YtPpO+Zmi8Ru179zqvatVT kJBJDfbCKZT0rG4081SnfQ/XWgf99Ow+GmHwZlIH18vImlfnkNr7W8CHZGi4gebUR0jC HJ8g== 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=jmihnNx9a8ngnjGpBVnL5oRbTRd5IDasvbCKgd/5Jpo=; b=iikA1DhQi0uwJRdkhljRrhJ9g54G9+gaZeLqBl7eAnIqFGgtSGks8PLbppxMhD2GsH cP66Seb188y/aJgtNw2MBdGhFt5pZC2ciY1s97d/cEOd3Xoeg8amSpzdVQTUq7EpdLoo yfsZe8h5sVy5b7QPUBUTlSObiVtIPCjlecQssRK7HBfHeOetl9eAQ4j9ar+8vbAEsSsJ 6vUN3UhF96JYCbl6v0gpuIyz1ahAmSNmDGaLt1m224L6EisBE8lys53fdGJSXtBMQHNx jlADxVm6HTZg4zdBfKGJsOXZXyp5hUk7RfbPyOxIOe/Fzbp11fS3jUEaVF1ftktiwbew 9sNA== X-Gm-Message-State: AIVw112dhkezxiQENqXHut0FLJHN6LHequX7uJn1/qJwFDshDXSEpizJ LeQySzrdbobOvw== X-Received: by 10.223.134.207 with SMTP id 15mr2514124wry.127.1499852592785; Wed, 12 Jul 2017 02:43:12 -0700 (PDT) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id i185sm1856256wmf.34.2017.07.12.02.43.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Jul 2017 02:43:12 -0700 (PDT) From: Amir Goldstein To: Eryu Guan Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, fstests@vger.kernel.org Subject: [PATCH 1/2] fstest: add helper _require_fs_feature Date: Wed, 12 Jul 2017 12:43:24 +0300 Message-Id: <1499852605-27759-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1499852605-27759-1-git-send-email-amir73il@gmail.com> References: <1499852605-27759-1-git-send-email-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 The helper is used to test if a specific filesystem feature can be enabled. Currently only implemented testing overlayfs features. Overalyfs features (e.g. redirect_dir, index) are configurable from Kconfig (the build default), by module parameter (the system default) and per mount using the mount option ${feature}=[on|off]. The helper is going to be used by overlay tests, which depend on the inodes index feature. Signed-off-by: Amir Goldstein --- common/rc | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/common/rc b/common/rc index b505365..260b48d 100644 --- a/common/rc +++ b/common/rc @@ -3626,6 +3626,54 @@ _get_fs_sysfs_attr() cat /sys/fs/${FSTYP}/${dname}/${attr} } +# Print the value of a filesystem module parameter +# at /sys/module/$FSTYP/parameters/$PARAM +# +# Usage example (FSTYP=overlay): +# _get_fs_module_param index +_get_fs_module_param() +{ + cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null +} + +# Generic test for specific filesystem feature. +# Currently only implemented to test overlayfs features. +_require_fs_feature() +{ + local feature=$1 + + case "$FSTYP" in + overlay) + # overalyfs features (e.g. redirect_dir, index) are + # configurable from Kconfig (the build default), by module + # parameter (the system default) and per mount by mount + # option ${feature}=[on|off]. + # + # If the module parameter does not exist then there is no + # point in checking the mount option. + local default=`_get_fs_module_param ${feature}` + [ "$default" = Y ] || [ "$default" = N ] || \ + _notrun "feature '${feature}' not supported by ${FSTYP}" + + _scratch_mkfs > /dev/null 2>&1 + _scratch_mount -o ${feature}=on || \ + _notrun "${FSTYP} feature '${feature}' cannot be enabled on ${SCRATCH_DEV}" + # Check options to be sure. For example, Overlayfs will fallback to + # index=off if underlying fs does not support file handles. + # Overlayfs only displays mount option if it differs from the default. + # Overlayfs may enable the feature, but fallback to read-only mount. + ((( [ "$default" = N ] && _fs_options $SCRATCH_DEV | grep -q "${feature}=on" ) || \ + ( [ "$default" = Y ] && ! _fs_options $SCRATCH_DEV | grep -q "${feature}=off" )) && \ + touch $SCRATCH_MNT/foo 2>/dev/null ) || \ + _notrun "${FSTYP} feature '${feature}' cannot be enabled on ${SCRATCH_DEV}" + _scratch_unmount + ;; + *) + _fail "Test for feature '${feature}' of ${FSTYP} is not implemented" + ;; + esac +} + init_rc