From patchwork Wed May 31 07:20:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 687754 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3859C7EE24 for ; Wed, 31 May 2023 07:20:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234596AbjEaHU2 (ORCPT ); Wed, 31 May 2023 03:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbjEaHU0 (ORCPT ); Wed, 31 May 2023 03:20:26 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87A28EE; Wed, 31 May 2023 00:20:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1AhsMC0b8Le+Qj8+/F9cJR6e5GLVWYekas+17NCVqqI=; b=ngxKf22NWcVmXxqJwcEfwC+j8T 3PxkmTMDjWxvvbR0duw8sA22hBD8npF8M7zy6uMP4A5nP81zq24egxiseYxIct9QT3BCtbnaev2MP wbiG/KzTwrwXiTebokTJ7zF2jRnxdAYau+XBec+F7XpGZX21QBO/OVfktTd4rlLpzooJH46MVsmsK +e4Tx0iJl2vZNXf3rTUvEhj2U+bq4yTQ5Rorj9IL8ZzUYJY9U+Zj+4quc3/7Yk+xX4BT5iyozg9is oymt/Or6TlEeT9TsG94njHW/hepEKG1n0Fi1TB0ymGUOgiWMRRS2N8SqiUunjzPtuqt/z9Padv5X7 cRckgdNw==; Received: from [2001:4bb8:182:6d06:f5c3:53d7:b5aa:b6a7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q4G7y-00GPht-1z; Wed, 31 May 2023 07:20:14 +0000 From: Christoph Hellwig To: Matthew Wilcox Cc: Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , "Theodore Ts'o" , Jaegeuk Kim , Chao Yu , Miklos Szeredi , Andreas Gruenbacher , "Darrick J. Wong" , Trond Myklebust , Anna Schumaker , Damien Le Moal , Andrew Morton , linux-block@vger.kernel.org, ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, Hannes Reinecke Subject: [PATCH 2/8] iomap: update ki_pos a little later in iomap_dio_complete Date: Wed, 31 May 2023 09:20:00 +0200 Message-Id: <20230531072006.476386-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531072006.476386-1-hch@lst.de> References: <20230531072006.476386-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Move the ki_pos update down a bit to prepare for a better common helper that invalidates pages based of an iocb. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Reviewed-by: Darrick J. Wong --- fs/iomap/direct-io.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 019cc87d0fb339..6207a59d2162e1 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -94,7 +94,6 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio) if (offset + ret > dio->i_size && !(dio->flags & IOMAP_DIO_WRITE)) ret = dio->i_size - offset; - iocb->ki_pos += ret; } /* @@ -120,19 +119,21 @@ ssize_t iomap_dio_complete(struct iomap_dio *dio) } inode_dio_end(file_inode(iocb->ki_filp)); - /* - * 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); - if (ret > 0) - ret += dio->done_before; + if (ret > 0) { + iocb->ki_pos += ret; + /* + * If this is a DSYNC write, make sure we push it to stable + * storage now that we've written data. + */ + if (dio->flags & IOMAP_DIO_NEED_SYNC) + ret = generic_write_sync(iocb, ret); + if (ret > 0) + ret += dio->done_before; + } trace_iomap_dio_complete(iocb, dio->error, ret); kfree(dio); - return ret; } EXPORT_SYMBOL_GPL(iomap_dio_complete);