From patchwork Wed May 31 07:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261555 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 68375C7EE43 for ; Wed, 31 May 2023 07:20:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E025C280005; Wed, 31 May 2023 03:20:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D89CF280003; Wed, 31 May 2023 03:20:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB55A280005; Wed, 31 May 2023 03:20:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A03F9280003 for ; Wed, 31 May 2023 03:20:40 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 62514120214 for ; Wed, 31 May 2023 07:20:40 +0000 (UTC) X-FDA: 80849702640.21.0C091BF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf02.hostedemail.com (Postfix) with ESMTP id B1A0280012 for ; Wed, 31 May 2023 07:20:38 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=juedmjHF; dmarc=none; spf=none (imf02.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=1685517638; 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=QPotZX83+KGH5tmJqw2+GqSJeTIHeyDnKGkAPMFZfBMAfjcH69dg7UEEqT1q6LxADSrM8t yv0BMGrc8KJCPlxDtYATiRguyAuiSrxSx+2kcHTaI1hdQWjfD2ogXrB/f89Bi4Qup6vGsQ AQQge/gkuWSQM/7UdJaGDm49Xsc+M+I= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=juedmjHF; dmarc=none; spf=none (imf02.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=1685517638; a=rsa-sha256; cv=none; b=yZ422JyQ5rEDyuBqHlY5FOMKhGFjTRrPPb2/ktzcE8eftW47yQZnw3CevmEj7eHQU6SajF 7CX+KOLrg/V9ZQzF+WymDoqPQKcpzE6MWPz27Rplaw+f/btO2y/DYqDyOKSJueJ9N0Kkdi WC9qgqCucgAJUMOIUGPc8PytBio7wgU= 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=juedmjHFrERjVgI+I6F168RFU1 8pH8XOy3sucLV1v0mN1uWgXZCJ/dLQBD7d3VBl/n8a2N/x7DxsnF356O5Ue6J+a0dsBF+fjJTzd3l aOGNVfiVsTfKiUKyyIX4T1XXnubzaLIRwJv8n8CPQOCI+Vg53c09fBs8+EIxQr3RJ9F+A3wRPkVWA rtQiT8SCwODXG3Kl5EfHPmokqaMRG+7Ss0IgI2ZnYZV9neu8xowjG+6QkLMMCeSKyxsCLF/tXUCiR qmIjbcbIAfCWj0L6Pccxh5vJeTEW/6QWeuF8ClfTQzy8NiMHp1n9IFioL7Jm14IwGVM3KU2JFJ35V iDgZl8Hg==; 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 1q4G8C-00GPk2-0F; Wed, 31 May 2023 07:20:28 +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 7/8] iomap: update ki_pos in iomap_file_buffered_write Date: Wed, 31 May 2023 09:20:05 +0200 Message-Id: <20230531072006.476386-8-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 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: B1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ovcHUdOTX3koZ+oSnUpmNRCJWnvTUOhmrq/I3M5qGihEOrnpFGQ0c902+nEDRd2GlVnosjwRu7WL27DsSVXT0c7l3SVffeUHw94Ja4dc6aMzLkErDuWcivrzbBAciM3yv859GjrhZytpROrUo2Ew1XmHsum/6Cb8ZUXeF3BfYvm/Ff0GSJr8sCD7xkjS792i38j4OD8ZEfpSzLXPbQ0OSZxMLooqOI1EII9v4gd5/hwODR0dkFwaYq9Q5L/V3sZvcUy4P5EFSR36Yf9IJgqTJSrtEeXl7HFSw1KLNMf2bRjW/RNlDOGl2jnDTwEVRqWq8ovAbnvhOz4CABqPHL0nyFtHB8+97vG7AyxpBGUg0mP+oitr7bsFUZ4yO82O1krYZI2KpwMeF4ZQWWHXPVS166Gz5z//bchVt2oHCuduEAmPGxpeKJsoq0Ql8EtTB37tstFp2A4tn3Q9TIUSNHTf8Mhtt4Z3rLVTtvnDBjsckg/blB2fQkv5aIVOHKdzXDZC6jzqCdfz620KeTWp8b+ 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: