Skip to content

Commit 57cdc8d

Browse files
kdaveChris Mason
authored andcommitted
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: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
1 parent c6f83c7 commit 57cdc8d

5 files changed

Lines changed: 52 additions & 52 deletions

File tree

‎fs/btrfs/ctree.h‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,12 +1776,12 @@ struct btrfs_root {
17761776

17771777
/* free ino cache stuff */
17781778
struct btrfs_free_space_ctl *free_ino_ctl;
1779-
enum btrfs_caching_type cached;
1780-
spinlock_t cache_lock;
1781-
wait_queue_head_t cache_wait;
1779+
enum btrfs_caching_type ino_cache_state;
1780+
spinlock_t ino_cache_lock;
1781+
wait_queue_head_t ino_cache_wait;
17821782
struct btrfs_free_space_ctl *free_ino_pinned;
1783-
u64 cache_progress;
1784-
struct inode *cache_inode;
1783+
u64 ino_cache_progress;
1784+
struct inode *ino_cache_inode;
17851785

17861786
struct mutex log_mutex;
17871787
wait_queue_head_t log_writer_wait;

‎fs/btrfs/disk-io.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,8 +1573,8 @@ int btrfs_init_fs_root(struct btrfs_root *root)
15731573
root->subv_writers = writers;
15741574

15751575
btrfs_init_free_ino_ctl(root);
1576-
spin_lock_init(&root->cache_lock);
1577-
init_waitqueue_head(&root->cache_wait);
1576+
spin_lock_init(&root->ino_cache_lock);
1577+
init_waitqueue_head(&root->ino_cache_wait);
15781578

15791579
ret = get_anon_bdev(&root->anon_dev);
15801580
if (ret)
@@ -3532,7 +3532,7 @@ void btrfs_drop_and_free_fs_root(struct btrfs_fs_info *fs_info,
35323532

35333533
static void free_fs_root(struct btrfs_root *root)
35343534
{
3535-
iput(root->cache_inode);
3535+
iput(root->ino_cache_inode);
35363536
WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree));
35373537
btrfs_free_block_rsv(root, root->orphan_block_rsv);
35383538
root->orphan_block_rsv = NULL;

‎fs/btrfs/free-space-cache.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3033,21 +3033,21 @@ struct inode *lookup_free_ino_inode(struct btrfs_root *root,
30333033
{
30343034
struct inode *inode = NULL;
30353035

3036-
spin_lock(&root->cache_lock);
3037-
if (root->cache_inode)
3038-
inode = igrab(root->cache_inode);
3039-
spin_unlock(&root->cache_lock);
3036+
spin_lock(&root->ino_cache_lock);
3037+
if (root->ino_cache_inode)
3038+
inode = igrab(root->ino_cache_inode);
3039+
spin_unlock(&root->ino_cache_lock);
30403040
if (inode)
30413041
return inode;
30423042

30433043
inode = __lookup_free_space_inode(root, path, 0);
30443044
if (IS_ERR(inode))
30453045
return inode;
30463046

3047-
spin_lock(&root->cache_lock);
3047+
spin_lock(&root->ino_cache_lock);
30483048
if (!btrfs_fs_closing(root->fs_info))
3049-
root->cache_inode = igrab(inode);
3050-
spin_unlock(&root->cache_lock);
3049+
root->ino_cache_inode = igrab(inode);
3050+
spin_unlock(&root->ino_cache_lock);
30513051

30523052
return inode;
30533053
}

‎fs/btrfs/inode-map.c‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static int caching_kthread(void *data)
8787
*/
8888
btrfs_item_key_to_cpu(leaf, &key, 0);
8989
btrfs_release_path(path);
90-
root->cache_progress = last;
90+
root->ino_cache_progress = last;
9191
up_read(&fs_info->commit_root_sem);
9292
schedule_timeout(1);
9393
goto again;
@@ -106,7 +106,7 @@ static int caching_kthread(void *data)
106106
if (last != (u64)-1 && last + 1 != key.objectid) {
107107
__btrfs_add_free_space(ctl, last + 1,
108108
key.objectid - last - 1);
109-
wake_up(&root->cache_wait);
109+
wake_up(&root->ino_cache_wait);
110110
}
111111

112112
last = key.objectid;
@@ -119,14 +119,14 @@ static int caching_kthread(void *data)
119119
root->highest_objectid - last - 1);
120120
}
121121

122-
spin_lock(&root->cache_lock);
123-
root->cached = BTRFS_CACHE_FINISHED;
124-
spin_unlock(&root->cache_lock);
122+
spin_lock(&root->ino_cache_lock);
123+
root->ino_cache_state = BTRFS_CACHE_FINISHED;
124+
spin_unlock(&root->ino_cache_lock);
125125

126-
root->cache_progress = (u64)-1;
126+
root->ino_cache_progress = (u64)-1;
127127
btrfs_unpin_free_ino(root);
128128
out:
129-
wake_up(&root->cache_wait);
129+
wake_up(&root->ino_cache_wait);
130130
up_read(&fs_info->commit_root_sem);
131131

132132
btrfs_free_path(path);
@@ -144,20 +144,20 @@ static void start_caching(struct btrfs_root *root)
144144
if (!btrfs_test_opt(root, INODE_MAP_CACHE))
145145
return;
146146

147-
spin_lock(&root->cache_lock);
148-
if (root->cached != BTRFS_CACHE_NO) {
149-
spin_unlock(&root->cache_lock);
147+
spin_lock(&root->ino_cache_lock);
148+
if (root->ino_cache_state != BTRFS_CACHE_NO) {
149+
spin_unlock(&root->ino_cache_lock);
150150
return;
151151
}
152152

153-
root->cached = BTRFS_CACHE_STARTED;
154-
spin_unlock(&root->cache_lock);
153+
root->ino_cache_state = BTRFS_CACHE_STARTED;
154+
spin_unlock(&root->ino_cache_lock);
155155

156156
ret = load_free_ino_cache(root->fs_info, root);
157157
if (ret == 1) {
158-
spin_lock(&root->cache_lock);
159-
root->cached = BTRFS_CACHE_FINISHED;
160-
spin_unlock(&root->cache_lock);
158+
spin_lock(&root->ino_cache_lock);
159+
root->ino_cache_state = BTRFS_CACHE_FINISHED;
160+
spin_unlock(&root->ino_cache_lock);
161161
return;
162162
}
163163

@@ -196,11 +196,11 @@ int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid)
196196

197197
start_caching(root);
198198

199-
wait_event(root->cache_wait,
200-
root->cached == BTRFS_CACHE_FINISHED ||
199+
wait_event(root->ino_cache_wait,
200+
root->ino_cache_state == BTRFS_CACHE_FINISHED ||
201201
root->free_ino_ctl->free_space > 0);
202202

203-
if (root->cached == BTRFS_CACHE_FINISHED &&
203+
if (root->ino_cache_state == BTRFS_CACHE_FINISHED &&
204204
root->free_ino_ctl->free_space == 0)
205205
return -ENOSPC;
206206
else
@@ -214,17 +214,17 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
214214
if (!btrfs_test_opt(root, INODE_MAP_CACHE))
215215
return;
216216
again:
217-
if (root->cached == BTRFS_CACHE_FINISHED) {
217+
if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
218218
__btrfs_add_free_space(pinned, objectid, 1);
219219
} else {
220220
down_write(&root->fs_info->commit_root_sem);
221-
spin_lock(&root->cache_lock);
222-
if (root->cached == BTRFS_CACHE_FINISHED) {
223-
spin_unlock(&root->cache_lock);
221+
spin_lock(&root->ino_cache_lock);
222+
if (root->ino_cache_state == BTRFS_CACHE_FINISHED) {
223+
spin_unlock(&root->ino_cache_lock);
224224
up_write(&root->fs_info->commit_root_sem);
225225
goto again;
226226
}
227-
spin_unlock(&root->cache_lock);
227+
spin_unlock(&root->ino_cache_lock);
228228

229229
start_caching(root);
230230

@@ -235,10 +235,10 @@ void btrfs_return_ino(struct btrfs_root *root, u64 objectid)
235235
}
236236

237237
/*
238-
* When a transaction is committed, we'll move those inode numbers which
239-
* are smaller than root->cache_progress from pinned tree to free_ino tree,
240-
* and others will just be dropped, because the commit root we were
241-
* searching has changed.
238+
* When a transaction is committed, we'll move those inode numbers which are
239+
* smaller than root->ino_cache_progress from pinned tree to free_ino tree, and
240+
* others will just be dropped, because the commit root we were searching has
241+
* changed.
242242
*
243243
* Must be called with root->fs_info->commit_root_sem held
244244
*/
@@ -261,10 +261,10 @@ void btrfs_unpin_free_ino(struct btrfs_root *root)
261261
info = rb_entry(n, struct btrfs_free_space, offset_index);
262262
BUG_ON(info->bitmap); /* Logic error */
263263

264-
if (info->offset > root->cache_progress)
264+
if (info->offset > root->ino_cache_progress)
265265
goto free;
266-
else if (info->offset + info->bytes > root->cache_progress)
267-
count = root->cache_progress - info->offset + 1;
266+
else if (info->offset + info->bytes > root->ino_cache_progress)
267+
count = root->ino_cache_progress - info->offset + 1;
268268
else
269269
count = info->bytes;
270270

@@ -462,13 +462,13 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
462462
}
463463
}
464464

465-
spin_lock(&root->cache_lock);
466-
if (root->cached != BTRFS_CACHE_FINISHED) {
465+
spin_lock(&root->ino_cache_lock);
466+
if (root->ino_cache_state != BTRFS_CACHE_FINISHED) {
467467
ret = -1;
468-
spin_unlock(&root->cache_lock);
468+
spin_unlock(&root->ino_cache_lock);
469469
goto out_put;
470470
}
471-
spin_unlock(&root->cache_lock);
471+
spin_unlock(&root->ino_cache_lock);
472472

473473
spin_lock(&ctl->tree_lock);
474474
prealloc = sizeof(struct btrfs_free_space) * ctl->free_extents;

‎fs/btrfs/ioctl.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2526,9 +2526,9 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
25262526
ASSERT(dest->send_in_progress == 0);
25272527

25282528
/* the last ref */
2529-
if (dest->cache_inode) {
2530-
iput(dest->cache_inode);
2531-
dest->cache_inode = NULL;
2529+
if (dest->ino_cache_inode) {
2530+
iput(dest->ino_cache_inode);
2531+
dest->ino_cache_inode = NULL;
25322532
}
25332533
}
25342534
out_dput:

0 commit comments

Comments
 (0)