From nobody Mon Feb 9 09:23:05 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7887C2ECD32; Wed, 14 Jan 2026 04:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365166; cv=none; b=FB0wqHXToKnjvA6g2YIA7IMDjuktjQDrwVzZRySb3ofgDhZu6SaO4CSgynzvtJ1dtYBEsjiy3XN+ygZ6M9M56fKPgTus1IA0QezWfO6U7Vu0dLTo812S6J4hlwwRq9boZFJGizyX7SFG3nmQAk1tBLqNIx07Hn/wsVg201hkfog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365166; c=relaxed/simple; bh=dE58klLdJyYeLgmYgH2S9UY8ti9ZdbpVbR2JG3eQ58s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pv0tQv7xFPpZ7Q84rmqaURCkz81S5mYNTbPBHhm9WUPDnqR1B51MknQjZLfC11kV1dxmQ30+fZ/XaXAOexxyJ9S/cpZnEfSAJnNTKjUH1s1mPFKjVM4VnZsOSksTq8kIAffKWgDBY5Wbmx7QGLTLOjkQJvjLkFIz5IE8oqNSiNs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=sydw1VNi; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="sydw1VNi" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NoKL1OH7YXcP+lrXLXeIuIs7vol+bgLYWcjnamU1jiw=; b=sydw1VNiFb7DVAa9E1+U17CpJc jlx9yqIBUtkJFonN/bbjdrl5pxrwEwonpw+81suoKR9Ss14c6LM40rxZ4aM9DSU1pdmB5mqONmf6Y e8DH98O3v+IDOwIocQNTzKDuNvF1mduFTb5a1kOu1W2R9y0coS39h7ohYsK7IH4i+GLNkmOS2ONy0 lUKgHn4l+1eGxAq+ZRgxNZTb6aGT9559DI7Rz5Kw84srvxDTbJ6Ef+WEeJlhjNxRmiTaJzYjjuGIG lH+aC2EjuzXfM5P/ieRqYx4bbkjuKnbI/rNWqNzdM5rH87nFG1/DoHek81fis3zusa7SrADMbewS2 1RBfnIDw==; Received: from [177.139.22.247] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vfsYT-0057lT-Rz; Wed, 14 Jan 2026 05:32:26 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 14 Jan 2026 01:31:41 -0300 Subject: [PATCH 1/3] exportfs: Rename get_uuid() to get_disk_uuid() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260114-tonyk-get_disk_uuid-v1-1-e6a319e25d57@igalia.com> References: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> In-Reply-To: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> To: Christoph Hellwig , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Carlos Maiolino , Amir Goldstein , Chris Mason , David Sterba , Miklos Szeredi , Christian Brauner , Alexander Viro , Jan Kara Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-unionfs@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.3 To make clear which UUID is being returned, rename get_uuid() to get_disk_uuid(). Expand the function documentation to note that this function can be also used for filesystem that supports cloned devices that might have different UUIDs for userspace tools, while having the same UUID for internal usage. Signed-off-by: Andr=C3=A9 Almeida --- fs/nfsd/blocklayout.c | 2 +- fs/nfsd/nfs4layouts.c | 2 +- fs/xfs/xfs_export.c | 2 +- fs/xfs/xfs_pnfs.c | 2 +- fs/xfs/xfs_pnfs.h | 2 +- include/linux/exportfs.h | 8 +++++--- 6 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c index afa16d7a8013..713a1f69f8fe 100644 --- a/fs/nfsd/blocklayout.c +++ b/fs/nfsd/blocklayout.c @@ -218,7 +218,7 @@ nfsd4_block_get_device_info_simple(struct super_block *= sb, =20 b->type =3D PNFS_BLOCK_VOLUME_SIMPLE; b->simple.sig_len =3D PNFS_BLOCK_UUID_LEN; - return sb->s_export_op->get_uuid(sb, b->simple.sig, &b->simple.sig_len, + return sb->s_export_op->get_disk_uuid(sb, b->simple.sig, &b->simple.sig_l= en, &b->simple.offset); } =20 diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index ad7af8cfcf1f..50bb29b2017c 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -136,7 +136,7 @@ void nfsd4_setup_layout_type(struct svc_export *exp) exp->ex_layout_types |=3D 1 << LAYOUT_FLEX_FILES; #endif #ifdef CONFIG_NFSD_BLOCKLAYOUT - if (sb->s_export_op->get_uuid && + if (sb->s_export_op->get_disk_uuid && sb->s_export_op->map_blocks && sb->s_export_op->commit_blocks) exp->ex_layout_types |=3D 1 << LAYOUT_BLOCK_VOLUME; diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 201489d3de08..d09570ba7445 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -244,7 +244,7 @@ const struct export_operations xfs_export_operations = =3D { .get_parent =3D xfs_fs_get_parent, .commit_metadata =3D xfs_fs_nfs_commit_metadata, #ifdef CONFIG_EXPORTFS_BLOCK_OPS - .get_uuid =3D xfs_fs_get_uuid, + .get_disk_uuid =3D xfs_fs_get_disk_uuid, .map_blocks =3D xfs_fs_map_blocks, .commit_blocks =3D xfs_fs_commit_blocks, #endif diff --git a/fs/xfs/xfs_pnfs.c b/fs/xfs/xfs_pnfs.c index afe7497012d4..6ef7b29c4060 100644 --- a/fs/xfs/xfs_pnfs.c +++ b/fs/xfs/xfs_pnfs.c @@ -50,7 +50,7 @@ xfs_break_leased_layouts( * the exported device. */ int -xfs_fs_get_uuid( +xfs_fs_get_disk_uuid( struct super_block *sb, u8 *buf, u32 *len, diff --git a/fs/xfs/xfs_pnfs.h b/fs/xfs/xfs_pnfs.h index 940c6c2ad88c..df82a6ba1a11 100644 --- a/fs/xfs/xfs_pnfs.h +++ b/fs/xfs/xfs_pnfs.h @@ -3,7 +3,7 @@ #define _XFS_PNFS_H 1 =20 #ifdef CONFIG_EXPORTFS_BLOCK_OPS -int xfs_fs_get_uuid(struct super_block *sb, u8 *buf, u32 *len, u64 *offset= ); +int xfs_fs_get_disk_uuid(struct super_block *sb, u8 *buf, u32 *len, u64 *o= ffset); int xfs_fs_map_blocks(struct inode *inode, loff_t offset, u64 length, struct iomap *iomap, bool write, u32 *device_generation); int xfs_fs_commit_blocks(struct inode *inode, struct iomap *maps, int nr_m= aps, diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h index 262e24d83313..dc7029949a62 100644 --- a/include/linux/exportfs.h +++ b/include/linux/exportfs.h @@ -252,8 +252,10 @@ struct handle_to_path_ctx { * @commit_metadata: * @commit_metadata should commit metadata changes to stable storage. * - * @get_uuid: - * Get a filesystem unique signature exposed to clients. + * @get_disk_uuid: + * Get a filesystem unique signature exposed to clients. It's also usef= ul for + * filesystems that support mounting cloned disks and export different = UUIDs + * for userspace, while being internally the same. * * @map_blocks: * Map and, if necessary, allocate blocks for a layout. @@ -282,7 +284,7 @@ struct export_operations { struct dentry * (*get_parent)(struct dentry *child); int (*commit_metadata)(struct inode *inode); =20 - int (*get_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offset); + int (*get_disk_uuid)(struct super_block *sb, u8 *buf, u32 *len, u64 *offs= et); int (*map_blocks)(struct inode *inode, loff_t offset, u64 len, struct iomap *iomap, bool write, u32 *device_generation); --=20 2.52.0 From nobody Mon Feb 9 09:23:05 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFCBB326951; Wed, 14 Jan 2026 04:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365175; cv=none; b=KlO94seM68soCdwLCMlMKK3MhxzitBFss+3CcTJUQquvOcXiUx7PUXlnoI1YsmZcA7b/zQqPUW6gmVa4VhbpaR53trCk5TJzc1RMhY5gxwsexWyYmLWDvzdWFrSfZE1QVh+u3ENq1ha9l+w69wye8ZyhC8ad5JyLyy4VobJJ1ps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365175; c=relaxed/simple; bh=RpYdlUyxv1m9KBTMQMhcFdZfnQX6+KM2DDV3JhZbmFE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CA2e3KRYRHKdl3bHhxPPxcUMnu47OFnIJHXOzox7dT2Or6/fAKClcIgF04uQdhBBPlhxNrkI1g/wWX/aKCxEpet10CVgjuPY9urPUae1m3vd1vNn9HoigfXuTu/zJ1xBp8piiga+u1Uwya7gP+cfNqVoW1JZ0/q4IRoeL++/tO4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=M3dMvsPn; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="M3dMvsPn" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=4mbTK5RSQYergtgPKWt7Z+qG+/ykqryRCZrQNU2VHZA=; b=M3dMvsPnnu+FYdOlweB93GGuxe hLKxw0/bDaMe/qtQfNxg3sGB2bS39IVAV8UowTmb638MIuTL8iWWQq6FyRac4S8r1um7E3F+IYLXc zSH2UM0Z+TB1J3L4NaecEsQBmqkeBq3gyqm4fw1Y88XADoOV3bWGsQ5+MDfpShsBq/jS9fMofDBaH 4rLPcF23LQ9aOAFsUS0kqA6pBBZK4z9GerzpKxFsiT2HKsj8YkILJPZSz1sQmhrf73+zarDCeW2By jF16iUJ5as0wlj4RGJf7pD2VNmnk0UKoY60lpYq3w28V8E6A578e+C/II5RpzKgYD7yGCAzQr/YkG 0oil3DPQ==; Received: from [177.139.22.247] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vfsYY-0057lT-Vb; Wed, 14 Jan 2026 05:32:31 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 14 Jan 2026 01:31:42 -0300 Subject: [PATCH 2/3] btrfs: Implement get_disk_uuid() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260114-tonyk-get_disk_uuid-v1-2-e6a319e25d57@igalia.com> References: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> In-Reply-To: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> To: Christoph Hellwig , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Carlos Maiolino , Amir Goldstein , Chris Mason , David Sterba , Miklos Szeredi , Christian Brauner , Alexander Viro , Jan Kara Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-unionfs@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.3 Every time btrfs mounts a image that it's already mounted (cloned images), it will assign a new random UUID to it to avoid conflicts. However, for some internal kernel usage, it's important to access the original UUID of a given image. For instance, overlayfs' "index" feature keeps track of the UUID of the mounted filesystem on it's upper layer, to avoid being remounted with a different filesystem. However, overlayfs uses the same random UUID exposed to userspace, so the "index" check will fail when trying to remount the very same filesystem. Implement export operation get_disk_uuid() to export the real image UUID. Signed-off-by: Andr=C3=A9 Almeida --- fs/btrfs/export.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index 230d9326b685..09f9ef8c1b1e 100644 --- a/fs/btrfs/export.c +++ b/fs/btrfs/export.c @@ -8,6 +8,7 @@ #include "export.h" #include "accessors.h" #include "super.h" +#include "volumes.h" =20 #define BTRFS_FID_SIZE_NON_CONNECTABLE (offsetof(struct btrfs_fid, \ parent_objectid) / 4) @@ -298,10 +299,29 @@ static int btrfs_get_name(struct dentry *parent, char= *name, return 0; } =20 +static int btrfs_get_disk_uuid(struct super_block *sb, u8 *buf, u32 *len, + u64 *offset) +{ + struct btrfs_fs_devices *fs_dev =3D btrfs_sb(sb)->fs_devices; + + if (fs_dev->temp_fsid) + return -ENODATA; + + if (*len < sizeof(uuid_t)) + return -EINVAL; + + memcpy(buf, &fs_dev->metadata_uuid, sizeof(uuid_t)); + *offset =3D offsetof(struct btrfs_fs_devices, metadata_uuid); + *len =3D sizeof(uuid_t); + + return 0; +} + const struct export_operations btrfs_export_ops =3D { .encode_fh =3D btrfs_encode_fh, .fh_to_dentry =3D btrfs_fh_to_dentry, .fh_to_parent =3D btrfs_fh_to_parent, .get_parent =3D btrfs_get_parent, .get_name =3D btrfs_get_name, + .get_disk_uuid =3D btrfs_get_disk_uuid, }; --=20 2.52.0 From nobody Mon Feb 9 09:23:05 2026 Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51305302151; Wed, 14 Jan 2026 04:32:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.97.179.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365177; cv=none; b=jBuNv1JGlHhTx/3GqKtv57aic1M3/o36Mz406r/CFpqkAvgr/FwrCKIyWEtVOY2Rxe6vJZAcK+5/lqRWn8sxsRyJYx/3p9JBBpoLqjeYSkiC/Cp06lAohIqcLK3x24XpbYo2O5xRfgiohG2/qcfHSsqYEKKNu1upC4EFvjZYCjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768365177; c=relaxed/simple; bh=Gaqat4jw+piMBKROSNm/Id/kd9FzARkuhkgXExJAHe4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yzxva9tL0u9F2CMds5Q0YDUeTsBtRCq8wg2X0QuBH2wktsn9xFm4SQqCAKjuplDMk77M3Kub6Lw7lsfoNmo6/PaGsJDu/eg9tQFawEdFz1Hul57Rn2384ff+XWFbgbHWeXujqRcypqdcq5hkxvwOL1ejabFhKh0xuT25SY9+B1w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=dSBOj4wQ; arc=none smtp.client-ip=213.97.179.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="dSBOj4wQ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=C4IGWB9h4YXDBFwtQ7Qk1rJLaL0FHlCcZCE95extF/o=; b=dSBOj4wQBA9FpAH4NpK+TpFUYR y5DcsbjLUVm51q80Z01h1w35kjdDQR1hj12yNi3PqiQPksYCuu4/SmtgxbrTi4LhQNc4lofS5bf0S hn9rR9DJmdQC58QGOTtTvVYqaoL07iiBINhuDiwoS6GyH3tOyEmvF0p2aFot4GlMLcpUo6u8My9Qh /lyCoG6eqxbR5UaTizfRFYjds1mZLZXYKn5eD3kXDuZ8/jhjhxJcMvlGBXH8dPS/d6hZi+blw9s7w fsx5cBS1/MjQVp1EN3kCkki9gTDWmAr16KlgiKXT3Q4zB2f7bOicFnhaYrw/e71TlSTeKZXGFNPcl NkfNI8vA==; Received: from [177.139.22.247] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1vfsYe-0057lT-2r; Wed, 14 Jan 2026 05:32:36 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Wed, 14 Jan 2026 01:31:43 -0300 Subject: [PATCH 3/3] ovl: Use real disk UUID for origin file handles Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260114-tonyk-get_disk_uuid-v1-3-e6a319e25d57@igalia.com> References: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> In-Reply-To: <20260114-tonyk-get_disk_uuid-v1-0-e6a319e25d57@igalia.com> To: Christoph Hellwig , Chuck Lever , Jeff Layton , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Carlos Maiolino , Amir Goldstein , Chris Mason , David Sterba , Miklos Szeredi , Christian Brauner , Alexander Viro , Jan Kara Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-unionfs@vger.kernel.org, kernel-dev@igalia.com, =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.3 Some filesystem, like btrfs, supports mounting cloned images, but assign random UUIDs for them to avoid conflicts. This breaks overlayfs "index" check, given that every time the same image is mounted, it get's assigned a new UUID. Fix this assigning the disk UUID for filesystem that implements the export operation get_disk_uuid(), so overlayfs check is also against the same value. Signed-off-by: Andr=C3=A9 Almeida --- fs/overlayfs/copy_up.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 758611ee4475..8551681fffd3 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -421,8 +421,26 @@ struct ovl_fh *ovl_encode_real_fh(struct ovl_fs *ofs, = struct inode *realinode, struct ovl_fh *fh; int fh_type, dwords; int buflen =3D MAX_HANDLE_SZ; - uuid_t *uuid =3D &realinode->i_sb->s_uuid; - int err; + struct super_block *real_sb =3D realinode->i_sb; + uuid_t *uuid =3D &real_sb->s_uuid, real_uuid; + u32 len =3D sizeof(uuid_t); + int err, ret; + u64 offset; + + /* + * Some filesystems that support cloned devices may expose random UUIDs + * for userspace, which will cause the upper root origin check to fail + * during a remount. To avoid this, store the real disk UUID. + * + * ENODATA means that the filesystem implements get_disk_uuid(), but + * this instance is using the real UUID so we can skip the operation. + */ + if (real_sb->s_export_op && real_sb->s_export_op->get_disk_uuid) { + ret =3D real_sb->s_export_op->get_disk_uuid(real_sb, real_uuid.b, &len, = &offset); + + if (!ret || ret !=3D ENODATA) + uuid =3D &real_uuid; + } =20 /* Make sure the real fid stays 32bit aligned */ BUILD_BUG_ON(OVL_FH_FID_OFFSET % 4); --=20 2.52.0