mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-24 20:54:17 +08:00
6b03e0dc40
The original dump format only contains a magic member to verify the format, this means if we want to introduce new on-disk format or change certain size limit, we can only introduce new magic as version. Introduce the framework to allow multiple magic numbers to co-exist for further extensions. Introduce the following members for each dump version. - max_pending_size The threshold size of a cluster. It's not a hard limit but a soft one. One cluster can go larger than max_pending_size for one item, but next item would go to the next cluster. - magic_cpu The magic number in CPU byte order. - extra_sb_flags If the super block of this restore needs extra super block flags like BTRFS_SUPER_FLAG_METADUMP_V2. For incoming data dump feature, we don't need any extra super block flags. This change also implies that all image dumps will use the same magic for all clusters. No mixing is allowed, as we will use the first cluster to determine the dump version. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
79 lines
2.0 KiB
C
79 lines
2.0 KiB
C
/*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public
|
|
* License v2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public
|
|
* License along with this program; if not, write to the
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
* Boston, MA 021110-1307, USA.
|
|
*/
|
|
|
|
#ifndef __BTRFS_IMAGE_METADUMP_H__
|
|
#define __BTRFS_IMAGE_METADUMP_H__
|
|
|
|
#include "kerncompat.h"
|
|
#include "kernel-lib/rbtree.h"
|
|
#include "kernel-lib/list.h"
|
|
#include "kernel-shared/ctree.h"
|
|
|
|
#define BLOCK_SIZE SZ_1K
|
|
#define BLOCK_MASK (BLOCK_SIZE - 1)
|
|
|
|
#define ITEMS_PER_CLUSTER ((BLOCK_SIZE - sizeof(struct meta_cluster)) / \
|
|
sizeof(struct meta_cluster_item))
|
|
|
|
#define COMPRESS_NONE 0
|
|
#define COMPRESS_ZLIB 1
|
|
|
|
struct dump_version {
|
|
u64 magic_cpu;
|
|
int version;
|
|
int max_pending_size;
|
|
unsigned int extra_sb_flags:1;
|
|
};
|
|
|
|
extern const struct dump_version dump_versions[];
|
|
const extern struct dump_version *current_version;
|
|
|
|
struct meta_cluster_item {
|
|
__le64 bytenr;
|
|
__le32 size;
|
|
} __attribute__ ((__packed__));
|
|
|
|
struct meta_cluster_header {
|
|
__le64 magic;
|
|
__le64 bytenr;
|
|
__le32 nritems;
|
|
u8 compress;
|
|
} __attribute__ ((__packed__));
|
|
|
|
/* cluster header + index items + buffers */
|
|
struct meta_cluster {
|
|
struct meta_cluster_header header;
|
|
struct meta_cluster_item items[];
|
|
} __attribute__ ((__packed__));
|
|
|
|
struct fs_chunk {
|
|
u64 logical;
|
|
u64 physical;
|
|
/*
|
|
* physical_dup only store additional physical for BTRFS_BLOCK_GROUP_DUP
|
|
* currently restore only support single and DUP
|
|
* TODO: modify this structure and the function related to this
|
|
* structure for support RAID*
|
|
*/
|
|
u64 physical_dup;
|
|
u64 bytes;
|
|
struct rb_node l;
|
|
struct rb_node p;
|
|
struct list_head list;
|
|
};
|
|
|
|
#endif
|