From patchwork Fri May 19 09:35:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13248028 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 66897C7EE29 for ; Fri, 19 May 2023 09:36:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDD0728000A; Fri, 19 May 2023 05:36:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E64BB280001; Fri, 19 May 2023 05:36:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDE5A28000A; Fri, 19 May 2023 05:36:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BBEF9280001 for ; Fri, 19 May 2023 05:36:19 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 939C91208C2 for ; Fri, 19 May 2023 09:36:19 +0000 (UTC) X-FDA: 80806498878.10.F62896E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf05.hostedemail.com (Postfix) with ESMTP id DBDAD100012 for ; Fri, 19 May 2023 09:36:17 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jBbC+jMl; spf=none (imf05.hostedemail.com: domain of BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aecf67361b95543ec79f+7208+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=1684488977; 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=TKBAB7v33dbYW3H4NRpBXoH9tha0ccQ02cfBeOuFf/4=; b=3zW7CaIN+oleqAQdkUy/4cYnPN34YPygFDsZGyiAOEPU8LdZoUWAX8B1IXrWpWAc8qWmb5 R/SEOaiVvgYmBvR0Iz7nONRu4+EMeWLK7UIC4oh2eIZQJ5bbCpx+eTqCPvUucVL+RU7yNv WKmD8oCF9fYB8GtPnyiXR6ySvulljQs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684488977; a=rsa-sha256; cv=none; b=zeQT7GCkCfBDIN/cUaMDBxxMN344iOZDXL4SGMWgXI5kRB24fT54EhENf4A+XEobCVVHZp tX2wat/0yX0vWsx3b1SSYwV7r5iOvfDGwGVgTq+KdlvYkZVMRDnSJV8MKFcwQyX0AN9xtf qgLoSNGPm8B0KcRTcnKWCvlekM9oy/c= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=jBbC+jMl; spf=none (imf05.hostedemail.com: domain of BATV+aecf67361b95543ec79f+7208+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+aecf67361b95543ec79f+7208+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=TKBAB7v33dbYW3H4NRpBXoH9tha0ccQ02cfBeOuFf/4=; b=jBbC+jMl9D3UjfJN7p2yKZDP/I WbBFLIN3Q/AJih3OxKSHbTD9vT/F1tJobu4KuSjWuiUGnD5rFBmeuEaeD/Iu5pzKBe+WoF0cJV/pR aHdHe3VblJTeUN80/WZVfFkLjN2xPcAqkhJGTHlmMCBAXleLOTmJaaYavT1/S9aM9V0FApxTI8BsN kq2VaEl7CyULWIrWWkY30KLE99zxPFDr6mlVbG53PUvDT0Owj+1Oafd0P6BmL8cNhjdjQCmT8ZUKw mgdHI+yL0Zy6QHpBrK9tCvQI2IS8OZd316ApM4Rm2MZrQDKXQ1/k3sGBk62SyeqnLCKYpmESn7t8M izw91Nrw==; Received: from [2001:4bb8:188:3dd5:e8d0:68bb:e5be:210a] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pzwWh-00Fjj0-1m; Fri, 19 May 2023 09:35:55 +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 (open list:F2FS FILE SYSTEM), cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 11/13] fuse: update ki_pos in fuse_perform_write Date: Fri, 19 May 2023 11:35:19 +0200 Message-Id: <20230519093521.133226-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230519093521.133226-1-hch@lst.de> References: <20230519093521.133226-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-Stat-Signature: fx14dp5xj1wgxjogt1o3shtrb5nx7edz X-Rspamd-Server: rspam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1Hk6hKt8PyIeHyjrJW22BLVxGDm9+ab4uk5AYGXD90caXWdV6yyySR3C4SIlt34yH7YvVYYSWzQcAGReuLBldyBeF/ULC5WwDiJdYQ9Qg5x95Sfa+Vux3WZhK/WvpfHYt5wsePD+Lwygw1heuEYHsOjblYJt5zZEN1cWO4rYhhnjDaJswmidewX/B7WqbFFMcgF/1xGS9t3lw95XJzoKSMbmvETy5JZSb/bo0n9gxECuLOGtSvvs0Ww41V1PBftR9S6WAN1dgJFGeBkxbKpdGrvg9fJGvK9WM8aWbVjQ609b7BuHkgb8jmhSo4JefitBrTSOb+eQJDmXgA2oFq87z5gm25Z7xlbD2I19zd2k0mTDAjSnd4NxGXdQtXQqzjfZ/e38uPnOC6/Q53cLX0t9Ih+hNo1GWaksLeaWZc3fbweXCFyXXH2+Llg+bfXPnvwx48E4wZA== 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 --- 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 89d97f6188e05e..fd2f27f2144750 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) @@ -1378,42 +1381,36 @@ 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: current->backing_dev_info = NULL; inode_unlock(inode); - if (written > 0) - written = generic_write_sync(iocb, written); - return written ? written : err; }