diff options
| -rw-r--r-- | fs/btrfs/reada.c | 18 |
1 files changed, 7 insertions, 11 deletions
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 | ||
