From: Filipe Manana <fdmanana@kernel.org>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 01/12] btrfs: fix missing error handling when searching for inode refs during log replay
Date: Wed, 25 Jun 2025 11:58:44 +0100 [thread overview]
Message-ID: <CAL3q7H77qpeSaXB+niVXViaNPs=Pnxurm=WNLtUxDfJOea2nkQ@mail.gmail.com> (raw)
In-Reply-To: <4c76858f-ee2d-4462-9668-d788950ca795@wdc.com>
On Wed, Jun 25, 2025 at 10:45 AM Johannes Thumshirn
<Johannes.Thumshirn@wdc.com> wrote:
>
> On 24.06.25 16:56, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > During log replay, at __add_inode_ref(), when we are searching for inode
> > ref keys we totally ignore if btrfs_search_slot() returns an error. This
> > may make a log replay succeed when there was an actual error and leave
> > some metadata inconsistency in a subvolume tree. Fix this by checking if
> > an error was returned from btrfs_search_slot() and if so, return it to
> > the caller.
> >
> > Fixes: e02119d5a7b4 ("Btrfs: Add a write ahead tree log to optimize synchronous operations")
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> > ---
> > fs/btrfs/tree-log.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> > index 839252881138..08948803c857 100644
> > --- a/fs/btrfs/tree-log.c
> > +++ b/fs/btrfs/tree-log.c
> > @@ -1073,7 +1073,9 @@ static inline int __add_inode_ref(struct btrfs_trans_handle *trans,
> > search_key.type = BTRFS_INODE_REF_KEY;
> > search_key.offset = parent_objectid;
> > ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
> > - if (ret == 0) {
> > + if (ret < 0) {
> > + return ret;
> > + } else if (ret == 0) {
>
> Technically the else is not needed after the return.
Yes, but I don't think we have any rule that dictates to not use the else.
Just a matter of personal preference.
Thanks.
>
> Otherwise:
> Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
next prev parent reply other threads:[~2025-06-25 10:59 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-24 14:42 [PATCH 00/12] btrfs: log tree fixes and cleanups fdmanana
2025-06-24 14:42 ` [PATCH 01/12] btrfs: fix missing error handling when searching for inode refs during log replay fdmanana
2025-06-25 9:45 ` Johannes Thumshirn
2025-06-25 10:58 ` Filipe Manana [this message]
2025-06-24 14:42 ` [PATCH 02/12] btrfs: fix iteration of extrefs " fdmanana
2025-06-25 10:30 ` Johannes Thumshirn
2025-06-27 10:51 ` Qu Wenruo
2025-06-27 12:09 ` Filipe Manana
2025-06-24 14:42 ` [PATCH 03/12] btrfs: fix inode lookup error handling " fdmanana
2025-06-25 10:34 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 04/12] btrfs: record new subvolume in parent dir earlier to avoid dir logging races fdmanana
2025-06-25 10:39 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 05/12] btrfs: propagate last_unlink_trans earlier when doing a rmdir fdmanana
2025-06-25 10:46 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 06/12] btrfs: use btrfs_record_snapshot_destroy() during rmdir fdmanana
2025-06-25 10:47 ` Johannes Thumshirn
2025-06-25 10:55 ` Filipe Manana
2025-06-27 10:11 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 07/12] btrfs: use inode already stored in local variable at btrfs_rmdir() fdmanana
2025-06-25 10:52 ` Johannes Thumshirn
2025-06-25 10:54 ` Filipe Manana
2025-06-27 10:10 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 08/12] btrfs: use btrfs inodes in btrfs_rmdir() to avoid so much usage of BTRFS_I() fdmanana
2025-06-25 10:54 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 09/12] btrfs: split inode ref processing from __add_inode_ref() into a helper fdmanana
2025-06-25 11:07 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 10/12] btrfs: split inode rextef " fdmanana
2025-06-25 11:35 ` Johannes Thumshirn
2025-06-27 10:09 ` David Sterba
2025-06-24 14:42 ` [PATCH 11/12] btrfs: add btrfs prefix to is_fsstree() and make it return bool fdmanana
2025-06-25 11:35 ` Johannes Thumshirn
2025-06-24 14:42 ` [PATCH 12/12] btrfs: split btrfs_is_fsstree() into multiple if statements for readability fdmanana
2025-06-25 11:37 ` Johannes Thumshirn
2025-06-27 11:04 ` [PATCH 00/12] btrfs: log tree fixes and cleanups Qu Wenruo
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='CAL3q7H77qpeSaXB+niVXViaNPs=Pnxurm=WNLtUxDfJOea2nkQ@mail.gmail.com' \
--to=fdmanana@kernel.org \
--cc=Johannes.Thumshirn@wdc.com \
--cc=linux-btrfs@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).