OCFS2-Devel Archive mirror
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Jia Rui <jindui71@gmail.com>,
	mark@fasheh.com, akpm <akpm@linux-foundation.org>
Cc: jlbec@evilplan.org, ocfs2-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error()
Date: Thu, 19 Oct 2023 09:22:16 +0800	[thread overview]
Message-ID: <7a8b2331-a252-58ef-6553-ceb73a9a63c9@linux.alibaba.com> (raw)
In-Reply-To: <20231018191811.412458-1-jindui71@gmail.com>



On 10/19/23 3:18 AM, Jia Rui wrote:
> The BUG_ON() at ocfs2_num_free_extents() handles the error that
> l_tree_deepth of leaf extent block just read form disk is invalid.
> This error is mostly caused by file system metadata corruption on
> the disk. There is no need to call BUG_ON() to handle such errors.
> We can return error code, since the caller can deal with errors
> from ocfs2_num_free_extents(). Also, we should make the file
> system read-only to avoid the damage from expanding.
> 
> Therefore, BUG_ON() is removed and ocfs2_error() is called instead.
> 
> Signed-off-by: Jia Rui <jindui71@gmail.com>

Looks reasonable.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>

> ---
>  fs/ocfs2/alloc.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index aef58f1395c8..d6bcf00f6843 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -967,7 +967,14 @@ int ocfs2_num_free_extents(struct ocfs2_extent_tree *et)
>  		el = &eb->h_list;
>  	}
>  
> -	BUG_ON(el->l_tree_depth != 0);
> +	if (el->l_tree_depth != 0) {
> +		retval = ocfs2_error(ocfs2_metadata_cache_get_super(et->et_ci),
> +				"Owner %llu has leaf extent block %llu with an invalid l_tree_depth of %u\n",
> +				(unsigned long long)ocfs2_metadata_cache_owner(et->et_ci),
> +				(unsigned long long)last_eb_blk,
> +				le16_to_cpu(el->l_tree_depth));
> +		goto bail;
> +	}
>  
>  	retval = le16_to_cpu(el->l_count) - le16_to_cpu(el->l_next_free_rec);
>  bail:

      reply	other threads:[~2023-10-19  1:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18 19:18 [PATCH] ocfs2: replace BUG_ON() at ocfs2_num_free_extents() with ocfs2_error() Jia Rui
2023-10-19  1:22 ` Joseph Qi [this message]

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=7a8b2331-a252-58ef-6553-ceb73a9a63c9@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=jindui71@gmail.com \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).