From patchwork Wed May 31 07:50:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13261647 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 1EBFCC77B7A for ; Wed, 31 May 2023 07:51:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B82D96B007B; Wed, 31 May 2023 03:51:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B33006B0081; Wed, 31 May 2023 03:51:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FB4D6B0082; Wed, 31 May 2023 03:51:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 91C106B007B for ; Wed, 31 May 2023 03:51:12 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6947B120258 for ; Wed, 31 May 2023 07:51:12 +0000 (UTC) X-FDA: 80849779584.29.C825109 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf01.hostedemail.com (Postfix) with ESMTP id B917840014 for ; Wed, 31 May 2023 07:51:10 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lXdWtXE9; 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=1685519470; 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=2D8XoARsLusIaNOTQgxJjzpyZIj7rnVFP+jfuTSd/MY=; b=zbaYjjR1lCqvsZmxCvaNlon8rn/dSVVj+obuAapnjhqO+aLhTD3zUW1HkNgIONLjQNaoZV Z0AHTJicUlZwoEcRLqjT08fws7WwaAzc1aYbaAr1VHAPXw/O/iDFChsPoKe4zxD99XdW3B nI0cJVd/DQ0x2iOw3jyT7ihdNvpdaeQ= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lXdWtXE9; 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=1685519470; a=rsa-sha256; cv=none; b=dZ69+MP2yxEIljK5WbwekANctmBRhl89HQnUb0LGsAzQsvYvOlZtn3rvDGuOiJuGW6P7Gp 6TbY80mV6WrZ2hdyAbuZ9DEypoOSY654NKAenErtMov/HqDCMZN77v4ckNV9bbEt1FOFRG il+LpGpaJ/P3pXDBD+KdxZG6ILd/hxY= 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=2D8XoARsLusIaNOTQgxJjzpyZIj7rnVFP+jfuTSd/MY=; b=lXdWtXE9H+JciBmtuVsLbtCKPT GX5uIP0+yZkYtTfcDXxQOuFNApqhc8M9a/zDOXzkMRYwgr7TzOkpfLGgPe06Jxxcgo77pUOh6aL/V cWdk3/2TwD9HylHUqpmuONFzpVY5cXRQ56KFBc6U5yo91xVSGeiPuYQclHPRi06FBVrLcF1/VREE1 EEHcUGOTEFBntJf9n7KAFBDECmypX7Jo8o0eYSy00fkUm999rHZKipMlAd/fVmEto4kUOgxK097xh PN+BNthoICWgs8N/EnwICdmd1e51zusTZ/kvayY6r1y7C0Mo62C1gt4VCrQhJMWoYVJfZgfWJiumA Wr6wcc2w==; 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 1q4Gbf-00GVxd-1r; Wed, 31 May 2023 07:50: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, cluster-devel@redhat.com, linux-xfs@vger.kernel.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 10/12] fuse: update ki_pos in fuse_perform_write Date: Wed, 31 May 2023 09:50:24 +0200 Message-Id: <20230531075026.480237-11-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-Rspam-User: X-Stat-Signature: rztpxfusbpukn1mi5153ma7n5cxdexju X-Rspamd-Server: rspam07 X-Rspamd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mW5gtWw1l9krj7tn1c/Jv6egBgc5B1xWEz32kHl07xWe+VwIIuZ2SiWNx8iz3jsMq2VEb4biXx7bKkat2jBn2wWp2c2Okq27VNiumdeFf6j4hkVd0sATuIX/WMS1Sl5XobZex3wxHaKWXW9LsI15U+ruUpS+IVVXvR/uMrOSZuRcle5/eOOBs8XQY5ZSznzV7C/A+FrWxhE+1ltGL02m814yuXVkyn9kTcNPgoJfSmwe41CdDfQbWUqXptUmhYQP0/Im5/dhdq9nPMqMIxDaFC/+UzuZhKdevROX63GCL5nPuTYuQRDz1IftxwHW3H1n/6GbVEe794SUmz0Lgn9qIQvr6+ipBIouhiRsg215r3LtTfZEe5rNUKiXHdfCaXP2NSZeuYfgef+B5IZS5J+Yv9tkk6aS6uJ8G6GWh9QbFpIOIpCco3dqgP7JiqQ2lj7NXcUg2kTRLDwliW0ijb1KuMvzoTBpyOqwHrANAPYg= 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 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 97d435874b14aa..e60e48bf392d49 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) @@ -1341,7 +1344,6 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = mapping->host; ssize_t err; struct fuse_conn *fc = get_fuse_conn(inode); - loff_t endbyte = 0; if (fc->writeback_cache) { /* Update size (EOF optimization) and mode (SUID clearing) */ @@ -1375,19 +1377,20 @@ 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; + loff_t pos, endbyte; + 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; + pos = iocb->ki_pos - written_buffered; + endbyte = iocb->ki_pos - 1; err = filemap_write_and_wait_range(file->f_mapping, pos, endbyte); @@ -1399,17 +1402,11 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) endbyte >> PAGE_SHIFT); written += written_buffered; - iocb->ki_pos = 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; }