aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2009-09-21 15:56:00 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-21 15:56:00 -0400
commit4df27c4d5cc1dda54ed7d0a8389347f2df359cf9 (patch)
tree2008f348d28c6c19e31924ae4fb414ca929a01f1 /fs/btrfs/ctree.h
parent13a8a7c8c47e542b3cdb45bec3f431f96af79361 (diff)
Btrfs: change how subvolumes are organized
btrfs allows subvolumes and snapshots anywhere in the directory tree. If we snapshot a subvolume that contains a link to other subvolume called subvolA, subvolA can be accessed through both the original subvolume and the snapshot. This is similar to creating hard link to directory, and has the very similar problems. The aim of this patch is enforcing there is only one access point to each subvolume. Only the first directory entry (the one added when the subvolume/snapshot was created) is treated as valid access point. The first directory entry is distinguished by checking root forward reference. If the corresponding root forward reference is missing, we know the entry is not the first one. This patch also adds snapshot/subvolume rename support, the code allows rename subvolume link across subvolumes. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 746a9acd2189..6ade48b227e9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -114,6 +114,10 @@ struct btrfs_ordered_sum;
114 */ 114 */
115#define BTRFS_DEV_ITEMS_OBJECTID 1ULL 115#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
116 116
117#define BTRFS_BTREE_INODE_OBJECTID 1
118
119#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
120
117/* 121/*
118 * we can actually store much bigger names, but lets not confuse the rest 122 * we can actually store much bigger names, but lets not confuse the rest
119 * of linux 123 * of linux
@@ -792,6 +796,8 @@ struct btrfs_fs_info {
792 796
793 /* the log root tree is a directory of all the other log roots */ 797 /* the log root tree is a directory of all the other log roots */
794 struct btrfs_root *log_root_tree; 798 struct btrfs_root *log_root_tree;
799
800 spinlock_t fs_roots_radix_lock;
795 struct radix_tree_root fs_roots_radix; 801 struct radix_tree_root fs_roots_radix;
796 802
797 /* block group cache stuff */ 803 /* block group cache stuff */
@@ -1011,6 +1017,8 @@ struct btrfs_root {
1011 u64 highest_objectid; 1017 u64 highest_objectid;
1012 int ref_cows; 1018 int ref_cows;
1013 int track_dirty; 1019 int track_dirty;
1020 int in_radix;
1021
1014 u64 defrag_trans_start; 1022 u64 defrag_trans_start;
1015 struct btrfs_key defrag_progress; 1023 struct btrfs_key defrag_progress;
1016 struct btrfs_key defrag_max; 1024 struct btrfs_key defrag_max;
@@ -2111,12 +2119,15 @@ int btrfs_drop_subtree(struct btrfs_trans_handle *trans,
2111 struct extent_buffer *parent); 2119 struct extent_buffer *parent);
2112/* root-item.c */ 2120/* root-item.c */
2113int btrfs_find_root_ref(struct btrfs_root *tree_root, 2121int btrfs_find_root_ref(struct btrfs_root *tree_root,
2114 struct btrfs_path *path, 2122 struct btrfs_path *path,
2115 u64 root_id, u64 ref_id); 2123 u64 root_id, u64 ref_id);
2116int btrfs_add_root_ref(struct btrfs_trans_handle *trans, 2124int btrfs_add_root_ref(struct btrfs_trans_handle *trans,
2117 struct btrfs_root *tree_root, 2125 struct btrfs_root *tree_root,
2118 u64 root_id, u8 type, u64 ref_id, 2126 u64 root_id, u64 ref_id, u64 dirid, u64 sequence,
2119 u64 dirid, u64 sequence, 2127 const char *name, int name_len);
2128int btrfs_del_root_ref(struct btrfs_trans_handle *trans,
2129 struct btrfs_root *tree_root,
2130 u64 root_id, u64 ref_id, u64 dirid, u64 *sequence,
2120 const char *name, int name_len); 2131 const char *name, int name_len);
2121int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root, 2132int btrfs_del_root(struct btrfs_trans_handle *trans, struct btrfs_root *root,
2122 struct btrfs_key *key); 2133 struct btrfs_key *key);
@@ -2149,6 +2160,10 @@ btrfs_lookup_dir_index_item(struct btrfs_trans_handle *trans,
2149 struct btrfs_path *path, u64 dir, 2160 struct btrfs_path *path, u64 dir,
2150 u64 objectid, const char *name, int name_len, 2161 u64 objectid, const char *name, int name_len,
2151 int mod); 2162 int mod);
2163struct btrfs_dir_item *
2164btrfs_search_dir_index_item(struct btrfs_root *root,
2165 struct btrfs_path *path, u64 dirid,
2166 const char *name, int name_len);
2152struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root, 2167struct btrfs_dir_item *btrfs_match_dir_item_name(struct btrfs_root *root,
2153 struct btrfs_path *path, 2168 struct btrfs_path *path,
2154 const char *name, int name_len); 2169 const char *name, int name_len);
@@ -2171,6 +2186,7 @@ int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
2171 struct btrfs_root *root, u64 offset); 2186 struct btrfs_root *root, u64 offset);
2172int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, 2187int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
2173 struct btrfs_root *root, u64 offset); 2188 struct btrfs_root *root, u64 offset);
2189int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset);
2174 2190
2175/* inode-map.c */ 2191/* inode-map.c */
2176int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, 2192int btrfs_find_free_objectid(struct btrfs_trans_handle *trans,
@@ -2243,6 +2259,10 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans,
2243int btrfs_add_link(struct btrfs_trans_handle *trans, 2259int btrfs_add_link(struct btrfs_trans_handle *trans,
2244 struct inode *parent_inode, struct inode *inode, 2260 struct inode *parent_inode, struct inode *inode,
2245 const char *name, int name_len, int add_backref, u64 index); 2261 const char *name, int name_len, int add_backref, u64 index);
2262int btrfs_unlink_subvol(struct btrfs_trans_handle *trans,
2263 struct btrfs_root *root,
2264 struct inode *dir, u64 objectid,
2265 const char *name, int name_len);
2246int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, 2266int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
2247 struct btrfs_root *root, 2267 struct btrfs_root *root,
2248 struct inode *inode, u64 new_size, 2268 struct inode *inode, u64 new_size,