Skip to contentSkip to conversation

f2fs: skip writeback meta pages if cp_mutex acquire failed

PATCH Superseded Yunlei He 2 participants 3 messages Mar 1, 2017 F2FS file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: skip writeback meta pages if cp_mutex acquire failed

Skip writeback meta pages if cp_mutex lock acquire failed, cp will flush dirty pages instead.

---
 fs/f2fs/checkpoint.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/checkpoint.c +7 -5
index 0339daf..5ce24b1 100644
@@ -275,13 +275,15 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
 		get_pages(sbi, F2FS_DIRTY_META) < nr_pages_to_skip(sbi, META))
 		goto skip_write;
 
-	trace_f2fs_writepages(mapping->host, wbc, META);
+	/* if locked failed, cp will flush dirty pages instead */
+	if (mutex_trylock(&sbi->cp_mutex)) {
+		diff = nr_pages_to_write(sbi, META, wbc);
+		written = sync_meta_pages(sbi, META, wbc->nr_to_write);
+	} else
+		goto skip_write;
 
-	/* if mounting is failed, skip writing node pages */
-	mutex_lock(&sbi->cp_mutex);
-	diff = nr_pages_to_write(sbi, META, wbc);
-	written = sync_meta_pages(sbi, META, wbc->nr_to_write);
 	mutex_unlock(&sbi->cp_mutex);
+	trace_f2fs_writepages(mapping->host, wbc, META);
 	wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
 	return 0;
 
Signature · 6 lines
2.10.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
#1 lore raw
Quoted 2 lines · Yunlei He

Skip writeback meta pages if cp_mutex lock acquire failed, cp will flush dirty pages instead.

Make sense to me. :)

Quoted 11 lines
---
 fs/f2fs/checkpoint.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/checkpoint.c +0 -0
index 0339daf..5ce24b1 100644

fs/f2fs/checkpoint.c static int f2fs_write_meta_pages(struct address_space *mapping, · line 283

Quoted 10 lines
fs/f2fs/checkpoint.c +6 -1
@@ -275,13 +275,15 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
 		get_pages(sbi, F2FS_DIRTY_META) < nr_pages_to_skip(sbi, META))
 		goto skip_write;
 
-	trace_f2fs_writepages(mapping->host, wbc, META);
+	/* if locked failed, cp will flush dirty pages instead */
+	if (mutex_trylock(&sbi->cp_mutex)) {
+		diff = nr_pages_to_write(sbi, META, wbc);
+		written = sync_meta_pages(sbi, META, wbc->nr_to_write);
+	} else
+		goto skip_write;

Would it be better to change:

/* your comments */
if (!mutex_trylock(&sbi->cp_mutex))

	goto skip_write;

trace_f2fs_writepages();
diff = nr_pages_to_write();
...

Thanks,

fs/f2fs/checkpoint.c static int f2fs_write_meta_pages(struct address_space *mapping,

Quoted 11 lines
fs/f2fs/checkpoint.c +1 -4
-	/* if mounting is failed, skip writing node pages */
-	mutex_lock(&sbi->cp_mutex);
-	diff = nr_pages_to_write(sbi, META, wbc);
-	written = sync_meta_pages(sbi, META, wbc->nr_to_write);
 	mutex_unlock(&sbi->cp_mutex);
+	trace_f2fs_writepages(mapping->host, wbc, META);
 	wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
 	return 0;
 
 

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot

author
#2 lore raw

Hi Chao,

Quoted 32 lines · Chao Yu
Quoted 2 lines · Yunlei He

Skip writeback meta pages if cp_mutex lock acquire failed, cp will flush dirty pages instead.

Make sense to me. :)

Quoted 11 lines
---
 fs/f2fs/checkpoint.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
fs/f2fs/checkpoint.c +0 -0
index 0339daf..5ce24b1 100644

fs/f2fs/checkpoint.c static int f2fs_write_meta_pages(struct address_space *mapping, · line 283

Quoted 10 lines
fs/f2fs/checkpoint.c +6 -1
@@ -275,13 +275,15 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
 		get_pages(sbi, F2FS_DIRTY_META) < nr_pages_to_skip(sbi, META))
 		goto skip_write;
 
-	trace_f2fs_writepages(mapping->host, wbc, META);
+	/* if locked failed, cp will flush dirty pages instead */
+	if (mutex_trylock(&sbi->cp_mutex)) {
+		diff = nr_pages_to_write(sbi, META, wbc);
+		written = sync_meta_pages(sbi, META, wbc->nr_to_write);
+	} else
+		goto skip_write;

Would it be better to change:

/* your comments */
if (!mutex_trylock(&sbi->cp_mutex))

Quoted 7 lines
	goto skip_write;

trace_f2fs_writepages();
diff = nr_pages_to_write();
...

Thanks,

Yes, it's better, I'll send a new version.

Thanks.

Quoted 16 lines

fs/f2fs/checkpoint.c static int f2fs_write_meta_pages(struct address_space *mapping,

Quoted 12 lines
fs/f2fs/checkpoint.c +1 -4
-	/* if mounting is failed, skip writing node pages */
-	mutex_lock(&sbi->cp_mutex);
-	diff = nr_pages_to_write(sbi, META, wbc);
-	written = sync_meta_pages(sbi, META, wbc->nr_to_write);
 	mutex_unlock(&sbi->cp_mutex);
+	trace_f2fs_writepages(mapping->host, wbc, META);
 	wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
 	return 0;
 
 

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot