From patchwork Wed May 24 06:38:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13253309 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 81E6DC7EE43 for ; Wed, 24 May 2023 06:38:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 18446280006; Wed, 24 May 2023 02:38:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 133E9280001; Wed, 24 May 2023 02:38:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3DB6280006; Wed, 24 May 2023 02:38:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id DF6FB280001 for ; Wed, 24 May 2023 02:38:48 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BB723808DD for ; Wed, 24 May 2023 06:38:48 +0000 (UTC) X-FDA: 80824195536.05.A2DD126 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id 247FC1C0014 for ; Wed, 24 May 2023 06:38:46 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dZJR1oP4; dmarc=none; spf=none (imf20.hostedemail.com: domain of BATV+8349dc162fb675e8d54f+7213+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8349dc162fb675e8d54f+7213+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=1684910327; 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=5bzp/0by06gXMZwpvo50hn7+jgjD2rUy1lubnHgSTkM=; b=Qvp/EHNEBXVIaiwvxWPQaUHdAHmmP0QzbipW7pJTbeOr5TAzsSm+63JeoD1atQRrJuqaJG +v7td6Q1p3+PnCRaPBz+ftrFdzPrpmzH3/0pxMJ5SH1ekj5QtTiNLAVcMgXGN62xo8JBlr tkLi6DSZFE/w59HDdcasJj3i2qc8K2w= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=dZJR1oP4; dmarc=none; spf=none (imf20.hostedemail.com: domain of BATV+8349dc162fb675e8d54f+7213+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8349dc162fb675e8d54f+7213+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684910327; a=rsa-sha256; cv=none; b=AIEP926v6tCpIRnG8ZcvonpCz8kQ6mu/nyzU9pwCUX7YB5eUAoTF6aJGajzGWuNwrSZFJc /DZEVOfKdMelwH5x0mXrx4ygG8OshKoP8HWm8Z7MTEy7I744NzrN2xokkZ50/BC5K2o17P hC793g6EQGYBmHiqg8g6H4X2xv8KIkQ= 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=5bzp/0by06gXMZwpvo50hn7+jgjD2rUy1lubnHgSTkM=; b=dZJR1oP4oAplc7LAjvEqiOhesB j7mrqWb9DWAuwPSwrRP2EQ4KmmmV/xPU693vKh+gRgrPd4FlnzipdL0Tf3RnH8pWT04fo2OrOt/MX N1AnYXpvNNNDzD80MVj5+yqF0hc7fZtkFgL7ZOqnTIPICju9QtDmjIBAK2jbAVsb+3FH+XPugCtsf x8MO+Ly2fr6FyFgNfot7iOnrIBg3YP7NDK2ldi9YCmXeaf0hzldjZA0PlqFpHHlViiNiMN3NJ3PDd FeEiw0uOKKPmsMpwvOBJX0eYgoM6ge9MKvyHE60E5CTNznh6tpfnhAAxqy0uCep+knDMbYOYuRMev QNE8HMIw==; Received: from [2001:4bb8:188:23b2:cbb8:fcea:a637:5089] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1q1i8n-00CVgm-2V; Wed, 24 May 2023 06:38:34 +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 Subject: [PATCH 07/11] iomap: update ki_pos in iomap_file_buffered_write Date: Wed, 24 May 2023 08:38:06 +0200 Message-Id: <20230524063810.1595778-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230524063810.1595778-1-hch@lst.de> References: <20230524063810.1595778-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-Rspam-User: X-Stat-Signature: 7tj13yb837qqca1oj9pn9p9uufke9cib X-Rspamd-Server: rspam07 X-Rspamd-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+irSzzGmTLR2lvE4RwJq24+TK8C2xL3Xo/VD11ksI3DwIvO0ZFe2xzxK3tI2xjDPkf4xS7aIfFApKTQxXG4VXspkVZwUowLTgTlo5BWGVOVvetftY8Nho3cdqDphHxDcZQDyQQ1CYcHlB8arEROE32E23+7umGuUX4b15JbJj7flvfKm9RVQR3oUa4sIzYOLxluMRh8VQHNkxHeZyuhKYw5719OsFGeMqk0/WqlmryQeq0Cw9HbCI+EDD7OQdYtu/ytZYrDpbioMj+s9HNwDlJDOSO6x1WjUp2943LFM/GVjNhX2FjjU/B9vQkl8eWzxh89QYjD7YdraPept3p+UHr0pW6qOXfsiZLr55DYfaFne1qs7Loa1WvzUbnvNjPeZwluAa/qOYjkf+Zcq/OKbyt/P7N4oFO5016sJd8PGKqcx5SJm9sc3BjuZ3MH+4CN0mOgvLrbLUwbRrhP9cRZ/0yBecITh1WU22bC1GJ8SSDapkZxBe2ZXeQUJqBk7Fjc5Rjggje44MENQJw== 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 Acked-by: Damien Le Moal Reviewed-by: Darrick J. Wong Reviewed-by: Andreas Gruenbacher Reviewed-by: Hannes Reinecke --- 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: