Linux real-time development
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Deepanshu Kartikey <kartikey406@gmail.com>,
	akpm <akpm@linux-foundation.org>
Cc: ocfs2-devel@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-rt-devel@lists.linux.dev,
	syzbot+ce129763ce7d7e914739@syzkaller.appspotmail.com,
	Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>,
	bigeasy@linutronix.de, clrkwllms@kernel.org, rostedt@goodmis.org,
	Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH v2] ocfs2: use inode_lock_nested() for orphan dir locking
Date: Mon, 22 Jun 2026 08:58:55 +0800	[thread overview]
Message-ID: <df25ea2d-1485-4ef5-9aae-9e88c41b14be@linux.alibaba.com> (raw)
In-Reply-To: <20260620231223.46588-1-kartikey406@gmail.com>



On 6/21/26 7:12 AM, Deepanshu Kartikey wrote:
> PREEMPT_RT's rtmutex PI chain walker warns about a lock dependency
> cycle when inode_lock(orphan_dir_inode) is called while holding
> inode_lock(file_inode):
> 
>   ocfs2_file_write_iter()
>     inode_lock(file_inode)               [class 0]
>       ocfs2_dio_end_io_write()
>         ocfs2_del_inode_from_orphan()
>           inode_lock(orphan_dir_inode)   [class 0] <- warning!
> 
> However this is a false positive. write_iter() is never called on a
> directory, and orphan_dir is always a directory, so these two locks
> can never actually conflict in practice.
> 
> Fix by using inode_lock_nested(orphan_dir_inode, I_MUTEX_NONDIR2) in
> all three places where orphan_dir_inode is locked in namei.c, placing
> it in a separate lock class so the rtmutex PI chain walker understands
> these locks have distinct roles and does not warn about their ordering.
> 
> Suggested-by: Matthew Wilcox <willy@infradead.org>
> Reported-by: syzbot+ce129763ce7d7e914739@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=ce129763ce7d7e914739
> Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>

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

> 
> ---
> Changes in v2:
> - Replaced inode_lock() with inode_lock_nested(orphan_dir_inode,
>   I_MUTEX_NONDIR2) in all three call sites in namei.c
> - Dropped incorrect v1 changes to aops.c and namei.c that
>   restructured lock ordering, as the deadlock was a false positive
> - Approach suggested by Matthew Wilcox
> ---
>  fs/ocfs2/namei.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 1277666c77cd..4cfd7b3d3e1a 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -2126,7 +2126,7 @@ static int ocfs2_lookup_lock_orphan_dir(struct ocfs2_super *osb,
>  		return ret;
>  	}
>  
> -	inode_lock(orphan_dir_inode);
> +	inode_lock_nested(orphan_dir_inode, I_MUTEX_NONDIR2);
>  
>  	ret = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
>  	if (ret < 0) {
> @@ -2725,7 +2725,7 @@ int ocfs2_del_inode_from_orphan(struct ocfs2_super *osb,
>  		goto bail;
>  	}
>  
> -	inode_lock(orphan_dir_inode);
> +	inode_lock_nested(orphan_dir_inode, I_MUTEX_NONDIR2);
>  	status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
>  	if (status < 0) {
>  		inode_unlock(orphan_dir_inode);
> @@ -2838,7 +2838,7 @@ int ocfs2_mv_orphaned_inode_to_new(struct inode *dir,
>  		goto leave;
>  	}
>  
> -	inode_lock(orphan_dir_inode);
> +	inode_lock_nested(orphan_dir_inode, I_MUTEX_NONDIR2);
>  
>  	status = ocfs2_inode_lock(orphan_dir_inode, &orphan_dir_bh, 1);
>  	if (status < 0) {


      parent reply	other threads:[~2026-06-22  0:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20 23:12 [PATCH v2] ocfs2: use inode_lock_nested() for orphan dir locking Deepanshu Kartikey
2026-06-20 23:25 ` sashiko-bot
2026-06-22  0:58 ` 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=df25ea2d-1485-4ef5-9aae-9e88c41b14be@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=jlbec@evilplan.org \
    --cc=kartikey406@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=syzbot+ce129763ce7d7e914739@syzkaller.appspotmail.com \
    --cc=willy@infradead.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