diff options
Diffstat (limited to 'fs/btrfs')
| -rw-r--r-- | fs/btrfs/acl.c | 8 | ||||
| -rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
| -rw-r--r-- | fs/btrfs/delayed-inode.c | 8 | ||||
| -rw-r--r-- | fs/btrfs/delayed-ref.h | 2 | ||||
| -rw-r--r-- | fs/btrfs/extent_io.c | 6 | ||||
| -rw-r--r-- | fs/btrfs/inode.c | 17 | ||||
| -rw-r--r-- | fs/btrfs/ioctl.c | 38 | ||||
| -rw-r--r-- | fs/btrfs/reada.c | 18 |
8 files changed, 52 insertions, 47 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c index 761e2cd8fed1..0c16e3dbfd56 100644 --- a/fs/btrfs/acl.c +++ b/fs/btrfs/acl.c | |||
| @@ -61,7 +61,7 @@ struct posix_acl *btrfs_get_acl(struct inode *inode, int type) | |||
| 61 | size = __btrfs_getxattr(inode, name, value, size); | 61 | size = __btrfs_getxattr(inode, name, value, size); |
| 62 | } | 62 | } |
| 63 | if (size > 0) { | 63 | if (size > 0) { |
| 64 | acl = posix_acl_from_xattr(value, size); | 64 | acl = posix_acl_from_xattr(&init_user_ns, value, size); |
| 65 | } else if (size == -ENOENT || size == -ENODATA || size == 0) { | 65 | } else if (size == -ENOENT || size == -ENODATA || size == 0) { |
| 66 | /* FIXME, who returns -ENOENT? I think nobody */ | 66 | /* FIXME, who returns -ENOENT? I think nobody */ |
| 67 | acl = NULL; | 67 | acl = NULL; |
| @@ -91,7 +91,7 @@ static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name, | |||
| 91 | return PTR_ERR(acl); | 91 | return PTR_ERR(acl); |
| 92 | if (acl == NULL) | 92 | if (acl == NULL) |
| 93 | return -ENODATA; | 93 | return -ENODATA; |
| 94 | ret = posix_acl_to_xattr(acl, value, size); | 94 | ret = posix_acl_to_xattr(&init_user_ns, acl, value, size); |
| 95 | posix_acl_release(acl); | 95 | posix_acl_release(acl); |
| 96 | 96 | ||
| 97 | return ret; | 97 | return ret; |
| @@ -141,7 +141,7 @@ static int btrfs_set_acl(struct btrfs_trans_handle *trans, | |||
| 141 | goto out; | 141 | goto out; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | ret = posix_acl_to_xattr(acl, value, size); | 144 | ret = posix_acl_to_xattr(&init_user_ns, acl, value, size); |
| 145 | if (ret < 0) | 145 | if (ret < 0) |
| 146 | goto out; | 146 | goto out; |
| 147 | } | 147 | } |
| @@ -169,7 +169,7 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name, | |||
| 169 | return -EOPNOTSUPP; | 169 | return -EOPNOTSUPP; |
| 170 | 170 | ||
| 171 | if (value) { | 171 | if (value) { |
| 172 | acl = posix_acl_from_xattr(value, size); | 172 | acl = posix_acl_from_xattr(&init_user_ns, value, size); |
| 173 | if (IS_ERR(acl)) | 173 | if (IS_ERR(acl)) |
| 174 | return PTR_ERR(acl); | 174 | return PTR_ERR(acl); |
| 175 | 175 | ||
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d195b507660..9821b672f5a2 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
| @@ -116,7 +116,7 @@ struct btrfs_ordered_sum; | |||
| 116 | #define BTRFS_FREE_SPACE_OBJECTID -11ULL | 116 | #define BTRFS_FREE_SPACE_OBJECTID -11ULL |
| 117 | 117 | ||
| 118 | /* | 118 | /* |
| 119 | * The inode number assigned to the special inode for sotring | 119 | * The inode number assigned to the special inode for storing |
| 120 | * free ino cache | 120 | * free ino cache |
| 121 | */ | 121 | */ |
| 122 | #define BTRFS_FREE_INO_OBJECTID -12ULL | 122 | #define BTRFS_FREE_INO_OBJECTID -12ULL |
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c index 07d5eeb1e6f1..52c85e2b95d0 100644 --- a/fs/btrfs/delayed-inode.c +++ b/fs/btrfs/delayed-inode.c | |||
| @@ -1715,8 +1715,8 @@ static void fill_stack_inode_item(struct btrfs_trans_handle *trans, | |||
| 1715 | struct btrfs_inode_item *inode_item, | 1715 | struct btrfs_inode_item *inode_item, |
| 1716 | struct inode *inode) | 1716 | struct inode *inode) |
| 1717 | { | 1717 | { |
| 1718 | btrfs_set_stack_inode_uid(inode_item, inode->i_uid); | 1718 | btrfs_set_stack_inode_uid(inode_item, i_uid_read(inode)); |
| 1719 | btrfs_set_stack_inode_gid(inode_item, inode->i_gid); | 1719 | btrfs_set_stack_inode_gid(inode_item, i_gid_read(inode)); |
| 1720 | btrfs_set_stack_inode_size(inode_item, BTRFS_I(inode)->disk_i_size); | 1720 | btrfs_set_stack_inode_size(inode_item, BTRFS_I(inode)->disk_i_size); |
| 1721 | btrfs_set_stack_inode_mode(inode_item, inode->i_mode); | 1721 | btrfs_set_stack_inode_mode(inode_item, inode->i_mode); |
| 1722 | btrfs_set_stack_inode_nlink(inode_item, inode->i_nlink); | 1722 | btrfs_set_stack_inode_nlink(inode_item, inode->i_nlink); |
| @@ -1764,8 +1764,8 @@ int btrfs_fill_inode(struct inode *inode, u32 *rdev) | |||
| 1764 | 1764 | ||
| 1765 | inode_item = &delayed_node->inode_item; | 1765 | inode_item = &delayed_node->inode_item; |
| 1766 | 1766 | ||
| 1767 | inode->i_uid = btrfs_stack_inode_uid(inode_item); | 1767 | i_uid_write(inode, btrfs_stack_inode_uid(inode_item)); |
| 1768 | inode->i_gid = btrfs_stack_inode_gid(inode_item); | 1768 | i_gid_write(inode, btrfs_stack_inode_gid(inode_item)); |
| 1769 | btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item)); | 1769 | btrfs_i_size_write(inode, btrfs_stack_inode_size(inode_item)); |
| 1770 | inode->i_mode = btrfs_stack_inode_mode(inode_item); | 1770 | inode->i_mode = btrfs_stack_inode_mode(inode_item); |
| 1771 | set_nlink(inode, btrfs_stack_inode_nlink(inode_item)); | 1771 | set_nlink(inode, btrfs_stack_inode_nlink(inode_item)); |
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h index ab5300595847..c9d703693df0 100644 --- a/fs/btrfs/delayed-ref.h +++ b/fs/btrfs/delayed-ref.h | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | #ifndef __DELAYED_REF__ | 18 | #ifndef __DELAYED_REF__ |
| 19 | #define __DELAYED_REF__ | 19 | #define __DELAYED_REF__ |
| 20 | 20 | ||
| 21 | /* these are the possible values of struct btrfs_delayed_ref->action */ | 21 | /* these are the possible values of struct btrfs_delayed_ref_node->action */ |
| 22 | #define BTRFS_ADD_DELAYED_REF 1 /* add one backref to the tree */ | 22 | #define BTRFS_ADD_DELAYED_REF 1 /* add one backref to the tree */ |
| 23 | #define BTRFS_DROP_DELAYED_REF 2 /* delete one backref from the tree */ | 23 | #define BTRFS_DROP_DELAYED_REF 2 /* delete one backref from the tree */ |
| 24 | #define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */ | 24 | #define BTRFS_ADD_DELAYED_EXTENT 3 /* record a full extent allocation */ |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 4c878476bb91..b08ea4717e9d 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
| @@ -107,6 +107,12 @@ void extent_io_exit(void) | |||
| 107 | list_del(&eb->leak_list); | 107 | list_del(&eb->leak_list); |
| 108 | kmem_cache_free(extent_buffer_cache, eb); | 108 | kmem_cache_free(extent_buffer_cache, eb); |
| 109 | } | 109 | } |
| 110 | |||
| 111 | /* | ||
| 112 | * Make sure all delayed rcu free are flushed before we | ||
| 113 | * destroy caches. | ||
| 114 | */ | ||
| 115 | rcu_barrier(); | ||
| 110 | if (extent_state_cache) | 116 | if (extent_state_cache) |
| 111 | kmem_cache_destroy(extent_state_cache); | 117 | kmem_cache_destroy(extent_state_cache); |
| 112 | if (extent_buffer_cache) | 118 | if (extent_buffer_cache) |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index ec154f954646..a6ed6944e50c 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -1971,8 +1971,8 @@ out: | |||
| 1971 | ordered_extent->len - 1, NULL, GFP_NOFS); | 1971 | ordered_extent->len - 1, NULL, GFP_NOFS); |
| 1972 | 1972 | ||
| 1973 | /* | 1973 | /* |
| 1974 | * This needs to be dont to make sure anybody waiting knows we are done | 1974 | * This needs to be done to make sure anybody waiting knows we are done |
| 1975 | * upating everything for this ordered extent. | 1975 | * updating everything for this ordered extent. |
| 1976 | */ | 1976 | */ |
| 1977 | btrfs_remove_ordered_extent(inode, ordered_extent); | 1977 | btrfs_remove_ordered_extent(inode, ordered_extent); |
| 1978 | 1978 | ||
| @@ -2572,8 +2572,8 @@ static void btrfs_read_locked_inode(struct inode *inode) | |||
| 2572 | struct btrfs_inode_item); | 2572 | struct btrfs_inode_item); |
| 2573 | inode->i_mode = btrfs_inode_mode(leaf, inode_item); | 2573 | inode->i_mode = btrfs_inode_mode(leaf, inode_item); |
| 2574 | set_nlink(inode, btrfs_inode_nlink(leaf, inode_item)); | 2574 | set_nlink(inode, btrfs_inode_nlink(leaf, inode_item)); |
| 2575 | inode->i_uid = btrfs_inode_uid(leaf, inode_item); | 2575 | i_uid_write(inode, btrfs_inode_uid(leaf, inode_item)); |
| 2576 | inode->i_gid = btrfs_inode_gid(leaf, inode_item); | 2576 | i_gid_write(inode, btrfs_inode_gid(leaf, inode_item)); |
| 2577 | btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item)); | 2577 | btrfs_i_size_write(inode, btrfs_inode_size(leaf, inode_item)); |
| 2578 | 2578 | ||
| 2579 | tspec = btrfs_inode_atime(inode_item); | 2579 | tspec = btrfs_inode_atime(inode_item); |
| @@ -2651,8 +2651,8 @@ static void fill_inode_item(struct btrfs_trans_handle *trans, | |||
| 2651 | struct btrfs_inode_item *item, | 2651 | struct btrfs_inode_item *item, |
| 2652 | struct inode *inode) | 2652 | struct inode *inode) |
| 2653 | { | 2653 | { |
| 2654 | btrfs_set_inode_uid(leaf, item, inode->i_uid); | 2654 | btrfs_set_inode_uid(leaf, item, i_uid_read(inode)); |
| 2655 | btrfs_set_inode_gid(leaf, item, inode->i_gid); | 2655 | btrfs_set_inode_gid(leaf, item, i_gid_read(inode)); |
| 2656 | btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); | 2656 | btrfs_set_inode_size(leaf, item, BTRFS_I(inode)->disk_i_size); |
| 2657 | btrfs_set_inode_mode(leaf, item, inode->i_mode); | 2657 | btrfs_set_inode_mode(leaf, item, inode->i_mode); |
| 2658 | btrfs_set_inode_nlink(leaf, item, inode->i_nlink); | 2658 | btrfs_set_inode_nlink(leaf, item, inode->i_nlink); |
| @@ -7076,6 +7076,11 @@ static void init_once(void *foo) | |||
| 7076 | 7076 | ||
| 7077 | void btrfs_destroy_cachep(void) | 7077 | void btrfs_destroy_cachep(void) |
| 7078 | { | 7078 | { |
| 7079 | /* | ||
| 7080 | * Make sure all delayed rcu free inodes are flushed before we | ||
| 7081 | * destroy cache. | ||
| 7082 | */ | ||
| 7083 | rcu_barrier(); | ||
| 7079 | if (btrfs_inode_cachep) | 7084 | if (btrfs_inode_cachep) |
| 7080 | kmem_cache_destroy(btrfs_inode_cachep); | 7085 | kmem_cache_destroy(btrfs_inode_cachep); |
| 7081 | if (btrfs_trans_handle_cachep) | 7086 | if (btrfs_trans_handle_cachep) |
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 9df50fa8a078..47127c1bd290 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c | |||
| @@ -575,13 +575,13 @@ fail: | |||
| 575 | */ | 575 | */ |
| 576 | static inline int btrfs_check_sticky(struct inode *dir, struct inode *inode) | 576 | static inline int btrfs_check_sticky(struct inode *dir, struct inode *inode) |
| 577 | { | 577 | { |
| 578 | uid_t fsuid = current_fsuid(); | 578 | kuid_t fsuid = current_fsuid(); |
| 579 | 579 | ||
| 580 | if (!(dir->i_mode & S_ISVTX)) | 580 | if (!(dir->i_mode & S_ISVTX)) |
| 581 | return 0; | 581 | return 0; |
| 582 | if (inode->i_uid == fsuid) | 582 | if (uid_eq(inode->i_uid, fsuid)) |
| 583 | return 0; | 583 | return 0; |
| 584 | if (dir->i_uid == fsuid) | 584 | if (uid_eq(dir->i_uid, fsuid)) |
| 585 | return 0; | 585 | return 0; |
| 586 | return !capable(CAP_FOWNER); | 586 | return !capable(CAP_FOWNER); |
| 587 | } | 587 | } |
| @@ -1397,7 +1397,6 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file, | |||
| 1397 | u64 *transid, bool readonly, | 1397 | u64 *transid, bool readonly, |
| 1398 | struct btrfs_qgroup_inherit **inherit) | 1398 | struct btrfs_qgroup_inherit **inherit) |
| 1399 | { | 1399 | { |
| 1400 | struct file *src_file; | ||
| 1401 | int namelen; | 1400 | int namelen; |
| 1402 | int ret = 0; | 1401 | int ret = 0; |
| 1403 | 1402 | ||
| @@ -1421,25 +1420,24 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file, | |||
| 1421 | ret = btrfs_mksubvol(&file->f_path, name, namelen, | 1420 | ret = btrfs_mksubvol(&file->f_path, name, namelen, |
| 1422 | NULL, transid, readonly, inherit); | 1421 | NULL, transid, readonly, inherit); |
| 1423 | } else { | 1422 | } else { |
| 1423 | struct fd src = fdget(fd); | ||
| 1424 | struct inode *src_inode; | 1424 | struct inode *src_inode; |
| 1425 | src_file = fget(fd); | 1425 | if (!src.file) { |
| 1426 | if (!src_file) { | ||
| 1427 | ret = -EINVAL; | 1426 | ret = -EINVAL; |
| 1428 | goto out_drop_write; | 1427 | goto out_drop_write; |
| 1429 | } | 1428 | } |
| 1430 | 1429 | ||
| 1431 | src_inode = src_file->f_path.dentry->d_inode; | 1430 | src_inode = src.file->f_path.dentry->d_inode; |
| 1432 | if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) { | 1431 | if (src_inode->i_sb != file->f_path.dentry->d_inode->i_sb) { |
| 1433 | printk(KERN_INFO "btrfs: Snapshot src from " | 1432 | printk(KERN_INFO "btrfs: Snapshot src from " |
| 1434 | "another FS\n"); | 1433 | "another FS\n"); |
| 1435 | ret = -EINVAL; | 1434 | ret = -EINVAL; |
| 1436 | fput(src_file); | 1435 | } else { |
| 1437 | goto out_drop_write; | 1436 | ret = btrfs_mksubvol(&file->f_path, name, namelen, |
| 1437 | BTRFS_I(src_inode)->root, | ||
| 1438 | transid, readonly, inherit); | ||
| 1438 | } | 1439 | } |
| 1439 | ret = btrfs_mksubvol(&file->f_path, name, namelen, | 1440 | fdput(src); |
| 1440 | BTRFS_I(src_inode)->root, | ||
| 1441 | transid, readonly, inherit); | ||
| 1442 | fput(src_file); | ||
| 1443 | } | 1441 | } |
| 1444 | out_drop_write: | 1442 | out_drop_write: |
| 1445 | mnt_drop_write_file(file); | 1443 | mnt_drop_write_file(file); |
| @@ -2341,7 +2339,7 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
| 2341 | { | 2339 | { |
| 2342 | struct inode *inode = fdentry(file)->d_inode; | 2340 | struct inode *inode = fdentry(file)->d_inode; |
| 2343 | struct btrfs_root *root = BTRFS_I(inode)->root; | 2341 | struct btrfs_root *root = BTRFS_I(inode)->root; |
| 2344 | struct file *src_file; | 2342 | struct fd src_file; |
| 2345 | struct inode *src; | 2343 | struct inode *src; |
| 2346 | struct btrfs_trans_handle *trans; | 2344 | struct btrfs_trans_handle *trans; |
| 2347 | struct btrfs_path *path; | 2345 | struct btrfs_path *path; |
| @@ -2376,24 +2374,24 @@ static noinline long btrfs_ioctl_clone(struct file *file, unsigned long srcfd, | |||
| 2376 | if (ret) | 2374 | if (ret) |
| 2377 | return ret; | 2375 | return ret; |
| 2378 | 2376 | ||
| 2379 | src_file = fget(srcfd); | 2377 | src_file = fdget(srcfd); |
| 2380 | if (!src_file) { | 2378 | if (!src_file.file) { |
| 2381 | ret = -EBADF; | 2379 | ret = -EBADF; |
| 2382 | goto out_drop_write; | 2380 | goto out_drop_write; |
| 2383 | } | 2381 | } |
| 2384 | 2382 | ||
| 2385 | ret = -EXDEV; | 2383 | ret = -EXDEV; |
| 2386 | if (src_file->f_path.mnt != file->f_path.mnt) | 2384 | if (src_file.file->f_path.mnt != file->f_path.mnt) |
| 2387 | goto out_fput; | 2385 | goto out_fput; |
| 2388 | 2386 | ||
| 2389 | src = src_file->f_dentry->d_inode; | 2387 | src = src_file.file->f_dentry->d_inode; |
| 2390 | 2388 | ||
| 2391 | ret = -EINVAL; | 2389 | ret = -EINVAL; |
| 2392 | if (src == inode) | 2390 | if (src == inode) |
| 2393 | goto out_fput; | 2391 | goto out_fput; |
| 2394 | 2392 | ||
| 2395 | /* the src must be open for reading */ | 2393 | /* the src must be open for reading */ |
| 2396 | if (!(src_file->f_mode & FMODE_READ)) | 2394 | if (!(src_file.file->f_mode & FMODE_READ)) |
| 2397 | goto out_fput; | 2395 | goto out_fput; |
| 2398 | 2396 | ||
| 2399 | /* don't make the dst file partly checksummed */ | 2397 | /* don't make the dst file partly checksummed */ |
| @@ -2724,7 +2722,7 @@ out_unlock: | |||
| 2724 | vfree(buf); | 2722 | vfree(buf); |
| 2725 | btrfs_free_path(path); | 2723 | btrfs_free_path(path); |
| 2726 | out_fput: | 2724 | out_fput: |
| 2727 | fput(src_file); | 2725 | fdput(src_file); |
| 2728 | out_drop_write: | 2726 | out_drop_write: |
| 2729 | mnt_drop_write_file(file); | 2727 | mnt_drop_write_file(file); |
| 2730 | return ret; | 2728 | return ret; |
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index 48a4882d8ad5..a955669519a2 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c | |||
| @@ -68,7 +68,7 @@ struct reada_extent { | |||
| 68 | u32 blocksize; | 68 | u32 blocksize; |
| 69 | int err; | 69 | int err; |
| 70 | struct list_head extctl; | 70 | struct list_head extctl; |
| 71 | struct kref refcnt; | 71 | int refcnt; |
| 72 | spinlock_t lock; | 72 | spinlock_t lock; |
| 73 | struct reada_zone *zones[BTRFS_MAX_MIRRORS]; | 73 | struct reada_zone *zones[BTRFS_MAX_MIRRORS]; |
| 74 | int nzones; | 74 | int nzones; |
| @@ -126,7 +126,7 @@ static int __readahead_hook(struct btrfs_root *root, struct extent_buffer *eb, | |||
| 126 | spin_lock(&fs_info->reada_lock); | 126 | spin_lock(&fs_info->reada_lock); |
| 127 | re = radix_tree_lookup(&fs_info->reada_tree, index); | 127 | re = radix_tree_lookup(&fs_info->reada_tree, index); |
| 128 | if (re) | 128 | if (re) |
| 129 | kref_get(&re->refcnt); | 129 | re->refcnt++; |
| 130 | spin_unlock(&fs_info->reada_lock); | 130 | spin_unlock(&fs_info->reada_lock); |
| 131 | 131 | ||
| 132 | if (!re) | 132 | if (!re) |
| @@ -336,7 +336,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, | |||
| 336 | spin_lock(&fs_info->reada_lock); | 336 | spin_lock(&fs_info->reada_lock); |
| 337 | re = radix_tree_lookup(&fs_info->reada_tree, index); | 337 | re = radix_tree_lookup(&fs_info->reada_tree, index); |
| 338 | if (re) | 338 | if (re) |
| 339 | kref_get(&re->refcnt); | 339 | re->refcnt++; |
| 340 | spin_unlock(&fs_info->reada_lock); | 340 | spin_unlock(&fs_info->reada_lock); |
| 341 | 341 | ||
| 342 | if (re) | 342 | if (re) |
| @@ -352,7 +352,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, | |||
| 352 | re->top = *top; | 352 | re->top = *top; |
| 353 | INIT_LIST_HEAD(&re->extctl); | 353 | INIT_LIST_HEAD(&re->extctl); |
| 354 | spin_lock_init(&re->lock); | 354 | spin_lock_init(&re->lock); |
| 355 | kref_init(&re->refcnt); | 355 | re->refcnt = 1; |
| 356 | 356 | ||
| 357 | /* | 357 | /* |
| 358 | * map block | 358 | * map block |
| @@ -398,7 +398,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root, | |||
| 398 | if (ret == -EEXIST) { | 398 | if (ret == -EEXIST) { |
| 399 | re_exist = radix_tree_lookup(&fs_info->reada_tree, index); | 399 | re_exist = radix_tree_lookup(&fs_info->reada_tree, index); |
| 400 | BUG_ON(!re_exist); | 400 | BUG_ON(!re_exist); |
| 401 | kref_get(&re_exist->refcnt); | 401 | re_exist->refcnt++; |
| 402 | spin_unlock(&fs_info->reada_lock); | 402 | spin_unlock(&fs_info->reada_lock); |
| 403 | goto error; | 403 | goto error; |
| 404 | } | 404 | } |
| @@ -465,10 +465,6 @@ error: | |||
| 465 | return re_exist; | 465 | return re_exist; |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | static void reada_kref_dummy(struct kref *kr) | ||
| 469 | { | ||
| 470 | } | ||
| 471 | |||
| 472 | static void reada_extent_put(struct btrfs_fs_info *fs_info, | 468 | static void reada_extent_put(struct btrfs_fs_info *fs_info, |
| 473 | struct reada_extent *re) | 469 | struct reada_extent *re) |
| 474 | { | 470 | { |
| @@ -476,7 +472,7 @@ static void reada_extent_put(struct btrfs_fs_info *fs_info, | |||
| 476 | unsigned long index = re->logical >> PAGE_CACHE_SHIFT; | 472 | unsigned long index = re->logical >> PAGE_CACHE_SHIFT; |
| 477 | 473 | ||
| 478 | spin_lock(&fs_info->reada_lock); | 474 | spin_lock(&fs_info->reada_lock); |
| 479 | if (!kref_put(&re->refcnt, reada_kref_dummy)) { | 475 | if (--re->refcnt) { |
| 480 | spin_unlock(&fs_info->reada_lock); | 476 | spin_unlock(&fs_info->reada_lock); |
| 481 | return; | 477 | return; |
| 482 | } | 478 | } |
| @@ -671,7 +667,7 @@ static int reada_start_machine_dev(struct btrfs_fs_info *fs_info, | |||
| 671 | return 0; | 667 | return 0; |
| 672 | } | 668 | } |
| 673 | dev->reada_next = re->logical + re->blocksize; | 669 | dev->reada_next = re->logical + re->blocksize; |
| 674 | kref_get(&re->refcnt); | 670 | re->refcnt++; |
| 675 | 671 | ||
| 676 | spin_unlock(&fs_info->reada_lock); | 672 | spin_unlock(&fs_info->reada_lock); |
| 677 | 673 | ||
