Skip to content

Commit c1c3fac

Browse files
lorddoskiaskdave
authored andcommitted
btrfs: Remove btrfs_inode::delayed_iput_count
delayed_iput_count wa supposed to be used to implement, well, delayed iput. The idea is that we keep accumulating the number of iputs we do until eventually the inode is deleted. Turns out we never really switched the delayed_iput_count from 0 to 1, hence all conditional code relying on the value of that member being different than 0 was never executed. This, as it turns out, didn't cause any problem due to the simple fact that the generic inode's i_count member was always used to count the number of iputs. So let's just remove the unused member and all unused code. This patch essentially provides no functional changes. While at it, also add proper documentation for btrfs_add_delayed_iput Signed-off-by: Nikolay Borisov <[email protected]> Reviewed-by: David Sterba <[email protected]> [ reformat comment ] Signed-off-by: David Sterba <[email protected]>
1 parent 793ff2c commit c1c3fac

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

fs/btrfs/btrfs_inode.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ struct btrfs_inode {
195195

196196
/* Hook into fs_info->delayed_iputs */
197197
struct list_head delayed_iput;
198-
long delayed_iput_count;
199198

200199
/*
201200
* To avoid races between lockless (i_mutex not held) direct IO writes

fs/btrfs/inode.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,6 +3242,16 @@ static int btrfs_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
32423242
start, (size_t)(end - start + 1));
32433243
}
32443244

3245+
/*
3246+
* btrfs_add_delayed_iput - perform a delayed iput on @inode
3247+
*
3248+
* @inode: The inode we want to perform iput on
3249+
*
3250+
* This function uses the generic vfs_inode::i_count to track whether we should
3251+
* just decrement it (in case it's > 1) or if this is the last iput then link
3252+
* the inode to the delayed iput machinery. Delayed iputs are processed at
3253+
* transaction commit time/superblock commit/cleaner kthread.
3254+
*/
32453255
void btrfs_add_delayed_iput(struct inode *inode)
32463256
{
32473257
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
@@ -3251,12 +3261,8 @@ void btrfs_add_delayed_iput(struct inode *inode)
32513261
return;
32523262

32533263
spin_lock(&fs_info->delayed_iput_lock);
3254-
if (binode->delayed_iput_count == 0) {
3255-
ASSERT(list_empty(&binode->delayed_iput));
3256-
list_add_tail(&binode->delayed_iput, &fs_info->delayed_iputs);
3257-
} else {
3258-
binode->delayed_iput_count++;
3259-
}
3264+
ASSERT(list_empty(&binode->delayed_iput));
3265+
list_add_tail(&binode->delayed_iput, &fs_info->delayed_iputs);
32603266
spin_unlock(&fs_info->delayed_iput_lock);
32613267
}
32623268

@@ -3269,13 +3275,7 @@ void btrfs_run_delayed_iputs(struct btrfs_fs_info *fs_info)
32693275

32703276
inode = list_first_entry(&fs_info->delayed_iputs,
32713277
struct btrfs_inode, delayed_iput);
3272-
if (inode->delayed_iput_count) {
3273-
inode->delayed_iput_count--;
3274-
list_move_tail(&inode->delayed_iput,
3275-
&fs_info->delayed_iputs);
3276-
} else {
3277-
list_del_init(&inode->delayed_iput);
3278-
}
3278+
list_del_init(&inode->delayed_iput);
32793279
spin_unlock(&fs_info->delayed_iput_lock);
32803280
iput(&inode->vfs_inode);
32813281
spin_lock(&fs_info->delayed_iput_lock);
@@ -9333,7 +9333,6 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
93339333
ei->dir_index = 0;
93349334
ei->last_unlink_trans = 0;
93359335
ei->last_log_commit = 0;
9336-
ei->delayed_iput_count = 0;
93379336

93389337
spin_lock_init(&ei->lock);
93399338
ei->outstanding_extents = 0;

0 commit comments

Comments
 (0)