Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5365783rwd; Wed, 24 May 2023 00:10:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6d0ENrhPjjvpquCsYNhiv2ZuZAmXH7yyT/5foO/fTzWojEfwiM+rq9uIOqPn3TOu/Kv6/u X-Received: by 2002:a17:902:ef94:b0:1ab:1241:f671 with SMTP id iz20-20020a170902ef9400b001ab1241f671mr15141714plb.29.1684912258379; Wed, 24 May 2023 00:10:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684912258; cv=none; d=google.com; s=arc-20160816; b=D8MjW7qlkhF8FtMVANtoWXKN1hhAJKn4b8TcWd293+if6o6rsXwM86LgPjK+4qhuUV 0Aofxmi9vINgNANf1FC8epkq4Go32gcM0CRIpvm8NTZY1GaR2EjuY21akTZZ7nrDnp1u HCVVPFUgLLLGwzC/2IO8U4geEHdzrebdvno5eE9daMr+K6YC+rQ6UmJYeBtSiJz+rQQ5 g0J1Q8e48Kg+I5urFd9hq4BG/T1seGiZJ7hdFwrLCbcGVZtBfAwJSQ/YGdD/4XoNrNgu XnwDqqD8dIlN9H103Efvd/S4E7j069T7wkTaQjR2dJAlJQXH2zvmujPJBZO/9Xsj4Xj6 x7AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=q4naoP/v86EKmAo+u6ifRRW3QrLb6CXC2bVZOo7DIRg=; b=WDgo+lXjsVAW9lDgA+B1pwASPnMrRuRxE0+x78zOQnGD5hhFaGmDEYTZvgbj6HXrwh YkItpHNWNdU8T4gNFNxnaPeBD0sxsQfzkog5wZs+iTz5fnpR4zn6R5xb0Xn8aK98mnd6 +QR0HZv6Sd4WtmV4a+OEjbfsLyvcxW77KSxDHcpCpjqUcG3DlZQuFxlybPjkkEqshe4A 4+lQX3GDgYhw4oxLvUJR2mGWcGnwxwRuyUWllUe/ibCLNOQBh7m7kQoLK64X7r9gbbZY /bAd+8YxQfCLAbSD7pZWOl5R9lYkHYZwJDNcjClHMx0MDPFxh4j3fYxHRArojJsx/1vf Nxfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@szeredi.hu header.s=google header.b=CfBlFjin; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e19-20020a170902ed9300b0019ca5ddecfesi753051plj.92.2023.05.24.00.10.44; Wed, 24 May 2023 00:10:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@szeredi.hu header.s=google header.b=CfBlFjin; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=szeredi.hu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239947AbjEXHKP (ORCPT + 99 others); Wed, 24 May 2023 03:10:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240030AbjEXHJt (ORCPT ); Wed, 24 May 2023 03:09:49 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B7219B2 for ; Wed, 24 May 2023 00:08:00 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-51408729f43so1324160a12.0 for ; Wed, 24 May 2023 00:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; t=1684912054; x=1687504054; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=q4naoP/v86EKmAo+u6ifRRW3QrLb6CXC2bVZOo7DIRg=; b=CfBlFjin9AiglVZYNj73FBrJiDD1bgOexikX1Ibnhzpuzz+5EcbqenYVDEno0ACDa2 djfaNXoukq6AOI2QGVjbJUY4tHB5nQ6aQa9Gdah0n42uhwzekGmDHDHIYrNrS1Zi1uq7 d0cnXvOfRcG2l6Z3wViMElw5AIOQmwbbeQ2o0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684912054; x=1687504054; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=q4naoP/v86EKmAo+u6ifRRW3QrLb6CXC2bVZOo7DIRg=; b=M4YEG/6nPA4F0RocLDrenO0JtM9punVYykwxqk7g1sKS9jmm1tRNYYiSGq/DS+rBWr YvKrMBV4XN3AdzzyWUNIaXmWDRf/OKzVBJPUYoVOmVwWNj53OTn+YltrLzrpoKYRJJ1z 7dgHnpdZnTuZbhH62rQW8CighfvzvaEUQbD/O5G+ex70kgWKzQDCiGEsufIiSiHq4AQP W9ssmz5t/qa7Xa50VN0SMb09aNDFeFcAPhUoZStJ6CRT/NIo/Mgux+1xgIZn9kB+GtIS wGNj7xiBti8CUavZXnBhTXjhvHVd/sLqyLPW24JQFkKJpdW9EJRhHlDGxb7ErbE8XuNd yaNg== X-Gm-Message-State: AC+VfDyOAfB4odlghrdI6mnTroU3EBt99Kz0lBzTUbK96pazTfFftOTu PsCASAkubDpZaVsYMRHNq+MT7JmBehAmsWo045gRqg== X-Received: by 2002:a05:6402:2792:b0:50d:83d4:6174 with SMTP id b18-20020a056402279200b0050d83d46174mr1222660ede.12.1684912053956; Wed, 24 May 2023 00:07:33 -0700 (PDT) MIME-Version: 1.0 References: <20230524063810.1595778-1-hch@lst.de> <20230524063810.1595778-11-hch@lst.de> In-Reply-To: <20230524063810.1595778-11-hch@lst.de> From: Miklos Szeredi Date: Wed, 24 May 2023 09:07:22 +0200 Message-ID: Subject: Re: [PATCH 10/11] fuse: update ki_pos in fuse_perform_write To: Christoph Hellwig Cc: Matthew Wilcox , Jens Axboe , Xiubo Li , Ilya Dryomov , Alexander Viro , Christian Brauner , "Theodore Ts'o" , Jaegeuk Kim , Chao Yu , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org On Wed, 24 May 2023 at 08:38, Christoph Hellwig wrote: > > 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 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; Wrong endpos. > > - err = filemap_write_and_wait_range(file->f_mapping, pos, > + err = filemap_write_and_wait_range(file->f_mapping, > + iocb->ki_pos, Wrong startpos. > endbyte); > if (err) > goto out; > > invalidate_mapping_pages(file->f_mapping, > - pos >> PAGE_SHIFT, > + iocb->ki_pos >> PAGE_SHIFT, Same here. > endbyte >> PAGE_SHIFT); > > written += written_buffered; > - iocb->ki_pos = pos + written_buffered; > + iocb->ki_pos += written_buffered; Already added in fuse_perform_write(). > } 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; > } > > -- > 2.39.2 >