aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorMark Fasheh <mfasheh@suse.de>2012-08-08 14:32:27 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-09 09:14:45 -0400
commitf186373fef005cee948a4a39e6a14c2e5f517298 (patch)
tree5683c66a7112e56147149f379658517ab18e7689 /fs/btrfs/ctree.h
parent5a1d7843ca4b3a9009bea87f85ad33854b910aea (diff)
btrfs: extended inode refs
This patch adds basic support for extended inode refs. This includes support for link and unlink of the refs, which basically gets us support for rename as well. Inode creation does not need changing - extended refs are only added after the ref array is full. Signed-off-by: Mark Fasheh <mfasheh@suse.de>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h53
1 files changed, 46 insertions, 7 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 399521ab61da..50dcd0fbae11 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -154,6 +154,13 @@ struct btrfs_ordered_sum;
154 */ 154 */
155#define BTRFS_NAME_LEN 255 155#define BTRFS_NAME_LEN 255
156 156
157/*
158 * Theoretical limit is larger, but we keep this down to a sane
159 * value. That should limit greatly the possibility of collisions on
160 * inode ref items.
161 */
162#define BTRFS_LINK_MAX 65535U
163
157/* 32 bytes in various csum fields */ 164/* 32 bytes in various csum fields */
158#define BTRFS_CSUM_SIZE 32 165#define BTRFS_CSUM_SIZE 32
159 166
@@ -489,6 +496,8 @@ struct btrfs_super_block {
489 */ 496 */
490#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5) 497#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
491 498
499#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
500
492#define BTRFS_FEATURE_COMPAT_SUPP 0ULL 501#define BTRFS_FEATURE_COMPAT_SUPP 0ULL
493#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL 502#define BTRFS_FEATURE_COMPAT_RO_SUPP 0ULL
494#define BTRFS_FEATURE_INCOMPAT_SUPP \ 503#define BTRFS_FEATURE_INCOMPAT_SUPP \
@@ -496,7 +505,8 @@ struct btrfs_super_block {
496 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \ 505 BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL | \
497 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \ 506 BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS | \
498 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \ 507 BTRFS_FEATURE_INCOMPAT_BIG_METADATA | \
499 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO) 508 BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO | \
509 BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)
500 510
501/* 511/*
502 * A leaf is full of items. offset and size tell us where to find 512 * A leaf is full of items. offset and size tell us where to find
@@ -643,6 +653,14 @@ struct btrfs_inode_ref {
643 /* name goes here */ 653 /* name goes here */
644} __attribute__ ((__packed__)); 654} __attribute__ ((__packed__));
645 655
656struct btrfs_inode_extref {
657 __le64 parent_objectid;
658 __le64 index;
659 __le16 name_len;
660 __u8 name[0];
661 /* name goes here */
662} __attribute__ ((__packed__));
663
646struct btrfs_timespec { 664struct btrfs_timespec {
647 __le64 sec; 665 __le64 sec;
648 __le32 nsec; 666 __le32 nsec;
@@ -1601,6 +1619,7 @@ struct btrfs_ioctl_defrag_range_args {
1601 */ 1619 */
1602#define BTRFS_INODE_ITEM_KEY 1 1620#define BTRFS_INODE_ITEM_KEY 1
1603#define BTRFS_INODE_REF_KEY 12 1621#define BTRFS_INODE_REF_KEY 12
1622#define BTRFS_INODE_EXTREF_KEY 13
1604#define BTRFS_XATTR_ITEM_KEY 24 1623#define BTRFS_XATTR_ITEM_KEY 24
1605#define BTRFS_ORPHAN_ITEM_KEY 48 1624#define BTRFS_ORPHAN_ITEM_KEY 48
1606/* reserve 2-15 close to the inode for later flexibility */ 1625/* reserve 2-15 close to the inode for later flexibility */
@@ -1987,6 +2006,13 @@ BTRFS_SETGET_STACK_FUNCS(block_group_flags,
1987BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16); 2006BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
1988BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64); 2007BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64);
1989 2008
2009/* struct btrfs_inode_extref */
2010BTRFS_SETGET_FUNCS(inode_extref_parent, struct btrfs_inode_extref,
2011 parent_objectid, 64);
2012BTRFS_SETGET_FUNCS(inode_extref_name_len, struct btrfs_inode_extref,
2013 name_len, 16);
2014BTRFS_SETGET_FUNCS(inode_extref_index, struct btrfs_inode_extref, index, 64);
2015
1990/* struct btrfs_inode_item */ 2016/* struct btrfs_inode_item */
1991BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64); 2017BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64);
1992BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64); 2018BTRFS_SETGET_FUNCS(inode_sequence, struct btrfs_inode_item, sequence, 64);
@@ -3184,12 +3210,12 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
3184 struct btrfs_root *root, 3210 struct btrfs_root *root,
3185 const char *name, int name_len, 3211 const char *name, int name_len,
3186 u64 inode_objectid, u64 ref_objectid, u64 *index); 3212 u64 inode_objectid, u64 ref_objectid, u64 *index);
3187struct btrfs_inode_ref * 3213int btrfs_get_inode_ref_index(struct btrfs_trans_handle *trans,
3188btrfs_lookup_inode_ref(struct btrfs_trans_handle *trans, 3214 struct btrfs_root *root,
3189 struct btrfs_root *root, 3215 struct btrfs_path *path,
3190 struct btrfs_path *path, 3216 const char *name, int name_len,
3191 const char *name, int name_len, 3217 u64 inode_objectid, u64 ref_objectid, int mod,
3192 u64 inode_objectid, u64 ref_objectid, int mod); 3218 u64 *ret_index);
3193int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans, 3219int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
3194 struct btrfs_root *root, 3220 struct btrfs_root *root,
3195 struct btrfs_path *path, u64 objectid); 3221 struct btrfs_path *path, u64 objectid);
@@ -3197,6 +3223,19 @@ int btrfs_lookup_inode(struct btrfs_trans_handle *trans, struct btrfs_root
3197 *root, struct btrfs_path *path, 3223 *root, struct btrfs_path *path,
3198 struct btrfs_key *location, int mod); 3224 struct btrfs_key *location, int mod);
3199 3225
3226struct btrfs_inode_extref *
3227btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans,
3228 struct btrfs_root *root,
3229 struct btrfs_path *path,
3230 const char *name, int name_len,
3231 u64 inode_objectid, u64 ref_objectid, int ins_len,
3232 int cow);
3233
3234int btrfs_find_name_in_ext_backref(struct btrfs_path *path,
3235 u64 ref_objectid, const char *name,
3236 int name_len,
3237 struct btrfs_inode_extref **extref_ret);
3238
3200/* file-item.c */ 3239/* file-item.c */
3201int btrfs_del_csums(struct btrfs_trans_handle *trans, 3240int btrfs_del_csums(struct btrfs_trans_handle *trans,
3202 struct btrfs_root *root, u64 bytenr, u64 len); 3241 struct btrfs_root *root, u64 bytenr, u64 len);