Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6560257rdb; Tue, 2 Jan 2024 06:06:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IFT/wFlDL+MHQosATMha/uBRrtzNpChjLo3S5yVduwHKUfIPiWOSMNU6MRm74zSEpL4BO90 X-Received: by 2002:a05:6402:4316:b0:554:a3e9:a66f with SMTP id m22-20020a056402431600b00554a3e9a66fmr9304407edc.82.1704204382536; Tue, 02 Jan 2024 06:06:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704204382; cv=none; d=google.com; s=arc-20160816; b=klDf6LBz/HTrIGXI28Yn6Zga3YalbwP0FIHfcFE5XhMpJgKbBhxhbm3Sfh0YeQy+SR AyQzn/WXtYeB+iXPC+gEZpqrqK/nbVNoEYYr4aQtau5FQIGlspGY88heXFKoMY3f5r3a 29eK4cF9gsnWzuGroIsqTs8iwyJYe4ZNdEmrCoSHQFyMaxpCcSumWOEL1JgMdvleWzW6 IDVOrP285isFDixAgIg9051fB60yhmg5w/MwcVOkXAl0QSzUMBCH2CZ7wr3r0KA2ID51 vaahHWyUKkMC9D9zX3nLagvHLqRe3A0VYO0TxDs9rGNVtz2oKmEsfmKf+93EOj/zGrP0 jP8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=jHtxspFYMXLgbsoHlUfpova+2SNX3zK7sveiyj8ThoY=; fh=stGEWgWyf+JTuHf1Tm+RxwFUEwp72MLxA4B5feIA99A=; b=FHd+Tt/qSBiTLdl677XgRklCFyjqVpHZiNhrJXsY2wS/t/tYBRauiUl0ybhyKi9dkD s+TL9QCPgRG2GGKa6qiW51Ytg2YSrrdIubZruGlUuP1+qGEvL8MHzyJrECdJrEWh4Uiu bmhC0sYD7VMTSLjwhFyRSh2lefVkcyUjLIOvWxDfvE0CqOOtM2FidAh19yB5Daje1wKa rq2eENRSNA9OFLyFRvzQ9zbSH/wTVB8ZLJWQpkNfKLvs8UNsbxRb0Xo6dszf8InbLrVK Au64eFssO5nuhhKDVKOvxgEniCOdrWNkrjVvtWAUNiAO7OBmcYlIbpOAtjPTYa3MxiOR thRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h6-20020a05640250c600b00553614cb71esi11366514edb.643.2024.01.02.06.06.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 06:06:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs+bounces-860-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-860-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 49E841F22AF3 for ; Tue, 2 Jan 2024 14:06:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C16A61095C; Tue, 2 Jan 2024 14:04:28 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43699101FA; Tue, 2 Jan 2024 14:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=22;SR=0;TI=SMTPD_---0VzqtEDH_1704204253; Received: from 192.168.33.9(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0VzqtEDH_1704204253) by smtp.aliyun-inc.com; Tue, 02 Jan 2024 22:04:14 +0800 Message-ID: <750e8251-ba30-4f53-a17b-73c79e3739ce@linux.alibaba.com> Date: Tue, 2 Jan 2024 22:04:12 +0800 Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 33/40] netfs, cachefiles: Pass upper bound length to allow expansion To: David Howells Cc: Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Eric Van Hensbergen , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jeff Layton , Steve French References: <20231221132400.1601991-1-dhowells@redhat.com> <20231221132400.1601991-34-dhowells@redhat.com> From: Gao Xiang In-Reply-To: <20231221132400.1601991-34-dhowells@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi David, On 2023/12/21 21:23, David Howells wrote: > Make netfslib pass the maximum length to the ->prepare_write() op to tell > the cache how much it can expand the length of a write to. This allows a > write to the server at the end of a file to be limited to a few bytes > whilst writing an entire block to the cache (something required by direct > I/O). > > Signed-off-by: David Howells > Reviewed-by: Jeff Layton > cc: linux-cachefs@redhat.com > cc: linux-fsdevel@vger.kernel.org > cc: linux-mm@kvack.org > --- > fs/cachefiles/internal.h | 2 +- > fs/cachefiles/io.c | 10 ++++++---- > fs/cachefiles/ondemand.c | 2 +- > fs/netfs/fscache_io.c | 2 +- > fs/netfs/io.c | 2 +- > fs/netfs/objects.c | 1 + > fs/netfs/output.c | 25 ++++++++++--------------- > fs/smb/client/fscache.c | 2 +- > include/linux/netfs.h | 5 +++-- > 9 files changed, 25 insertions(+), 26 deletions(-) > > diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h > index 2ad58c465208..1af48d576a34 100644 > --- a/fs/cachefiles/internal.h > +++ b/fs/cachefiles/internal.h > @@ -233,7 +233,7 @@ extern bool cachefiles_begin_operation(struct netfs_cache_resources *cres, > enum fscache_want_state want_state); > extern int __cachefiles_prepare_write(struct cachefiles_object *object, > struct file *file, > - loff_t *_start, size_t *_len, > + loff_t *_start, size_t *_len, size_t upper_len, > bool no_space_allocated_yet); > extern int __cachefiles_write(struct cachefiles_object *object, > struct file *file, > diff --git a/fs/cachefiles/io.c b/fs/cachefiles/io.c > index 009d23cd435b..bffffedce4a9 100644 > --- a/fs/cachefiles/io.c > +++ b/fs/cachefiles/io.c > @@ -518,7 +518,7 @@ cachefiles_prepare_ondemand_read(struct netfs_cache_resources *cres, > */ > int __cachefiles_prepare_write(struct cachefiles_object *object, > struct file *file, > - loff_t *_start, size_t *_len, > + loff_t *_start, size_t *_len, size_t upper_len, > bool no_space_allocated_yet) > { > struct cachefiles_cache *cache = object->volume->cache; > @@ -530,6 +530,8 @@ int __cachefiles_prepare_write(struct cachefiles_object *object, > down = start - round_down(start, PAGE_SIZE); > *_start = start - down; > *_len = round_up(down + len, PAGE_SIZE); > + if (down < start || *_len > upper_len) > + return -ENOBUFS; Sorry for bothering. We just found some strange when testing today-next EROFS over fscache. I'm not sure the meaning of if (down < start For example, if start is page-aligned, down == 0. so as long as start > 0 and page-aligned, it will return -ENOBUFS. Does it an intended behavior? Thanks, Gao Xiang