Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7753293rwn; Wed, 14 Sep 2022 04:05:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR4FHDHZ+DYaXXg8EniTh3PErt/o7c1pvAxAmf43crR+vGtHe9fBVilG67yb7rkyceMAwWCM X-Received: by 2002:a17:907:a40a:b0:77e:f3ee:c791 with SMTP id sg10-20020a170907a40a00b0077ef3eec791mr7881484ejc.384.1663153521039; Wed, 14 Sep 2022 04:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663153521; cv=none; d=google.com; s=arc-20160816; b=cqt+QgQLmZP/4obqXR1cbkJhfypwTqmhbFlQn+g9+YY1y56hdRlwRxQjzhjkwYpUp9 /0/Hqa0cuSaHfZpDOWQ3LCcX6OfObgOTyDQVC5z0teJLsnV/wBwHX14Ok6TCfrt1FGjC +6n/F/uTebLYbzY0ZKMpOxr9MuRp4X32Vu1CfbafD18tTmV5P5b2HJqK5XHF3NUSYwEN 1lpijIo+a+ugXUd6mxD7iEquFpVlT1WS2ebywEXhwx4v2VCkspkDNm/FqiD6S+kxvkUg rM9h8oiXXN++TcUgrv62aRFSXtN5wKkof3diNVfPmZ9grynZDpjVlMcXBl2Efr+Sj2th DMlg== 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:dkim-signature; bh=LYcxOKu2hY3Ck4lzUI/59K93yUcPpPY2I3tWA+VQB5o=; b=V/apGt1gkU4l90rsKZp8OFCr7NVHM+8Zuxb1d4pjb93LWL3/+7s1+3jgMWU9R04/fl hLapD3nPkK1/dUDygNHP3ukbeBaFAj/+CRnNH8D/erqTh8GN1v4/OP5Q9NGjlak20h7E DyUrZoKSXrdgbPSOOUWbg1CVqrgeZp8+PWh+9MspSAvf/ZaxUdsCsfofl/c6YaH9p+0K HAylXY4onGaek44nhcaKMlBI4XTAtrCwTETZPjQ79PB9r/2elXBJnzG25CYUXP3e65rb KAQGV5BU/wjavOO3uA8e0XuimWQj/Qhkdfj3HhzJidqntVd8s6o6OtFZnSTRevzmS4uI QSnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aadbHEus; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n9-20020a056402514900b004528a244b08si2512240edd.513.2022.09.14.04.04.51; Wed, 14 Sep 2022 04:05:21 -0700 (PDT) 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; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=aadbHEus; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbiINKvA (ORCPT + 99 others); Wed, 14 Sep 2022 06:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbiINKuw (ORCPT ); Wed, 14 Sep 2022 06:50:52 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B418C5E64C for ; Wed, 14 Sep 2022 03:50:50 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id q9so4837514pgq.8 for ; Wed, 14 Sep 2022 03:50:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=LYcxOKu2hY3Ck4lzUI/59K93yUcPpPY2I3tWA+VQB5o=; b=aadbHEusxVFO24XXVWyu75Q05FIobqxakoxHouAFdwoxQ+FHrZDSlGzoPP0O4swNXH 04lGwh4QXhef8MKGYrdZ8AtqRbgoNctImTGvoEZdf1O00zeRfAArnsStWoo9K7I6GnrH MOznkgq6WTje0gwqZDfuuD5QsOFQ433jThDTTN1iRE1RXbT979RqvEAUrzp5UHTRsw2f U7D6J4yycRG2/MYQJF66KzvrBAf/TkY6dvq504JO39VYTM3eLfTzULSLruFngwzB9uUA zvPeN7P9E7KgIUtW0G8oUAP7W3ZDezCw6F48XWb9lnNHDdVhF8dIK2hiBfywJNSwH85/ p3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=LYcxOKu2hY3Ck4lzUI/59K93yUcPpPY2I3tWA+VQB5o=; b=Is8xj7HAOoXVMJBkzBrrNVizYIRwOHzZhwvtwuZnPunog6v4e6yFC0Ft2a5/VYZDjM bk1k5J2OPFntNTs3K6uvrbSwTReOKxBVA+M43bFIaYHJcPtkgwqVwo6h/rxvMjOA4j3s yhnY83advG/nv9qGpjKYlWv2duaSpFFutS35JVO7DOyCRFYV4k9RJEtRyYHJfzFbAMS5 A46VWzrvanejBcmVVqHegMI9M/gWbKXmEJOcyXuldLQf5IokqhrO16G4fZ44PPgpp+Cw Sv/5nSMuQAsRAkQcSsdKCMYkkiCqlevxphakSiDiJe5qvXMv/wtgKQwPoIdZS+YXvAEU CS2w== X-Gm-Message-State: ACgBeo27fcMHDXcYH3VP55Cf5ABW6cxkRYNDEPw0omcHvD90N4ZUtE9L batRZ4SNknk3LVGW2Uudati9Hw== X-Received: by 2002:a05:6a00:f86:b0:547:6910:4ae0 with SMTP id ct6-20020a056a000f8600b0054769104ae0mr3316718pfb.5.1663152650260; Wed, 14 Sep 2022 03:50:50 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([2400:8800:1f02:83:4000:0:1:2]) by smtp.gmail.com with ESMTPSA id x13-20020a170902ec8d00b0016dc2366722sm10537042plg.77.2022.09.14.03.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Sep 2022 03:50:49 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, huyue2@coolpad.com, Jia Zhu Subject: [PATCH V3 0/6] Introduce erofs shared domain Date: Wed, 14 Sep 2022 18:50:35 +0800 Message-Id: <20220914105041.42970-1-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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-kernel@vger.kernel.org Changes since V2: 1. Some code cleanups: 1.1 Optimize the input parameters and return values of some functions. 1.2 Only reserve a pair of function declarations for fscache related codes. 1.3 Remove useless null check. 1.4 Replace some ternary operators to make the code more intuitive. 2. Increase the granularity of @domain->mutex to a global lock. 3. Adjust patchset structure and order. [Kernel Patchset] =============== Git tree: https://github.com/userzj/linux.git zhujia/shared-domain-v3 Git web: https://github.com/userzj/linux/tree/zhujia/shared-domain-v3 [User Daemon for Quick Test] ============================ Git web: https://github.com/userzj/demand-read-cachefilesd/tree/shared-domain More test cases will be added to: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git/log/?h=experimental-tests-fscache [E2E Container Demo for Quick Test] =================================== [Issue] https://github.com/containerd/nydus-snapshotter/issues/161 [PR] https://github.com/containerd/nydus-snapshotter/pull/162 [Background] ============ In ondemand read mode, we use individual volume to present an erofs mountpoint, cookies to present bootstrap and data blobs. In which case, since cookies can't be shared between fscache volumes, even if the data blobs between different mountpoints are exactly same, they can't be shared. [Introduction] ============== Here we introduce erofs shared domain to resolve above mentioned case. Several erofs filesystems can belong to one domain, and data blobs can be shared among these erofs filesystems of same domain. [Usage] Users could specify 'domain_id' mount option to create or join into a domain which reuses the same cookies(blobs). [Design] ======== 1. Use pseudo mnt to manage domain's lifecycle. 2. Use a linked list to maintain & traverse domains. 3. Use pseudo sb to create anonymous inode for recording cookie's info and manage cookies lifecycle. [Flow Path] =========== 1. User specify a new 'domain_id' in mount option. 1.1 Traverse domain list, compare domain_id with existing domain.[Miss] 1.2 Create a new domain(volume), add it to domain list. 1.3 Traverse pseudo sb's inode list, compare cookie name with existing cookies.[Miss] 1.4 Alloc new anonymous inodes and cookies. 2. User specify an existing 'domain_id' in mount option and the data blob is existed in domain. 2.1 Traverse domain list, compare domain_id with existing domain.[Hit] 2.2 Reuse the domain and increase its refcnt. 2.3 Traverse pseudo sb's inode list, compare cookie name with existing cookies.[Hit] 2.4 Reuse the cookie and increase its refcnt. RFC: https://lore.kernel.org/all/YxAlO%2FDHDrIAafR2@B-P7TQMD6M-0146.local/ V1: https://lore.kernel.org/all/20220902034748.60868-1-zhujia.zj@bytedance.com/ V2: https://lore.kernel.org/all/20220902105305.79687-1-zhujia.zj@bytedance.com/ Jia Zhu (6): erofs: use kill_anon_super() to kill super in fscache mode erofs: code clean up for fscache erofs: introduce 'domain_id' mount option erofs: introduce fscache-based domain erofs: introduce a pseudo mnt to manage shared cookies erofs: Support sharing cookies in the same domain fs/erofs/fscache.c | 252 +++++++++++++++++++++++++++++++++++++++----- fs/erofs/internal.h | 30 ++++-- fs/erofs/super.c | 72 ++++++++++--- fs/erofs/sysfs.c | 19 +++- 4 files changed, 321 insertions(+), 52 deletions(-) -- 2.20.1