Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1884431rwn; Fri, 16 Sep 2022 02:15:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AtaMyF6vRKOg6anEuDz6JzOKoMUhg3FetSc+9Ttvz6rN4//+/KPSkmIe9VeDrpys7C3w0 X-Received: by 2002:a05:6402:b85:b0:44e:dad7:3e24 with SMTP id cf5-20020a0564020b8500b0044edad73e24mr3289053edb.264.1663319740519; Fri, 16 Sep 2022 02:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663319740; cv=none; d=google.com; s=arc-20160816; b=XrtgVqDwjwex2qqZlgxOOCSGy6HVbeOdeKJSk+M3SClrqtwmCqAF6r9GKdF7qnjAhM SE/hNS8jezp/FMNTh6CY/g1weJDyanMBPqbwnQEJGESUQsyBsV7bHhRmq3vrxJd2jkUD kNjSmySRcMaEtRKrxSq/JQTRh6Os+0VIhef+rxCEZAMxCu+ZXkJGaszs18fv23Gg8H0k cH1b+ug3eTIDw6fYznklwjurQKAi032hZE68Eb5gZXUzEyH5US1hFEKdr0rClGYoVhF7 5fbinnUAOS1BKuuh2FMbMFekL7BypevBFZKJy9/zP0ElbqPGQC4c579fIhqU42Gq+M1B l5EA== 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=bpay7ieFN7L2BD1r82YunERmYrsWOu8zYKex4r+0oWE=; b=MZgqakShM7Sy23w2c+F12F20WzE2TRhBCRj8Z0pUQa/wMTN+wQRN5QVVQ0k3FoKJ/M 4d2qMCOKj96ujN1NQ7yLOhNrKOhAqLAxr5tmVY8y/s9WOMa/M+9MfkMsOsr5B9hF4FP5 L03ovAmmangxaVKcET8LoG61uBwOdboYrKfA914vXdImLu4rrej+bEtRIwI5+ohHiAoQ GrJxEjAs6ssr36Tu4OMbK2LiNIuR6teRW1r0ifjZKBiJweVk2gF/I7IdsXo3yGsXIrwy GNyzh22yXX6lxeaXEXUIOaAReMHDs1MFX7ZCUzlhdbyutUlqDGFZTjDyjfwtmrGwzDpJ RjCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=PFppksqT; 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 nb41-20020a1709071ca900b0077f5096f6edsi12742758ejc.592.2022.09.16.02.15.14; Fri, 16 Sep 2022 02:15:40 -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=PFppksqT; 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 S230473AbiIPI75 (ORCPT + 99 others); Fri, 16 Sep 2022 04:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbiIPI7z (ORCPT ); Fri, 16 Sep 2022 04:59:55 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A353CE03E for ; Fri, 16 Sep 2022 01:59:51 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id y11so3486692pjv.4 for ; Fri, 16 Sep 2022 01:59:51 -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=bpay7ieFN7L2BD1r82YunERmYrsWOu8zYKex4r+0oWE=; b=PFppksqTikwmeE7hjwS3gKaMSubi4w8nin/s0f8Y78blL3QN/srJIxl00OgBygNxxA uLI5mknRGe/QUsBXg9PkfQmXDGapb6+kTcRr+Lb70NU6v8BtWyZLb8TTMHvAowT+nd7O 4s1QoXILXUqDbnyvPzYatuaq56I/HklY5hg+QOQzm9ekqYJuWl/W71mIL2i+26LwII1C Rmmar2t20U21mDlS/JXBLr8i/QN6tKr6tuPVPq8iXGj6k+eeVoayxnV+udj7Gfxz4an/ 1sNkvPSKFMgw4Z6VnDjtxmEJuLafHwNNkn23SdnjgMqomPPmkCyIsE35YTK9jOPJvEMb l2Ug== 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=bpay7ieFN7L2BD1r82YunERmYrsWOu8zYKex4r+0oWE=; b=62qS+3gVn6rI441idYv8NyBEnugyZVxTdQk8udt1Y1KkHYXhIUKfekSDOw0TiJrnxp W+nLbEdZQuR15ChChUcrKdabMfHe9Y7/NH8hBsEaRlG9Y1VXHu+JLqpJlxpGPmNigHZn HEKvfCEeQ28JoCuNYWrrpTPA/+/3+T7ltJ0t3UpvfBkXbAKWyjs3saHGWB07F+KuZvnE QBIVN7voX3hGl8/CLHxtH7EqNL1GAbxi7YX80Mc1Yv12TdnC13kiYQQbD2zMerRJQTQ+ bveU4ptcReVUmxThgKdqZgDNzz8XM86o+0DiNLDJDF3CIsze+wJLYqi2B7NYZo0Ru1Oy a4cw== X-Gm-Message-State: ACrzQf0CoV8nYKvI5r8LLY1h9AX7/A3m5S37rm2dQa9RvP3HWIBGmhBk vdbZIW7PDXX73Lw6i5fA0u+5AQ== X-Received: by 2002:a17:902:e212:b0:178:5c:8248 with SMTP id u18-20020a170902e21200b00178005c8248mr3884974plb.102.1663318790508; Fri, 16 Sep 2022 01:59:50 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id u11-20020a17090a450b00b001fd7fe7d369sm970578pjg.54.2022.09.16.01.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 01:59:49 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, jefflexu@linux.alibaba.com, Jia Zhu Subject: [PATCH V5 0/6] Introduce erofs shared domain Date: Fri, 16 Sep 2022 16:59:34 +0800 Message-Id: <20220916085940.89392-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 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 V4: 0. Relinquish the volume after mutex unlock in erofs_fscache_domain_put(). 1. Use kill_anon_super() instead of kill_litter_super() to umount pseudo mnt. 2. Extract erofs_fscache_relinquish_cookie() to reduce lines. 3. Add code comments. 4. Remove useless local variable initialization. 5. Add "Fixes" line to patch 1. 6. Add Reviewed-by lines from Jingbo Xu. [Kernel Patchset] =============== Git tree: https://github.com/userzj/linux.git zhujia/shared-domain-v5 Git web: https://github.com/userzj/linux/tree/zhujia/shared-domain-v5 [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/ V3: https://lore.kernel.org/all/20220914105041.42970-1-zhujia.zj@bytedance.com/ V4: https://lore.kernel.org/all/20220915124213.25767-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 fscache-based domain erofs: introduce a pseudo mnt to manage shared cookies erofs: Support sharing cookies in the same domain erofs: introduce 'domain_id' mount option fs/erofs/fscache.c | 264 ++++++++++++++++++++++++++++++++++++++------ fs/erofs/internal.h | 32 ++++-- fs/erofs/super.c | 73 +++++++++--- fs/erofs/sysfs.c | 19 +++- 4 files changed, 325 insertions(+), 63 deletions(-) -- 2.20.1