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 275E0C00528 for ; Mon, 31 Jul 2023 18:48:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231186AbjGaSr5 (ORCPT ); Mon, 31 Jul 2023 14:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229713AbjGaSrs (ORCPT ); Mon, 31 Jul 2023 14:47:48 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8E74101 for ; Mon, 31 Jul 2023 11:47:47 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-686daaa5f1fso3367465b3a.3 for ; Mon, 31 Jul 2023 11:47:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; t=1690829267; x=1691434067; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JN96jnVa8IBWwtTClB8xPfkb6N6bM5c/T3ET8uC8oJ8=; b=CcpnP8uIrewmUPxFzGigZZ3wM009a2S2lsstGRByU7TVDE4ACXyD8Q2cIWpB9vMe4V lwLjoXxULsemtIkLeCagPlwSVYxBlMwYXDOV1GvqLzv1sfzKeZbtwiVdUIVdvw5LnMVk cjbDwGJtbi39YEqp6zlMG9hewljSHKqfi6oQs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690829267; x=1691434067; 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=JN96jnVa8IBWwtTClB8xPfkb6N6bM5c/T3ET8uC8oJ8=; b=hGWZBWijiJgoQV5EhFjG/qmLEFY3DTQWqA+aZgoLIC2Hh/LMf6KzlUEFrq6UkRsJFa RTCmkAgNT1EkjwO33GQjPGTSVztviSahPfS3ZXvnjjeNTvHuS/6BqiMJGcxNW8rFw2O2 E/0rjo1OjW1CstrEzdDcPc1egl6A2zQjZ/B/q/ImFCidIg661KGtaQu1Fqda5py07Noo I6P154j3TL0nMvvz2IYT4jVbaueKtcuRofkyDj8W7Qjeb8upBZsMAnhOwVO0uw7SLsR/ T6XAw0sxNfiOx7w+WLoXV6Ht45MaaXpNoPl51AnpVKLD9ctG/wNt/VreKKi3121kRW0L 1vww== X-Gm-Message-State: ABy/qLb8CNDM1sh6RFYF9FS9OKTqTXACmJXis0vpcu2ShbUyjJCzvCJg UBkl9XA+uA33fu6TtUbmSIe8LQ== X-Google-Smtp-Source: APBJJlFFmAw8wiJvudwPvziHRcbnHNI3lcjMWLFmj8ZikGiQEC40ijLtuYe0d8UqxM6xtOdS1jKsUA== X-Received: by 2002:a05:6a21:3806:b0:13d:315f:26b7 with SMTP id yi6-20020a056a21380600b0013d315f26b7mr5548436pzb.1.1690829267232; Mon, 31 Jul 2023 11:47:47 -0700 (PDT) Received: from localhost ([2601:644:200:aea:74c2:128c:7249:4816]) by smtp.gmail.com with ESMTPSA id e21-20020a62aa15000000b006826df9e286sm8099232pff.143.2023.07.31.11.47.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 11:47:46 -0700 (PDT) From: Ivan Babrou To: linux-fsdevel@vger.kernel.org Cc: kernel-team@cloudflare.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, Amir Goldstein , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Ivan Babrou , Jan Kara , Greg Kroah-Hartman , Tejun Heo Subject: [PATCH v2] kernfs: attach uuid for every kernfs and report it in fsid Date: Mon, 31 Jul 2023 11:47:31 -0700 Message-ID: <20230731184731.64568-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 Acked-by: Jan Kara --- v2: Added a missing static and an ack from Jan Kara --- 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