Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128848
b: refs/heads/master
c: aec7477
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik authored and Chris Mason committed Sep 25, 2008
1 parent a391b04 commit 1d85802
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 34 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3eaa2885276fd6dac7b076a793932428b7168e74
refs/heads/master: aec7477b3b0e8ec93f6d274f25ba40b0665134d4
15 changes: 15 additions & 0 deletions trunk/fs/btrfs/btrfs_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ struct btrfs_inode {
u64 delalloc_bytes;
u64 disk_i_size;
u32 flags;

/*
* if this is a directory then index_cnt is the counter for the index
* number for new files that are created
*/
u64 index_cnt;

/*
* index holds the directory index for this inode on creation, so
* add_link can do what its supposed to. This isn't populated when the
* inode is read because there isn't really a reason to know this unless
* we are creating the directory index or deleting it, and deletion
* reads the index off of the inode reference at unlink time.
*/
u64 index;
};

static inline struct btrfs_inode *BTRFS_I(struct inode *inode)
Expand Down
8 changes: 5 additions & 3 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ struct btrfs_dev_extent {
} __attribute__ ((__packed__));

struct btrfs_inode_ref {
__le64 index;
__le16 name_len;
/* name goes here */
} __attribute__ ((__packed__));
Expand Down Expand Up @@ -902,6 +903,7 @@ BTRFS_SETGET_STACK_FUNCS(block_group_flags,

/* struct btrfs_inode_ref */
BTRFS_SETGET_FUNCS(inode_ref_name_len, struct btrfs_inode_ref, name_len, 16);
BTRFS_SETGET_FUNCS(inode_ref_index, struct btrfs_inode_ref, index, 64);

/* struct btrfs_inode_item */
BTRFS_SETGET_FUNCS(inode_generation, struct btrfs_inode_item, generation, 64);
Expand Down Expand Up @@ -1528,7 +1530,7 @@ int btrfs_find_dead_roots(struct btrfs_root *root, u64 objectid,
/* dir-item.c */
int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
*root, const char *name, int name_len, u64 dir,
struct btrfs_key *location, u8 type);
struct btrfs_key *location, u8 type, u64 index);
struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_path *path, u64 dir,
Expand Down Expand Up @@ -1566,11 +1568,11 @@ int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid);
int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
const char *name, int name_len,
u64 inode_objectid, u64 ref_objectid);
u64 inode_objectid, u64 ref_objectid, u64 index);
int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
const char *name, int name_len,
u64 inode_objectid, u64 ref_objectid);
u64 inode_objectid, u64 ref_objectid, u64 *index);
int btrfs_insert_empty_inode(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_path *path, u64 objectid);
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/btrfs/dir-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,

int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
*root, const char *name, int name_len, u64 dir,
struct btrfs_key *location, u8 type)
struct btrfs_key *location, u8 type, u64 index)
{
int ret = 0;
int ret2 = 0;
Expand Down Expand Up @@ -156,7 +156,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
btrfs_release_path(root, path);

btrfs_set_key_type(&key, BTRFS_DIR_INDEX_KEY);
key.offset = location->objectid;
key.offset = index;
dir_item = insert_with_overflow(trans, root, path, &key, data_size,
name, name_len);
if (IS_ERR(dir_item)) {
Expand Down
10 changes: 8 additions & 2 deletions trunk/fs/btrfs/inode-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int find_name_in_backref(struct btrfs_path *path, const char * name,
int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
const char *name, int name_len,
u64 inode_objectid, u64 ref_objectid)
u64 inode_objectid, u64 ref_objectid, u64 *index)
{
struct btrfs_path *path;
struct btrfs_key key;
Expand Down Expand Up @@ -86,6 +86,10 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
}
leaf = path->nodes[0];
item_size = btrfs_item_size_nr(leaf, path->slots[0]);

if (index)
*index = btrfs_inode_ref_index(leaf, ref);

if (del_len == item_size) {
ret = btrfs_del_item(trans, root, path);
goto out;
Expand All @@ -106,7 +110,7 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans,
int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
const char *name, int name_len,
u64 inode_objectid, u64 ref_objectid)
u64 inode_objectid, u64 ref_objectid, u64 index)
{
struct btrfs_path *path;
struct btrfs_key key;
Expand Down Expand Up @@ -138,6 +142,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
struct btrfs_inode_ref);
ref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size);
btrfs_set_inode_ref_name_len(path->nodes[0], ref, name_len);
btrfs_set_inode_ref_index(path->nodes[0], ref, index);
ptr = (unsigned long)(ref + 1);
ret = 0;
} else if (ret < 0) {
Expand All @@ -146,6 +151,7 @@ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,
ref = btrfs_item_ptr(path->nodes[0], path->slots[0],
struct btrfs_inode_ref);
btrfs_set_inode_ref_name_len(path->nodes[0], ref, name_len);
btrfs_set_inode_ref_index(path->nodes[0], ref, index);
ptr = (unsigned long)(ref + 1);
}
write_extent_buffer(path->nodes[0], name, ptr, name_len);
Expand Down
Loading

0 comments on commit 1d85802

Please sign in to comment.