diff options
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0f369da5cd9..adb1cd7ceb9 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -712,6 +712,36 @@ struct btrfs_root_item { | |||
712 | struct btrfs_disk_key drop_progress; | 712 | struct btrfs_disk_key drop_progress; |
713 | u8 drop_level; | 713 | u8 drop_level; |
714 | u8 level; | 714 | u8 level; |
715 | |||
716 | /* | ||
717 | * The following fields appear after subvol_uuids+subvol_times | ||
718 | * were introduced. | ||
719 | */ | ||
720 | |||
721 | /* | ||
722 | * This generation number is used to test if the new fields are valid | ||
723 | * and up to date while reading the root item. Everytime the root item | ||
724 | * is written out, the "generation" field is copied into this field. If | ||
725 | * anyone ever mounted the fs with an older kernel, we will have | ||
726 | * mismatching generation values here and thus must invalidate the | ||
727 | * new fields. See btrfs_update_root and btrfs_find_last_root for | ||
728 | * details. | ||
729 | * the offset of generation_v2 is also used as the start for the memset | ||
730 | * when invalidating the fields. | ||
731 | */ | ||
732 | __le64 generation_v2; | ||
733 | u8 uuid[BTRFS_UUID_SIZE]; | ||
734 | u8 parent_uuid[BTRFS_UUID_SIZE]; | ||
735 | u8 received_uuid[BTRFS_UUID_SIZE]; | ||
736 | __le64 ctransid; /* updated when an inode changes */ | ||
737 | __le64 otransid; /* trans when created */ | ||
738 | __le64 stransid; /* trans when sent. non-zero for received subvol */ | ||
739 | __le64 rtransid; /* trans when received. non-zero for received subvol */ | ||
740 | struct btrfs_timespec ctime; | ||
741 | struct btrfs_timespec otime; | ||
742 | struct btrfs_timespec stime; | ||
743 | struct btrfs_timespec rtime; | ||
744 | __le64 reserved[8]; /* for future */ | ||
715 | } __attribute__ ((__packed__)); | 745 | } __attribute__ ((__packed__)); |
716 | 746 | ||
717 | /* | 747 | /* |
@@ -1520,6 +1550,8 @@ struct btrfs_root { | |||
1520 | dev_t anon_dev; | 1550 | dev_t anon_dev; |
1521 | 1551 | ||
1522 | int force_cow; | 1552 | int force_cow; |
1553 | |||
1554 | spinlock_t root_times_lock; | ||
1523 | }; | 1555 | }; |
1524 | 1556 | ||
1525 | struct btrfs_ioctl_defrag_range_args { | 1557 | struct btrfs_ioctl_defrag_range_args { |
@@ -2358,6 +2390,16 @@ BTRFS_SETGET_STACK_FUNCS(root_used, struct btrfs_root_item, bytes_used, 64); | |||
2358 | BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64); | 2390 | BTRFS_SETGET_STACK_FUNCS(root_limit, struct btrfs_root_item, byte_limit, 64); |
2359 | BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, | 2391 | BTRFS_SETGET_STACK_FUNCS(root_last_snapshot, struct btrfs_root_item, |
2360 | last_snapshot, 64); | 2392 | last_snapshot, 64); |
2393 | BTRFS_SETGET_STACK_FUNCS(root_generation_v2, struct btrfs_root_item, | ||
2394 | generation_v2, 64); | ||
2395 | BTRFS_SETGET_STACK_FUNCS(root_ctransid, struct btrfs_root_item, | ||
2396 | ctransid, 64); | ||
2397 | BTRFS_SETGET_STACK_FUNCS(root_otransid, struct btrfs_root_item, | ||
2398 | otransid, 64); | ||
2399 | BTRFS_SETGET_STACK_FUNCS(root_stransid, struct btrfs_root_item, | ||
2400 | stransid, 64); | ||
2401 | BTRFS_SETGET_STACK_FUNCS(root_rtransid, struct btrfs_root_item, | ||
2402 | rtransid, 64); | ||
2361 | 2403 | ||
2362 | static inline bool btrfs_root_readonly(struct btrfs_root *root) | 2404 | static inline bool btrfs_root_readonly(struct btrfs_root *root) |
2363 | { | 2405 | { |
@@ -2893,6 +2935,21 @@ int btrfs_search_forward(struct btrfs_root *root, struct btrfs_key *min_key, | |||
2893 | struct btrfs_key *max_key, | 2935 | struct btrfs_key *max_key, |
2894 | struct btrfs_path *path, int cache_only, | 2936 | struct btrfs_path *path, int cache_only, |
2895 | u64 min_trans); | 2937 | u64 min_trans); |
2938 | enum btrfs_compare_tree_result { | ||
2939 | BTRFS_COMPARE_TREE_NEW, | ||
2940 | BTRFS_COMPARE_TREE_DELETED, | ||
2941 | BTRFS_COMPARE_TREE_CHANGED, | ||
2942 | }; | ||
2943 | typedef int (*btrfs_changed_cb_t)(struct btrfs_root *left_root, | ||
2944 | struct btrfs_root *right_root, | ||
2945 | struct btrfs_path *left_path, | ||
2946 | struct btrfs_path *right_path, | ||
2947 | struct btrfs_key *key, | ||
2948 | enum btrfs_compare_tree_result result, | ||
2949 | void *ctx); | ||
2950 | int btrfs_compare_trees(struct btrfs_root *left_root, | ||
2951 | struct btrfs_root *right_root, | ||
2952 | btrfs_changed_cb_t cb, void *ctx); | ||
2896 | int btrfs_cow_block(struct btrfs_trans_handle *trans, | 2953 | int btrfs_cow_block(struct btrfs_trans_handle *trans, |
2897 | struct btrfs_root *root, struct extent_buffer *buf, | 2954 | struct btrfs_root *root, struct extent_buffer *buf, |
2898 | struct extent_buffer *parent, int parent_slot, | 2955 | struct extent_buffer *parent, int parent_slot, |
@@ -3046,6 +3103,9 @@ int __must_check btrfs_update_root(struct btrfs_trans_handle *trans, | |||
3046 | struct btrfs_root *root, | 3103 | struct btrfs_root *root, |
3047 | struct btrfs_key *key, | 3104 | struct btrfs_key *key, |
3048 | struct btrfs_root_item *item); | 3105 | struct btrfs_root_item *item); |
3106 | void btrfs_read_root_item(struct btrfs_root *root, | ||
3107 | struct extent_buffer *eb, int slot, | ||
3108 | struct btrfs_root_item *item); | ||
3049 | int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct | 3109 | int btrfs_find_last_root(struct btrfs_root *root, u64 objectid, struct |
3050 | btrfs_root_item *item, struct btrfs_key *key); | 3110 | btrfs_root_item *item, struct btrfs_key *key); |
3051 | int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); | 3111 | int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid); |
@@ -3053,6 +3113,8 @@ int btrfs_find_orphan_roots(struct btrfs_root *tree_root); | |||
3053 | void btrfs_set_root_node(struct btrfs_root_item *item, | 3113 | void btrfs_set_root_node(struct btrfs_root_item *item, |
3054 | struct extent_buffer *node); | 3114 | struct extent_buffer *node); |
3055 | void btrfs_check_and_init_root_item(struct btrfs_root_item *item); | 3115 | void btrfs_check_and_init_root_item(struct btrfs_root_item *item); |
3116 | void btrfs_update_root_times(struct btrfs_trans_handle *trans, | ||
3117 | struct btrfs_root *root); | ||
3056 | 3118 | ||
3057 | /* dir-item.c */ | 3119 | /* dir-item.c */ |
3058 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, | 3120 | int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, |