From patchwork Tue Feb 12 02:17:39 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: 10807209 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 B19F31575 for ; Tue, 12 Feb 2019 02:17:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2DB82B2B9 for ; Tue, 12 Feb 2019 02:17:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 968A82B2BC; Tue, 12 Feb 2019 02:17:45 +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=unavailable 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 35B722B2BE for ; Tue, 12 Feb 2019 02:17:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727652AbfBLCRo (ORCPT ); Mon, 11 Feb 2019 21:17:44 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:49852 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727265AbfBLCRo (ORCPT ); Mon, 11 Feb 2019 21:17:44 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x1C2FrjV031266; Tue, 12 Feb 2019 02:17:42 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=aY+MXP1VHN+k7RsxormnKgrE+PCUOsv1aaL4KW0M7eI=; b=PunSEoATY+e2cB1mfttMGY777+A+2M+iHL182CIZiRcugangdhiJtldGOJwSPB7UCzTZ 3mnyrvV2PxBWZGk/X0aRQI4TPGlQd/akCj5777xklREslnXAXBeatdeG6KEpCX6yErj/ iT7xjTH9kFd9215xV54pNf7O3re9gZ2ZZccJ4IbwCjUEZAOdBReT5ZAhlp0JFCLywSlW 94guaM5hkfxo6uhSCbKgOvTuTiBXeeX38NMMFPxaIYkkDWCI0sL329llMw8+ylUmdGdD G1lmYMJCsOj6QC84ZcaJxp1bVutBjbHTXDTyAFMREd7mmvSABM0ZDv+Z3f7PDD5C9Khl FA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2qhredsaca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Feb 2019 02:17:42 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x1C2He2v004965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Feb 2019 02:17:41 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x1C2He4s012174; Tue, 12 Feb 2019 02:17:40 GMT Received: from localhost (/10.159.237.14) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Feb 2019 18:17:40 -0800 Subject: [PATCH 3/3] 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: Mon, 11 Feb 2019 18:17:39 -0800 Message-ID: <154993785921.1948.13721935036926653125.stgit@magnolia> In-Reply-To: <154993784038.1948.7502664832930298472.stgit@magnolia> References: <154993784038.1948.7502664832930298472.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9164 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902120014 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@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 | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/generic/709.out | 2 ++ tests/generic/group | 1 + 3 files changed, 56 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..ebec10de --- /dev/null +++ b/tests/generic/709 @@ -0,0 +1,53 @@ +#! /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_test +_require_xfs_io_command "statx" "-r" +_require_btime + +rm -f $seqres.full +rm -f $testfile + +# Create a file and the time we created it +now=$(date +%s) +touch $testfile + +# Make sure the reported btime is within 5 seconds of the time we recorded +# just prior to creating the file. +btime=$(date +%s -d "$($XFS_IO_PROG -c "statx -v -m $STATX_BTIME" $testfile | \ + grep 'stat.btime =' | cut -d '=' -f 2)") +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 cfd003d3..f56eb475 100644 --- a/tests/generic/group +++ b/tests/generic/group @@ -528,3 +528,4 @@ 523 auto quick attr 524 auto quick 525 auto quick rw +709 auto quick