Skip to content

Commit 60fd4da

Browse files
committed
ext4: Cleanup ext4_check_dir_entry so __func__ is now implicit
Also start passing the line number to ext4_check_dir since we're going to need it in upcoming patch. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 90c7201 commit 60fd4da

3 files changed

Lines changed: 17 additions & 16 deletions

File tree

‎fs/ext4/dir.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ static unsigned char get_dtype(struct super_block *sb, int filetype)
6161
}
6262

6363

64-
int ext4_check_dir_entry(const char *function, struct inode *dir,
65-
struct ext4_dir_entry_2 *de,
66-
struct buffer_head *bh,
67-
unsigned int offset)
64+
int __ext4_check_dir_entry(const char *function, unsigned int line,
65+
struct inode *dir,
66+
struct ext4_dir_entry_2 *de,
67+
struct buffer_head *bh,
68+
unsigned int offset)
6869
{
6970
const char *error_msg = NULL;
7071
const int rlen = ext4_rec_len_from_disk(de->rec_len,
@@ -194,7 +195,7 @@ static int ext4_readdir(struct file *filp,
194195
while (!error && filp->f_pos < inode->i_size
195196
&& offset < sb->s_blocksize) {
196197
de = (struct ext4_dir_entry_2 *) (bh->b_data + offset);
197-
if (!ext4_check_dir_entry("ext4_readdir", inode, de,
198+
if (!ext4_check_dir_entry(inode, de,
198199
bh, offset)) {
199200
/*
200201
* On error, skip the f_pos to the next block

‎fs/ext4/ext4.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,9 +1515,11 @@ extern unsigned ext4_init_block_bitmap(struct super_block *sb,
15151515
ext4_init_block_bitmap(sb, NULL, group, desc)
15161516

15171517
/* dir.c */
1518-
extern int ext4_check_dir_entry(const char *, struct inode *,
1519-
struct ext4_dir_entry_2 *,
1520-
struct buffer_head *, unsigned int);
1518+
extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *,
1519+
struct ext4_dir_entry_2 *,
1520+
struct buffer_head *, unsigned int);
1521+
#define ext4_check_dir_entry(dir, de, bh, offset) \
1522+
__ext4_check_dir_entry(__func__, __LINE__, (dir), (de), (bh), (offset))
15211523
extern int ext4_htree_store_dirent(struct file *dir_file, __u32 hash,
15221524
__u32 minor_hash,
15231525
struct ext4_dir_entry_2 *dirent);

‎fs/ext4/namei.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
605605
dir->i_sb->s_blocksize -
606606
EXT4_DIR_REC_LEN(0));
607607
for (; de < top; de = ext4_next_entry(de, dir->i_sb->s_blocksize)) {
608-
if (!ext4_check_dir_entry("htree_dirblock_to_tree", dir, de, bh,
608+
if (!ext4_check_dir_entry(dir, de, bh,
609609
(block<<EXT4_BLOCK_SIZE_BITS(dir->i_sb))
610610
+((char *)de - bh->b_data))) {
611611
/* On error, skip the f_pos to the next block. */
@@ -844,8 +844,7 @@ static inline int search_dirblock(struct buffer_head *bh,
844844
if ((char *) de + namelen <= dlimit &&
845845
ext4_match (namelen, name, de)) {
846846
/* found a match - just to be sure, do a full check */
847-
if (!ext4_check_dir_entry("ext4_find_entry",
848-
dir, de, bh, offset))
847+
if (!ext4_check_dir_entry(dir, de, bh, offset))
849848
return -1;
850849
*res_dir = de;
851850
return 1;
@@ -1019,7 +1018,7 @@ static struct buffer_head * ext4_dx_find_entry(struct inode *dir, const struct q
10191018
int off = (block << EXT4_BLOCK_SIZE_BITS(sb))
10201019
+ ((char *) de - bh->b_data);
10211020

1022-
if (!ext4_check_dir_entry(__func__, dir, de, bh, off)) {
1021+
if (!ext4_check_dir_entry(dir, de, bh, off)) {
10231022
brelse(bh);
10241023
*err = ERR_BAD_DX_DIR;
10251024
goto errout;
@@ -1303,8 +1302,7 @@ static int add_dirent_to_buf(handle_t *handle, struct dentry *dentry,
13031302
de = (struct ext4_dir_entry_2 *)bh->b_data;
13041303
top = bh->b_data + blocksize - reclen;
13051304
while ((char *) de <= top) {
1306-
if (!ext4_check_dir_entry("ext4_add_entry", dir, de,
1307-
bh, offset))
1305+
if (!ext4_check_dir_entry(dir, de, bh, offset))
13081306
return -EIO;
13091307
if (ext4_match(namelen, name, de))
13101308
return -EEXIST;
@@ -1671,7 +1669,7 @@ static int ext4_delete_entry(handle_t *handle,
16711669
pde = NULL;
16721670
de = (struct ext4_dir_entry_2 *) bh->b_data;
16731671
while (i < bh->b_size) {
1674-
if (!ext4_check_dir_entry("ext4_delete_entry", dir, de, bh, i))
1672+
if (!ext4_check_dir_entry(dir, de, bh, i))
16751673
return -EIO;
16761674
if (de == de_del) {
16771675
BUFFER_TRACE(bh, "get_write_access");
@@ -1954,7 +1952,7 @@ static int empty_dir(struct inode *inode)
19541952
}
19551953
de = (struct ext4_dir_entry_2 *) bh->b_data;
19561954
}
1957-
if (!ext4_check_dir_entry("empty_dir", inode, de, bh, offset)) {
1955+
if (!ext4_check_dir_entry(inode, de, bh, offset)) {
19581956
de = (struct ext4_dir_entry_2 *)(bh->b_data +
19591957
sb->s_blocksize);
19601958
offset = (offset | (sb->s_blocksize - 1)) + 1;

0 commit comments

Comments
 (0)