OSDN Git Service

btrfs: Cleanup and simplify find_newest_super_backup
authorNikolay Borisov <nborisov@suse.com>
Tue, 15 Oct 2019 15:42:17 +0000 (18:42 +0300)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 16:51:46 +0000 (17:51 +0100)
commit01f0f9da9dc8b4d60921af92bc9329a1eb2fa8e0
treead87c2ac27d704b03e9c2bb92ae01a1ce798b87d
parent16ad3be1752a7b8ea18f0f97e8383fec0e470e7c
btrfs: Cleanup and simplify find_newest_super_backup

Backup roots are always written in a circular manner. By definition we
can only ever have 1 backup root whose generation equals to that of the
superblock. Hence, the 'if' in the for loop will trigger at most once.
This is sufficient to return the newest backup root.

Furthermore the newest_gen parameter is always set to the generation of
the superblock. This value can be obtained from the fs_info.

This patch removes the unnecessary code dealing with the wraparound
case and makes 'newest_gen' a local variable.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/disk-io.c