This is a note to let you know that I've just added the patch titled btrfs: update latest_dev when we create a sprout device to the 5.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-update-latest_dev-when-we-create-a-sprout-device.patch and it can be found in the queue-5.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Fri Dec 17 03:55:51 PM CET 2021 From: Anand Jain <anand.jain@xxxxxxxxxx> Date: Thu, 16 Dec 2021 21:04:12 +0800 Subject: btrfs: update latest_dev when we create a sprout device To: linux-kernel@xxxxxxxxxxxxxxx, stable@xxxxxxxxxxxxxxx Cc: linux-btrfs@xxxxxxxxxxxxxxx, Anand Jain <anand.jain@xxxxxxxxxx>, Su Yue <l@xxxxxxxxxx>, David Sterba <dsterba@xxxxxxxx> Message-ID: <3cc9f5d26cf29f91b3a87df814ff84420e31080a.1639658429.git.anand.jain@xxxxxxxxxx> From: Anand Jain <anand.jain@xxxxxxxxxx> Commit b7cb29e666fe79dda5dbe5f57fb7c92413bf161c upstream. When we add a device to the seed filesystem (sprouting) it is a new filesystem (and fsid) on the device added. Update the latest_dev so that /proc/self/mounts shows the correct device. Example: $ btrfstune -S1 /dev/vg/seed $ mount /dev/vg/seed /btrfs mount: /btrfs: WARNING: device write-protected, mounted read-only. $ cat /proc/self/mounts | grep btrfs /dev/mapper/vg-seed /btrfs btrfs ro,relatime,space_cache,subvolid=5,subvol=/ 0 0 $ btrfs dev add -f /dev/vg/new /btrfs Before: $ cat /proc/self/mounts | grep btrfs /dev/mapper/vg-seed /btrfs btrfs ro,relatime,space_cache,subvolid=5,subvol=/ 0 0 After: $ cat /proc/self/mounts | grep btrfs /dev/mapper/vg-new /btrfs btrfs ro,relatime,space_cache,subvolid=5,subvol=/ 0 0 Tested-by: Su Yue <l@xxxxxxxxxx> Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> Reviewed-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: David Sterba <dsterba@xxxxxxxx> Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/volumes.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2634,6 +2634,8 @@ int btrfs_init_new_device(struct btrfs_f btrfs_abort_transaction(trans, ret); goto error_trans; } + btrfs_assign_next_active_device(fs_info->fs_devices->latest_dev, + device); } device->fs_devices = fs_devices; Patches currently in stable-queue which might be from anand.jain@xxxxxxxxxx are queue-5.15/btrfs-use-latest_dev-in-btrfs_show_devname.patch queue-5.15/btrfs-convert-latest_bdev-type-to-btrfs_device-and-rename.patch queue-5.15/btrfs-remove-stale-comment-about-the-btrfs_show_devname.patch queue-5.15/btrfs-update-latest_dev-when-we-create-a-sprout-device.patch