Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2711168rdb; Fri, 22 Sep 2023 06:34:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEX5VC7EVXyj/soFkiMVdRKkHaLNd5m/p61aWQRLx3qQIkIv+Td6zNKPXrjU/KkBh81bNy3 X-Received: by 2002:a05:6358:c60a:b0:143:8601:54d with SMTP id fd10-20020a056358c60a00b001438601054dmr3673505rwb.2.1695389680170; Fri, 22 Sep 2023 06:34:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695389680; cv=none; d=google.com; s=arc-20160816; b=x33Shu2guNr3tOHpxQactjvk7XccpbXc79Jt5y09zzrodUpOupl3e1adkszrxWoBoJ IPmMQ1P5iFOp/JtUOkXvXaQTPW+Bx8OiXZsCY08MsWBZ4eBoQHa37xQi4mhhPOFmMBKE DoVHX3m+Lc4DdjkT9azgzFMTq4Q/1ykhfPbW3eOc+udqVPzMtZs/IokONofJNjQu/RyH MrT4kNRyforB+nT+AAtMvjGur5UhNBCqKvhrmyvYeKhepwl4hULP2krkC/Q+ASkBZhaC 37JpIrkF3X4qNNY3Owj8LL+eu/tAI4NgqSQxmrXqQ40f0TFecgvwDlnDtVsiAe96iV7Y Cb4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=ihgWgoQsfAl8saOUuzysw4N8TQZ0/C+cPeCA1Z8AZl0=; fh=arFGBVjDyJM4hGHD62XDr/okxAVzMHX5ou2z2oYzjOo=; b=VbBbSsw08q8k+/uOGXeNLxc9hIK/VS7hKKwu5H2+f16nffdp4RZ7LiIAPqqlHMAIjl p5Eg5vF+d+NafFgQSAuPqYzMybnsBggZeiQlUmt4JgWQNpS0B54EYDJLLiFztUn7KHlx uFMQOZvhiyF28vepL3z1iaorRHHitas2LMOwVlxM41CHq9/UFqyIFK5Fa06REHZIg1iy MZ+sKCmwUmeSY8T5v38rSg98s9YIBpZQTXmD9xabAaK8obQeF5tSn8ECbqFT5+VdgFdK EC8wMqjgsXjK1pyLW7MprTCDCH/wcJhsML8QPssF2dgZXtWglYjNyIvRN9C5JznnIkOA 5Mog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bv126-20020a632e84000000b00578d78f2a70si3746059pgb.388.2023.09.22.06.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:34:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EFDCB8097293; Fri, 22 Sep 2023 06:30:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234190AbjIVNa1 (ORCPT + 99 others); Fri, 22 Sep 2023 09:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234065AbjIVNaL (ORCPT ); Fri, 22 Sep 2023 09:30:11 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E0231A8; Fri, 22 Sep 2023 06:30:03 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0Vsdceue_1695389400; Received: from 192.168.3.4(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0Vsdceue_1695389400) by smtp.aliyun-inc.com; Fri, 22 Sep 2023 21:30:01 +0800 Message-ID: <7ce321e3-3250-5627-18f8-230249fbf78f@linux.alibaba.com> Date: Fri, 22 Sep 2023 21:29:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] generic: Add integrity tests with synchronous directio To: "Ritesh Harjani (IBM)" , fstests@vger.kernel.org Cc: linux-ext4@vger.kernel.org, Jan Kara , Theodore Ts'o References: <87y1gy5s9c.fsf@doe.com> <434beffaf18d39f898518ea9eb1cea4548e77c3a.1695383715.git.ritesh.list@gmail.com> From: Gao Xiang In-Reply-To: <434beffaf18d39f898518ea9eb1cea4548e77c3a.1695383715.git.ritesh.list@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 22 Sep 2023 06:30:29 -0700 (PDT) Hi Ritesh, On 2023/9/22 20:10, Ritesh Harjani (IBM) wrote: > This test covers data & metadata integrity check with directio with > o_sync flag and checks the file contents & size after sudden fileystem > shutdown once the directio write is completed. ext4 directio after iomap > conversion was broken in the sense that if the FS crashes after > synchronous directio write, it's file size is not properly updated. > This test adds a testcase to cover such scenario. > > Man page of open says that - > O_SYNC provides synchronized I/O file integrity completion, meaning write > operations will flush data and all associated metadata to the underlying > hardware > > Reported-by: Gao Xiang > Signed-off-by: Ritesh Harjani (IBM) > --- > tests/generic/471 | 45 +++++++++++++++++++++++++++++++++++++++++++ > tests/generic/471.out | 8 ++++++++ > 2 files changed, 53 insertions(+) > create mode 100755 tests/generic/471 > create mode 100644 tests/generic/471.out > > diff --git a/tests/generic/471 b/tests/generic/471 > new file mode 100755 > index 00000000..6c31cff8 > --- /dev/null > +++ b/tests/generic/471 > @@ -0,0 +1,45 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2023 IBM Corporation. All Rights Reserved. > +# > +# FS QA Test 471 > +# > +# Integrity test with DIRECT_IO & O_SYNC with sudden shutdown > +# > +. ./common/preamble > +_begin_fstest auto quick shutdown > + > +# Override the default cleanup function. > +_cleanup() > +{ > + cd / > + rm -r -f $tmp.* > +} > + > +# Import common functions. > +. ./common/filter > + > +# real QA test starts here > + > +# Modify as appropriate. > +_supported_fs generic > +_require_scratch > +_require_scratch_shutdown > + > +_scratch_mkfs > $seqres.full 2>&1 > +_scratch_mount > + > +echo "Create a 1M file using O_DIRECT & O_SYNC" > +xfs_io -fsd -c "pwrite -S 0x5a 0 1M" $SCRATCH_MNT/testfile > /dev/null 2>&1 Thanks for the time on this. I'm fine with this as it's the exact regression test to my report. Although the original issue from our guest real workload is actually aio + O_SYNC, but that doesn't matter for ext4 since it will serialize the whole process of DIO write beyond i_size with inode lock. Yet if my understanding is correct, some other fses (e.g. XFS) seem to be more relaxed than this, see xfs_file_dio_write_aligned() and xfs_file_write_checks(), so I'm not sure if we need to cover AIO cases as well, anyway. Thanks, Gao Xiang > + > +echo "Shutdown the fs suddenly" > +_scratch_shutdown > + > +echo "Cycle mount" > +_scratch_cycle_mount > + > +echo "File contents after cycle mount" > +_hexdump $SCRATCH_MNT/testfile > + > +status=0 > +exit > diff --git a/tests/generic/471.out b/tests/generic/471.out > new file mode 100644 > index 00000000..ae279b79 > --- /dev/null > +++ b/tests/generic/471.out > @@ -0,0 +1,8 @@ > +QA output created by 471 > +Create a 1M file using O_DIRECT & O_SYNC > +Shutdown the fs suddenly > +Cycle mount > +File contents after cycle mount > +000000 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a >ZZZZZZZZZZZZZZZZ< > +* > +100000