Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2223328rwd; Fri, 19 May 2023 02:43:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7R5F8Xy41AxI6mog6/VF6jJfXeFAwGow9tVXKy7Z5s05Vcf9Ovq/D6h+O/xG7RIqfZDio6 X-Received: by 2002:a17:902:7287:b0:1a9:8ba4:d0d3 with SMTP id d7-20020a170902728700b001a98ba4d0d3mr1958590pll.8.1684489410356; Fri, 19 May 2023 02:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684489410; cv=none; d=google.com; s=arc-20160816; b=NC8Th6OpE3QUB0GWLqJv3SKAMn+jVEaUBIs8qSIfvn+2WeLSw3AxiaC5wst2gSYUXo Vw+yfonmE/P5czIyp5wDP2TDlkX10c5vxfBo74/ub4vAyIxYo+s83xmv36tI4hVAqvAi ll1OXhmqA5rTDoT/mahMQD4lJkZ4ea9WINa2O09EEQa8Tq7j3ycog/pBKf3CkNnqMqpX TqSJyTMANgPmuMRhz1ulq08zE2FjscJOBNWAR1NiBD55GCksVOsqbD9K9YU8tSbkiL5D MgDFNVXvkGMitL5iV93nhl05I/JMqel+Ovw5tFXxd1TOtzUYj7WujrC3ysDuql+chg1l Z2cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=TKBAB7v33dbYW3H4NRpBXoH9tha0ccQ02cfBeOuFf/4=; b=nKvjJFRid6nYthkKDRahBDA3TBZb9Znftj9fSdx357TlQsXiLBuxGfMq/GN0qHauKA G19veYPBaU8g1IB5gYAXfrEnHYYgKkEuiTZgdlwBQ/q8yvYVRMnz1EEUjbrAwTLPFgt9 LKz5rwKAlMKO3ojgZWzDzRBkGY4LcwboAkOU7x0I1uffCBSQ7lSbdWbQQnHPmcygrkpW WQs4wUHnvCVqUqYUsvlBi2kQGuj22PoeXWLbPcDv9njAM8RUGfk+pHVvc5ibKdx1pSnZ W0dMUnWYM4eFnsDqgxS0QUp7R26c9R+c7/SFLuheYqPvPwTd63ULsGrat00efpLB+gtg hHyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=jBbC+jMl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902ac8800b001ac2eae0714si3165020plr.358.2023.05.19.02.43.17; Fri, 19 May 2023 02:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=jBbC+jMl; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbjESJiN (ORCPT + 99 others); Fri, 19 May 2023 05:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbjESJhQ (ORCPT ); Fri, 19 May 2023 05:37:16 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF271BC6; Fri, 19 May 2023 02:36:51 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Both callers of fuse_perform_write need to updated ki_pos, move it into common code. Signed-off-by: Christoph Hellwig --- 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; } -- 2.39.2