summaryrefslogtreecommitdiff
path: root/disk-io.c
diff options
context:
space:
mode:
authorNikolay Borisov <nborisov@suse.com>2017-12-05 10:39:47 +0200
committerDavid Sterba <dsterba@suse.com>2018-01-31 15:14:01 +0100
commit90a16b10b328d63ea90b3f4a04fd52a0bc0b689f (patch)
treef9bf12150ee9d7a536abb6a1248c079eeedc0535 /disk-io.c
parent8075fd4da1a5c759261413461a4bd7f9af81722c (diff)
btrfs-progs: Document logic of btrfs_read_dev_super
Signed-off-by: Nikolay Borisov <nborisov@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/disk-io.c b/disk-io.c
index 3d8785d5..0b83be71 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1419,6 +1419,23 @@ error_out:
return -EIO;
}
+/*
+ * btrfs_read_dev_super - read a valid superblock from a block device
+ * @fd: file descriptor of the device
+ * @sb: buffer where the superblock is going to be read in
+ * @sb_bytenr: offset of the particular superblock copy we want
+ * @sbflags: flags controlling how the superblock is read
+ *
+ * This function is used by various btrfs comands to obtain a valid superblock.
+ *
+ * It's mode of operation is controlled by the @sb_bytenr and @sbdflags
+ * parameters. If SBREAD_RECOVER flag is set and @sb_bytenr is
+ * BTRFS_SUPER_INFO_OFFSET then the function reads all 3 superblock copies and
+ * returns the newest one. If SBREAD_RECOVER is not set then only a single
+ * copy is read, which one is decided by @sb_bytenr. If @sb_bytenr !=
+ * BTRFS_SUPER_INFO_OFFSET then the @sbflags is effectively ignored and only a
+ * single copy is read.
+ */
int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,
unsigned sbflags)
{