From 572d8650340550a467d4583eb7d5c2b184eb7475 Mon Sep 17 00:00:00 2001 From: ligd Date: Thu, 7 Jul 2022 14:43:59 +0800 Subject: [PATCH] rpmsgfs: cache statfs result in case of deadlock rptun: msg from other cpu [ap] [ 5] [<0x2c353768>] arm_switchcontext+0xc/0x10 [ap] [ 5] [<0x2c322266>] sem_wait+0x5a/0xbc [ap] [ 5] [<0x2c7400a8>] inode_semtake+0x24/0x5c [ap] [ 5] [<0x2c74087a>] inode_release+0x6/0x60 [ap] [ 5] [<0x2c741284>] file_close+0x18/0x44 [ap] [ 5] [<0x2c74fb06>] rpmsgfs_close_handler+0x86/0xe4 [ap] [ 5] [<0x2c75b8de>] rpmsg_virtio_rx_callback+0xba/0x1b4 [ap] [ 5] [<0x2c75af70>] rproc_virtio_notified+0x44/0x5c [ap] [ 5] [<0x2c75a93c>] remoteproc_get_notification+0x1c/0x2c [ap] [ 5] [<0x2c335a08>] rptun_thread+0x74/0x208 [ap] [ 5] [<0x2c323e72>] nxtask_start+0x3a/0x60 nsh: send msg to other cpu with inode lock [ap] [10] [<0x2c353768>] arm_switchcontext+0xc/0x10 [ap] [10] [<0x2c3221b2>] nxsem_wait_uninterruptible+0x6e/0xc8 [ap] [10] [<0x2c74e498>] rpmsgfs_send_recv.constprop.0+0x78/0xc0 [ap] [10] [<0x2c74ebc0>] rpmsgfs_client_statfs+0x50/0x80 [ap] [10] [<0x2c3221ca>] nxsem_wait_uninterruptible+0x86/0xc8 [ap] [10] [<0x2c74da78>] rpmsgfs_statfs+0x28/0x50 [ap] [10] [<0x2c74534e>] mountpoint_filter+0x66/0x90 [ap] [10] [<0x2c740016>] foreach_inodelevel+0x66/0x88 [ap] [10] [<0x2c73fffa>] foreach_inodelevel+0x4a/0x88 [ap] [10] [<0x2c740062>] foreach_inode+0x2a/0x48 [ap] [10] [<0x2c745388>] foreach_mountpoint+0x10/0x20 [ap] [10] [<0x2c745606>] mount_read+0x36/0x70 [ap] [10] [<0x2c742a34>] read+0x30/0x5c [ap] [10] [<0x2c371096>] nsh_catfile+0x36/0x140 [ap] [10] [<0x2c36d01a>] nsh_parse_command+0x7fe/0xc54 [ap] [10] [<0x2c370f92>] nsh_session+0x66/0x134 [ap] [10] [<0x2c3721a4>] nsh_consolemain+0x2c/0x44 [ap] [10] [<0x2c374fde>] nsh_main+0x2a/0x4c [ap] [10] [<0x2c33f7f8>] lib_cxx_initialize+0x24/0x48 [ap] [10] [<0x2c34274a>] nxtask_startup+0x12/0x24 [ap] [10] [<0x2c323e7e>] nxtask_start+0x46/0x60 Signed-off-by: ligd --- fs/rpmsgfs/rpmsgfs.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/rpmsgfs/rpmsgfs.c b/fs/rpmsgfs/rpmsgfs.c index 36ef3fd90a..e225d8e79d 100644 --- a/fs/rpmsgfs/rpmsgfs.c +++ b/fs/rpmsgfs/rpmsgfs.c @@ -78,6 +78,7 @@ struct rpmsgfs_mountpt_s char fs_root[PATH_MAX]; void *handle; int timeout; /* Connect timeout */ + struct statfs statfs; }; /**************************************************************************** @@ -1232,12 +1233,21 @@ static int rpmsgfs_statfs(FAR struct inode *mountpt, FAR struct statfs *buf) return ret; } + if (fs->statfs.f_type == RPMSGFS_MAGIC) + { + memcpy(buf, &fs->statfs, sizeof(struct statfs)); + rpmsgfs_semgive(fs); + return 0; + } + /* Call the host fs to perform the statfs */ memset(buf, 0, sizeof(struct statfs)); ret = rpmsgfs_client_statfs(fs->handle, fs->fs_root, buf); buf->f_type = RPMSGFS_MAGIC; + memcpy(&fs->statfs, buf, sizeof(struct statfs)); + rpmsgfs_semgive(fs); return ret; }