Skip to content

Commit 19ebc8f

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: fix file_path handling in tracepoints
Since file_path() takes the output buffer as one of its arguments, we might as well have it format directly into the tracepoint's char array instead of wasting stack space. Fixes: 3934e8e ("xfs: create a big array data structure") Fixes: 5076a60 ("xfs: support in-memory buffer cache targets") Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202403290419.HPcyvqZu-lkp@intel.com/ Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
1 parent 39c1ddb commit 19ebc8f

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

fs/xfs/scrub/trace.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -959,18 +959,16 @@ TRACE_EVENT(xfile_create,
959959
TP_STRUCT__entry(
960960
__field(dev_t, dev)
961961
__field(unsigned long, ino)
962-
__array(char, pathname, 256)
962+
__array(char, pathname, MAXNAMELEN)
963963
),
964964
TP_fast_assign(
965-
char pathname[257];
966965
char *path;
967966

968967
__entry->ino = file_inode(xf->file)->i_ino;
969-
memset(pathname, 0, sizeof(pathname));
970-
path = file_path(xf->file, pathname, sizeof(pathname) - 1);
968+
path = file_path(xf->file, __entry->pathname, MAXNAMELEN);
971969
if (IS_ERR(path))
972-
path = "(unknown)";
973-
strncpy(__entry->pathname, path, sizeof(__entry->pathname));
970+
strncpy(__entry->pathname, "(unknown)",
971+
sizeof(__entry->pathname));
974972
),
975973
TP_printk("xfino 0x%lx path '%s'",
976974
__entry->ino,

fs/xfs/xfs_trace.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4715,20 +4715,18 @@ TRACE_EVENT(xmbuf_create,
47154715
TP_STRUCT__entry(
47164716
__field(dev_t, dev)
47174717
__field(unsigned long, ino)
4718-
__array(char, pathname, 256)
4718+
__array(char, pathname, MAXNAMELEN)
47194719
),
47204720
TP_fast_assign(
4721-
char pathname[257];
47224721
char *path;
47234722
struct file *file = btp->bt_file;
47244723

47254724
__entry->dev = btp->bt_mount->m_super->s_dev;
47264725
__entry->ino = file_inode(file)->i_ino;
4727-
memset(pathname, 0, sizeof(pathname));
4728-
path = file_path(file, pathname, sizeof(pathname) - 1);
4726+
path = file_path(file, __entry->pathname, MAXNAMELEN);
47294727
if (IS_ERR(path))
4730-
path = "(unknown)";
4731-
strncpy(__entry->pathname, path, sizeof(__entry->pathname));
4728+
strncpy(__entry->pathname, "(unknown)",
4729+
sizeof(__entry->pathname));
47324730
),
47334731
TP_printk("dev %d:%d xmino 0x%lx path '%s'",
47344732
MAJOR(__entry->dev), MINOR(__entry->dev),

0 commit comments

Comments
 (0)