Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 309924
b: refs/heads/master
c: 926dd8a
h: refs/heads/master
v: v3
  • Loading branch information
Jan Schmidt committed May 31, 2012
1 parent bdf7f2f commit 708c6ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 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: 3301958b7c1dae8f0f5ded63aa881e0b71e78464
refs/heads/master: 926dd8a640da1bbf7478eebea1c23a842fc9c890
23 changes: 18 additions & 5 deletions trunk/fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,11 @@ __tree_mod_log_insert(struct btrfs_fs_info *fs_info, struct tree_mod_elem *tm)
return ret;
}

int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
struct tree_mod_elem **tm_ret)
static inline int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
struct tree_mod_elem **tm_ret)
{
struct tree_mod_elem *tm;
u64 seq = 0;
int seq;

smp_mb();
if (list_empty(&fs_info->tree_mod_seq_list))
Expand All @@ -469,9 +469,22 @@ int tree_mod_alloc(struct btrfs_fs_info *fs_info, gfp_t flags,
if (!tm)
return -ENOMEM;

__get_tree_mod_seq(fs_info, &tm->elem);
seq = tm->elem.seq;
tm->elem.flags = 0;
spin_lock(&fs_info->tree_mod_seq_lock);
if (list_empty(&fs_info->tree_mod_seq_list)) {
/*
* someone emptied the list while we were waiting for the lock.
* we must not add to the list, because no blocker exists. items
* are removed from the list only when the existing blocker is
* removed from the list.
*/
kfree(tm);
seq = 0;
} else {
__get_tree_mod_seq(fs_info, &tm->elem);
seq = tm->elem.seq;
}
spin_unlock(&fs_info->tree_mod_seq_lock);

return seq;
}
Expand Down

0 comments on commit 708c6ae

Please sign in to comment.