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: 10337883 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 8687F604D4 for ; Thu, 12 Apr 2018 05:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 760B026E38 for ; Thu, 12 Apr 2018 05:07:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AB8C26E55; Thu, 12 Apr 2018 05:07:41 +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=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 217C826E38 for ; Thu, 12 Apr 2018 05:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751597AbeDLFHj (ORCPT ); Thu, 12 Apr 2018 01:07:39 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44002 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751112AbeDLFHi (ORCPT ); Thu, 12 Apr 2018 01:07:38 -0400 Received: by mail-pf0-f196.google.com with SMTP id u8so2281848pfg.10 for ; Wed, 11 Apr 2018 22:07:38 -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=nOqyeDn0wsmdk3gVGbBF59MbSj5CGUqxdmP/R+OPtO46RG/ykDnwCGNokwZ25q3upw LmPPhFNPkIqNum9E/oLY8EmL5CAN7FQyG1CMEdY6ZTBY9flvbfc6skpO58YP4LUEqFAl O+hi861RQOHp5sweUnfp+2b9k+JhDiXftQm549aYMc+a2IUGh6UmGqi1yrF8CCwYXLHY oG8HaQVbKhKrtR3o8lALeySXQVugcZhY0ddSABIMJNc9ucfJfPnVA6C4bsWA2Z0FDc5h FSyC6WMKha8ZHQg0RhLt73hfVqhh0edd3B9Gj/+LerGCkSJ48EykCks5GF69BUkGvCK7 KaAQ== X-Gm-Message-State: ALQs6tDGWvSulDAx5lkT/eMZoVVmruaaZpg/dBjvAfmlOKA3+htvqxZD WCqoAUrnGHftRxSrjKO8k1ayTjLO9FA= 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: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@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; } /*