diff mbox series

btrfs: drop bytenr_orig and fix comment in btrfs_scan_one_device

Message ID 0de852fd1caaf97aadd2ac62bf178c664069ed17.1715833048.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: drop bytenr_orig and fix comment in btrfs_scan_one_device | expand

Commit Message

Anand Jain May 16, 2024, 4:20 a.m. UTC
Drop the single-use variable bytenr_orig and instead use btrfs_sb_offset()
in the function argument passing.
Fix a stale comment about not automatically fixing a bad primary
superblock from the backup mirror copies. Also, move the comment
closer to where the primary superblock read occurs.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

Comments

David Sterba May 17, 2024, 3:38 p.m. UTC | #1
On Thu, May 16, 2024 at 12:20:13PM +0800, Anand Jain wrote:
> Drop the single-use variable bytenr_orig and instead use btrfs_sb_offset()
> in the function argument passing.
> Fix a stale comment about not automatically fixing a bad primary
> superblock from the backup mirror copies. Also, move the comment
> closer to where the primary superblock read occurs.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>
diff mbox series

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 34ba1892c62d..5596c0d054df 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1377,19 +1377,12 @@  struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
 	bool new_device_added = false;
 	struct btrfs_device *device = NULL;
 	struct file *bdev_file;
-	u64 bytenr, bytenr_orig;
+	u64 bytenr;
 	dev_t devt;
 	int ret;
 
 	lockdep_assert_held(&uuid_mutex);
 
-	/*
-	 * we would like to check all the supers, but that would make
-	 * a btrfs mount succeed after a mkfs from a different FS.
-	 * So, we need to add a special mount option to scan for
-	 * later supers, using BTRFS_SUPER_MIRROR_MAX instead
-	 */
-
 	/*
 	 * Avoid an exclusive open here, as the systemd-udev may initiate the
 	 * device scan which may race with the user's mount or mkfs command,
@@ -1404,7 +1397,12 @@  struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
 	if (IS_ERR(bdev_file))
 		return ERR_CAST(bdev_file);
 
-	bytenr_orig = btrfs_sb_offset(0);
+	/*
+	 * We would like to check all the supers, but doing so would allow a
+	 * btrfs mount to succeed after a mkfs from a different filesystem.
+	 * Currently, recovery from a bad primary btrfs superblock is done using
+	 * the userspace command btrfs check --super.
+	 */
 	ret = btrfs_sb_log_location_bdev(file_bdev(bdev_file), 0, READ, &bytenr);
 	if (ret) {
 		device = ERR_PTR(ret);
@@ -1412,7 +1410,7 @@  struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags,
 	}
 
 	disk_super = btrfs_read_disk_super(file_bdev(bdev_file), bytenr,
-					   bytenr_orig);
+					   btrfs_sb_offset(0));
 	if (IS_ERR(disk_super)) {
 		device = ERR_CAST(disk_super);
 		goto error_bdev_put;