From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B90CC54EE9 for ; Fri, 16 Sep 2022 09:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbiIPJBS (ORCPT ); Fri, 16 Sep 2022 05:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231132AbiIPJAl (ORCPT ); Fri, 16 Sep 2022 05:00:41 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B443728709 for ; Fri, 16 Sep 2022 02:00:13 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id r23so11181157pgr.6 for ; Fri, 16 Sep 2022 02:00:13 -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=iEzb9HK8KHfeOzls8+GISrwCsRaN3ytpe+kCbEKskwk=; b=DVO8CqAbRZ+yuYZTJ7CS7HeeYkIq8qDtVlU+qfvFfkG/QE8i659DpmUZcGP7gBCc10 viUUvhMTkzUHbf49O8rmr4kglc1kPxeSIOzmtQtnhgqrhMw2nOqtG4AJh2CjygJu7Yny QOr52J//uCAkeH+3uPUL5/0aL+u5zFFARzUT8JkVYOrVWZueRFYlLi3Ba1SvZt+Uk2Vx nMoF2go4xAlEEpzs9S4ifJI1Es35oPFPC5YFXMCw5HWPyFtwL4nCwNQ1fvceA221mdx4 CW6VghI+Pe/IN0NWBsKsSxns99XOMT2QulB0LNtStQGRJBRNWxWX2qC0I4vphw09fvXo 2fAA== 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=iEzb9HK8KHfeOzls8+GISrwCsRaN3ytpe+kCbEKskwk=; b=wz6FJ/XeaGGFfWhk3XQuJAWDRsSPlp9yOv0yMyqTX98TZBu4yZARqwHZYpVHrc/LA6 rHhfbMq6znC9pyL5FSwqXgxiYfwNM23lGNz7sw8lvH5SMrGGZd86pMbgegaPBO2N8ZxJ dx1UTygQRQ4YePwSfP6slEDy1F1aMb/IJXyOTHg5ooAON7SWfEFdnknbV9eCdF/5pEV9 r3vt6TYeM3rZJMN2tyXi1Qb3T8TGVF3tqE9wY6vLN2rmhu3p4WhZ/lzhJXu24trQwzhn f4cbz4RT8LtZStHiaCGK44mUoqKA9Mtj0Hu2z878LRmcHoiU8p4Ianggr9t6Nhp0SQNn 3jgA== X-Gm-Message-State: ACrzQf1bVzwJChC+bk9mxljTKW605wCZNWkxCu2BJsA4Eee3eZBGTMka dTcXlv4EAg5Trq9SQffAcene9w== X-Google-Smtp-Source: AMsMyM7bKl1Vfe4YAQVoqlwzgw1wGBqaMakUqUIVjaFKI/HT98YObmSlD5XT54ZCIDeCV3T/n+z4tA== X-Received: by 2002:a05:6a00:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr3780465pfm.27.1663318812997; Fri, 16 Sep 2022 02:00:12 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id u11-20020a17090a450b00b001fd7fe7d369sm970578pjg.54.2022.09.16.02.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:00:12 -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 6/6] erofs: introduce 'domain_id' mount option Date: Fri, 16 Sep 2022 16:59:40 +0800 Message-Id: <20220916085940.89392-7-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220916085940.89392-1-zhujia.zj@bytedance.com> References: <20220916085940.89392-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Jingbo Xu --- 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 ab746181ae08..9f7fe6c04e65 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); } @@ -916,6 +930,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; } @@ -1068,6 +1083,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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C6E8C54EE9 for ; Fri, 16 Sep 2022 09:00:21 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4MTShM6Bdbz3blb for ; Fri, 16 Sep 2022 19:00:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=DVO8CqAb; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=bytedance.com (client-ip=2607:f8b0:4864:20::432; helo=mail-pf1-x432.google.com; envelope-from=zhujia.zj@bytedance.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bytedance-com.20210112.gappssmtp.com header.i=@bytedance-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=DVO8CqAb; dkim-atps=neutral Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4MTShF5tP6z3c2q for ; Fri, 16 Sep 2022 19:00:13 +1000 (AEST) Received: by mail-pf1-x432.google.com with SMTP id b23so20600523pfp.9 for ; Fri, 16 Sep 2022 02:00:13 -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=iEzb9HK8KHfeOzls8+GISrwCsRaN3ytpe+kCbEKskwk=; b=DVO8CqAbRZ+yuYZTJ7CS7HeeYkIq8qDtVlU+qfvFfkG/QE8i659DpmUZcGP7gBCc10 viUUvhMTkzUHbf49O8rmr4kglc1kPxeSIOzmtQtnhgqrhMw2nOqtG4AJh2CjygJu7Yny QOr52J//uCAkeH+3uPUL5/0aL+u5zFFARzUT8JkVYOrVWZueRFYlLi3Ba1SvZt+Uk2Vx nMoF2go4xAlEEpzs9S4ifJI1Es35oPFPC5YFXMCw5HWPyFtwL4nCwNQ1fvceA221mdx4 CW6VghI+Pe/IN0NWBsKsSxns99XOMT2QulB0LNtStQGRJBRNWxWX2qC0I4vphw09fvXo 2fAA== 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=iEzb9HK8KHfeOzls8+GISrwCsRaN3ytpe+kCbEKskwk=; b=G5v5i4N0ove8pbnYFU5Gahg+npXGD4576F8aGlQmL+4Esc5+7hqbO5wmMYy/1IEbIv s56TbyRf7bzOerR4VMz0JBi74j0Fia8R+U/3a5hRq3GM7LD4VV07yC2UV6ZMKKqVyfRV iRirzJQJ0UMQrGwYcchu+oUe3O3VIN3ROly2flk1p3WGOcxQ1RRLIFldjfbCSc2gheJg ffj2rX3UDARQuexBSkaijlHOI7HpBdHsEQTHSx6mrG5y1j3pN29q4I2qfKop35ok+kId lfg+lW3cfK0F9vc7yBvpEXeaRBXw9ev4ptKQaf/v1ItCx9q58rm6G879ld3e/ojetCAm nmGw== X-Gm-Message-State: ACrzQf1b+0fuCvKSe4u/ncarJ+Rk2N2dt09V7QR2H1Xm9r8oXozP365j yXzuBN6aouZ6538tELHer24Kdw6EwMThJw== X-Google-Smtp-Source: AMsMyM7bKl1Vfe4YAQVoqlwzgw1wGBqaMakUqUIVjaFKI/HT98YObmSlD5XT54ZCIDeCV3T/n+z4tA== X-Received: by 2002:a05:6a00:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr3780465pfm.27.1663318812997; Fri, 16 Sep 2022 02:00:12 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([61.120.150.76]) by smtp.gmail.com with ESMTPSA id u11-20020a17090a450b00b001fd7fe7d369sm970578pjg.54.2022.09.16.02.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 02:00:12 -0700 (PDT) From: Jia Zhu To: linux-erofs@lists.ozlabs.org Subject: [PATCH V5 6/6] erofs: introduce 'domain_id' mount option Date: Fri, 16 Sep 2022 16:59:40 +0800 Message-Id: <20220916085940.89392-7-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20220916085940.89392-1-zhujia.zj@bytedance.com> References: <20220916085940.89392-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" 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 Reviewed-by: Jingbo Xu --- 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 ab746181ae08..9f7fe6c04e65 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); } @@ -916,6 +930,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; } @@ -1068,6 +1083,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