From patchwork Tue Dec 15 18:06:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Goldwyn Rodrigues X-Patchwork-Id: 11975503 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4D6CC2BB48 for ; Tue, 15 Dec 2020 18:07:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACBD522B3B for ; Tue, 15 Dec 2020 18:07:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730264AbgLOSHc (ORCPT ); Tue, 15 Dec 2020 13:07:32 -0500 Received: from mx2.suse.de ([195.135.220.15]:58454 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729683AbgLOSHV (ORCPT ); Tue, 15 Dec 2020 13:07:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id EE9E5AE4B; Tue, 15 Dec 2020 18:06:39 +0000 (UTC) From: Goldwyn Rodrigues To: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org Cc: darrick.wong@oracle.com, hch@infradead.org, nborisov@suse.com, Goldwyn Rodrigues Subject: [PATCH 1/2] iomap: Separate out generic_write_sync() from iomap_dio_complete() Date: Tue, 15 Dec 2020 12:06:35 -0600 Message-Id: X-Mailer: git-send-email 2.29.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Goldwyn Rodrigues This introduces a separate function __iomap_dio_complte() which completes the Direct I/O without performing the write sync. Filesystems such as btrfs which require an inode_lock for sync can call __iomap_dio_complete() and must perform sync on their own after unlock. Signed-off-by: Goldwyn Rodrigues Reported-by: kernel test robot --- fs/iomap/direct-io.c | 16 +++++++++++++--- include/linux/iomap.h | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 933f234d5bec..11a108f39fd9 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -76,7 +76,7 @@ static void iomap_dio_submit_bio(struct iomap_dio *dio, struct iomap *iomap, dio->submit.cookie = submit_bio(bio); } -ssize_t iomap_dio_complete(struct iomap_dio *dio) +ssize_t __iomap_dio_complete(struct iomap_dio *dio) { const struct iomap_dio_ops *dops = dio->dops; struct kiocb *iocb = dio->iocb; @@ -119,18 +119,28 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio) } inode_dio_end(file_inode(iocb->ki_filp)); + + return ret; +} +EXPORT_SYMBOL_GPL(__iomap_dio_complete); + +ssize_t iomap_dio_complete(struct iomap_dio *dio) +{ + ssize_t ret; + + ret = __iomap_dio_complete(dio); /* * If this is a DSYNC write, make sure we push it to stable storage now * that we've written data. */ if (ret > 0 && (dio->flags & IOMAP_DIO_NEED_SYNC)) - ret = generic_write_sync(iocb, ret); + ret = generic_write_sync(dio->iocb, ret); kfree(dio); return ret; } -EXPORT_SYMBOL_GPL(iomap_dio_complete); + static void iomap_dio_complete_work(struct work_struct *work) { diff --git a/include/linux/iomap.h b/include/linux/iomap.h index 5bd3cac4df9c..5785dc0b8ec5 100644 --- a/include/linux/iomap.h +++ b/include/linux/iomap.h @@ -262,7 +262,7 @@ ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter, const struct iomap_ops *ops, const struct iomap_dio_ops *dops, bool wait_for_completion); -ssize_t iomap_dio_complete(struct iomap_dio *dio); +ssize_t __iomap_dio_complete(struct iomap_dio *dio); int iomap_dio_iopoll(struct kiocb *kiocb, bool spin); #ifdef CONFIG_SWAP