mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] f2fs: check sit bitmap under sentry_lock
@ 2017-11-13  9:54 Chao Yu
  2017-11-15 12:33 ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2017-11-13  9:54 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu

This patch protects sit bitmap accessing in __check_sit_bitmap with
sentry_lock, meanwhile, in allocate_data_block, f2fs_wait_discard_bio
will not access/update sit cache, let's exclude it from sentry_lock's
region.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fs/f2fs/segment.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c117e0913f2a..464696b1612a 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -894,6 +894,8 @@ void __check_sit_bitmap(struct f2fs_sb_info *sbi,
 	unsigned long offset, size, max_blocks = sbi->blocks_per_seg;
 	unsigned long *map;
 
+	down_read(&SIT_I(sbi)->sentry_lock);
+
 	while (blk < end) {
 		segno = GET_SEGNO(sbi, blk);
 		sentry = get_seg_entry(sbi, segno);
@@ -908,6 +910,8 @@ void __check_sit_bitmap(struct f2fs_sb_info *sbi,
 		f2fs_bug_on(sbi, offset != size);
 		blk = START_BLOCK(sbi, segno + 1);
 	}
+
+	up_read(&SIT_I(sbi)->sentry_lock);
 #endif
 }
 
@@ -2527,12 +2531,13 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 	down_read(&SM_I(sbi)->curseg_lock);
 
 	mutex_lock(&curseg->curseg_mutex);
-	down_write(&sit_i->sentry_lock);
 
 	*new_blkaddr = NEXT_FREE_BLKADDR(sbi, curseg);
 
 	f2fs_wait_discard_bio(sbi, *new_blkaddr);
 
+	down_write(&sit_i->sentry_lock);
+
 	/*
 	 * __add_sum_entry should be resided under the curseg_mutex
 	 * because, this function updates a summary entry in the
-- 
2.15.0.55.gc2ece9dc4de6

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

end of thread, other threads:[~2017-11-15 16:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-13  9:54 [PATCH] f2fs: check sit bitmap under sentry_lock Chao Yu
2017-11-15 12:33 ` Chao Yu
2017-11-15 16:30   ` Jaegeuk Kim

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®