Skip to contentSkip to conversation

f2fs: no need lock_op in f2fs_write_inline_data

PATCH In review Yunlei He 3 participants 7 messages Feb 23, 2017 – Feb 25, 2017 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH 1/1 f2fs: no need lock_op in f2fs_write_inline_data

Similar as f2fs_write_inode, f2fs_write_inline_data just mark inode page dirty, so it's no need to write inline data under read lock of cp_rwsem.

---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
index 5f3bc98..836a15a 100644
@@ -1414,9 +1414,9 @@ static int __write_data_page(struct page *page, bool *submitted,
 		goto redirty_out;
 
 	err = -EAGAIN;
-	f2fs_lock_op(sbi);
 	if (f2fs_has_inline_data(inode))
 		err = f2fs_write_inline_data(inode, page);
+	f2fs_lock_op(sbi);
 	if (err == -EAGAIN)
 		err = do_write_data_page(&fio);
 	if (F2FS_I(inode)->last_disk_size < psize)
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
maintainer
#1 lore raw

Hi Yunlei,

Quoted 3 lines · Yunlei He

Similar as f2fs_write_inode, f2fs_write_inline_data just mark inode page dirty, so it's no need to write inline data under read lock of cp_rwsem.

We count # of dirty inodes that we need to flush through f2fs_write_inode, so it's fine to go without f2fs_lock_op. In this case, however, I don't think we can do like this.

Thanks,

Quoted 23 lines
---
 fs/f2fs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/data.c +1 -1
index 5f3bc98..836a15a 100644
@@ -1414,9 +1414,9 @@ static int __write_data_page(struct page *page, bool *submitted,
 		goto redirty_out;
 
 	err = -EAGAIN;
-	f2fs_lock_op(sbi);
 	if (f2fs_has_inline_data(inode))
 		err = f2fs_write_inline_data(inode, page);
+	f2fs_lock_op(sbi);
 	if (err == -EAGAIN)
 		err = do_write_data_page(&fio);
 	if (F2FS_I(inode)->last_disk_size < psize)
Signature · 1 line
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

author
#2 lore raw

Hi Jaegeuk,

Can you explain more about this? Besides, how about inplace update?

Quoted 2 lines · Jaegeuk Kim

In this case, however, I don't think we
can do like this.

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

maintainer
#3 lore raw
Quoted 3 lines · heyunlei

Hi Jaegeuk,

Can you explain more about this? Besides, how about inplace update?

Oh, sorry. I confused it was the inline_data conversion. ;)
Yup, we can avoid entire f2fs_lock_op like this. And we can avoid IPU as well, but it's quite difficult to detect that.

Quoted 1 line

From 146e4c1ca458b1e33bf7f658f8796a8763e67a4e Mon Sep 17 00:00:00 2001

From: Yunlei He <[email protected]>
Date: Thu, 23 Feb 2017 20:31:20 +0800
Subject: [PATCH] f2fs: no need lock_op in f2fs_write_inline_data

Similar as f2fs_write_inode, f2fs_write_inline_data just mark inode page dirty, so it's no need to write inline data under read lock of cp_rwsem.

---
 fs/f2fs/data.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/data.c +5 -2
index 80f9863dc4b0..9e51c5e40ce1 100644
@@ -1414,9 +1414,12 @@ static int __write_data_page(struct page *page, bool *submitted,
 		goto redirty_out;
 
 	err = -EAGAIN;
-	f2fs_lock_op(sbi);
-	if (f2fs_has_inline_data(inode))
+	if (f2fs_has_inline_data(inode)) {
 		err = f2fs_write_inline_data(inode, page);
+		if (!err)
+			goto out;
+	}
+	f2fs_lock_op(sbi);
 	if (err == -EAGAIN)
 		err = do_write_data_page(&fio);
 	if (F2FS_I(inode)->last_disk_size < psize)
Signature · 6 lines
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
#4 lore raw
Quoted 8 lines · Jaegeuk Kim
Quoted 3 lines · heyunlei

Hi Jaegeuk,

Can you explain more about this? Besides, how about inplace update?

Oh, sorry. I confused it was the inline_data conversion. ;)
Yup, we can avoid entire f2fs_lock_op like this. And we can avoid IPU as well, but it's quite difficult to detect that.

Seems when there is a large number of dirty inline data in page cache, then trigger intensively writeback and CP can run out of free space?

Thanks,

Quoted 26 lines
Quoted 2 lines

From 146e4c1ca458b1e33bf7f658f8796a8763e67a4e Mon Sep 17 00:00:00 2001

From: Yunlei He <[email protected]>
Date: Thu, 23 Feb 2017 20:31:20 +0800
Subject: [PATCH] f2fs: no need lock_op in f2fs_write_inline_data

Similar as f2fs_write_inode, f2fs_write_inline_data just mark inode page dirty, so it's no need to write inline data under read lock of cp_rwsem.

---
 fs/f2fs/data.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/data.c +0 -1
index 80f9863dc4b0..9e51c5e40ce1 100644
@@ -1414,9 +1414,12 @@ static int __write_data_page(struct page *page, bool *submitted,
 		goto redirty_out;
 
 	err = -EAGAIN;
-	f2fs_lock_op(sbi);

fs/f2fs/data.c static int __write_data_page(struct page *page, bool *submitted, · line 1425

Quoted 10 lines
fs/f2fs/data.c +5 -1
-	if (f2fs_has_inline_data(inode))
+	if (f2fs_has_inline_data(inode)) {
 		err = f2fs_write_inline_data(inode, page);
+		if (!err)
+			goto out;
+	}
+	f2fs_lock_op(sbi);
 	if (err == -EAGAIN)
 		err = do_write_data_page(&fio);
 	if (F2FS_I(inode)->last_disk_size < psize)

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

author
#5 lore raw

Hi Chao,
Can we add below to avoid this case?

fs/f2fs/data.c +1 -0
index 80f9863..c4f3db0 100644
@@ -1695,6 +1695,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
 
         if (f2fs_has_inline_data(inode)) {
                 if (pos + len <= MAX_INLINE_DATA) {
+                       dn.node_changed = true;
                         read_inline_data(page, ipage);
                         set_inode_flag(inode, FI_DATA_EXIST);
                         if (inode->i_nlink)

Thanks.

Quoted 2 lines · Chao Yu

Seems when there is a large number of dirty inline data in page cache, then trigger intensively writeback and CP can run out of free space?

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

maintainer
#6 lore raw
In reply to Chao Yu
Quoted 4 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim
Quoted 2 lines · heyunlei

Hi Jaegeuk,

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Can you explain more about this? Besides, how about inplace update?

Oh, sorry. I confused it was the inline_data conversion. ;)
Yup, we can avoid entire f2fs_lock_op like this. And we can avoid IPU as well, but it's quite difficult to detect that.

Seems when there is a large number of dirty inline data in page cache, then trigger intensively writeback and CP can run out of free space?

I expect that f2fs_balance_fs() will hopefully block them.

Thanks,

Quoted 41 lines

Thanks,

Quoted 26 lines
Quoted 2 lines

From 146e4c1ca458b1e33bf7f658f8796a8763e67a4e Mon Sep 17 00:00:00 2001

From: Yunlei He <[email protected]>
Date: Thu, 23 Feb 2017 20:31:20 +0800
Subject: [PATCH] f2fs: no need lock_op in f2fs_write_inline_data

Similar as f2fs_write_inode, f2fs_write_inline_data just mark inode page dirty, so it's no need to write inline data under read lock of cp_rwsem.

---
 fs/f2fs/data.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/f2fs/data.c +0 -1
index 80f9863dc4b0..9e51c5e40ce1 100644
@@ -1414,9 +1414,12 @@ static int __write_data_page(struct page *page, bool *submitted,
 		goto redirty_out;
 
 	err = -EAGAIN;
-	f2fs_lock_op(sbi);

fs/f2fs/data.c static int __write_data_page(struct page *page, bool *submitted, · line 1425

Quoted 10 lines
fs/f2fs/data.c +5 -1
-	if (f2fs_has_inline_data(inode))
+	if (f2fs_has_inline_data(inode)) {
 		err = f2fs_write_inline_data(inode, page);
+		if (!err)
+			goto out;
+	}
+	f2fs_lock_op(sbi);
 	if (err == -EAGAIN)
 		err = do_write_data_page(&fio);
 	if (F2FS_I(inode)->last_disk_size < psize)
Quoted 7 lines

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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