From patchwork Tue Feb 2 20:17:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 8195251 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 20AE3BEEE5 for ; Tue, 2 Feb 2016 20:17:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1AADE202B8 for ; Tue, 2 Feb 2016 20:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DBC50202D1 for ; Tue, 2 Feb 2016 20:17:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757855AbcBBURo (ORCPT ); Tue, 2 Feb 2016 15:17:44 -0500 Received: from casper.infradead.org ([85.118.1.10]:40018 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755492AbcBBURm (ORCPT ); Tue, 2 Feb 2016 15:17:42 -0500 Received: from [83.175.99.196] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.85 #2 (Red Hat Linux)) id 1aQhOP-0002ZA-3e; Tue, 02 Feb 2016 20:17:41 +0000 From: Christoph Hellwig To: linux-fsdevel@vger.kernel.org, xfs@oss.sgi.com, linux-ext4@vger.kernel.org, ocfs2-devel@oss.oracle.com Cc: darrick.wong@oracle.com Subject: [PATCH 1/3] direct-io: always call ->end_io if non-NULL Date: Tue, 2 Feb 2016 21:17:35 +0100 Message-Id: <1454444257-9086-2-git-send-email-hch@lst.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1454444257-9086-1-git-send-email-hch@lst.de> References: <1454444257-9086-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP See http://www.infradead.org/rpr.html This way we can pass back errors to the file system, and allow for cleanup required for all direct I/O invocations. Signed-off-by: Christoph Hellwig --- fs/dax.c | 2 +- fs/direct-io.c | 4 ++-- fs/ext4/inode.c | 3 +++ fs/ocfs2/aops.c | 3 +++ fs/xfs/xfs_aops.c | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 4fd6b0c..e47d1ba 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -267,7 +267,7 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) inode_unlock(inode); - if ((retval > 0) && end_io) + if (end_io) end_io(iocb, pos, retval, bh.b_private); if (!(flags & DIO_SKIP_DIO_COUNT)) diff --git a/fs/direct-io.c b/fs/direct-io.c index 1b2f7ff..ead7ac1 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -253,8 +253,8 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, if (ret == 0) ret = transferred; - if (dio->end_io && dio->result) - dio->end_io(dio->iocb, offset, transferred, dio->private); + if (dio->end_io) + dio->end_io(dio->iocb, offset, ret, dio->private); if (!(dio->flags & DIO_SKIP_DIO_COUNT)) inode_dio_end(dio->inode); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 83bc8bf..d04555b 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3166,6 +3166,9 @@ static void ext4_end_io_dio(struct kiocb *iocb, loff_t offset, { ext4_io_end_t *io_end = iocb->private; + if (size <= 0) + return; + /* if not async direct IO just return */ if (!io_end) return; diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 794fd15..1eeb804 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c @@ -628,6 +628,9 @@ static void ocfs2_dio_end_io(struct kiocb *iocb, struct inode *inode = file_inode(iocb->ki_filp); int level; + if (bytes <= 0) + return; + /* this io's submitter should not have unlocked this before we could */ BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index 379c089..c318e9f 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c @@ -1655,6 +1655,9 @@ xfs_end_io_direct_write( struct inode *inode = file_inode(iocb->ki_filp); struct xfs_ioend *ioend = private; + if (size <= 0) + return; + trace_xfs_gbmap_direct_endio(XFS_I(inode), offset, size, ioend ? ioend->io_type : 0, NULL);