From patchwork Wed May 31 07:50:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261644 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BEC00C77B7A for ; Wed, 31 May 2023 07:51:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B78E6B0080; Wed, 31 May 2023 03:51:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58FF56B0081; Wed, 31 May 2023 03:51:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45577900002; Wed, 31 May 2023 03:51:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 35AFD6B0080 for ; Wed, 31 May 2023 03:51:01 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 051F140263 for ; Wed, 31 May 2023 07:51:00 +0000 (UTC) X-FDA: 80849779122.11.0689742 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf06.hostedemail.com (Postfix) with ESMTP id 530C3180012 for ; Wed, 31 May 2023 07:50:59 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dtzDh96n; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+b81a8c9a6d22e8bb2302+7220+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b81a8c9a6d22e8bb2302+7220+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685519459; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=a5Lvr5nZsxWnI6T+V3CK7XOpJ+ONTwidG7DsWkZk2X0=; b=cE2PB1QZ+5LdTtFt0I/IZjtSSVEKr4z4G5hbDK48SsXIC5BmfTPmPuXuA/zUX0Z1C1FKCb CK/w8nNqKnXsxJrcSz00+ohKh0y9TE7RM7s/6WMj1/bD5K4hglQrnzKKicJZ9d5HFHAwGc kTwU8O/Mrjcd28URH1Nt0LtEwzWVqE4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dtzDh96n; dmarc=none; spf=none (imf06.hostedemail.com: domain of BATV+b81a8c9a6d22e8bb2302+7220+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+b81a8c9a6d22e8bb2302+7220+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685519459; a=rsa-sha256; cv=none; b=BaurnE4/9HR0yTdduj6Gp1eWjnNp49o6NwzstuRX6fpLMVbwEAwIB2yjrmAotGzcey02DA 0XiZEUdtgwhy1XUGtTEqza7Ypco5cqezn8oWTZSeZnuv7VrAkx45biMNqznnPn3jkTGXMs Wt+P8MKBUwqklZ1S35d3xTi9G1TZzR8= 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=a5Lvr5nZsxWnI6T+V3CK7XOpJ+ONTwidG7DsWkZk2X0=; b=dtzDh96nnXtXyfwl4BSC7ayjQE qh58dEtcSivNAYmh7iKknqZcpZJBK3+VDCEhLSEqAyjvf5uEOpUBBDBNO1k8OfFRVDZwQUidhp5Fi htnHhQOD2HjbNoLI3Bwf0DFq9gfTLu5OqINK1Var/z/5Ne5P14U+UDPJMpXNS2G7Xy08+i9OJ0Nsr c3nqm3UjKGw0V4AJYwEPhJjo/dE+uP+Rpl8EhugrdpQqxLRO7hQYKYxH1h7dYoLBZIrjFB/MMKECA UuMW7v6bMKsd3oSI64dTyA3e0ZEMIV8p7moXb/sPDTbln+xmyY0r0ktJMrFiI1YrJCcCf2PQJDZkU Py5GgmrA==; 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 1q4GbX-00GVrP-2h; Wed, 31 May 2023 07:50:48 +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 07/12] iomap: update ki_pos in iomap_file_buffered_write Date: Wed, 31 May 2023 09:50:21 +0200 Message-Id: <20230531075026.480237-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230531075026.480237-1-hch@lst.de> References: <20230531075026.480237-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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: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y8vdUFoQ0yUq7LvZ7rw82Bzn7lU+rpNQYDKxGTME0+cPYfFN8uJtVBhoxZ4v7HfRmrcBONEmb89lIYXRJ8VqYIAU6DJu/Qytfes1bKI5JEgMEsrneXS0AQVWrmea7K7cXanvDT0QZTviETZPpM5IfxViwznhYYF0hrYOw8vzJrteoeVBxUH0or+eKygVDb6C41aDm88B340fmVRMlDMYPLeJ/LBpJ7mVjK5Im/fpTgYsu0RKlwKB4G9Vh56Tt/3w4UV/mCsVVrTCIhCCYOK80W2gTAvGOf18vZMqNfhxtN/BjSHIGdEqXo2pNN5IhZTmdrq/XOpfTJWUZvha8mVWk0QqkFwcyzFAh08O03mWpsWimLyEB1xBA0aKzz3kfmNBWpcjhl9JxTM7FA1tZg/c+cNXOG4hh1tudhnMn7MUeidHjjlGBfh6lUSaTjUW0tEfAQ3CgJ0jaefGDuzcvm4QjklQzB7pqC3ukuQt7F9zgxlTDju/3u2iqy9YmHrhZ4x4AQCm/QeWPKc6b66+2Uf/TkNb4jJuXCCivmK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: All callers of iomap_file_buffered_write need to updated ki_pos, move it into common code. Signed-off-by: Christoph Hellwig Reviewed-by: Andreas Gruenbacher Reviewed-by: Hannes Reinecke Reviewed-by: Darrick J. Wong Acked-by: Damien Le Moal --- fs/gfs2/file.c | 4 +--- fs/iomap/buffered-io.c | 9 ++++++--- fs/xfs/xfs_file.c | 2 -- fs/zonefs/file.c | 4 +--- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 904a0d6ac1a1a9..c6a7555d5ad8bb 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1044,10 +1044,8 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, pagefault_disable(); ret = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); pagefault_enable(); - if (ret > 0) { - iocb->ki_pos += ret; + if (ret > 0) written += ret; - } if (inode == sdp->sd_rindex) gfs2_glock_dq_uninit(statfs_gh); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 063133ec77f49e..550525a525c45c 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -864,16 +864,19 @@ iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *i, .len = iov_iter_count(i), .flags = IOMAP_WRITE, }; - int ret; + ssize_t ret; if (iocb->ki_flags & IOCB_NOWAIT) iter.flags |= IOMAP_NOWAIT; while ((ret = iomap_iter(&iter, ops)) > 0) iter.processed = iomap_write_iter(&iter, i); - if (iter.pos == iocb->ki_pos) + + if (unlikely(ret < 0)) return ret; - return iter.pos - iocb->ki_pos; + ret = iter.pos - iocb->ki_pos; + iocb->ki_pos += ret; + return ret; } EXPORT_SYMBOL_GPL(iomap_file_buffered_write); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 431c3fd0e2b598..d57443db633637 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -720,8 +720,6 @@ xfs_file_buffered_write( trace_xfs_file_buffered_write(iocb, from); ret = iomap_file_buffered_write(iocb, from, &xfs_buffered_write_iomap_ops); - if (likely(ret >= 0)) - iocb->ki_pos += ret; /* * If we hit a space limit, try to free up some lingering preallocated diff --git a/fs/zonefs/file.c b/fs/zonefs/file.c index 132f01d3461f14..e212d0636f848e 100644 --- a/fs/zonefs/file.c +++ b/fs/zonefs/file.c @@ -643,9 +643,7 @@ static ssize_t zonefs_file_buffered_write(struct kiocb *iocb, goto inode_unlock; ret = iomap_file_buffered_write(iocb, from, &zonefs_write_iomap_ops); - if (ret > 0) - iocb->ki_pos += ret; - else if (ret == -EIO) + if (ret == -EIO) zonefs_io_error(inode, true); inode_unlock: