[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <kxo27vjuqawoynwttpg56tzhvxeuobmvgdfglp5g2xcuy4vfnq@t7t4zxq27qon>
Date: Mon, 7 Jul 2025 20:12:49 -0400
From: Ivan Pravdin <ipravdin.official@...il.com>
To: Joseph Qi <joseph.qi@...ux.alibaba.com>, mark@...heh.com,
jlbec@...lplan.org, ocfs2-devel@...ts.linux.dev, linux-kernel@...r.kernel.org
Cc: syzbot+6bf948e47f9bac7aacfa@...kaller.appspotmail.com
Subject: Re: [PATCH v2] ocfs2: avoid potential ABBA deadlock by reordering
tl_inode lock
On Mon, Jul 07, 2025 at 01:58:35PM GMT, Joseph Qi wrote:
> > /*
> > * ocfs2_move_extent() didn't reserve any clusters in lock_allocators()
> > * logic, while we still need to lock the global_bitmap.
> > @@ -637,13 +639,11 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> > goto out_unlock_gb_mutex;
> > }
> >
>
> You've missed unlock tl_inode when ocfs2_get_system_file_inode() fails.
I will add it, thanks.
>
>
> > - inode_lock(tl_inode);
> > -
> > handle = ocfs2_start_trans(osb, credits);
> > if (IS_ERR(handle)) {
> > ret = PTR_ERR(handle);
> > mlog_errno(ret);
> > - goto out_unlock_tl_inode;
> > + goto out_unlock_gb_inode;
> > }
> >
> > new_phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *new_phys_cpos);
> > @@ -704,12 +704,13 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> > ocfs2_commit_trans(osb, handle);
> > brelse(gd_bh);
> >
> > -out_unlock_tl_inode:
> > - inode_unlock(tl_inode);
> > -
> > +out_unlock_gb_inode:
> > ocfs2_inode_unlock(gb_inode, 1);
> > +
> > out_unlock_gb_mutex:
>
> inode lock has changed to rw_semaphore, so 'mutex' is no longer proper.
>
> > inode_unlock(gb_inode);
> > +
> > + inode_unlock(tl_inode);
> > brelse(gb_bh);
> > iput(gb_inode);
> >
>
> How about the following alternative:
>
> diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
> index 369c7d27befd..d56c337204f6 100644
> --- a/fs/ocfs2/move_extents.c
> +++ b/fs/ocfs2/move_extents.c
> @@ -611,6 +611,8 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> goto out;
> }
>
> + inode_lock(tl_inode);
> +
> /*
> * need to count 2 extra credits for global_bitmap inode and
> * group descriptor.
> @@ -626,7 +628,7 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> if (!gb_inode) {
> mlog(ML_ERROR, "unable to get global_bitmap inode\n");
> ret = -EIO;
> - goto out;
> + goto out_unlock_tl_inode;
> }
>
> inode_lock(gb_inode);
> @@ -634,16 +636,14 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> ret = ocfs2_inode_lock(gb_inode, &gb_bh, 1);
> if (ret) {
> mlog_errno(ret);
> - goto out_unlock_gb_mutex;
> + goto out_unlock_gb_inode;
> }
>
> - inode_lock(tl_inode);
> -
> handle = ocfs2_start_trans(osb, credits);
> if (IS_ERR(handle)) {
> ret = PTR_ERR(handle);
> mlog_errno(ret);
> - goto out_unlock_tl_inode;
> + goto out_unlock;
> }
>
> new_phys_blkno = ocfs2_clusters_to_blocks(inode->i_sb, *new_phys_cpos);
> @@ -703,16 +703,14 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
> out_commit:
> ocfs2_commit_trans(osb, handle);
> brelse(gd_bh);
> -
> -out_unlock_tl_inode:
> - inode_unlock(tl_inode);
> -
> +out_unlock:
> ocfs2_inode_unlock(gb_inode, 1);
> -out_unlock_gb_mutex:
> +out_unlock_gb_inode:
> inode_unlock(gb_inode);
> brelse(gb_bh);
> iput(gb_inode);
> -
> +out_unlock_tl_inode:
> + inode_unlock(tl_inode);
> out:
> if (context->meta_ac) {
> ocfs2_free_alloc_context(context->meta_ac);
>
>
This is definitely better. I will update the patch, thank you.
Ivan Pravdin
Powered by blists - more mailing lists