From patchwork Tue Feb 21 10:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingbo Xu X-Patchwork-Id: 5672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1791192wrn; Tue, 21 Feb 2023 02:41:15 -0800 (PST) X-Google-Smtp-Source: AK7set8Nxgd1o+7fv3TlVDby8PV0QQry75WMyl3YqV0rFEToAICA+vIYt9y4eVZU4WidEXFUT3Vz X-Received: by 2002:a05:6402:1482:b0:4ab:c411:8ac5 with SMTP id e2-20020a056402148200b004abc4118ac5mr2545728edv.17.1676976075357; Tue, 21 Feb 2023 02:41:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676976075; cv=none; d=google.com; s=arc-20160816; b=SB5VsqMm5cunHsycbu98lDUqZ7h3Uj3Ho8UT9VHmLReUj9rnoau50YnPVSaG3x2IYh nmuuWCypDnyxT0DF6QpIdpElmkCaJ6jCZnukAieKiTGIPgml2MlnMghKyvxlHXPzNFSk 1QzNtAAu19e6Y2IGLlJuh7T3qQlPhe5phwQRP+LHXORaxm/jUnD5CzKInHw/o4s9IXuP n3PQjInyrpptP6ne9bz7i2pfIQ1vqSWZNk6+kVV3ls9eSaSzpqTGcEZ/qEQucGrzaO4a BqVzgwz2bRRK0ok8SLDLss/rGZNo29K0Dei9WRLEaa9kYJsiCiFLDz6+mcPJssCOUNG3 PJdg== 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 :message-id:date:subject:cc:to:from; bh=KxQT0jO4Oweq7v1tNBX57LEYyKq69w448WM9oO7Jnuo=; b=xwtc1t6ojko2yhWClQ7+aFvSLn97sZ/mJy5ajFGe0alFTkWjFKkVulm/TGG3sYdgDD vdcUllTz80I4SPHBz3WFP6jEGemn5IJ2Z0BUotwPKze24NhE7JpH079SXQILNZM6iDpN PtgqaqdfwPjJdXwacGYnCQp9tm6mSKnIHBLf308oap7Pqu0wld5dV0whMFCoinhmFd64 NXRfPal0fpn9abfM+G7sIs/Ik6KgrMS6jTqDBL/8740jt1L0nsmiNHCXDchvIxjSBrCj YyLYPybKW4xqol/VyeQmCd90fFa265cLna+fhTwk9HDyAQZib+9BRHgU13dAzwUFkfQl VDag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a056402069200b004acbe0c5f69si5180761edy.444.2023.02.21.02.40.51; Tue, 21 Feb 2023 02:41:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233743AbjBUKdX (ORCPT + 99 others); Tue, 21 Feb 2023 05:33:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbjBUKdV (ORCPT ); Tue, 21 Feb 2023 05:33:21 -0500 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A9D7EE7 for ; Tue, 21 Feb 2023 02:33:16 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0VcC.gMp_1676975593; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VcC.gMp_1676975593) by smtp.aliyun-inc.com; Tue, 21 Feb 2023 18:33:14 +0800 From: Jingbo Xu To: dhowells@redhat.com, linux-cachefs@redhat.com Cc: linux-kernel@vger.kernel.org Subject: [PATCH 0/2] fscache/cachefiles: some work for on-demand mode Date: Tue, 21 Feb 2023 18:33:11 +0800 Message-Id: <20230221103313.120834-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758436865571983881?= X-GMAIL-MSGID: =?utf-8?q?1758436865571983881?= Hi there's some work to make users of fscache on-demand mode support PAGE_SIZE larger than 4KB (e.g. 16/64KB in aarch64) [1]. I think they may be also useful for other users of fscache/cachefiles. Strictly speacking, patch 1 is a bug fix though the issue doesn't cause serious harm when erofs doesn't support large PAGE_SIZE (other than 4KB). __cachefiles_prepare_write() will align the requested file range to PAGE_SIZE boundary. This is reasonable for libnetfs as libnetfs will construct an iter with the aligned file range from the ground. While for fscache on-demand mode, cachefiles_ondemand_fd_write_iter() is called by the user daemon, and thus it is unexpected to align the file range to PAGE_SIZE boundary, as the iov_iter/kiocb is given by the user daemon. If the given file range is not aligned with the block size of the backing filesystem, let's fail the write directly. Patch 2 adds a new helper, by which users of fscache on-demand mode could wait for the wrangling of the cache object and then derive the object size (set in cachefiles_ondemand_copen()). fscache_begin_read_operation() is not feasible for this purpose as in this case @want_state is FSCACHE_WANT_PARAMS and it will not wait there for object wrangling when cookie is in FSCACHE_COOKIE_STATE_CREATING state. An example use case of this helper is illustrated in [2]. Any comment is welcomed. [1] https://lore.kernel.org/all/20230221091719.126127-1-jefflexu@linux.alibaba.com/ [2] https://lore.kernel.org/all/20230221091719.126127-2-jefflexu@linux.alibaba.com/ Jingbo Xu (2): cachefiles: don't align the write IO in ondemand mode fscache: introduce fscache_begin_wait_operation() helper fs/cachefiles/ondemand.c | 3 ++- fs/fscache/io.c | 9 +++++++++ include/linux/fscache.h | 22 ++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-)