From patchwork Wed May 31 07:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261641 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 343A0C7EE32 for ; Wed, 31 May 2023 07:50:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D5746B0078; Wed, 31 May 2023 03:50:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 086DE6B007B; Wed, 31 May 2023 03:50:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF37E6B007D; Wed, 31 May 2023 03:50:51 -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 CC08F6B0078 for ; Wed, 31 May 2023 03:50:51 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9F90F4027C for ; Wed, 31 May 2023 07:50:51 +0000 (UTC) X-FDA: 80849778702.20.9CC1F01 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id E1E1A40018 for ; Wed, 31 May 2023 07:50:49 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=rp8mwzag; dmarc=none; spf=none (imf01.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=1685519449; 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=zBZfLo79n2onda8TMRoaSImQJ1x4yClUpeA3xrekMTk=; b=EgmrdCBK6pB9bPiajYFkmOVCamW8V+u/H1/m4ApLqyyDInx1mpCCGgGKYRdSH0sgedvEDj xMQL/RjwScQQUVGq9LDObJ7c49FYju+3TqflPaTA83kibFRlokDtgvrGAbZOGhPW9tr3Z0 xgu0KvFcQGQ7p2F3baV9y5KD8dpTxso= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=rp8mwzag; dmarc=none; spf=none (imf01.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=1685519449; a=rsa-sha256; cv=none; b=TjxsxnIw6up08Dr9x/ZZM/5XIJUc4IWKkpxa85RO6DYV3feHLdFddJchBtm2Pg/W5C7AwE Qk196BzVXVllholtRzu8WuCukwKwUr6CrME8Gmg4Z2/734CQre/Ihv4n8MBNJTL9GOEtuC NYVO5hSOXU0DWjXO/NSByY+B83Y9/5k= 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=zBZfLo79n2onda8TMRoaSImQJ1x4yClUpeA3xrekMTk=; b=rp8mwzagdteTZ0EXk9oVQdo1Qd tc5MZw6BKx0YGXCFQAmrduC/QSle4P0r46LzB8VqcNfa6VIs95D5MS/JwOJshsPGwbrKtTmvKuewN zvjk+SM00mwYSG7acM0n2iiX4E/D2ZFT/bMioR7WIoszzM9PJMnXK5H5hx2nqeiXPoFn8dJMv9Cg9 FpAH1BOcgSrYBAzQRKv5yjQdA+A+l0eFMLu2cO0WcozGKfjeszHvvqaI2/Omfv44j/S3xyvFjN3fs +W9WAdIpr3pT/xdVp7xohI2bPhFHcjVQn6z85d85ZvwqdNARep4OIN1/9fs0xf1FwfLnmpl30rSKV F4ujuWRA==; 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 1q4GbN-00GVny-1J; Wed, 31 May 2023 07:50:37 +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 03/12] filemap: update ki_pos in generic_perform_write Date: Wed, 31 May 2023 09:50:17 +0200 Message-Id: <20230531075026.480237-4-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-Queue-Id: E1E1A40018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature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29Rjr3Ppqd4kjSjTUsDxWPbuOO5tY1zT2V0moldBPqjauOt6fHHeGEEwpTWLY2xEyJ+kaUDt8Q04ywPqoUwq+LdeSdyKMktWLPrrpgwU5eeLE6VHSAuCZ4zJIg51C1YMIUzgt0/vBfnNCu9+kirn/8+sLN/vx36QRxkfLKPtYJ3Fl/yMuCaUYXpiwj607do1Nie1ubmSWrraw89WJQNVNGUZ0+Lbn58PFyiKM6vRlFtmTK67K8eiCXc6ajGd2uQp8u4xYohzhGhiM8DBKqC3eYyLFRpre9wOZoaCUP8gL7r9R3I4UaXna5c7DiQMT3+i6VSnP4QX3xb5nn5D0w2YhUFt27qGxQvNsxBGC8GK8+1jzWO34OwAaJMbW1hdcZIQ0JofCH43GWcUaqruS1oeX+Ru82E0FFvjhl19RTKcApT2Fpkp7LG95pgCT4wQslc24m175/2Gvtybrqm1POJb1xPSun8iSUz2Y/q0xgtDSTk8I5lB0P7cPvBtlX/rOCJy1W/EehpaP1Fd6jR7bOH870ME 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 generic_perform_write need to updated ki_pos, move it into common code. Signed-off-by: Christoph Hellwig Reviewed-by: Xiubo Li Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke Acked-by: Darrick J. Wong --- fs/ceph/file.c | 2 -- fs/ext4/file.c | 9 +++------ fs/f2fs/file.c | 1 - fs/nfs/file.c | 1 - mm/filemap.c | 8 ++++---- 5 files changed, 7 insertions(+), 14 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index c8ef72f723badd..767f4dfe7def64 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1891,8 +1891,6 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) * can not run at the same time */ written = generic_perform_write(iocb, from); - if (likely(written >= 0)) - iocb->ki_pos = pos + written; ceph_end_io_write(inode); } diff --git a/fs/ext4/file.c b/fs/ext4/file.c index bc430270c23c19..ea0ada3985cba2 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -289,12 +289,9 @@ static ssize_t ext4_buffered_write_iter(struct kiocb *iocb, out: inode_unlock(inode); - if (likely(ret > 0)) { - iocb->ki_pos += ret; - ret = generic_write_sync(iocb, ret); - } - - return ret; + if (unlikely(ret <= 0)) + return ret; + return generic_write_sync(iocb, ret); } static ssize_t ext4_handle_inode_extension(struct inode *inode, loff_t offset, diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 4f423d367a44b9..7134fe8bd008cb 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -4520,7 +4520,6 @@ static ssize_t f2fs_buffered_write_iter(struct kiocb *iocb, ret = generic_perform_write(iocb, from); if (ret > 0) { - iocb->ki_pos += ret; f2fs_update_iostat(F2FS_I_SB(inode), inode, APP_BUFFERED_IO, ret); } diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 665ce3fc62eaf4..e8bb4c48a3210a 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -655,7 +655,6 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from) goto out; written = result; - iocb->ki_pos += written; nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, written); if (mntflags & NFS_MOUNT_WRITE_EAGER) { diff --git a/mm/filemap.c b/mm/filemap.c index 33b54660ad2b39..15907af4a57ff5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3957,7 +3957,10 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i) balance_dirty_pages_ratelimited(mapping); } while (iov_iter_count(i)); - return written ? written : status; + if (!written) + return status; + iocb->ki_pos += written; + return written; } EXPORT_SYMBOL(generic_perform_write); @@ -4034,7 +4037,6 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) endbyte = pos + status - 1; err = filemap_write_and_wait_range(mapping, pos, endbyte); if (err == 0) { - iocb->ki_pos = endbyte + 1; written += status; invalidate_mapping_pages(mapping, pos >> PAGE_SHIFT, @@ -4047,8 +4049,6 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from) } } else { written = generic_perform_write(iocb, from); - if (likely(written > 0)) - iocb->ki_pos += written; } out: return written ? written : err;