Commit 57cdc8db authored by David Sterba's avatar David Sterba Committed by Chris Mason

btrfs: cleanup ino cache members of btrfs_root

The naming is confusing, generic yet used for a specific cache. Add a
prefix 'ino_' or rename appropriately.
Signed-off-by: default avatarDavid Sterba <dsterba@suse.cz>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent c6f83c74
...@@ -1776,12 +1776,12 @@ struct btrfs_root { ...@@ -1776,12 +1776,12 @@ struct btrfs_root {
/* free ino cache stuff */ /* free ino cache stuff */
struct btrfs_free_space_ctl *free_ino_ctl; struct btrfs_free_space_ctl *free_ino_ctl;
enum btrfs_caching_type cached; enum btrfs_caching_type ino_cache_state;
spinlock_t cache_lock; spinlock_t ino_cache_lock;
wait_queue_head_t cache_wait; wait_queue_head_t ino_cache_wait;
struct btrfs_free_space_ctl *free_ino_pinned; struct btrfs_free_space_ctl *free_ino_pinned;
u64 cache_progress; u64 ino_cache_progress;
struct inode *cache_inode; struct inode *ino_cache_inode;
struct mutex log_mutex; struct mutex log_mutex;
wait_queue_head_t log_writer_wait; wait_queue_head_t log_writer_wait;
......
...@@ -1573,8 +1573,8 @@ int btrfs_init_fs_root(struct btrfs_root *root) ...@@ -1573,8 +1573,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
root->subv_writers = writers; root->subv_writers = writers;
btrfs_init_free_ino_ctl(root); btrfs_init_free_ino_ctl(root);
spin_lock_init(&root->cache_lock); spin_lock_init(&root->ino_cache_lock);
init_waitqueue_head(&root->cache_wait); init_waitqueue_head(&root->ino_cache_wait);
ret = get_anon_bdev(&root->anon_dev); ret = get_anon_bdev(&root->anon_dev);
if (ret) if (ret)
...@@ -3532,7 +3532,7 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info, ...@@ -3532,7 +3532,7 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
static void free_fs_root(struct btrfs_root *root) static void free_fs_root(struct btrfs_root *root)
{ {
iput(root->cache_inode); iput(root->ino_cache_inode);
WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree));
btrfs_free_block_rsv(root, root->orphan_block_rsv); btrfs_free_block_rsv(root, root->orphan_block_rsv);
root->orphan_block_rsv = NULL; root->orphan_block_rsv = NULL;
......
...@@ -3033,10 +3033,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root, ...@@ -3033,10 +3033,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,
{ {
struct inode *inode = NULL; struct inode *inode = NULL;
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
if (root->cache_inode) if (root->ino_cache_inode)
inode = igrab(root->cache_inode); inode = igrab(root->ino_cache_inode);
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
if (inode) if (inode)
return inode; return inode;
...@@ -3044,10 +3044,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root, ...@@ -3044,10 +3044,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,
if (IS_ERR(inode)) if (IS_ERR(inode))
return inode; return inode;
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
if (!btrfs_fs_closing(root->fs_info)) if (!btrfs_fs_closing(root->fs_info))
root->cache_inode = igrab(inode); root->ino_cache_inode = igrab(inode);
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
return inode; return inode;
} }
......
...@@ -87,7 +87,7 @@ static int caching_kthread(void *data) ...@@ -87,7 +87,7 @@ static int caching_kthread(void *data)
*/ */
btrfs_item_key_to_cpu(leaf, &key, 0); btrfs_item_key_to_cpu(leaf, &key, 0);
btrfs_release_path(path); btrfs_release_path(path);
root->cache_progress = last; root->ino_cache_progress = last;
up_read(&fs_info->commit_root_sem); up_read(&fs_info->commit_root_sem);
schedule_timeout(1); schedule_timeout(1);
goto again; goto again;
...@@ -106,7 +106,7 @@ static int caching_kthread(void *data) ...@@ -106,7 +106,7 @@ static int caching_kthread(void *data)
if (last != (u64)-1 && last + 1 != key.objectid) { if (last != (u64)-1 && last + 1 != key.objectid) {
__btrfs_add_free_space(ctl, last + 1, __btrfs_add_free_space(ctl, last + 1,
key.objectid - last - 1); key.objectid - last - 1);
wake_up(&root->cache_wait); wake_up(&root->ino_cache_wait);
} }
last = key.objectid; last = key.objectid;
...@@ -119,14 +119,14 @@ static int caching_kthread(void *data) ...@@ -119,14 +119,14 @@ static int caching_kthread(void *data)
root->highest_objectid - last - 1); root->highest_objectid - last - 1);
} }
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
root->cached = BTRFS_CACHE_FINISHED; root->ino_cache_state = BTRFS_CACHE_FINISHED;
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
root->cache_progress = (u64)-1; root->ino_cache_progress = (u64)-1;
btrfs_unpin_free_ino(root); btrfs_unpin_free_ino(root);
out: out:
wake_up(&root->cache_wait); wake_up(&root->ino_cache_wait);
up_read(&fs_info->commit_root_sem); up_read(&fs_info->commit_root_sem);
btrfs_free_path(path); btrfs_free_path(path);
...@@ -144,20 +144,20 @@ static void start_caching(struct btrfs_root *root) ...@@ -144,20 +144,20 @@ static void start_caching(struct btrfs_root *root)
if (!btrfs_test_opt(root, INODE_MAP_CACHE)) if (!btrfs_test_opt(root, INODE_MAP_CACHE))
return; return;
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
if (root->cached != BTRFS_CACHE_NO) { if (root->ino_cache_state != BTRFS_CACHE_NO) {
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
return; return;
} }
root->cached = BTRFS_CACHE_STARTED; root->ino_cache_state = BTRFS_CACHE_STARTED;
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
ret = load_free_ino_cache(root->fs_info, root); ret = load_free_ino_cache(root->fs_info, root);
if (ret == 1) { if (ret == 1) {
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
root->cached = BTRFS_CACHE_FINISHED; root->ino_cache_state = BTRFS_CACHE_FINISHED;
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
return; return;
} }
...@@ -196,11 +196,11 @@ int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) ...@@ -196,11 +196,11 @@ int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)
start_caching(root); start_caching(root);
wait_event(root->cache_wait, wait_event(root->ino_cache_wait,
root->cached == BTRFS_CACHE_FINISHED || root->ino_cache_state == BTRFS_CACHE_FINISHED ||
root->free_ino_ctl->free_space > 0); root->free_ino_ctl->free_space > 0);
if (root->cached == BTRFS_CACHE_FINISHED && if (root->ino_cache_state == BTRFS_CACHE_FINISHED &&
root->free_ino_ctl->free_space == 0) root->free_ino_ctl->free_space == 0)
return -ENOSPC; return -ENOSPC;
else else
...@@ -214,17 +214,17 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid) ...@@ -214,17 +214,17 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
if (!btrfs_test_opt(root, INODE_MAP_CACHE)) if (!btrfs_test_opt(root, INODE_MAP_CACHE))
return; return;
again: again:
if (root->cached == BTRFS_CACHE_FINISHED) { if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
__btrfs_add_free_space(pinned, objectid, 1); __btrfs_add_free_space(pinned, objectid, 1);
} else { } else {
down_write(&root->fs_info->commit_root_sem); down_write(&root->fs_info->commit_root_sem);
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
if (root->cached == BTRFS_CACHE_FINISHED) { if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
up_write(&root->fs_info->commit_root_sem); up_write(&root->fs_info->commit_root_sem);
goto again; goto again;
} }
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
start_caching(root); start_caching(root);
...@@ -235,10 +235,10 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid) ...@@ -235,10 +235,10 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
} }
/* /*
* When a transaction is committed, we'll move those inode numbers which * When a transaction is committed, we'll move those inode numbers which are
* are smaller than root->cache_progress from pinned tree to free_ino tree, * smaller than root->ino_cache_progress from pinned tree to free_ino tree, and
* and others will just be dropped, because the commit root we were * others will just be dropped, because the commit root we were searching has
* searching has changed. * changed.
* *
* Must be called with root->fs_info->commit_root_sem held * Must be called with root->fs_info->commit_root_sem held
*/ */
...@@ -261,10 +261,10 @@ void btrfs_unpin_free_ino(struct btrfs_root *root) ...@@ -261,10 +261,10 @@ void btrfs_unpin_free_ino(struct btrfs_root *root)
info = rb_entry(n, struct btrfs_free_space, offset_index); info = rb_entry(n, struct btrfs_free_space, offset_index);
BUG_ON(info->bitmap); /* Logic error */ BUG_ON(info->bitmap); /* Logic error */
if (info->offset > root->cache_progress) if (info->offset > root->ino_cache_progress)
goto free; goto free;
else if (info->offset + info->bytes > root->cache_progress) else if (info->offset + info->bytes > root->ino_cache_progress)
count = root->cache_progress - info->offset + 1; count = root->ino_cache_progress - info->offset + 1;
else else
count = info->bytes; count = info->bytes;
...@@ -462,13 +462,13 @@ int btrfs_save_ino_cache(struct btrfs_root *root, ...@@ -462,13 +462,13 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
} }
} }
spin_lock(&root->cache_lock); spin_lock(&root->ino_cache_lock);
if (root->cached != BTRFS_CACHE_FINISHED) { if (root->ino_cache_state != BTRFS_CACHE_FINISHED) {
ret = -1; ret = -1;
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
goto out_put; goto out_put;
} }
spin_unlock(&root->cache_lock); spin_unlock(&root->ino_cache_lock);
spin_lock(&ctl->tree_lock); spin_lock(&ctl->tree_lock);
prealloc = sizeof(struct btrfs_free_space) * ctl->free_extents; prealloc = sizeof(struct btrfs_free_space) * ctl->free_extents;
......
...@@ -2526,9 +2526,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, ...@@ -2526,9 +2526,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
ASSERT(dest->send_in_progress == 0); ASSERT(dest->send_in_progress == 0);
/* the last ref */ /* the last ref */
if (dest->cache_inode) { if (dest->ino_cache_inode) {
iput(dest->cache_inode); iput(dest->ino_cache_inode);
dest->cache_inode = NULL; dest->ino_cache_inode = NULL;
} }
} }
out_dput: out_dput:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment