From patchwork Mon Jul 10 18:33:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Babrou X-Patchwork-Id: 118023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp16143vqm; Mon, 10 Jul 2023 12:07:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlGs7lVRB2mUplVmESQsxPl/osaSDUQX9FHdkAX6JyemXKhFo+EAS69BnOf8kzvJhVRdm4cZ X-Received: by 2002:a17:90a:1b09:b0:263:f776:8ba3 with SMTP id q9-20020a17090a1b0900b00263f7768ba3mr11475100pjq.9.1689016077336; Mon, 10 Jul 2023 12:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689016077; cv=none; d=google.com; s=arc-20160816; b=Iaw5fGcD+gjmcmQCdJUQ57YSpGSpz+32GsS/GtkrNF4WGyeHD4YIdt9EV9nqnucGlp UlGh5suwiABs7vD1WsdWs+bG2c0a7HKCtu4l5YfCAs1sgbEJDp7ka2M1+teA9s2f4ZcB XJJsZklk0gP2f+//U90/4TQe/pyxikV+nOpj+Kig3AZrfdoEj4B0JpH2LDIAGrJYlw4m /BeJY0DuIhUpzuTyUU5f6rJjpraX6atpjxIWbJfgX+Bvg7lKAMpWkmkCe1ptaId8uc8Z q3YQCS7VnskDccKFVdbP8CN7n26IAdjKaAwd8dOcBavdPzv+X9CY/f5sX1pxvMNmWfsF qh9Q== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pg10-20020a17090b1e0a00b002631de09798si8231858pjb.53.2023.07.10.12.07.44; Mon, 10 Jul 2023 12:07:57 -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 S231769AbjGJSdq (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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771060811482402243 X-GMAIL-MSGID: 1771061722350993343 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 --- 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);