From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Yangtao Li <frank.li@vivo.com>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: introduce sanity_check_blocks()
Date: Wed, 18 Jan 2023 18:19:33 -0800 [thread overview]
Message-ID: <Y8iotYUXzfPZLhj9@google.com> (raw)
In-Reply-To: <20230112142213.22784-1-frank.li@vivo.com>
On 01/12, Yangtao Li wrote:
> There are very similar codes in release_compress_blocks() and
> reserve_compress_blocks() which is used for data blocks check.
>
> This patch introduces a new helper sanity_check_blocks()
> to include those common codes, and used it instead for cleanup.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> fs/f2fs/file.c | 36 ++++++++++++++++++++----------------
> 1 file changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index f5c1b7814954..0d539155379c 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3369,11 +3369,9 @@ static int f2fs_get_compress_blocks(struct file *filp, unsigned long arg)
> return put_user(blocks, (u64 __user *)arg);
> }
>
> -static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
> +static int sanity_check_blocks(struct dnode_of_data *dn, pgoff_t count)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
> - unsigned int released_blocks = 0;
> - int cluster_size = F2FS_I(dn->inode)->i_cluster_size;
> block_t blkaddr;
> int i;
>
> @@ -3390,6 +3388,21 @@ static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
> }
> }
>
> + return 0;
> +}
> +
> +static int release_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
> +{
> + struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
> + unsigned int released_blocks = 0;
> + int cluster_size = F2FS_I(dn->inode)->i_cluster_size;
> + block_t blkaddr;
> + int i, rc;
> +
> + rc = sanity_check_blocks(dn, count);
^
err
> + if (rc)
> + return rc;
> +
> while (count) {
> int compr_blocks = 0;
>
> @@ -3539,20 +3552,11 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count)
> unsigned int reserved_blocks = 0;
> int cluster_size = F2FS_I(dn->inode)->i_cluster_size;
> block_t blkaddr;
> - int i;
> + int i, rc;
>
> - for (i = 0; i < count; i++) {
> - blkaddr = data_blkaddr(dn->inode, dn->node_page,
> - dn->ofs_in_node + i);
> -
> - if (!__is_valid_data_blkaddr(blkaddr))
> - continue;
> - if (unlikely(!f2fs_is_valid_blkaddr(sbi, blkaddr,
> - DATA_GENERIC_ENHANCE))) {
> - f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR);
> - return -EFSCORRUPTED;
> - }
> - }
> + rc = sanity_check_blocks(dn, count);
> + if (rc)
> + return rc;
>
> while (count) {
> int compr_blocks = 0;
> --
> 2.25.1
_______________________________________________
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-19 2:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 14:22 [f2fs-dev] [PATCH] f2fs: introduce sanity_check_blocks() Yangtao Li via Linux-f2fs-devel
2023-01-19 2:19 ` Jaegeuk Kim [this message]
2023-01-28 10:47 ` 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=Y8iotYUXzfPZLhj9@google.com \
--to=jaegeuk@kernel.org \
--cc=frank.li@vivo.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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).