From patchwork Tue Sep 8 13:15:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 11763431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5319746 for ; Tue, 8 Sep 2020 14:54:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6636224D2 for ; Tue, 8 Sep 2020 14:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730104AbgIHOyH (ORCPT ); Tue, 8 Sep 2020 10:54:07 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:47426 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728975AbgIHOYw (ORCPT ); Tue, 8 Sep 2020 10:24:52 -0400 X-IronPort-AV: E=Sophos;i="5.76,405,1592841600"; d="scan'208";a="99008939" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2020 21:23:42 +0800 Received: from G08CNEXMBPEKD04.g08.fujitsu.local (unknown [10.167.33.201]) by cn.fujitsu.com (Postfix) with ESMTP id 6A72D48990E5; Tue, 8 Sep 2020 21:23:41 +0800 (CST) Received: from G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.203) by G08CNEXMBPEKD04.g08.fujitsu.local (10.167.33.201) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 21:23:40 +0800 Received: from Fedora-30.g08.fujitsu.local (10.167.220.106) by G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 21:23:35 +0800 From: Xiao Yang To: CC: , , , , Xiao Yang Subject: [PATCH 1/2] common/rc: Check 'tPnE' flags on a directory instead of a regilar file Date: Tue, 8 Sep 2020 21:15:22 +0800 Message-ID: <20200908131523.20899-1-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-yoursite-MailScanner-ID: 6A72D48990E5.AA09C X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org 'tPnE' flags are only valid for a directory so check them on a directory. Signed-off-by: Xiao Yang --- common/rc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/rc b/common/rc index aa5a7409..cf31eebc 100644 --- a/common/rc +++ b/common/rc @@ -2168,8 +2168,14 @@ _require_xfs_io_command() fi # Test xfs_io chattr support AND # filesystem FS_IOC_FSSETXATTR support - testio=`$XFS_IO_PROG -F -f -c "chattr +$param" $testfile 2>&1` - $XFS_IO_PROG -F -f -r -c "chattr -$param" $testfile 2>&1 + # 'tPnE' flags are only valid for a directory so check them on a directory. + if echo "$param" | egrep -q 't|P|n|E'; then + testio=`$XFS_IO_PROG -F -c "chattr +$param" $TEST_DIR 2>&1` + $XFS_IO_PROG -F -r -c "chattr -$param" $TEST_DIR 2>&1 + else + testio=`$XFS_IO_PROG -F -f -c "chattr +$param" $testfile 2>&1` + $XFS_IO_PROG -F -r -c "chattr -$param" $testfile 2>&1 + fi param_checked="+$param" ;; "chproj") From patchwork Tue Sep 8 13:15:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 11763427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E535138E for ; Tue, 8 Sep 2020 14:50:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EE6D20732 for ; Tue, 8 Sep 2020 14:50:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728957AbgIHOqA (ORCPT ); Tue, 8 Sep 2020 10:46:00 -0400 Received: from mail.cn.fujitsu.com ([183.91.158.132]:2468 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729785AbgIHO0J (ORCPT ); Tue, 8 Sep 2020 10:26:09 -0400 X-IronPort-AV: E=Sophos;i="5.76,405,1592841600"; d="scan'208";a="99008941" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Sep 2020 21:23:48 +0800 Received: from G08CNEXMBPEKD06.g08.fujitsu.local (unknown [10.167.33.206]) by cn.fujitsu.com (Postfix) with ESMTP id 3538948990E5; Tue, 8 Sep 2020 21:23:47 +0800 (CST) Received: from G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.203) by G08CNEXMBPEKD06.g08.fujitsu.local (10.167.33.206) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 21:23:46 +0800 Received: from Fedora-30.g08.fujitsu.local (10.167.220.106) by G08CNEXCHPEKD05.g08.fujitsu.local (10.167.33.209) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 21:23:42 +0800 From: Xiao Yang To: CC: , , , , Xiao Yang Subject: [PATCH 2/2] common/rc: Add extra check for xfs_io -c "chattr" on XFS Date: Tue, 8 Sep 2020 21:15:23 +0800 Message-ID: <20200908131523.20899-2-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200908131523.20899-1-yangx.jy@cn.fujitsu.com> References: <20200908131523.20899-1-yangx.jy@cn.fujitsu.com> MIME-Version: 1.0 X-yoursite-MailScanner-ID: 3538948990E5.A9CDD X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com X-Spam-Status: No Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org On XFS, ioctl(FSSETXATTR)(called by xfs_io -c "chattr") maskes off unsupported or invalid flags silently. For example, 1) With kernel v4.4 which doesn't support dax flag, try to set dax flag on a file by the lastest xfs_io -c "chattr" command: -------------------------------------------- # xfs_io -f -c "chattr +x" testfile;echo $? 0 # xfs_io -c "lsattr" testfile ----------------X testfile -------------------------------------------- 2) Realtime inheritance flag is only valid for a directory and try to set realtime inheritance flag on a file: -------------------------------------------- # xfs_io -f -c "chattr +t" testfile;echo $? 0 # xfs_io -c "lsattr" testfile ----------------X testfile -------------------------------------------- Signed-off-by: Xiao Yang --- common/rc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/common/rc b/common/rc index cf31eebc..e40f0a8a 100644 --- a/common/rc +++ b/common/rc @@ -2158,6 +2158,7 @@ _require_xfs_io_command() local param="$*" local param_checked="" local opts="" + local attr_info="" local testfile=$TEST_DIR/$$.xfs_io local testio @@ -2171,9 +2172,11 @@ _require_xfs_io_command() # 'tPnE' flags are only valid for a directory so check them on a directory. if echo "$param" | egrep -q 't|P|n|E'; then testio=`$XFS_IO_PROG -F -c "chattr +$param" $TEST_DIR 2>&1` + attr_info=`$XFS_IO_PROG -F -r -c "lsattr" $TEST_DIR | awk '{print $1}'` $XFS_IO_PROG -F -r -c "chattr -$param" $TEST_DIR 2>&1 else testio=`$XFS_IO_PROG -F -f -c "chattr +$param" $testfile 2>&1` + attr_info=`$XFS_IO_PROG -F -r -c "lsattr" $testfile | awk '{print $1}'` $XFS_IO_PROG -F -r -c "chattr -$param" $testfile 2>&1 fi param_checked="+$param" @@ -2297,6 +2300,19 @@ _require_xfs_io_command() echo $testio | grep -q "\(invalid option\|not supported\)" && \ _notrun "xfs_io $command doesn't support $param" fi + + # On XFS, ioctl(FSSETXATTR)(called by xfs_io -c "chattr") maskes off unsupported + # or invalid flags silently so need to check these flags by extra ioctl(FSGETXATTR) + # (called by xfs_io -c "lsattr"). + # The following URL explains why we don't change the behavior of XFS. + # https://www.spinics.net/lists/linux-xfs/msg44725.html + if [ -n "$attr_info" -a "$FSTYP" = "xfs" ]; then + local num=${#param} + for i in $(seq 0 $((num-1))); do + echo $attr_info | grep -q "${param:$i:1}" || \ + _notrun "xfs_io $command +${param:$i:1} support is missing (unknown flag in kernel)" + done + fi } # check that kernel and filesystem support direct I/O