From: Chao Yu <chao@kernel.org>
To: Christoph Hellwig <hch@lst.de>, Jaegeuk Kim <jaegeuk@kernel.org>
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 4/8] f2fs: factor the read/write tracing logic into a helper
Date: Sun, 29 Jan 2023 18:36:40 +0800 [thread overview]
Message-ID: <3e0e4fa3-f1d1-a8f0-507a-e9321dcc759f@kernel.org> (raw)
In-Reply-To: <20230119063625.466485-5-hch@lst.de>
On 2023/1/19 14:36, Christoph Hellwig wrote:
> Factor the logic to log a path for reads and writs into a helper
> shared between the read_iter and write_iter methods.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/f2fs/file.c | 60 +++++++++++++++++++++-----------------------------
> 1 file changed, 25 insertions(+), 35 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index f5c1b78149540c..305be6ac024196 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -4340,6 +4340,27 @@ static ssize_t f2fs_dio_read_iter(struct kiocb *iocb, struct iov_iter *to)
> return ret;
> }
>
> +static void f2fs_trace_rw_file_path(struct kiocb *iocb, size_t count, int rw)
> +{
> + struct inode *inode = file_inode(iocb->ki_filp);
> + char *buf, *path;
> +
> + buf = f2fs_kmalloc(F2FS_I_SB(inode), PATH_MAX, GFP_KERNEL);
> + if (!buf)
> + return;
> + path = dentry_path_raw(file_dentry(iocb->ki_filp), buf, PATH_MAX);
> + if (IS_ERR(path))
> + goto free_buf;
> + if (rw == WRITE)
> + trace_f2fs_datawrite_start(inode, iocb->ki_pos, count,
> + current->pid, path, current->comm);
> + else
> + trace_f2fs_dataread_start(inode, iocb->ki_pos, count,
> + current->pid, path, current->comm);
> +free_buf:
> + kfree(buf);
> +}
> +
> static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
> {
> struct inode *inode = file_inode(iocb->ki_filp);
> @@ -4349,24 +4370,9 @@ static ssize_t f2fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
> if (!f2fs_is_compress_backend_ready(inode))
> return -EOPNOTSUPP;
>
> - if (trace_f2fs_dataread_start_enabled()) {
> - char *p = f2fs_kmalloc(F2FS_I_SB(inode), PATH_MAX, GFP_KERNEL);
> - char *path;
> -
> - if (!p)
> - goto skip_read_trace;
> + if (trace_f2fs_dataread_start_enabled())
> + f2fs_trace_rw_file_path(iocb, iov_iter_count(to), READ);
>
> - path = dentry_path_raw(file_dentry(iocb->ki_filp), p, PATH_MAX);
> - if (IS_ERR(path)) {
> - kfree(p);
> - goto skip_read_trace;
> - }
> -
> - trace_f2fs_dataread_start(inode, pos, iov_iter_count(to),
> - current->pid, path, current->comm);
> - kfree(p);
> - }
> -skip_read_trace:
> if (f2fs_should_use_dio(inode, iocb, to)) {
> ret = f2fs_dio_read_iter(iocb, to);
> } else {
> @@ -4672,24 +4678,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
> if (preallocated < 0) {
> ret = preallocated;
> } else {
> - if (trace_f2fs_datawrite_start_enabled()) {
> - char *p = f2fs_kmalloc(F2FS_I_SB(inode),
> - PATH_MAX, GFP_KERNEL);
> - char *path;
> -
> - if (!p)
> - goto skip_write_trace;
> - path = dentry_path_raw(file_dentry(iocb->ki_filp),
> - p, PATH_MAX);
> - if (IS_ERR(path)) {
> - kfree(p);
> - goto skip_write_trace;
> - }
> - trace_f2fs_datawrite_start(inode, orig_pos, orig_count,
> - current->pid, path, current->comm);
> - kfree(p);
> - }
> -skip_write_trace:
> + f2fs_trace_rw_file_path(iocb, orig_count, WRITE);
if (trace_f2fs_datawrite_start_enabled())
f2fs_trace_rw_file_path(..);
Thanks,
> +
> /* Do the actual write. */
> ret = dio ?
> f2fs_dio_write_iter(iocb, from, &may_need_sync) :
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2023-01-29 10:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-19 6:36 [f2fs-dev] misc f2fs cleanups Christoph Hellwig
2023-01-19 6:36 ` [f2fs-dev] [PATCH 1/8] f2fs: remove __add_sum_entry Christoph Hellwig
2023-01-29 10:29 ` Chao Yu
2023-01-31 19:10 ` patchwork-bot+f2fs
2023-01-19 6:36 ` [f2fs-dev] [PATCH 2/8] f2fs: simplify do_checkpoint Christoph Hellwig
2023-01-29 10:30 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 3/8] f2fs: add a f2fs_curseg_valid_blocks helper Christoph Hellwig
2023-01-29 10:34 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 4/8] f2fs: factor the read/write tracing logic into a helper Christoph Hellwig
2023-01-29 10:36 ` Chao Yu [this message]
2023-01-30 23:00 ` Jaegeuk Kim
2023-01-19 6:36 ` [f2fs-dev] [PATCH 5/8] f2fs: refactor __allocate_new_segment Christoph Hellwig
2023-01-29 10:39 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 6/8] f2fs: remove __allocate_new_section Christoph Hellwig
2023-01-29 10:39 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 7/8] f2fs: refactor next blk selection Christoph Hellwig
2023-01-29 12:20 ` Chao Yu
2023-01-19 6:36 ` [f2fs-dev] [PATCH 8/8] f2fs: remove __has_curseg_space Christoph Hellwig
2023-01-29 12:24 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3e0e4fa3-f1d1-a8f0-507a-e9321dcc759f@kernel.org \
--to=chao@kernel.org \
--cc=hch@lst.de \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).