From patchwork Tue Jan 29 16:17:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10786579 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 5A6A21390 for ; Tue, 29 Jan 2019 16:17:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 427A52D336 for ; Tue, 29 Jan 2019 16:17:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33EF92D4A2; Tue, 29 Jan 2019 16:17:38 +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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 C23872D336 for ; Tue, 29 Jan 2019 16:17:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbfA2QRh (ORCPT ); Tue, 29 Jan 2019 11:17:37 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:46778 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725846AbfA2QRh (ORCPT ); Tue, 29 Jan 2019 11:17:37 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0TGDoFJ187396; Tue, 29 Jan 2019 16:17:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=EEjjJ0p/g0TG6v4YhSlOWpV2IRvNlLd2dWwb/V6Z39o=; b=2bXt6gVpqKk7O3LedngD6GzFPAEyXNOmJaDJ1VO8vpdOZzOKRfJUTystvNY+HBem2UZ0 IXvI2T6sM5gmI6UUckjx3rWJ25bN9ZtpGRBRZHzcxmQb32rX/9mfCuN46vKLYgM0Xl6G F1J7qJUczvFsBO7K8jhPaORGuAD0t7j6c17EIPoGcyKzXkOwxPEhbAofxomRD/vrZreL +WfD3oWCVDZh+PwebFYowoXSCwbufUwISqjg6qa1Mgp7VYksdTOtJQ6iZDeah2lQBvH8 JR6WExV2UUi9NfuaK9dhqiVuFO21Cg2ifcLF5wMjQeKOpuKbfEWHwHsw6VK2MQTlJIz0 ww== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2q8d2e5m9w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Jan 2019 16:17:34 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0TGHXUJ022270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Jan 2019 16:17:33 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0TGHXDK017372; Tue, 29 Jan 2019 16:17:33 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Jan 2019 08:17:33 -0800 Subject: [PATCH 4/4] generic: check for reasonable inode creation time From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org Date: Tue, 29 Jan 2019 08:17:31 -0800 Message-ID: <154877865178.9277.5385935769005684086.stgit@magnolia> In-Reply-To: <154877863279.9277.4463697450629081138.stgit@magnolia> References: <154877863279.9277.4463697450629081138.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9150 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901290122 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong If statx returns inode creation time (aka btime), check it to make sure that the filesystem is setting a creation time that's reasonably close to when it creates a file. Signed-off-by: Darrick J. Wong --- tests/generic/709 | 61 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/709.out | 2 ++ tests/generic/group | 1 + 3 files changed, 64 insertions(+) create mode 100755 tests/generic/709 create mode 100644 tests/generic/709.out diff --git a/tests/generic/709 b/tests/generic/709 new file mode 100755 index 00000000..724a16a8 --- /dev/null +++ b/tests/generic/709 @@ -0,0 +1,61 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2019 Oracle, Inc. All Rights Reserved. +# +# FS QA Test No. 709 +# +# Check that statx btime (aka creation time) is plausibly close to when +# we created a file. A bug caught during code review of xfs patches revealed +# that there weren't any sanity checks of the btime values. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" +tmp=/tmp/$$ +status=1 # failure is the default! +testfile=$TEST_DIR/$seq.txt +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* $testfile +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/attr +. ./common/filter + +# real QA test starts here +_supported_fs generic +_supported_os Linux +_require_xfs_io_command "statx" "-r" + +rm -f $seqres.full +rm -f $testfile + +# Create a file and the time we created it +now=$(date +%s) +touch $testfile + +# Does statx return results with the BTIME flag set in the result mask? +STATX_BTIME=0x800 +$XFS_IO_PROG -c "statx -F -r -m $STATX_BTIME" $testfile > $tmp.statx +cat $tmp.statx >> $seqres.full + +result_mask=$(grep 'stat.mask =' $tmp.statx | cut -d ' ' -f 3) +test -n "$result_mask" || _notrun "did not see stat.mask in output" + +test "$(( result_mask & STATX_BTIME ))" -ne 0 || \ + _notrun "statx did not return btime" + +# Make sure the reported btime is within 5 seconds of the time we recorded +# just prior to creating the file. +btime=$(grep 'stat.btime.tv_sec =' $tmp.statx | cut -d ' ' -f 3) +test -n "$btime" || echo "error: did not see btime in output??" + +_within_tolerance "btime" "$btime" "$now" 0 5 -v + +status=0 +exit diff --git a/tests/generic/709.out b/tests/generic/709.out new file mode 100644 index 00000000..d8495ace --- /dev/null +++ b/tests/generic/709.out @@ -0,0 +1,2 @@ +QA output created by 709 +btime is in range diff --git a/tests/generic/group b/tests/generic/group index 6f5f28d8..9ce608c0 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -527,3 +527,4 @@ 522 soak long_rw 523 auto quick attr 524 auto quick +709 auto quick