fs/inode: using rwsem lock as inode_lock to avoid deadlock

Example:
When executing "df -h" on Core A to view mount information, this
process will traverse inode nodes, thereby holding the inode_lock.
Since the inode type of the mount point may be rpmsgfs, it will fetch statfs
information from another Core B.

Meanwhile, rcS on Core B needs to obtain file information from Core A,
which will be achieved by fetching stat information through rpmsgfs.
When this message arrives at Core A, a deadlock can occur between Core A's
rptun ap and nsh task.

However, both of these places involve read operations only, thus a reader-writer lock
can be utilized to prevent such a deadlock.

Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
dongjiuzhu1
2024-09-29 22:00:04 +08:00
committed by Xiang Xiao
parent a367657d2d
commit 09a9611ae9
29 changed files with 121 additions and 224 deletions
+1 -6
View File
@@ -110,12 +110,7 @@ int nx_umount2(FAR const char *target, unsigned int flags)
/* Hold the semaphore through the unbind logic */
ret = inode_lock();
if (ret < 0)
{
goto errout_with_mountpt;
}
inode_lock();
ret = mountpt_inode->u.i_mops->unbind(mountpt_inode->i_private,
&blkdrvr_inode, flags);
if (ret < 0)