Skip to content

Commit 12062dd

Browse files
Eric Sandeentytso
authored andcommitted
ext4: move __func__ into a macro for ext4_warning, ext4_error
Just a pet peeve of mine; we had a mishash of calls with either __func__ or "function_name" and the latter tends to get out of sync. I think it's easier to just hide the __func__ in a macro, and it'll be consistent from then on. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent f710b4b commit 12062dd

13 files changed

Lines changed: 146 additions & 210 deletions

File tree

‎fs/ext4/balloc.c‎

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
9797
/* If checksum is bad mark all blocks used to prevent allocation
9898
* essentially implementing a per-group read-only flag. */
9999
if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
100-
ext4_error(sb, __func__,
101-
"Checksum bad for group %u", block_group);
100+
ext4_error(sb, "Checksum bad for group %u",
101+
block_group);
102102
ext4_free_blks_set(sb, gdp, 0);
103103
ext4_free_inodes_set(sb, gdp, 0);
104104
ext4_itable_unused_set(sb, gdp, 0);
@@ -210,19 +210,16 @@ struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
210210
struct ext4_sb_info *sbi = EXT4_SB(sb);
211211

212212
if (block_group >= ngroups) {
213-
ext4_error(sb, "ext4_get_group_desc",
214-
"block_group >= groups_count - "
215-
"block_group = %u, groups_count = %u",
216-
block_group, ngroups);
213+
ext4_error(sb, "block_group >= groups_count - block_group = %u,"
214+
" groups_count = %u", block_group, ngroups);
217215

218216
return NULL;
219217
}
220218

