aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/disk-io.h
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2020-06-24 18:02:49 +0200
committerTom Rini <trini@konsulko.com>2020-09-07 20:57:27 -0400
commit4aebb9948602de75c4640ea5a287341b662bb260 (patch)
tree6b9f506bcfbe878195ae841b1d74b047620e11da /fs/btrfs/disk-io.h
parent565a4147d17ae3b05531b8c3081ca5fa5bcd72fd (diff)
downloadu-boot-4aebb9948602de75c4640ea5a287341b662bb260.zip
u-boot-4aebb9948602de75c4640ea5a287341b662bb260.tar.gz
u-boot-4aebb9948602de75c4640ea5a287341b662bb260.tar.bz2
fs: btrfs: Crossport btrfs_read_dev_super() from btrfs-progs
This patch uses generic code from btrfs-progs to read one super block from block device. To support the btrfs-progs coding style, the following is also crossported: - BTRFS_SETGET_FUNC for btrfs_super_block - btrfs_check_super() function - Move btrfs_read_superblock() to disk-io.[ch] Since super.c only contains pretty small amount of code, and the extra check will be covered in later root read patches. Differences between this implementation and btrfs-progs: - No sbflags/sb_bytenr support Since we only need to read the primary super block (like kernel), sbflags/sb_bytenr used by super block recovery is not needed. This also changes the following behavior of U-Boot btrfs: - Only reads the primary super block The old implementation reads all 3 super blocks, and also one non-existing backup. This is not correct, especially if there is another filesystem created on the device but old superblocks are not rewritten. Just like kernel, we only check the primary super block. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek BehĂșn <marek.behun@nic.cz> [trini: Change error to be a define in compat.h] Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'fs/btrfs/disk-io.h')
-rw-r--r--fs/btrfs/disk-io.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.h b/fs/btrfs/disk-io.h
index efb7158..fe4093c 100644
--- a/fs/btrfs/disk-io.h
+++ b/fs/btrfs/disk-io.h
@@ -2,10 +2,14 @@
#ifndef __BTRFS_DISK_IO_H__
#define __BTRFS_DISK_IO_H__
+#include <linux/sizes.h>
+#include <fs_internal.h>
#include "crypto/hash.h"
#include "ctree.h"
#include "disk-io.h"
+#define BTRFS_SUPER_INFO_OFFSET SZ_64K
+#define BTRFS_SUPER_INFO_SIZE SZ_4K
static inline u64 btrfs_name_hash(const char *name, int len)
{
u32 crc;
@@ -17,4 +21,7 @@ static inline u64 btrfs_name_hash(const char *name, int len)
int btrfs_csum_data(u16 csum_type, const u8 *data, u8 *out, size_t len);
+int btrfs_read_dev_super(struct blk_desc *desc, struct disk_partition *part,
+ struct btrfs_super_block *sb);
+int btrfs_read_superblock(void);
#endif