mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: fix iostat lock protection
@ 2023-03-31  9:26 Bo Ye
  2023-03-31  9:26 ` [PATCH 2/2] f2fs: add __pack attribute for extent_info Bo Ye
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bo Ye @ 2023-03-31  9:26 UTC (permalink / raw)
  To: Jaegeuk Kim, Chao Yu, Matthias Brugger, AngeloGioacchino Del Regno
  Cc: yongdong.zhang, peng.zhou, browse.zhang, light.hsieh, Qilin Tan,
	linux-f2fs-devel, linux-kernel, linux-arm-kernel, linux-mediatek

From: Qilin Tan <qilin.tan@mediatek.com>

Made iostat lock irq safe to avoid potentinal deadlock.

Deadlock scenario:
f2fs_attr_store
  -> f2fs_sbi_store
  -> _sbi_store
  -> spin_lock(sbi->iostat_lock)
    <interrupt request>
    -> scsi_end_request
    -> bio_endio
    -> f2fs_dio_read_end_io
    -> f2fs_update_iostat
    -> spin_lock_irqsave(sbi->iostat_lock)  ===> Dead lock here

Signed-off-by: Qilin Tan <qilin.tan@mediatek.com>
---
 fs/f2fs/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c
index 0b19163c90d4..fd238a68017e 100644
--- a/fs/f2fs/sysfs.c
+++ b/fs/f2fs/sysfs.c
@@ -575,9 +575,9 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
 	if (!strcmp(a->attr.name, "iostat_period_ms")) {
 		if (t < MIN_IOSTAT_PERIOD_MS || t > MAX_IOSTAT_PERIOD_MS)
 			return -EINVAL;
-		spin_lock(&sbi->iostat_lock);
+		spin_lock_irq(&sbi->iostat_lock);
 		sbi->iostat_period_ms = (unsigned int)t;
-		spin_unlock(&sbi->iostat_lock);
+		spin_unlock_irq(&sbi->iostat_lock);
 		return count;
 	}
 #endif
-- 
2.17.0


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

end of thread, other threads:[~2023-04-07  9:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-31  9:26 [PATCH 1/2] f2fs: fix iostat lock protection Bo Ye
2023-03-31  9:26 ` [PATCH 2/2] f2fs: add __pack attribute for extent_info Bo Ye
2023-04-01  1:00   ` Chao Yu
2023-04-07  9:38     ` Bo Ye (叶波)
2023-04-01  0:53 ` [PATCH 1/2] f2fs: fix iostat lock protection Chao Yu
2023-04-03 18:30 ` [f2fs-dev] " patchwork-bot+f2fs

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

all inboxes | Powered by JetHome®