Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp783567rwn; Thu, 15 Sep 2022 06:30:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR5SpDzhux0AZAMLLOfaMixGAUdLEsUvqksZZX4xfhqAYpm7t976ZeKz/mr6s1FggJW3iuwU X-Received: by 2002:a17:907:2d23:b0:77c:ed93:3dc3 with SMTP id gs35-20020a1709072d2300b0077ced933dc3mr15250393ejc.705.1663248616301; Thu, 15 Sep 2022 06:30:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663248616; cv=none; d=google.com; s=arc-20160816; b=bwOwYp95hUyoFh6yPcjnBtyWDlUTW2n4a++Y0EJW0tsfIXIe5Rhhjdd9scp+40yivB ZG6h1W4UpZ1OdheOovAtGatyOC2R8e0NGuVA7HCkc6bcsngkDzo1ZEmCwFC0f1CBGOAW I4N7QHF9Yc4Boi8IDZFBO2JOdXqycU64F0QmLJRWppLw0OYAvsP964qRPXVceadFjxLd gEea9c0o8LvGTgbi7u9lg2A7H5gGLEcRPFrz1chrJGb5ZPsaT8XoZtwfUmkD+6l3TKep 669m/pLWBGWbzQWlpbXmfFSoCJ8Rv5rIUbrgxfb316x2dkqNbNQP+JYINxVCu/D/aCey CzIg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dBZRlmedpxhbheR4+YN0HocAk5E9pqe8yTyKp+a8Jvo=; b=ftdmeu5c4bBu1pw6xeu05y6ynofb0zuu8jrfpeq0N27TZNRuiu7h1/TYpzwNigbqLG MlR1NzKbMd865KIGxhvMudpisaYM8chuHy4UuF6WHdkWiVL4veuWg9+/VPCX82B8+nrH uDRM5ZlRMTjVVAQaDZte8q3r6u50+sZz1idlazUxi9IJm4pQmYlBnKGSJ0OZT+sTAS+X Jftc3iNFSyjOYUAoOHDQCyFiY4oul3zcxk2+hYldtlODjH2usw0HQjrravfADvM/rbkB xDDH4nwXdYIeZ+k0kiyZoVPbxCP/9Zra3KfgZ8DqfM9qAK6ecMrFnnUwzYMHJ1lgGrbc Z6wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=wGL+P0An; 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 t6-20020a056402524600b00450f9a404aasi13665904edd.31.2022.09.15.06.29.50; Thu, 15 Sep 2022 06:30:16 -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=wGL+P0An; 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 S230242AbiIOMnq (ORCPT + 99 others); Thu, 15 Sep 2022 08:43:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230234AbiIOMnB (ORCPT ); Thu, 15 Sep 2022 08:43:01 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C529CCDC for ; Thu, 15 Sep 2022 05:42:53 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id c2so18228334plo.3 for ; Thu, 15 Sep 2022 05:42:53 -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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=dBZRlmedpxhbheR4+YN0HocAk5E9pqe8yTyKp+a8Jvo=; b=wGL+P0AnD/GNLjjT24uVsLIZwCjtnS68EAO2WcfTxZFkhvVT/imehV4PqGdD9u11lo mHxyBtFq9duyXZIiKcqegXgI67PQGZyv1FARnxfLtJPl//LGhPBirrHxsHZMHRB9DLAz Wb7SJ6apxY7SF8Pc2g4Gg9+1s6+QI4I1vJhNBvhqpUPnYW8DdTU5YdGxp5D1QKIZck9/ L6U90aBZFVaRvvbGZrdF+ClZ5VxK0ZlwgZF9Wnhn6CBxbM6PAoQhJS5v/pkDOz2mIlAa Su3CDhC0H6wTECs2IS+AbHhCLSS2SpIfTFUYeIOdDAxrJ+UmNxGT+M5DuFAWmGzDqJWT +yqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=dBZRlmedpxhbheR4+YN0HocAk5E9pqe8yTyKp+a8Jvo=; b=FLLuob4YAw0OFz01ycHZNo30eGYZEGHJQf32UIN4vk8/2zrq3UK2NpjoFDxLSu/wrS 2HTzU+9wCim+LkdDx0bGXggUhCRUSApQW6kdoLqtMMS2qHyw6KZ2Db0slH6X9la3UwB1 hd1hpDtQh2mUT4dY2Z900GnqZ9qbfrNHgqG4QgKU+a6+baJYpaYlUDJYP2TjGdyDvNFP JQelo1vwY9NYzjWP04V+vNBP6UzOZ7Wxj179HTncWN4vQaefzBDWccVu/+vwHU+ZAe1F m91I4Mrp/zIIawojzs4bq2oKBLG1gFAd5yZGIDFUXWoc8oMumXKAKusM/K7nbPJ5JHzm BO8g== X-Gm-Message-State: ACrzQf2Z2y1yVp1yF6/IlBorzvkA3Az5uJhb9zPVJMu2ULO8DIjManX9 aB3su3O9SGUtVFFJCOlEY6bdog== X-Received: by 2002:a17:903:22c9:b0:178:18a1:d170 with SMTP id y9-20020a17090322c900b0017818a1d170mr4343590plg.2.1663245772723; Thu, 15 Sep 2022 05:42:52 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id p8-20020a170902780800b001637529493esm12721906pll.66.2022.09.15.05.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Sep 2022 05:42:52 -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 V4 6/6] erofs: introduce 'domain_id' mount option Date: Thu, 15 Sep 2022 20:42:13 +0800 Message-Id: <20220915124213.25767-7-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220915124213.25767-1-zhujia.zj@bytedance.com> References: <20220915124213.25767-1-zhujia.zj@bytedance.com> 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 Introduce 'domain_id' mount option to enable shared domain sementics. In which case, the related cookie is shared if two mountpoints in the same domain have the same data blob. Users could specify the name of domain by this mount option. Signed-off-by: Jia Zhu --- fs/erofs/super.c | 17 +++++++++++++++++ fs/erofs/sysfs.c | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 24bac58285e8..5e55c4fe6220 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -440,6 +440,7 @@ enum { Opt_dax_enum, Opt_device, Opt_fsid, + Opt_domain_id, Opt_err }; @@ -465,6 +466,7 @@ static const struct fs_parameter_spec erofs_fs_parameters[] = { fsparam_enum("dax", Opt_dax_enum, erofs_dax_param_enums), fsparam_string("device", Opt_device), fsparam_string("fsid", Opt_fsid), + fsparam_string("domain_id", Opt_domain_id), {} }; @@ -568,6 +570,16 @@ static int erofs_fc_parse_param(struct fs_context *fc, return -ENOMEM; #else errorfc(fc, "fsid option not supported"); +#endif + break; + case Opt_domain_id: +#ifdef CONFIG_EROFS_FS_ONDEMAND + kfree(ctx->opt.domain_id); + ctx->opt.domain_id = kstrdup(param->string, GFP_KERNEL); + if (!ctx->opt.domain_id) + return -ENOMEM; +#else + errorfc(fc, "domain_id option not supported"); #endif break; default: @@ -702,6 +714,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_fs_info = sbi; sbi->opt = ctx->opt; ctx->opt.fsid = NULL; + ctx->opt.domain_id = NULL; sbi->devs = ctx->devs; ctx->devs = NULL; @@ -846,6 +859,7 @@ static void erofs_fc_free(struct fs_context *fc) erofs_free_dev_context(ctx->devs); kfree(ctx->opt.fsid); + kfree(ctx->opt.domain_id); kfree(ctx); } @@ -914,6 +928,7 @@ static void erofs_kill_sb(struct super_block *sb) fs_put_dax(sbi->dax_dev, NULL); erofs_fscache_unregister_fs(sb); kfree(sbi->opt.fsid); + kfree(sbi->opt.domain_id); kfree(sbi); sb->s_fs_info = NULL; } @@ -1067,6 +1082,8 @@ static int erofs_show_options(struct seq_file *seq, struct dentry *root) #ifdef CONFIG_EROFS_FS_ONDEMAND if (opt->fsid) seq_printf(seq, ",fsid=%s", opt->fsid); + if (opt->domain_id) + seq_printf(seq, ",domain_id=%s", opt->domain_id); #endif return 0; } diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index c1383e508bbe..341fb43ad587 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -201,12 +201,27 @@ static struct kobject erofs_feat = { int erofs_register_sysfs(struct super_block *sb) { struct erofs_sb_info *sbi = EROFS_SB(sb); + char *name; + char *str = NULL; int err; + if (erofs_is_fscache_mode(sb)) { + if (sbi->opt.domain_id) { + str = kasprintf(GFP_KERNEL, "%s,%s", sbi->opt.domain_id, + sbi->opt.fsid); + if (!str) + return -ENOMEM; + name = str; + } else { + name = sbi->opt.fsid; + } + } else { + name = sb->s_id; + } sbi->s_kobj.kset = &erofs_root; init_completion(&sbi->s_kobj_unregister); - err = kobject_init_and_add(&sbi->s_kobj, &erofs_sb_ktype, NULL, "%s", - erofs_is_fscache_mode(sb) ? sbi->opt.fsid : sb->s_id); + err = kobject_init_and_add(&sbi->s_kobj, &erofs_sb_ktype, NULL, "%s", name); + kfree(str); if (err) goto put_sb_kobj; return 0; -- 2.20.1