From patchwork Mon Jul 31 18:47:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Babrou X-Patchwork-Id: 128865 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2254149vqg; Mon, 31 Jul 2023 13:39:45 -0700 (PDT) X-Google-Smtp-Source: APBJJlEtJy55G1KUFqsQeYdYPT1Rgb1DtZo5Th3ll4biO8Fvy1nXAlzZA5sMsvdg1l3zcKvPtUGv X-Received: by 2002:a17:90a:c287:b0:263:5d25:150c with SMTP id f7-20020a17090ac28700b002635d25150cmr8856496pjt.29.1690835985039; Mon, 31 Jul 2023 13:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690835985; cv=none; d=google.com; s=arc-20160816; b=DlxqL12pa47pPAZBM9L0zcv+l2av7an9Sg1+9PRXTDbo6S94WheUDuDb4HwHnz7V+M qKzWU0KKN+CKDyiNl3c2pBNZDASdmnr9e0JrCkLA0684ym6n8wJ9QJ71wHczjxq2MZ8f iGl8vXUc9t7okS6Xx4VGbIj8nqJcMDfemf44U1CjZHpK9ujzxxU0iApyo/61Hyofe0aK pZRbg4AWEbvWaYu4xleT9ouK0uJHlM5clhTOvV94O4HgTwPXl+zicXhqsrZ0aWzAEo1F ReUADlGJv8AmUOajTBwhO6x2QFumk5skbVEfctm8h/HLgHW+5lKd3YD5xyAUxG7vlpfG jogA== 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=JN96jnVa8IBWwtTClB8xPfkb6N6bM5c/T3ET8uC8oJ8=; fh=ugH1Gc5vV5ALZ9QnuWWzESKcGiGyZWZUeKXDpe+mqV0=; b=SRjo/naWABPpK3QDxLudk1quFebQe0tUxEiGRHrR6oojKEaeQ+N/Gk6D2LKFxfTprb 6U2gw1gZtnTR7kd0bLjOZrVGQGyOcqNNgl0Kuvho0HS1gzm136zvDKrCdyPzGV1v39mM TkwaLX1Q+0RJf2fOgTtv81fbN6k4ghGcWBlsbIqE5ekRAVe9l8xqLo2AZrrTcdLCZ5a6 WZNVAN61zkD9FW1YYEd3HNQLrPjTs/tp+I9/3EpZGmFgaNez3+/6VNdKpezOAacMGiua vhtEQLbHDZxsb+2+Q0nl0GROly/SFeM4RE/b/CxfcahanhdiTzYILS06UY/gx4zt4Cot f7JA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=CcpnP8uI; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a170902c40400b001ae67aab6a6si8236693plk.172.2023.07.31.13.39.32; Mon, 31 Jul 2023 13:39:45 -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=CcpnP8uI; 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 S231167AbjGaSrz (ORCPT + 99 others); Mon, 31 Jul 2023 14:47:55 -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-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_Koutn=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 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_BLOCKED,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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772968276219889366 X-GMAIL-MSGID: 1772970033964519562 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);