Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35733152rwd; Mon, 10 Jul 2023 11:42:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlEaV9hfI0REGf6eO4g1s0kT6ov/ZoLFFxIpk4Nyg/joxYDhtNkgCIgbMDbhTZz9rTifvMCL X-Received: by 2002:a2e:90c5:0:b0:2b6:eddf:d1e3 with SMTP id o5-20020a2e90c5000000b002b6eddfd1e3mr9076207ljg.40.1689014545222; Mon, 10 Jul 2023 11:42:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689014545; cv=none; d=google.com; s=arc-20160816; b=QApBYmPmLguS9isWZlZP5csQHJQOHDlIq3kXXAaXhsX2Ua6Tj2Spi9SHDtkVU5QxQb 1YwYku/xgYD3CwX+CQmbKbLMtf4RgP48o0on6GJQOCrPtRk1PcrvaQghTfHG0Zdxphwr U5tB8FSkwUuyYLkJYVKTdExL+XPoQoV1Y/J17Hri7rLMr+yLEiisyB5rNBePL4GgZgZR hw9Ahtans31D4KpupccUNevmzIC1SQ7qylJ/npo7T5CBpbHfEOR8CT4xNdWEhhUjYbi3 Zx55dG7JMxGuXpsxitgAgeERm1bSlzILG9E+sqmUuu4xE4FwWlotSdmaGV1zuOFncBtq CEcA== 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=KfOFwa2MqGzUVHMgMbaymeSQf/jXq0PE9ZHxapBD3Wg=; fh=5k5WGeoc8LucMOm/YETK10Zb5Yu1BPLLzGuGCk2BMoI=; b=RZF7RBqpg+Eg8upM0DLm7e8KsdG/JPniZzBIowlOtiWK6EHivIRrE7raWr2vltOU9Z VBwtHPgJ2vdGOFWjmGLHkbCPb+azldEvAw8OdyKPgH3qfhR3H5hY4iWTgSdHrBTkAWLd KnhRrxBvJXbTt6d2EViOLn+jlEKLKr9YgCTl6LKFYtapD5wKyDQgczeUoeN2iyY38M8W QY9REcHhOf+eOtQ09aci5NupPaVS023u5tmKsdNB7gEztly8wHVd7Gt4LXcgQzBbIVGZ 2LWqCAXFkZpwAfFSz0NI+0OOQf7L0Kigxb7JOw5hzYEG8Jbes9X1KGKBbX2hmG7FdVXw YozA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=L6sqxAkY; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o21-20020a1709062e9500b0099270bd1b10si157236eji.208.2023.07.10.11.42.00; Mon, 10 Jul 2023 11:42:25 -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=@cloudflare.com header.s=google header.b=L6sqxAkY; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231448AbjGJSdq (ORCPT + 99 others); Mon, 10 Jul 2023 14:33:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbjGJSdo (ORCPT ); Mon, 10 Jul 2023 14:33:44 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16F5C198 for ; Mon, 10 Jul 2023 11:33:42 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-666e64e97e2so2456474b3a.1 for ; Mon, 10 Jul 2023 11:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1689014021; x=1691606021; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KfOFwa2MqGzUVHMgMbaymeSQf/jXq0PE9ZHxapBD3Wg=; b=L6sqxAkYvprfFLOpuEhxBMp3KNnplB0ZZcAipTraoZiFvvCxf5cGIkbNgr1XsLKwwt dYDuePFBEKrJay9FP/gc2BkJQgoUC0I4JXHljZAkscoST0FgIb9tIOctKtBoElAIOCeJ RLip2ZlDiqlYFlPsq3R684aqltWpmCQoDLRgg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689014021; x=1691606021; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KfOFwa2MqGzUVHMgMbaymeSQf/jXq0PE9ZHxapBD3Wg=; b=g0etvl8heuRWEHKkeNDq97mMBcCxagLf0407etWOPFrOCy5+NiPb9ZvT8pYNxbT39e FeKvRzd5I37V6h+mTB7hLetk8cG+rReOFYCc6nmH93kIk3n7UzXLfsSPfIFRLuklZ+7+ Q6eG/q85fomo9B6MytxGflmiElC7CN/23egf/vbxPLx4g/DOv//JquKn9sLpbSW4MgZm Tvb5JiLqBs1ssMkjQsnvJXmsOtmQYuUu0Wtij1wwvbEmw9xYAp7u9QFrs+ByoDHJXJSK 6F5jsmWuquwU3ksxXKByqhZBz+lAbqiQ6vwIpEi0tnnXaUVcnRDTnWa6J7NfOJdLdA/g K2Zw== X-Gm-Message-State: ABy/qLa7kcZDb9n8VNakHrZ546DMc67bWMYC/rnwy7B+fSOjmWqQZ+iM RFMWV8ui5ltYJPKu4usAjelwxw== X-Received: by 2002:a05:6a00:1915:b0:64a:2dd6:4f18 with SMTP id y21-20020a056a00191500b0064a2dd64f18mr12947103pfi.13.1689014021308; Mon, 10 Jul 2023 11:33:41 -0700 (PDT) Received: from localhost ([2601:644:200:aea:60e1:d34a:f5f6:64b5]) by smtp.gmail.com with ESMTPSA id t17-20020aa79391000000b00679d3fb2f92sm96713pfe.154.2023.07.10.11.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 11:33:41 -0700 (PDT) From: Ivan Babrou To: linux-fsdevel@vger.kernel.org Cc: kernel-team@cloudflare.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Greg Kroah-Hartman , Tejun Heo , Hugh Dickins , Andrew Morton , Amir Goldstein , Christoph Hellwig , Jan Kara , Zefan Li , Johannes Weiner , Ivan Babrou Subject: [PATCH] kernfs: attach uuid for every kernfs and report it in fsid Date: Mon, 10 Jul 2023 11:33:38 -0700 Message-ID: <20230710183338.58531-1-ivan@cloudflare.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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 The following two commits added the same thing for tmpfs: * commit 2b4db79618ad ("tmpfs: generate random sb->s_uuid") * commit 59cda49ecf6c ("shmem: allow reporting fanotify events with file handles on tmpfs") Having fsid allows using fanotify, which is especially handy for cgroups, where one might be interested in knowing when they are created or removed. Signed-off-by: Ivan Babrou --- fs/kernfs/mount.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index d49606accb07..930026842359 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include #include "kernfs-internal.h" @@ -45,8 +47,15 @@ static int kernfs_sop_show_path(struct seq_file *sf, struct dentry *dentry) return 0; } +int kernfs_statfs(struct dentry *dentry, struct kstatfs *buf) +{ + simple_statfs(dentry, buf); + buf->f_fsid = uuid_to_fsid(dentry->d_sb->s_uuid.b); + return 0; +} + const struct super_operations kernfs_sops = { - .statfs = simple_statfs, + .statfs = kernfs_statfs, .drop_inode = generic_delete_inode, .evict_inode = kernfs_evict_inode, @@ -351,6 +360,8 @@ int kernfs_get_tree(struct fs_context *fc) } sb->s_flags |= SB_ACTIVE; + uuid_gen(&sb->s_uuid); + down_write(&root->kernfs_supers_rwsem); list_add(&info->node, &info->root->supers); up_write(&root->kernfs_supers_rwsem); -- 2.41.0