From patchwork Wed Apr 11 23:47:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10337649 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 48F4C602D8 for ; Wed, 11 Apr 2018 23:47:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2ADE81FF60 for ; Wed, 11 Apr 2018 23:47:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D52C212EE; Wed, 11 Apr 2018 23:47: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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 640B51FF60 for ; Wed, 11 Apr 2018 23:47:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbeDKXrn (ORCPT ); Wed, 11 Apr 2018 19:47:43 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:34993 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751633AbeDKXrm (ORCPT ); Wed, 11 Apr 2018 19:47:42 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so2554978plb.2 for ; Wed, 11 Apr 2018 16:47:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=vOlXOZA8Ab7NggSh9PD4aID6vcqO/bowRcCSfrZRU68=; b=GSaezqhNFnZMcxtMppsyK1/lZ9TNr5SrHOtdCmf46/bRswfWGNp3EFabmOSAe5ycxX p8r0xwlILXb9E67+f8jKUYeipzeWU//D0P9Fm7kqyP4zWO4dw0duhhMxt8kAuel/hUWK u2c9qML78kRtbgZw1EAgYtEf5XyK+u2ptjEeCKv1x2QcZShGrfkEAXmF2srVckgWVCxC yfW1Y1+LFmaw9Nvtqo54qSDaOSLP+kCmB05UrqSAtG68n+ZVGWnAMpIwmMlupkc0HKKG vDd+amm+VqtzM22igZN/6ElWElJjIUNm6GlO9pgUmXJrePYFotqZyXmDAffIrTSmKB96 keCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vOlXOZA8Ab7NggSh9PD4aID6vcqO/bowRcCSfrZRU68=; b=cObT+xPeK8GUUjO9bMjovVRyCS4/Stc+lRaLUgms6qO32iqQ22ioSlEq4ffNdMhBjP 0GCTeCPh/L38WQ2drxak6K0ib89MWdc27DIE9vCYZ+8yHc1sDzcQyI2T9M/dQNKJ3hqe JWeHu9ebF7KTls54xGb/NK3Cimzla2cAukS38f00NTnnJXzw04uI7ZoNQEjCeX2ZtkW9 +qVI0SkMu6x71SAS8MyGFZhoePs6iTMDI2mfNgsekKxW1BZvdpfSxYSgT4TuDcQRlRg8 ePurW7LyXEPpyN43RRyZ70U60VY8jjkX8PXrtE/RiYg5IEvqfYgCQSmg/sVQkv1c9krK 4L/A== X-Gm-Message-State: ALQs6tB8TsuwmHeQVkVuWDcUXov1SwdqQSNP9k/I9ZgdT5uqLzJF2qNk iA4apz/2iv9O2Bjjjj127FCJiQ== X-Google-Smtp-Source: AIpwx49cdzpHaC4lsYVJB1f/atvOmXMOllNvFwRvF3q7MvksGeslZmEloJg4Q7Z8hYqJpU+JW0VslQ== X-Received: by 2002:a17:902:9:: with SMTP id 9-v6mr7464171pla.42.1523490461657; Wed, 11 Apr 2018 16:47:41 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5b86]) by smtp.gmail.com with ESMTPSA id z65sm4264185pgz.24.2018.04.11.16.47.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Apr 2018 16:47:41 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org, Eryu Guan Cc: kernel-team@fb.com Subject: [PATCH 1/2] aio-dio-eof-race: handle aio pwrite errors and short reads Date: Wed, 11 Apr 2018 16:47:29 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Omar Sandoval generic/427 fails on Btrfs with a cryptic "pread: Success" message. This is because an aio pwrite fails with ENOSPC, so the file isn't as long as we expect it to be. Make sure we check the result of the aio writes and also print a more explicit message for short reads (which are technically valid but in practice shouldn't happen for this test case). Now the test fails with a much more informative "pwrite: No space left on device". Signed-off-by: Omar Sandoval --- src/aio-dio-regress/aio-dio-eof-race.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/aio-dio-regress/aio-dio-eof-race.c b/src/aio-dio-regress/aio-dio-eof-race.c index bb1890b5..04479035 100644 --- a/src/aio-dio-regress/aio-dio-eof-race.c +++ b/src/aio-dio-regress/aio-dio-eof-race.c @@ -154,6 +154,9 @@ int main(int argc, char *argv[]) /* Keep extending until size_MB */ while (eof < size_MB * 1024 * 1024) { + ssize_t sret; + int i; + memset(buf, IO_PATTERN, buf_size); fstat(fd, &statbuf); eof = statbuf.st_size; @@ -186,15 +189,32 @@ int main(int argc, char *argv[]) return 1; } + for (i = 0; i < err; i++) { + /* + * res is unsigned for some reason, so this is the best + * way to detect that it contains a negative errno. + */ + if (evs[i].res > buf_size / 4) { + fprintf(stderr, "pwrite: %s\n", + strerror(-evs[i].res)); + return 1; + } + } + /* * And then read it back. * * Using pread to keep it simple, but AIO has the same effect. * eof is the prior eof; we just wrote buf_size more. */ - if (pread(fd, buf, buf_size, eof) != buf_size) { + sret = pread(fd, buf, buf_size, eof); + if (sret == -1) { perror("pread"); return 1; + } else if (sret != buf_size) { + fprintf(stderr, "short read %zd was less than %zu\n", + sret, buf_size); + return 1; } /*