public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: avoid the deadlock case when stopping discard thread
@ 2024-03-20  0:14 Jaegeuk Kim
  2024-03-20 15:32 ` [f2fs-dev] " Chao Yu
  2024-03-21 22:42 ` Hillf Danton
  0 siblings, 2 replies; 12+ messages in thread
From: Jaegeuk Kim @ 2024-03-20  0:14 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

f2fs_ioc_shutdown(F2FS_GOING_DOWN_NOSYNC)  issue_discard_thread
 - mnt_want_write_file()
   - sb_start_write(SB_FREEZE_WRITE)
                                             - sb_start_intwrite(SB_FREEZE_FS);
 - f2fs_stop_checkpoint(sbi, false,            : waiting
    STOP_CP_REASON_SHUTDOWN);
 - f2fs_stop_discard_thread(sbi);
   - kthread_stop()
     : waiting

 - mnt_drop_write_file(filp);

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/segment.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 4fd76e867e0a..088b8c48cffa 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1923,7 +1923,9 @@ static int issue_discard_thread(void *data)
 			continue;
 		}
 
-		sb_start_intwrite(sbi->sb);
+		/* Avoid the deadlock from F2FS_GOING_DOWN_NOSYNC. */
+		if (!sb_start_intwrite_trylock(sbi->sb))
+			continue;
 
 		issued = __issue_discard_cmd(sbi, &dpolicy);
 		if (issued > 0) {
-- 
2.44.0.291.gc1ea87d7ee-goog


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-04-16  1:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-20  0:14 [PATCH] f2fs: avoid the deadlock case when stopping discard thread Jaegeuk Kim
2024-03-20 15:32 ` [f2fs-dev] " Chao Yu
2024-03-21 22:42 ` Hillf Danton
2024-03-22  0:29   ` Jaegeuk Kim
2024-03-22 11:33     ` Hillf Danton
     [not found]     ` <SI2PR03MB52607606AB0D29C8AB123C1484312@SI2PR03MB5260.apcprd03.prod.outlook.com>
2024-03-22 22:24       ` 回覆: " Jaegeuk Kim
2024-03-26 16:52         ` Jaegeuk Kim
     [not found]           ` <SI2PR03MB526041E42B6BD9C9DA9FBAC184352@SI2PR03MB5260.apcprd03.prod.outlook.com>
2024-04-03  3:39             ` 回覆: " Light Hsieh (謝明燈)
2024-04-04 19:55               ` Jaegeuk Kim
2024-04-12  0:18                 ` 回覆: " Light Hsieh (謝明燈)
2024-04-12 20:50                   ` Jaegeuk Kim
2024-04-16  1:50                     ` 回覆: " Light Hsieh (謝明燈)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox