Skip to content

Commit 5584785

Browse files
Wu BoJaegeuk Kim
authored andcommitted
f2fs: allocate trace path buffer from names_cache
It would be better to use the dedicated slab to store path. Signed-off-by: Wu Bo <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent c1660d8 commit 5584785

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

fs/f2fs/f2fs.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3347,6 +3347,19 @@ static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
33473347
return kmalloc(size, flags);
33483348
}
33493349

3350+
static inline void *f2fs_getname(struct f2fs_sb_info *sbi)
3351+
{
3352+
if (time_to_inject(sbi, FAULT_KMALLOC))
3353+
return NULL;
3354+
3355+
return __getname();
3356+
}
3357+
3358+
static inline void f2fs_putname(char *buf)
3359+
{
3360+
__putname(buf);
3361+
}
3362+
33503363
static inline void *f2fs_kzalloc(struct f2fs_sb_info *sbi,
33513364
size_t size, gfp_t flags)
33523365
{

fs/f2fs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4372,7 +4372,7 @@ static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw)
43724372
struct inode *inode = file_inode(iocb->ki_filp);
43734373
char *buf, *path;
43744374

4375-
buf = f2fs_kmalloc(F2FS_I_SB(inode), PATH_MAX, GFP_KERNEL);
4375+
buf = f2fs_getname(F2FS_I_SB(inode));
43764376
if (!buf)
43774377
return;
43784378
path = dentry_path_raw(file_dentry(iocb->ki_filp), buf, PATH_MAX);
@@ -4385,7 +4385,7 @@ static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw)
43854385
trace_f2fs_dataread_start(inode, iocb->ki_pos, count,
43864386
current->pid, path, current->comm);
43874387
free_buf:
4388-
kfree(buf);
4388+
f2fs_putname(buf);
43894389
}
43904390

43914391
static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)

0 commit comments

Comments
 (0)