221219
group_desc = block_group >> EXT4_DESC_PER_BLOCK_BITS(sb);
222220
offset = block_group & (EXT4_DESC_PER_BLOCK(sb) - 1);
223221
if (!sbi->s_group_desc[group_desc]) {
224-
ext4_error(sb, "ext4_get_group_desc",
225-
"Group descriptor not loaded - "
222+
ext4_error(sb, "Group descriptor not loaded - "
226223
"block_group = %u, group_desc = %u, desc = %u",
227224
block_group, group_desc, offset);
228225
return NULL;
@@ -282,9 +279,7 @@ static int ext4_valid_block_bitmap(struct super_block *sb,
282279
return 1;
283280

284281
err_out:
285-
ext4_error(sb, __func__,
286-
"Invalid block bitmap - "
287-
"block_group = %d, block = %llu",
282+
ext4_error(sb, "Invalid block bitmap - block_group = %d, block = %llu",
288283
block_group, bitmap_blk);
289284
return 0;
290285
}
@@ -311,8 +306,7 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
311306
bitmap_blk = ext4_block_bitmap(sb, desc);
312307
bh = sb_getblk(sb, bitmap_blk);
313308
if (unlikely(!bh)) {
314-
ext4_error(sb, __func__,
315-
"Cannot read block bitmap - "
309+
ext4_error(sb, "Cannot read block bitmap - "
316310
"block_group = %u, block_bitmap = %llu",
317311
block_group, bitmap_blk);
318312
return NULL;
@@ -354,8 +348,7 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group)
354348
set_bitmap_uptodate(bh);
355349
if (bh_submit_read(bh) < 0) {
356350
put_bh(bh);
357-
ext4_error(sb, __func__,
358-
"Cannot read block bitmap - "
351+
ext4_error(sb, "Cannot read block bitmap - "
359352
"block_group = %u, block_bitmap = %llu",
360353
block_group, bitmap_blk);
361354
return NULL;
@@ -419,8 +412,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
419412
in_range(block, ext4_inode_table(sb, desc), sbi->s_itb_per_group) ||
420413
in_range(block + count - 1, ext4_inode_table(sb, desc),
421414
sbi->s_itb_per_group)) {
422-
ext4_error(sb, __func__,
423-
"Adding blocks in system zones - "
415+
ext4_error(sb, "Adding blocks in system zones - "
424416
"Block = %llu, count = %lu",
425417
block, count);
426418
goto error_return;
@@ -453,8 +445,7 @@ void ext4_add_groupblocks(handle_t *handle, struct super_block *sb,
453445
BUFFER_TRACE(bitmap_bh, "clear bit");
454446
if (!ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
455447
bit + i, bitmap_bh->b_data)) {
456-
ext4_error(sb, __func__,
457-
"bit already cleared for block %llu",
448+
ext4_error(sb, "bit already cleared for block %llu",
458449
(ext4_fsblk_t)(block + i));
459450
BUFFER_TRACE(bitmap_bh, "bit already cleared");
460451
} else {

‎fs/ext4/dir.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ int ext4_check_dir_entry(const char *function, struct inode *dir,
8383
error_msg = "inode out of bounds";
8484

8585
if (error_msg != NULL)
86-
ext4_error(dir->i_sb, function,
86+
__ext4_error(dir->i_sb, function,
8787
"bad entry in directory #%lu: %s - "
8888
"offset=%u, inode=%u, rec_len=%d, name_len=%d",
8989
dir->i_ino, error_msg, offset,
@@ -150,7 +150,7 @@ static int ext4_readdir(struct file *filp,
150150
*/
151151
if (!bh) {
152152
if (!dir_has_error) {
153-
ext4_error(sb, __func__, "directory #%lu "
153+
ext4_error(sb, "directory #%lu "
154154
"contains a hole at offset %Lu",
155155
inode->i_ino,
156156
(unsigned long long) filp->f_pos);

‎fs/ext4/ext4.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,13 +1486,16 @@ extern int ext4_group_extend(struct super_block *sb,
14861486
ext4_fsblk_t n_blocks_count);
14871487

14881488
/* super.c */
1489-
extern void ext4_error(struct super_block *, const char *, const char *, ...)
1489+
extern void __ext4_error(struct super_block *, const char *, const char *, ...)
14901490
__attribute__ ((format (printf, 3, 4)));
1491+
#define ext4_error(sb, message...) __ext4_error(sb, __func__, ## message)
14911492
extern void __ext4_std_error(struct super_block *, const char *, int);
14921493
extern void ext4_abort(struct super_block *, const char *, const char *, ...)
14931494
__attribute__ ((format (printf, 3, 4)));
1494-
extern void ext4_warning(struct super_block *, const char *, const char *, ...)
1495+
extern void __ext4_warning(struct super_block *, const char *,
1496+
const char *, ...)
14951497
__attribute__ ((format (printf, 3, 4)));
1498+
#define ext4_warning(sb, message...) __ext4_warning(sb, __func__, ## message)
14961499
extern void ext4_msg(struct super_block *, const char *, const char *, ...)
14971500
__attribute__ ((format (printf, 3, 4)));
14981501
extern void ext4_grp_locked_error(struct super_block *, ext4_group_t,

‎fs/ext4/ext4_jbd2.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int __ext4_handle_dirty_metadata(const char *where, handle_t *handle,
132132
if (inode && inode_needs_sync(inode)) {
133133
sync_dirty_buffer(bh);
134134
if (buffer_req(bh) && !buffer_uptodate(bh)) {
135-
ext4_error(inode->i_sb, __func__,
135+
ext4_error(inode->i_sb,
136136
"IO error syncing inode, "
137137
"inode=%lu, block=%llu",
138138
inode->i_ino,

‎fs/ext4/extents.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ static int __ext4_ext_check(const char *function, struct inode *inode,
440440
return 0;
441441

442442
corrupted:
443-
ext4_error(inode->i_sb, function,
443+
__ext4_error(inode->i_sb, function,
444444
"bad header/extent in inode #%lu: %s - magic %x, "
445445
"entries %u, max %u(%u), depth %u(%u)",
446446
inode->i_ino, error_msg, le16_to_cpu(eh->eh_magic),
@@ -1538,8 +1538,9 @@ int ext4_ext_try_to_merge(struct inode *inode,
15381538
merge_done = 1;
15391539
WARN_ON(eh->eh_entries == 0);
15401540
if (!eh->eh_entries)
1541-
ext4_error(inode->i_sb, "ext4_ext_try_to_merge",
1542-
"inode#%lu, eh->eh_entries = 0!", inode->i_ino);
1541+
ext4_error(inode->i_sb,
1542+
"inode#%lu, eh->eh_entries = 0!",
1543+
inode->i_ino);
15431544
}
15441545

15451546
return merge_done;
@@ -3238,7 +3239,7 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
32383239
* this is why assert can't be put in ext4_ext_find_extent()
32393240
*/
32403241
if (path[depth].p_ext == NULL && depth != 0) {
3241-
ext4_error(inode->i_sb, __func__, "bad extent address "
3242+
ext4_error(inode->i_sb, "bad extent address "
32423243
"inode: %lu, iblock: %d, depth: %d",
32433244
inode->i_ino, iblock, depth);
32443245
err = -EIO;

‎fs/ext4/ialloc.c‎

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
7676
/* If checksum is bad mark all blocks and inodes use to prevent
7777
* allocation, essentially implementing a per-group read-only flag. */
7878
if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) {
79-
ext4_error(sb, __func__, "Checksum bad for group %u",
80-
block_group);
79+
ext4_error(sb, "Checksum bad for group %u", block_group);
8180
ext4_free_blks_set(sb, gdp, 0);
8281
ext4_free_inodes_set(sb, gdp, 0);
8382
ext4_itable_unused_set(sb, gdp, 0);
@@ -111,8 +110,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
111110
bitmap_blk = ext4_inode_bitmap(sb, desc);
112111
bh = sb_getblk(sb, bitmap_blk);
113112
if (unlikely(!bh)) {
114-
ext4_error(sb, __func__,
115-
"Cannot read inode bitmap - "
113+
ext4_error(sb, "Cannot read inode bitmap - "
116114
"block_group = %u, inode_bitmap = %llu",
117115
block_group, bitmap_blk);
118116
return NULL;
@@ -153,8 +151,7 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group)
153151
set_bitmap_uptodate(bh);
154152
if (bh_submit_read(bh) < 0) {
155153
put_bh(bh);
156-
ext4_error(sb, __func__,
157-
"Cannot read inode bitmap - "
154+
ext4_error(sb, "Cannot read inode bitmap - "
158155
"block_group = %u, inode_bitmap = %llu",
159156
block_group, bitmap_blk);
160157
return NULL;
@@ -229,8 +226,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
229226

230227
es = EXT4_SB(sb)->s_es;
231228
if (ino < EXT4_FIRST_INO(sb) || ino > le32_to_cpu(es->s_inodes_count)) {
232-
ext4_error(sb, "ext4_free_inode",
233-
"reserved or nonexistent inode %lu", ino);
229+
ext4_error(sb, "reserved or nonexistent inode %lu", ino);
234230
goto error_return;
235231
}
236232
block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
@@ -248,8 +244,7 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
248244
cleared = ext4_clear_bit_atomic(ext4_group_lock_ptr(sb, block_group),
249245
bit, bitmap_bh->b_data);
250246
if (!cleared)
251-
ext4_error(sb, "ext4_free_inode",
252-
"bit already cleared for inode %lu", ino);
247+
ext4_error(sb, "bit already cleared for inode %lu", ino);
253248
else {
254249
gdp = ext4_get_group_desc(sb, block_group, &bh2);
255250

@@ -736,8 +731,7 @@ static int ext4_claim_inode(struct super_block *sb,
736731
if ((group == 0 && ino < EXT4_FIRST_INO(sb)) ||
737732
ino > EXT4_INODES_PER_GROUP(sb)) {
738733
ext4_unlock_group(sb, group);
739-
ext4_error(sb, __func__,
740-
"reserved inode or inode > inodes count - "
734+
ext4_error(sb, "reserved inode or inode > inodes count - "
741735
"block_group = %u, inode=%lu", group,
742736
ino + group * EXT4_INODES_PER_GROUP(sb));
743737
return 1;
@@ -1099,17 +1093,15 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
10991093

11001094
/* Error cases - e2fsck has already cleaned up for us */
11011095
if (ino > max_ino) {
1102-
ext4_warning(sb, __func__,
1103-
"bad orphan ino %lu! e2fsck was run?", ino);
1096+
ext4_warning(sb, "bad orphan ino %lu! e2fsck was run?", ino);
11041097
goto error;
11051098
}
11061099

11071100
block_group = (ino - 1) / EXT4_INODES_PER_GROUP(sb);
11081101
bit = (ino - 1) % EXT4_INODES_PER_GROUP(sb);
11091102
bitmap_bh = ext4_read_inode_bitmap(sb, block_group);
11101103
if (!bitmap_bh) {
1111-
ext4_warning(sb, __func__,
1112-
"inode bitmap error for orphan %lu", ino);
1104+
ext4_warning(sb, "inode bitmap error for orphan %lu", ino);
11131105
goto error;
11141106
}
11151107

@@ -1141,8 +1133,7 @@ struct inode *ext4_orphan_get(struct super_block *sb, unsigned long ino)
11411133
err = PTR_ERR(inode);
11421134
inode = NULL;
11431135
bad_orphan:
1144-
ext4_warning(sb, __func__,
1145-
"bad orphan inode %lu! e2fsck was run?", ino);
1136+
ext4_warning(sb, "bad orphan inode %lu! e2fsck was run?", ino);
11461137
printk(KERN_NOTICE "ext4_test_bit(bit=%d, block=%llu) = %d\n",
11471138
bit, (unsigned long long)bitmap_bh->b_blocknr,
11481139
ext4_test_bit(bit, bitmap_bh->b_data));

‎fs/ext4/inode.c‎

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void ext4_delete_inode(struct inode *inode)
194194
inode->i_size = 0;
195195
err = ext4_mark_inode_dirty(handle, inode);
196196
if (err) {
197-
ext4_warning(inode->i_sb, __func__,
197+
ext4_warning(inode->i_sb,
198198
"couldn't mark inode dirty (err %d)", err);
199199
goto stop_handle;
200200
}
@@ -212,7 +212,7 @@ void ext4_delete_inode(struct inode *inode)
212212
if (err > 0)
213213
err = ext4_journal_restart(handle, 3);
214214
if (err != 0) {
215-
ext4_warning(inode->i_sb, __func__,
215+
ext4_warning(inode->i_sb,
216216
"couldn't extend journal (err %d)", err);
217217
stop_handle:
218218
ext4_journal_stop(handle);
@@ -323,8 +323,7 @@ static int ext4_block_to_path(struct inode *inode,
323323
offsets[n++] = i_block & (ptrs - 1);
324324
final = ptrs;
325325
} else {
326-
ext4_warning(inode->i_sb, "ext4_block_to_path",
327-
"block %lu > max in inode %lu",
326+
ext4_warning(inode->i_sb, "block %lu > max in inode %lu",
328327
i_block + direct_blocks +
329328
indirect_blocks + double_blocks, inode->i_ino);
330329
}
@@ -344,7 +343,7 @@ static int __ext4_check_blockref(const char *function, struct inode *inode,
344343
if (blk &&
345344
unlikely(!ext4_data_block_valid(EXT4_SB(inode->i_sb),
346345
blk, 1))) {
347-
ext4_error(inode->i_sb, function,
346+
__ext4_error(inode->i_sb, function,
348347
"invalid block reference %u "
349348
"in inode #%lu", blk, inode->i_ino);
350349
return -EIO;
@@ -1125,7 +1124,7 @@ static int check_block_validity(struct inode *inode, const char *msg,
11251124
sector_t logical, sector_t phys, int len)
11261125
{
11271126
if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), phys, len)) {
1128-
ext4_error(inode->i_sb, msg,
1127+
__ext4_error(inode->i_sb, msg,
11291128
"inode #%lu logical block %llu mapped to %llu "
11301129
"(size %d)", inode->i_ino,
11311130
(unsigned long long) logical,
@@ -4147,7 +4146,7 @@ static int ext4_clear_blocks(handle_t *handle, struct inode *inode,
41474146

41484147
if (!ext4_data_block_valid(EXT4_SB(inode->i_sb), block_to_free,
41494148
count)) {
4150-
ext4_error(inode->i_sb, __func__, "inode #%lu: "
4149+
ext4_error(inode->i_sb, "inode #%lu: "
41514150
"attempt to clear blocks %llu len %lu, invalid",
41524151
inode->i_ino, (unsigned long long) block_to_free,
41534152
count);
@@ -4255,7 +4254,7 @@ static void ext4_free_data(handle_t *handle, struct inode *inode,
42554254
if ((EXT4_JOURNAL(inode) == NULL) || bh2jh(this_bh))
42564255
ext4_handle_dirty_metadata(handle, inode, this_bh);
42574256
else
4258-
ext4_error(inode->i_sb, __func__,
4257+
ext4_error(inode->i_sb,
42594258
"circular indirect block detected, "
42604259
"inode=%lu, block=%llu",
42614260
inode->i_ino,
@@ -4297,7 +4296,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
42974296

42984297
if (!ext4_data_block_valid(EXT4_SB(inode->i_sb),
42994298
nr, 1)) {
4300-
ext4_error(inode->i_sb, __func__,
4299+
ext4_error(inode->i_sb,
43014300
"indirect mapped block in inode "
43024301
"#%lu invalid (level %d, blk #%lu)",
43034302
inode->i_ino, depth,
@@ -4313,7 +4312,7 @@ static void ext4_free_branches(handle_t *handle, struct inode *inode,
43134312
* (should be rare).
43144313
*/
43154314
if (!bh) {
4316-
ext4_error(inode->i_sb, "ext4_free_branches",
4315+
ext4_error(inode->i_sb,
43174316
"Read failure, inode=%lu, block=%llu",
43184317
inode->i_ino, nr);
43194318
continue;
@@ -4628,9 +4627,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
46284627

46294628
bh = sb_getblk(sb, block);
46304629
if (!bh) {
4631-
ext4_error(sb, "ext4_get_inode_loc", "unable to read "
4632-
"inode block - inode=%lu, block=%llu",
4633-
inode->i_ino, block);
4630+
ext4_error(sb, "unable to read inode block - "
4631+
"inode=%lu, block=%llu", inode->i_ino, block);
46344632
return -EIO;
46354633
}
46364634
if (!buffer_uptodate(bh)) {
@@ -4728,9 +4726,8 @@ static int __ext4_get_inode_loc(struct inode *inode,
47284726
submit_bh(READ_META, bh);
47294727
wait_on_buffer(bh);
47304728
if (!buffer_uptodate(bh)) {
4731-
ext4_error(sb, __func__,
4732-
"unable to read inode block - inode=%lu, "
4733-
"block=%llu", inode->i_ino, block);
4729+
ext4_error(sb, "unable to read inode block - inode=%lu,"
4730+
" block=%llu", inode->i_ino, block);
47344731
brelse(bh);
47354732
return -EIO;
47364733
}
@@ -4941,8 +4938,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
49414938
ret = 0;
49424939
if (ei->i_file_acl &&
49434940
!ext4_data_block_valid(EXT4_SB(sb), ei->i_file_acl, 1)) {
4944-
ext4_error(sb, __func__,
4945-
"bad extended attribute block %llu in inode #%lu",
4941+
ext4_error(sb, "bad extended attribute block %llu inode #%lu",
49464942
ei->i_file_acl, inode->i_ino);
49474943
ret = -EIO;
49484944
goto bad_inode;
@@ -4988,8 +4984,7 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
49884984
new_decode_dev(le32_to_cpu(raw_inode->i_block[1])));
49894985
} else {
49904986
ret = -EIO;
4991-
ext4_error(inode->i_sb, __func__,
4992-
"bogus i_mode (%o) for inode=%lu",
4987+
ext4_error(inode->i_sb, "bogus i_mode (%o) for inode=%lu",
49934988
inode->i_mode, inode->i_ino);
49944989
goto bad_inode;
49954990
}
@@ -5228,10 +5223,8 @@ int ext4_write_inode(struct inode *inode, int wait)
52285223
if (wait)
52295224
sync_dirty_buffer(iloc.bh);
52305225
if (buffer_req(iloc.bh) && !buffer_uptodate(iloc.bh)) {
5231-
ext4_error(inode->i_sb, __func__,
5232-
"IO error syncing inode, "
5233-
"inode=%lu, block=%llu",
5234-
inode->i_ino,
5226+
ext4_error(inode->i_sb, "IO error syncing inode, "
5227+
"inode=%lu, block=%llu", inode->i_ino,
52355228
(unsigned long long)iloc.bh->b_blocknr);
52365229
err = -EIO;
52375230
}
@@ -5644,7 +5637,7 @@ int ext4_mark_inode_dirty(handle_t *handle, struct inode *inode)
56445637
EXT4_STATE_NO_EXPAND);
56455638
if (mnt_count !=
56465639
le16_to_cpu(sbi->s_es->s_mnt_count)) {
5647-
ext4_warning(inode->i_sb, __func__,
5640+
ext4_warning(inode->i_sb,
56485641
"Unable to expand inode %lu. Delete"
56495642
" some EAs or run e2fsck.",
56505643
inode->i_ino);

0 commit comments

Comments
 (0)