[RFC PATCH] jffs2: fix recursive fs_reclaim deadlock

Zhihao Cheng chengzhihao1 at huawei.com
Tue Mar 19 00:56:13 PDT 2024


在 2024/3/19 14:41, Qingfang Deng 写道:
> On Fri, Mar 15, 2024 at 9:00 PM Zhihao Cheng <chengzhihao1 at huawei.com> wrote:
>>
>> 在 2024/3/15 20:19, Qingfang Deng 写道:
>>> Hi Zhihao,
>>>
>>> On Fri, Mar 15, 2024 at 7:19 PM Zhihao Cheng <chengzhihao1 at huawei.com> wrote:
>>>> I think it's a false positive warning. Jffs2 is trying to get root inode
>>>> in process '#1', which means that the filesystem is not mounted
>>>> yet(Because d_make_root is after jffs2_iget(sb,1), there is no way to
>>>> access other inodes.), so it is impossible that jffs2 inode is being
>>>> evicted in '#0'.
>>>>
>>>
>>> You're right that process '#1' is getting the root inode. However,
>>> lockdep only records the stack of the first unique lock ordering (see
>>> https://docs.kernel.org/locking/lockdep-design.html#performance ), and
>>> there are many occasions where GFP_KERNEL is used inside a
>>> jffs2_inode_info::sem 's critical section.
>>> .
>>>
>> Allocating memory without GFP_NOFS flags under sleeping lock is a normal
>> thing. The vfs_write is an example(eg. ext4), page is allocated with
>> FGP_WRITEBEGIN flag(no FGP_NOFS) when holding inode lock.
> 
> If this is a false positive, is there a way to suppress the warning?
> .
> 

I can't find a idea either. According to my poor knowledge on lockdep, 
it looks like that lockdep traces a class of locks(eg. f->sem in jffs2) 
rather than one certain lock, because the key of lock->dep_map is 
initialized with a static variable (See mutex_init). In some easy cases, 
we can add subclass to solve the false positive warnings(eg. 
lock_4_inodes). But now, jffs2 case is different, any 
jffs2_do_clear_inode calling could trigger it, and we cannot add limited 
subclasses to solve it.
Take a step back, I think we can just ignore the warning, 
fs_reclaim_acquire is a public path, other filesystems/modules could 
face the same case.



More information about the linux-mtd mailing list