btrfs: cleanup ino cache members of btrfs_root
authorDavid Sterba <dsterba@suse.cz>
Wed, 5 Feb 2014 01:37:48 +0000 (02:37 +0100)
committerChris Mason <clm@fb.com>
Wed, 17 Sep 2014 20:37:09 +0000 (13:37 -0700)
The naming is confusing, generic yet used for a specific cache. Add a
prefix 'ino_' or rename appropriately.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/free-space-cache.c
fs/btrfs/inode-map.c
fs/btrfs/ioctl.c

index 8e29b614fe93d9b8cc22c9eb5d54377d617bb9e7..a835a548e47e0d7409647fc34cbda972edcabf44 100644 (file)
@@ -1776,12 +1776,12 @@ struct btrfs_root {
 
        /* free ino cache stuff */
        struct btrfs_free_space_ctl *free_ino_ctl;
-       enum btrfs_caching_type cached;
-       spinlock_t cache_lock;
-       wait_queue_head_t cache_wait;
+       enum btrfs_caching_type ino_cache_state;
+       spinlock_t ino_cache_lock;
+       wait_queue_head_t ino_cache_wait;
        struct btrfs_free_space_ctl *free_ino_pinned;
-       u64 cache_progress;
-       struct inode *cache_inode;
+       u64 ino_cache_progress;
+       struct inode *ino_cache_inode;
 
        struct mutex log_mutex;
        wait_queue_head_t log_writer_wait;
index a1d36e62179c528041f292675e7452102863de45..354cc3f232bb2d6723c69f944b68d577c2db17bc 100644 (file)
@@ -1573,8 +1573,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
        root->subv_writers = writers;
 
        btrfs_init_free_ino_ctl(root);
-       spin_lock_init(&root->cache_lock);
-       init_waitqueue_head(&root->cache_wait);
+       spin_lock_init(&root->ino_cache_lock);
+       init_waitqueue_head(&root->ino_cache_wait);
 
        ret = get_anon_bdev(&root->anon_dev);
        if (ret)
@@ -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)
 {
-       iput(root->cache_inode);
+       iput(root->ino_cache_inode);
        WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree));
        btrfs_free_block_rsv(root, root->orphan_block_rsv);
        root->orphan_block_rsv = NULL;
index 2b0a627cb5f94e414d3c9751f5e8e384e39c42f9..f181c9afe5f4244e8adf6045ddc3f4d712430f0e 100644 (file)
@@ -3033,10 +3033,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,
 {
        struct inode *inode = NULL;
 
-       spin_lock(&root->cache_lock);
-       if (root->cache_inode)
-               inode = igrab(root->cache_inode);
-       spin_unlock(&root->cache_lock);
+       spin_lock(&root->ino_cache_lock);
+       if (root->ino_cache_inode)
+               inode = igrab(root->ino_cache_inode);
+       spin_unlock(&root->ino_cache_lock);
        if (inode)
                return inode;
 
@@ -3044,10 +3044,10 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,
        if (IS_ERR(inode))
                return inode;
 
-       spin_lock(&root->cache_lock);
+       spin_lock(&root->ino_cache_lock);
        if (!btrfs_fs_closing(root->fs_info))
-               root->cache_inode = igrab(inode);
-       spin_unlock(&root->cache_lock);
+               root->ino_cache_inode = igrab(inode);
+       spin_unlock(&root->ino_cache_lock);
 
        return inode;
 }
index 888fbe19079fd7589484feb089cfa88dcafa6a89..83d646bd2e4b90f34bd597b8ba6f6244071e48f1 100644 (file)
@@ -87,7 +87,7 @@ again:
                                 */
                                btrfs_item_key_to_cpu(leaf, &key, 0);
                                btrfs_release_path(path);
-                               root->cache_progress = last;
+                               root->ino_cache_progress = last;
                                up_read(&fs_info->commit_root_sem);
                                schedule_timeout(1);
                                goto again;
@@ -106,7 +106,7 @@ again:
                if (last != (u64)-1 && last + 1 != key.objectid) {
                        __btrfs_add_free_space(ctl, last + 1,
                                               key.objectid - last - 1);
-                       wake_up(&root->cache_wait);
+                       wake_up(&root->ino_cache_wait);
                }
 
                last = key.objectid;
@@ -119,14 +119,14 @@ next:
                                       root->highest_objectid - last - 1);
        }
 
-       spin_lock(&root->cache_lock);
-       root->cached = BTRFS_CACHE_FINISHED;
-       spin_unlock(&root->cache_lock);
+       spin_lock(&root->ino_cache_lock);
+       root->ino_cache_state = BTRFS_CACHE_FINISHED;
+       spin_unlock(&root->ino_cache_lock);
 
-       root->cache_progress = (u64)-1;
+       root->ino_cache_progress = (u64)-1;
        btrfs_unpin_free_ino(root);
 out:
-       wake_up(&root->cache_wait);
+       wake_up(&root->ino_cache_wait);
        up_read(&fs_info->commit_root_sem);
 
        btrfs_free_path(path);
@@ -144,20 +144,20 @@ static void start_caching(struct btrfs_root *root)
        if (!btrfs_test_opt(root, INODE_MAP_CACHE))
                return;
 
-       spin_lock(&root->cache_lock);
-       if (root->cached != BTRFS_CACHE_NO) {
-               spin_unlock(&root->cache_lock);
+       spin_lock(&root->ino_cache_lock);
+       if (root->ino_cache_state != BTRFS_CACHE_NO) {
+               spin_unlock(&root->ino_cache_lock);
                return;
        }
 
-       root->cached = BTRFS_CACHE_STARTED;
-       spin_unlock(&root->cache_lock);
+       root->ino_cache_state = BTRFS_CACHE_STARTED;
+       spin_unlock(&root->ino_cache_lock);
 
        ret = load_free_ino_cache(root->fs_info, root);
        if (ret == 1) {
-               spin_lock(&root->cache_lock);
-               root->cached = BTRFS_CACHE_FINISHED;
-               spin_unlock(&root->cache_lock);
+               spin_lock(&root->ino_cache_lock);
+               root->ino_cache_state = BTRFS_CACHE_FINISHED;
+               spin_unlock(&root->ino_cache_lock);
                return;
        }
 
@@ -196,11 +196,11 @@ again:
 
        start_caching(root);
 
-       wait_event(root->cache_wait,
-                  root->cached == BTRFS_CACHE_FINISHED ||
+       wait_event(root->ino_cache_wait,
+                  root->ino_cache_state == BTRFS_CACHE_FINISHED ||
                   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)
                return -ENOSPC;
        else
@@ -214,17 +214,17 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
        if (!btrfs_test_opt(root, INODE_MAP_CACHE))
                return;
 again:
-       if (root->cached == BTRFS_CACHE_FINISHED) {
+       if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
                __btrfs_add_free_space(pinned, objectid, 1);
        } else {
                down_write(&root->fs_info->commit_root_sem);
-               spin_lock(&root->cache_lock);
-               if (root->cached == BTRFS_CACHE_FINISHED) {
-                       spin_unlock(&root->cache_lock);
+               spin_lock(&root->ino_cache_lock);
+               if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
+                       spin_unlock(&root->ino_cache_lock);
                        up_write(&root->fs_info->commit_root_sem);
                        goto again;
                }
-               spin_unlock(&root->cache_lock);
+               spin_unlock(&root->ino_cache_lock);
 
                start_caching(root);
 
@@ -235,10 +235,10 @@ again:
 }
 
 /*
- * When a transaction is committed, we'll move those inode numbers which
- * are smaller than root->cache_progress from pinned tree to free_ino tree,
- * and others will just be dropped, because the commit root we were
- * searching has changed.
+ * When a transaction is committed, we'll move those inode numbers which are
+ * smaller than root->ino_cache_progress from pinned tree to free_ino tree, and
+ * others will just be dropped, because the commit root we were searching has
+ * changed.
  *
  * Must be called with root->fs_info->commit_root_sem held
  */
@@ -261,10 +261,10 @@ void btrfs_unpin_free_ino(struct btrfs_root *root)
                info = rb_entry(n, struct btrfs_free_space, offset_index);
                BUG_ON(info->bitmap); /* Logic error */
 
-               if (info->offset > root->cache_progress)
+               if (info->offset > root->ino_cache_progress)
                        goto free;
-               else if (info->offset + info->bytes > root->cache_progress)
-                       count = root->cache_progress - info->offset + 1;
+               else if (info->offset + info->bytes > root->ino_cache_progress)
+                       count = root->ino_cache_progress - info->offset + 1;
                else
                        count = info->bytes;
 
@@ -462,13 +462,13 @@ again:
                }
        }
 
-       spin_lock(&root->cache_lock);
-       if (root->cached != BTRFS_CACHE_FINISHED) {
+       spin_lock(&root->ino_cache_lock);
+       if (root->ino_cache_state != BTRFS_CACHE_FINISHED) {
                ret = -1;
-               spin_unlock(&root->cache_lock);
+               spin_unlock(&root->ino_cache_lock);
                goto out_put;
        }
-       spin_unlock(&root->cache_lock);
+       spin_unlock(&root->ino_cache_lock);
 
        spin_lock(&ctl->tree_lock);
        prealloc = sizeof(struct btrfs_free_space) * ctl->free_extents;
index 8a8e29878c34283812f8d990c2432cff94bbab2a..091c4d35671bb1ddf6db43c720c3787214eae3a8 100644 (file)
@@ -2526,9 +2526,9 @@ out_unlock:
                ASSERT(dest->send_in_progress == 0);
 
                /* the last ref */
-               if (dest->cache_inode) {
-                       iput(dest->cache_inode);
-                       dest->cache_inode = NULL;
+               if (dest->ino_cache_inode) {
+                       iput(dest->ino_cache_inode);
+                       dest->ino_cache_inode = NULL;
                }
        }
 out_dput: