From patchwork Wed May 24 06:38:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13253312 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 C127AC77B7A for ; Wed, 24 May 2023 06:39:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A246280008; Wed, 24 May 2023 02:39:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55223280001; Wed, 24 May 2023 02:39:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3F3CE280008; Wed, 24 May 2023 02:39:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 2DF28280001 for ; Wed, 24 May 2023 02:39:07 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 0F6A4A08AD for ; Wed, 24 May 2023 06:39:07 +0000 (UTC) X-FDA: 80824196334.30.FC8AAC4 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id 5C46A140017 for ; Wed, 24 May 2023 06:39:05 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="2ZfYf4T/"; spf=none (imf26.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; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684910345; 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=eobR5ofZ8yxLf84yh50zZqRr7gdMKJnXJJVUfhV2d0w=; b=oqQe+s0YyBMVnp83FKMBhb+1pseR4nFzHIEZIzeYrRDoQqTMnctY/ENMmMP9J4oAa1Kq1H mpZmRU/cN+Z1GgKSPIuIvVkTxLAchp5G/o24QEouuJckfBk6hZl2pEtNUcLvFp1WCrkJ6i /Anp9X4lyUnTGFT6L1L9KIXawRB6nFw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684910345; a=rsa-sha256; cv=none; b=67qWYHYIZ2ce6yrfA0fam+8iY4Olt91eW9+xq4UZ6aXGpY3CYx//Pqo3WodFUsWo29gTBm bFbUAHb4l9v79stdLxa0dh2talZ6VIg+nkHys13l8N3aayv9fuMwCtquzxDuPy/sDijvsS Y7F4jVOmMaIPdqfwNs0Kd7QMeJWWau8= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="2ZfYf4T/"; spf=none (imf26.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; dmarc=none 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=eobR5ofZ8yxLf84yh50zZqRr7gdMKJnXJJVUfhV2d0w=; b=2ZfYf4T/+f++kX0X6NMRNZXwFn 6aJYCflJ4wEp0XLVUCdXCN0nfsQ5luRD33XEc2EqYblO0dhiYNMTUNSmJchUW/7enLAPlmHRPVTRN HrjFHfPzJiM/nyFHTY8ScCLT7mFVz+NtIFvc/acgUikn31hWmFmFJ4FMTJq/43ss5+MCXBqLVImmE A9pdpS5w9NbP2G9XPCMhi0fFgf0vvzeY/WWuMXCznPPcLFetHBcLbiKST4MtObidiE+5CIpuLwNdm pCu2aMfTqEU6JWZiCVS25Y7Gz/zN3AFzBMMo8MRaMCSzXHj+V3ehXBI9NdPv8q47zr966sS5g1e0P EcTndYAw==; 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 1q1i8v-00CVjC-1x; Wed, 24 May 2023 06:38:42 +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 10/11] fuse: update ki_pos in fuse_perform_write Date: Wed, 24 May 2023 08:38:09 +0200 Message-Id: <20230524063810.1595778-11-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-Rspamd-Queue-Id: 5C46A140017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jppukfs1y8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rr3PsF3yp3xlQXJJIQpqQhVb0RzRDz6j7MKEPb/An1eSz3ogkUs5UKvOdvPvlbdKO/w/IKdL56/GVVJsTLygC1Bsj6Uam74yUPPypaSV2gwD0E5gCcOSnUE/76X4NYurH0Vre0OLut4Rub1AuZQlnldrc5xuLjsJ8ZgIEdAXCWQnj7GNMKAOh0fLt21AOIDVUuH6wGvcg8do9aRhmPwAgqCN92slGB1guiKhxnQe+LmK88Iw05sbYUZA9GKxK/8XT2il2NqLHecFfVQwEst7grLsBoGczOl9mCxCDOxHgI0CiHX2smSEKTr7U+DmocHfHbXtodK++olx+xmFgpfp8bkolZxzDWFIxOW9T8lWmopqoRUfC+avCtzqnmh36kv/qbkgy/GHZqr+pGfa7YhGgScNU6Jpf/VW8NyvlmVcpHtR3GLFmOhsMEiZZXYNU8JwXfdzOohv2sh5JUgPz8w= 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: Both callers of fuse_perform_write need to updated ki_pos, move it into common code. Signed-off-by: Christoph Hellwig Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- fs/fuse/file.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 97d435874b14aa..90d587a7bdf813 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1329,7 +1329,10 @@ static ssize_t fuse_perform_write(struct kiocb *iocb, fuse_write_update_attr(inode, pos, res); clear_bit(FUSE_I_SIZE_UNSTABLE, &fi->state); - return res > 0 ? res : err; + if (!res) + return err; + iocb->ki_pos += res; + return res; } static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) @@ -1375,41 +1378,35 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) goto out; if (iocb->ki_flags & IOCB_DIRECT) { - loff_t pos = iocb->ki_pos; written = generic_file_direct_write(iocb, from); if (written < 0 || !iov_iter_count(from)) goto out; - pos += written; - - written_buffered = fuse_perform_write(iocb, mapping, from, pos); + written_buffered = fuse_perform_write(iocb, mapping, from, + iocb->ki_pos); if (written_buffered < 0) { err = written_buffered; goto out; } - endbyte = pos + written_buffered - 1; + endbyte = iocb->ki_pos + written_buffered - 1; - err = filemap_write_and_wait_range(file->f_mapping, pos, + err = filemap_write_and_wait_range(file->f_mapping, + iocb->ki_pos, endbyte); if (err) goto out; invalidate_mapping_pages(file->f_mapping, - pos >> PAGE_SHIFT, + iocb->ki_pos >> PAGE_SHIFT, endbyte >> PAGE_SHIFT); written += written_buffered; - iocb->ki_pos = pos + written_buffered; + iocb->ki_pos += written_buffered; } else { written = fuse_perform_write(iocb, mapping, from, iocb->ki_pos); - if (written >= 0) - iocb->ki_pos += written; } out: inode_unlock(inode); - if (written > 0) - written = generic_write_sync(iocb, written); - return written ? written : err; }