1 ext4: minor cleanup of ext4_da_reserve_space()
3 From: Eric Whitney <enwlinux@gmail.com>
5 Remove outdated comments and dead code from ext4_da_reserve_space.
6 Clean up its trace point, and relocate it to make it more useful.
8 While we're at it, fix a nearby conditional used to determine if
9 we have a non-bigalloc file system. It doesn't match usage elsewhere
10 in the code, and misleadingly suggests that an s_cluster_ratio value
13 Signed-off-by: Eric Whitney <enwlinux@gmail.com>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
16 fs/ext4/inode.c | 22 +++++-----------------
17 include/trace/events/ext4.h | 10 ++++------
18 2 files changed, 9 insertions(+), 23 deletions(-)
20 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
21 index 7eb70b7..fecc1d0 100644
24 @@ -1262,13 +1262,12 @@ static int ext4_journalled_write_end(struct file *file,
28 - * Reserve a single cluster located at lblock
29 + * Reserve space for a single cluster
31 -static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock)
32 +static int ext4_da_reserve_space(struct inode *inode)
34 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb);
35 struct ext4_inode_info *ei = EXT4_I(inode);
36 - unsigned int md_needed;
40 @@ -1280,25 +1279,14 @@ static int ext4_da_reserve_space(struct inode *inode, ext4_lblk_t lblock)
45 - * recalculate the amount of metadata blocks to reserve
46 - * in order to allocate nrblocks
47 - * worse case is one extent per block
49 spin_lock(&ei->i_block_reservation_lock);
51 - * ext4_calc_metadata_amount() has side effects, which we have
52 - * to be prepared undo if we fail to claim space.
55 - trace_ext4_da_reserve_space(inode, 0);
57 if (ext4_claim_free_clusters(sbi, 1, 0)) {
58 spin_unlock(&ei->i_block_reservation_lock);
59 dquot_release_reservation_block(inode, EXT4_C2B(sbi, 1));
62 ei->i_reserved_data_blocks++;
63 + trace_ext4_da_reserve_space(inode);
64 spin_unlock(&ei->i_block_reservation_lock);
66 return 0; /* success */
67 @@ -1567,9 +1555,9 @@ add_delayed:
68 * then we don't need to reserve it again. However we still need
69 * to reserve metadata for every block we're going to write.
71 - if (EXT4_SB(inode->i_sb)->s_cluster_ratio <= 1 ||
72 + if (EXT4_SB(inode->i_sb)->s_cluster_ratio == 1 ||
73 !ext4_find_delalloc_cluster(inode, map->m_lblk)) {
74 - ret = ext4_da_reserve_space(inode, iblock);
75 + ret = ext4_da_reserve_space(inode);
77 /* not enough space to reserve */
79 diff --git a/include/trace/events/ext4.h b/include/trace/events/ext4.h
80 index 6e5abd6..6ed16df 100644
81 --- a/include/trace/events/ext4.h
82 +++ b/include/trace/events/ext4.h
83 @@ -1185,15 +1185,14 @@ TRACE_EVENT(ext4_da_update_reserve_space,
86 TRACE_EVENT(ext4_da_reserve_space,
87 - TP_PROTO(struct inode *inode, int md_needed),
88 + TP_PROTO(struct inode *inode),
90 - TP_ARGS(inode, md_needed),
96 __field( __u64, i_blocks )
97 - __field( int, md_needed )
98 __field( int, reserved_data_blocks )
99 __field( int, reserved_meta_blocks )
100 __field( __u16, mode )
101 @@ -1203,18 +1202,17 @@ TRACE_EVENT(ext4_da_reserve_space,
102 __entry->dev = inode->i_sb->s_dev;
103 __entry->ino = inode->i_ino;
104 __entry->i_blocks = inode->i_blocks;
105 - __entry->md_needed = md_needed;
106 __entry->reserved_data_blocks = EXT4_I(inode)->i_reserved_data_blocks;
107 __entry->reserved_meta_blocks = EXT4_I(inode)->i_reserved_meta_blocks;
108 __entry->mode = inode->i_mode;
111 - TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu md_needed %d "
112 + TP_printk("dev %d,%d ino %lu mode 0%o i_blocks %llu "
113 "reserved_data_blocks %d reserved_meta_blocks %d",
114 MAJOR(__entry->dev), MINOR(__entry->dev),
115 (unsigned long) __entry->ino,
116 __entry->mode, __entry->i_blocks,
117 - __entry->md_needed, __entry->reserved_data_blocks,
118 + __entry->reserved_data_blocks,
119 __entry->reserved_meta_blocks)