From patchwork Mon Mar 4 21:19:29 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: 10838623 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 872C81869 for ; Mon, 4 Mar 2019 21:19:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 772802B2C5 for ; Mon, 4 Mar 2019 21:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B8522B3B5; Mon, 4 Mar 2019 21:19: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,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 117C82B2C5 for ; Mon, 4 Mar 2019 21:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726080AbfCDVTi (ORCPT ); Mon, 4 Mar 2019 16:19:38 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:37872 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfCDVTi (ORCPT ); Mon, 4 Mar 2019 16:19:38 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x24LJDiv015426; Mon, 4 Mar 2019 21:19:36 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=Znln34Pj3/uod10Pd37gaaPMUOeHbJ/ceh0wqD2W7hg=; b=40G2iT0+i/hTin5Ss0e47zkirLx/gDYofaSEyf6/OxPp1sYvzYUIzJ0o5tNHnpP5P0IN L3S41lLC5u+OCxnQklTjKvxFYqeUfSQwzK0y/9ME/cADooeYzFosjeOEygra+gFxazS7 qCegjAf2LRfGzk1HvSY5LDj5WxIhlAM2M5XEWsrFDA0ULOe9dEbxM7nRavPJ1YBFQJ56 0E10M/tZfnhF56X4x8NkkZZllb3SOc1xhnEItcq5+CcIh8a86zFRBSZGyfXiWVljADId /FLS0cIVr8/dN9y9D1lYL2vU4nWc4AxmJYQXhropFNCQ3UI/uCaxsuKZziRri6bY5Xuu Rg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2qyh8u1byf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 Mar 2019 21:19:36 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x24LJUYv008731 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Mar 2019 21:19:30 GMT Received: from abhmp0022.oracle.com (abhmp0022.oracle.com [141.146.116.28]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x24LJUMe005194; Mon, 4 Mar 2019 21:19:30 GMT Received: from localhost (/10.159.248.244) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 Mar 2019 13:19:30 -0800 Subject: [PATCH 3/5] shared/298: unmount filesystem before examining underlying storage From: "Darrick J. Wong" To: guaneryu@gmail.com, darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, enwlinux@gmail.com Date: Mon, 04 Mar 2019 13:19:29 -0800 Message-ID: <155173436903.767.2030031690929754940.stgit@magnolia> In-Reply-To: <155173434205.767.15128498725168844621.stgit@magnolia> References: <155173434205.767.15128498725168844621.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9185 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=839 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903040150 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 This test does some weird things with live filesystems -- it seems to be validating the behavior of fstrim by comparing the filesystem's free space map to holes in the file image that backs the filesystem. However, this doesn't account for the fact that some filesystems maintain in-core preallocations and/or can perturb the free space data during unmount. This causes sporadic test failures when the two become out of sync. Therefore, make sure we unmount the filesystem before we start running tools against the filesystem image file to eliminate the possibility of changes to the free space map. This was found by running shared/298 on xfs with a 1k block size. cc: enwlinux@gmail.com Signed-off-by: Darrick J. Wong --- tests/shared/298 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/shared/298 b/tests/shared/298 index aafdc25f..5d6c6ccf 100755 --- a/tests/shared/298 +++ b/tests/shared/298 @@ -46,13 +46,21 @@ _cleanup() get_holes() { + # It's not a good idea to be running tools against the image file + # backing a live filesystem because the filesystem could be maintaining + # in-core state that will perturb the free space map on umount. Stick + # to established convention which requires the filesystem to be + # unmounted while we probe the underlying file. + $UMOUNT_PROG $loop_mnt $XFS_IO_PROG -F -c fiemap $1 | grep hole | $SED_PROG 's/.*\[\(.*\)\.\.\(.*\)\].*/\1 \2/' + _mount $loop_dev $loop_mnt } get_free_sectors() { case $FSTYP in ext4) + $UMOUNT_PROG $loop_mnt $DUMPE2FS_PROG $img_file 2>&1 | grep " Free blocks" | cut -d ":" -f2- | \ tr ',' '\n' | $SED_PROG 's/^ //' | \ $AWK_PROG -v spb=$sectors_per_block 'BEGIN{FS="-"}; @@ -195,6 +203,16 @@ while read line; do END { if(found) exit 0; else exit 1}' $merged_sectors then echo "Sectors $from-$to are not marked as free!" + + # Dump the state to make it easier to debug this... + echo free_sectors >> $seqres.full + sort -g < $free_sectors >> $seqres.full + echo fiemap_ref >> $seqres.full + sort -g < $fiemap_ref >> $seqres.full + echo merged_sectors >> $seqres.full + sort -g < $merged_sectors >> $seqres.full + echo fiemap_after >> $seqres.full + sort -g < $fiemap_after >> $seqres.full exit fi done < $fiemap_after