From patchwork Thu Oct 12 20:49:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Bo X-Patchwork-Id: 10002957 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 CFD7D6028A for ; Thu, 12 Oct 2017 21:51:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1B0828EFE for ; Thu, 12 Oct 2017 21:51:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B511228F01; Thu, 12 Oct 2017 21:51:55 +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, UNPARSEABLE_RELAY 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 47A6028EFE for ; Thu, 12 Oct 2017 21:51:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754765AbdJLVvy (ORCPT ); Thu, 12 Oct 2017 17:51:54 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:35826 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754586AbdJLVvy (ORCPT ); Thu, 12 Oct 2017 17:51:54 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9CLpqk5006437 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 12 Oct 2017 21:51:52 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v9CLppZp011660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 12 Oct 2017 21:51:52 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v9CLppw2001709 for ; Thu, 12 Oct 2017 21:51:51 GMT Received: from dhcp-10-211-47-181.usdhcp.oraclecorp.com.com (/10.211.47.181) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 12 Oct 2017 14:51:51 -0700 From: Liu Bo To: linux-xfs@vger.kernel.org Subject: [PATCH] xfs_io: report io error for pwrite -W and -w Date: Thu, 12 Oct 2017 14:49:49 -0600 Message-Id: <20171012204949.8225-1-bo.li.liu@oracle.com> X-Mailer: git-send-email 2.9.4 X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When IO error occurs, xfs_io -c "pwrite -W/w" doesn't report errors while xfs_io -c "pwrite" -c "fsync" does. This changes "pwrite -W/w" to report errors when it should. Signed-off-by: Liu Bo Reviewed-by: Eric Sandeen --- io/pwrite.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 2.9.4 @@ -390,0 +397,0 @@ -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/io/pwrite.c b/io/pwrite.c index 1c5dfca..71bcccc 100644 --- a/io/pwrite.c +++ b/io/pwrite.c @@ -379,11 +379,18 @@ pwrite_f( } if (c < 0) goto done; - if (Wflag) - fsync(file->fd); - if (wflag) - fdatasync(file->fd); + if (Wflag) { + if (fsync(file->fd) < 0) { + perror("fsync"); + goto done; + } + } + if (wflag) { + if (fdatasync(file->fd) < 0) { + perror("fdatasync"); + goto done; + } + } if (qflag) goto done; gettimeofday(&t2, NULL); --