From patchwork Thu Apr 12 05:07:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10337881 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 1A39F603B5 for ; Thu, 12 Apr 2018 05:07:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0568326E38 for ; Thu, 12 Apr 2018 05:07:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EDC6A26E55; Thu, 12 Apr 2018 05:07: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=-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 7017D26E38 for ; Thu, 12 Apr 2018 05:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751450AbeDLFHi (ORCPT ); Thu, 12 Apr 2018 01:07:38 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:37327 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbeDLFHi (ORCPT ); Thu, 12 Apr 2018 01:07:38 -0400 Received: by mail-pf0-f193.google.com with SMTP id p6so2638790pfn.4 for ; Wed, 11 Apr 2018 22:07:37 -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=D6QnIrEDBOv9Ldt+iGPLoVWKyW3uJyK/0XMEnElhCvpdI8LnEJkUSLuY1IjnO/+XGK L3qA+/VBhwVUXatG90DcMShX/JWSYxv2H9cMasdD/aIh7xx1dL8BdpUOhaFIj8gkcpDb PTUvoSpJ0N7GK9iNEgvYEpzeNdOG1QnBof/e+ZghWIa1N8PzxcXfHSVrIcx27YOaGA11 7OEpe4BP9rDhj4hUNF20SQyR8VT9BeOr3SwbTURnA4wCPf5VLFcaKXt+0LLsYDhZeVr0 kX6kCck/CKd5nzhGjfhUws5+g/rCc/LHEjQ6HHcQqEQvz4spxnF9D8500gDDEGHfANTE dDGw== 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=ssfN8ADuPoBNf3tZOZY3+UPP5P637NEM0sVmsylaikXJPbAD/DTEx32LWHCrIfhOwj dwWNmi/qjVmk89uo2EdHbcdX9xD1uYqwX5O/oWC8+U/7aA7sDzzo33py/rEnKULtg3LN YMEvFhS0ZYFQtlW1bVOhvlXBGXIVyk+8G6lWatxfi8aO8SQXj8/0OK4C2fO7KGZCuC2X znQxTAO1rS0mtliYoLWtBjx+16V1ufmrWH6vdeWmL8F4H1+8jInYQGl34lQfkqq5Wm9v fOVVATQxSu7IeS9puU5pPRnxhkGFrEcIV/TyUE2vzV2YiG08Gk//r/eBa8c+oToRRjwH 7Wjw== X-Gm-Message-State: ALQs6tD3vEGCr6ZEQy7tNmdiiHkOENJPAuE9/afLCp/nlvTCzSCbFi1o 3xty22GZSPwIW8ZMedHUsKzVng== X-Google-Smtp-Source: AIpwx4+yx5IeOijH097JlY40Jv0SLndYpQGS624E+67W/BdAhmw9d2pGXB9RUnKmQMfeHUuKNHsuIA== X-Received: by 10.99.167.75 with SMTP id w11mr4203525pgo.351.1523509657138; Wed, 11 Apr 2018 22:07:37 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:9c88]) by smtp.gmail.com with ESMTPSA id o2sm5163855pgq.87.2018.04.11.22.07.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Apr 2018 22:07:36 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org, Eryu Guan Cc: kernel-team@fb.com Subject: [PATCH v2 1/2] aio-dio-eof-race: handle aio pwrite errors and short reads Date: Wed, 11 Apr 2018 22:07:28 -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; } /*