Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2063055pxa; Mon, 3 Aug 2020 06:37:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBBjxz0qz7DjEpVpu/ao2v7DgZQFyEk/kbz4sB0ESzkjeEyORFKN1DN8MepNZTw2S2hMt+ X-Received: by 2002:a50:fb06:: with SMTP id d6mr15365083edq.165.1596461845887; Mon, 03 Aug 2020 06:37:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596461845; cv=none; d=google.com; s=arc-20160816; b=X1/04qSCvlKzg+TO7flMuLxhNFePDkyxv3w3mhXt5QL11jhHuDwnr8eT2ZRQstx7a0 +KTXU9XvB4P9zgjlnVjks4cWffOUY1e4716W6bm7paY1LjS9cu03ZjG9f0VONozbMTaM h+xGSFwwrW8I9CEZjkiKDpoUpVa4MPuB3jEbiywhzPuwaqn8lpSTKE3eY3WUexeIdXuE y66oVE6IpJct/XlNuHkRCPhijDEJPkkzvXk5vV2xKnJs2UlK1kHUKwu5uUJx4M9sUEqW LM2HfLywaimETR7hN7AniSkGi+UVy1fN/9v/uEvokF0j30LoOyOtUuJP0nWf6Rmxt8Fp 6vYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=7+vzuxe/5XjGwe/GuFGIwy7OmInPd2x4YKWYHE8bR2E=; b=Z4PIwnsKMtJ1Eg5NcjRmmIPH3EU5TJD8qx8Dkp1VXUu+poJBpFp76T8qkyrNrcxfEF 9VrT+rgEPMZd7194HF9cWzJd4zd0+e+TuidY0hVLv/G+/buhoo81/xkAYD9pAZgBgZHz 2/DnVS2l2JL5KDouAFcpOQ45jylmvVtQlNmzjNL2C8m+WLJm+1ze2c6jUKVVUOWv8702 QP/I+CxNCwQEjfhPVdIo1ozhDFLCWbQyUtZWEv4Q+3KmfL3Cb6KhOtesPSeV6CEXPlyd 7kCdn4cUicCwQUu5vcwNNG3brKlcalvmhH5XliPIzZiZH+E2b6y1ZaRAXf6ehR4h+Sr5 oy9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ggWo7IC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dm12si12638437ejc.675.2020.08.03.06.37.03; Mon, 03 Aug 2020 06:37:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ggWo7IC1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727120AbgHCNgu (ORCPT + 99 others); Mon, 3 Aug 2020 09:36:50 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20452 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727098AbgHCNgo (ORCPT ); Mon, 3 Aug 2020 09:36:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1596461803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7+vzuxe/5XjGwe/GuFGIwy7OmInPd2x4YKWYHE8bR2E=; b=ggWo7IC1+REkHlG8efAX01iYW+7YEXKbmiDJBgQSWxMd5MG6PyKgZYeZQLpuuYeYnkeWSj d0o4lpQyI9gtk84D6n5WsHEAZ/YoTuF+yS0ZEW5O0G8T3H5QtIiyhr3c8TgNJtWSjRlK3D /8pDVj1iJiQACfS1foN8LW7Hat1owXw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-11--NZquvIRNb6g8gRSpMhrHA-1; Mon, 03 Aug 2020 09:36:39 -0400 X-MC-Unique: -NZquvIRNb6g8gRSpMhrHA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 59EE8106B261; Mon, 3 Aug 2020 13:36:37 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-112-32.rdu2.redhat.com [10.10.112.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC9A81002391; Mon, 3 Aug 2020 13:36:34 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 01/18] fsinfo: Introduce a non-repeating system-unique superblock ID [ver #21] From: David Howells To: viro@zeniv.linux.org.uk Cc: dhowells@redhat.com, torvalds@linux-foundation.org, raven@themaw.net, mszeredi@redhat.com, christian@brauner.io, jannh@google.com, darrick.wong@oracle.com, kzak@redhat.com, jlayton@redhat.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 03 Aug 2020 14:36:34 +0100 Message-ID: <159646179405.1784947.10794350637774567265.stgit@warthog.procyon.org.uk> In-Reply-To: <159646178122.1784947.11705396571718464082.stgit@warthog.procyon.org.uk> References: <159646178122.1784947.11705396571718464082.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce an (effectively) non-repeating system-unique superblock ID that can be used to determine that two objects are in the same superblock without needing to worry about the ID changing in the meantime (as is possible with device IDs). The counter could also be used to tag other features, such as mount objects. Signed-off-by: David Howells --- fs/internal.h | 1 + fs/super.c | 2 ++ include/linux/fs.h | 3 +++ 3 files changed, 6 insertions(+) diff --git a/fs/internal.h b/fs/internal.h index 9b863a7bd708..ea60d864a8cb 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -103,6 +103,7 @@ extern struct file *alloc_empty_file_noaccount(int, const struct cred *); /* * super.c */ +extern atomic64_t vfs_unique_counter; extern int reconfigure_super(struct fs_context *); extern bool trylock_super(struct super_block *sb); extern struct super_block *user_get_super(dev_t); diff --git a/fs/super.c b/fs/super.c index 904459b35119..21ae8afeba3a 100644 --- a/fs/super.c +++ b/fs/super.c @@ -44,6 +44,7 @@ static int thaw_super_locked(struct super_block *sb); static LIST_HEAD(super_blocks); static DEFINE_SPINLOCK(sb_lock); +atomic64_t vfs_unique_counter; /* Unique identifier counter */ static char *sb_writers_name[SB_FREEZE_LEVELS] = { "sb_writers", @@ -273,6 +274,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, goto fail; if (list_lru_init_memcg(&s->s_inode_lru, &s->s_shrink)) goto fail; + s->s_unique_id = atomic64_inc_return(&vfs_unique_counter); return s; fail: diff --git a/include/linux/fs.h b/include/linux/fs.h index f5abba86107d..28a29356eace 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1564,6 +1564,9 @@ struct super_block { spinlock_t s_inode_wblist_lock; struct list_head s_inodes_wb; /* writeback inodes */ + + /* Superblock information */ + u64 s_unique_id; } __randomize_layout; /* Helper functions so that in most cases filesystems will