Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2820449rwb; Mon, 7 Nov 2022 19:05:40 -0800 (PST) X-Google-Smtp-Source: AMsMyM65bxpWtoDQGiFIRLteQ1q1fg0Hy10PhnBs9DT9gC/GB/Z0WKWRd8HHd5cvh7BNjw4YTmZX X-Received: by 2002:a17:906:1c52:b0:7ad:c6c5:eae8 with SMTP id l18-20020a1709061c5200b007adc6c5eae8mr44675350ejg.439.1667876739987; Mon, 07 Nov 2022 19:05:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667876739; cv=none; d=google.com; s=arc-20160816; b=ER6rj/tOrVcW7WMOg0kZqFvDtIyFGCMGt6Wid5gp7QO0gmDdIkXyAjRqDL1v1/whi3 yZC3VN5w+PU/hafIMyb/+BkFIRu2RxlTjMGAMuT6vLiblHczB5qzIKdpm3G07Dh5F1nH tJGJgr/RFypHpYsX3lzI2m0ypsnH5YtGwHvF4enBoPlrfDF3EGPolk2q5Mcc0U3yBILR MFTwzYyoaNauYrdFoGygPV+GTUiNE9sAfzCvWVReBxWhI0zZv5mQVZlue/yN+xwFR6N0 ie8NzET96nrHB39vAS2GXHzpJ1nK+ZUSjxPplqyzZQR5JnoSiJizU9Zg6dnhDgdzIIKx T86A== 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=gUjiDEavNxY+NuoOs/0lQmJ24gm9QxhRGI2wq9M8A6c=; b=X9YAzVL50rJdmflXMMS0+mM2FgmpqZAbZj+Pkhe7wN6kmzQIy5nDp803Fc+3kBf4i9 j8bzK/EgkUUUDRppwMB9mgFYHkjyue8vh0C5o+K/5XZLrIffJGu3fsYI2vbEk3/zKKwd T9JmpEQ34MoKyTKl5kvnNtLWM9BPKxfaFbLP6wzGX3I49SJPTrt9UwUo2CVtbjdhk3QF BcEAjWCVFq2heKuEugYDXIWWS0I+zXiZj6pz4YmWfCD6St35761K5i5MtX6uGSuQfArv x73WFJbYSbiEz3csIA1tp8GCtBaq9b23Dn9DOEF+8ChXIC7r3M/EarXejnBWIAOVHFz4 64uQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne25-20020a1709077b9900b007adc4a0aeb5si11454391ejc.873.2022.11.07.19.05.18; Mon, 07 Nov 2022 19:05:39 -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 S232884AbiKHC5M (ORCPT + 91 others); Mon, 7 Nov 2022 21:57:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233055AbiKHC5K (ORCPT ); Mon, 7 Nov 2022 21:57:10 -0500 Received: from out30-43.freemail.mail.aliyun.com (out30-43.freemail.mail.aliyun.com [115.124.30.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09DA51B9C6; Mon, 7 Nov 2022 18:57:08 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R791e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046060;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0VUHLUO9_1667876225; Received: from localhost(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0VUHLUO9_1667876225) by smtp.aliyun-inc.com; Tue, 08 Nov 2022 10:57:06 +0800 From: Jingbo Xu To: dhowells@redhat.com, jlayton@kernel.org, xiang@kernel.org, chao@kernel.org, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 0/2] fscache,cachefiles: add prepare_ondemand_read() interface Date: Tue, 8 Nov 2022 10:57:03 +0800 Message-Id: <20221108025705.14816-1-jefflexu@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 v2: - patch 1: the generic routine, i.e. cachefiles_do_prepare_read() now accepts a parameter list instead of netfs_io_subrequest, and thus some debug info retrieved from netfs_io_subrequest is removed from trace_cachefiles_prep_read(). - patch 2: add xas_retry() checking in erofs_fscache_req_complete() [Rationale] =========== Fscache has been landed as a generic caching management framework in the Linux kernel for decades. It aims to manage cache data availability or fetch data if needed. Currently it's mainly used for network fses, but in principle the main caching subsystem can be used more widely. We do really like fscache framework and we believe it'd be better to reuse such framework if possible instead of duplicating other alternatives for better maintenance and testing. Therefore for our container image use cases, we applied the existing fscache to implement on-demand read for erofs in the past months. For more details, also see [1]. In short, here each erofs filesystem is composed of multiple blobs (or devices). Each blob corresponds to one fscache cookie to strictly follow on-disk format and implement the image downloading in a deterministic manner, which means it has a unique checksum and is signed by vendors. Data of each erofs inode can be scattered among multiple blobs (cookie) since erofs supports chunk-level deduplication. In this case, each erofs inode can correspond to multiple cookies, and there's a logical to physical offset mapping between the logical offset in erofs inode and the physical offset in the backing file. As described above, per-cookie netfs model can not be used here directly. Instead, we'd like to propose/decouple a simple set of raw fscache APIs, to access cache for all fses to use. We believe it's useful since it's like the relationship between raw bio and iomap, both of which are useful for local fses. fscache_read() seems a reasonable candidate and is enough for such use case. In addition, the on-demand read feature relies on .prepare_read() to reuse the hole detecting logic as much as possible. However, after fscache/netfs rework, libnetfs is preferred to access fscache, making .prepare_read() closely coupled with libnetfs, or more precisely, netfs_io_subrequest. [What We Do] ============ As we discussed previously, we propose a new interface, i,e, .prepare_ondemand_read() dedicated for the on-demand read scenarios, which is independent on netfs_io_subrequest. The netfs will still use the original .prepare_read() as usual. Jingbo Xu (2): fscache,cachefiles: add prepare_ondemand_read() callback erofs: switch to prepare_ondemand_read() in fscache mode fs/cachefiles/io.c | 75 +++++---- fs/erofs/fscache.c | 259 +++++++++++------------------- include/linux/netfs.h | 7 + include/trace/events/cachefiles.h | 27 ++-- 4 files changed, 162 insertions(+), 206 deletions(-) -- 2.19.1.6.gb485710b