From patchwork Wed Nov 29 01:44:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Yang X-Patchwork-Id: 10081307 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A8D88602DC for ; Wed, 29 Nov 2017 01:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B18329783 for ; Wed, 29 Nov 2017 01:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90025297DB; Wed, 29 Nov 2017 01:44:35 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2D47B29783 for ; Wed, 29 Nov 2017 01:44:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753373AbdK2Boe (ORCPT ); Tue, 28 Nov 2017 20:44:34 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:31506 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752643AbdK2Bob (ORCPT ); Tue, 28 Nov 2017 20:44:31 -0500 X-IronPort-AV: E=Sophos;i="5.43,368,1503331200"; d="scan'208";a="30560291" Received: from localhost (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 29 Nov 2017 09:44:29 +0800 Received: from G08CNEXCHPEKD01.g08.fujitsu.local (unknown [10.167.33.80]) by cn.fujitsu.com (Postfix) with ESMTP id 017CC41B319D; Wed, 29 Nov 2017 09:44:25 +0800 (CST) Received: from localhost.localdomain (10.167.220.81) by G08CNEXCHPEKD01.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 29 Nov 2017 09:44:23 +0800 From: Xiao Yang To: CC: , Xiao Yang Subject: [PATCH v3] generic/465: just check the actual read data under dio read/write Date: Wed, 29 Nov 2017 09:44:17 +0800 Message-ID: <1511919857-21458-1-git-send-email-yangx.jy@cn.fujitsu.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20171128072028.GF2749@eguan.usersys.redhat.com> References: <20171128072028.GF2749@eguan.usersys.redhat.com> MIME-Version: 1.0 X-Originating-IP: [10.167.220.81] X-yoursite-MailScanner-ID: 017CC41B319D.AA5F6 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: yangx.jy@cn.fujitsu.com Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I got the following message when running generic/465 in ext4 data=journal mode --------------------------------------------------------------- QA output created by 465 non-aio dio test encounter an error: block 0 offset 4096, content 62 encounter an error: block 0 offset 122880, content 62 encounter an error: block 0 offset 274432, content 62 encounter an error: block 0 offset 86016, content 62 aio-dio test encounter an error: block 0 offset 28672, content 62 encounter an error: block 0 offset 12288, content 62 encounter an error: block 2 offset 16384, content 62 encounter an error: block 1 offset 565248, content 62 --------------------------------------------------------------- In ext4 data=journal mode, direct read will fall back to buffer read, and buffer read doesn't take inode lock, so it doesn't need to wait for the writer to finish first and sees the intermediate inode size and returns data less than 1M. We can just check the actual read data instead of the whole read buffer. Signed-off-by: Xiao Yang --- src/aio-dio-regress/aio-dio-append-write-read-race.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/aio-dio-regress/aio-dio-append-write-read-race.c b/src/aio-dio-regress/aio-dio-append-write-read-race.c index 8f94d50..7805af1 100644 --- a/src/aio-dio-regress/aio-dio-append-write-read-race.c +++ b/src/aio-dio-regress/aio-dio-append-write-read-race.c @@ -43,6 +43,7 @@ struct io_data { off_t offset; char *buf; int use_aio; + int read_sz; }; int reader_ready = 0; @@ -57,15 +58,14 @@ static void usage(const char *prog) static void *reader(void *arg) { struct io_data *data = (struct io_data *)arg; - int ret; memset(data->buf, 'b', data->blksize); reader_ready = 1; do { - ret = pread(data->fd, data->buf, data->blksize, data->offset); - if (ret < 0) + data->read_sz = pread(data->fd, data->buf, data->blksize, data->offset); + if (data->read_sz < 0) perror("read file"); - } while (ret <= 0); + } while (data->read_sz <= 0); return NULL; } @@ -203,7 +203,7 @@ int main(int argc, char *argv[]) goto err; } - for (j = 0; j < blksize; j++) { + for (j = 0; j < rdata.read_sz; j++) { if (rdata.buf[j] != 'a') { fail("encounter an error: " "block %d offset %d, content %x\n",