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 37560EB64DC for ; Mon, 10 Jul 2023 18:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231960AbjGJSdr (ORCPT ); Mon, 10 Jul 2023 14:33:47 -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-Google-Smtp-Source: APBJJlEqVexQ6jN2gO3KWfYqkBJoMzaqpFqQyvVnVP9eqYxWtYJk6TKV2fjLJpZdKtiKiwtFwVEYsg== 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 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