f2fs: do checkpoint for the renamed inode
Subsystems (2)
Jaegeuk Kim
maintainerPATCH 1/1 f2fs: do checkpoint for the renamed inode
If an inode is renamed, it should be registered as file_lost_pino to conduct checkpoint at f2fs_sync_file.
Otherwise, the inode cannot be recovered due to no dent_mark in the following scenario.
Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cut
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enter recover_dentry due to no dent_mark.
The reason is like below.
- The nid of "a" is checkpointed during #2, f2fs_sync_file.
- The inode page for "b" produced by #3 is written without dent_mark by sync_node_pages.
So, this patch fixes this bug by assinging file_lost_pino to the "a"'s inode. If the pino is lost, f2fs_sync_file conducts checkpoint, and then recovers the latest pino and its dentry information for further recovery.
--- fs/f2fs/namei.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/f2fs/namei.c +4 -6
@@ -411,9 +411,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, }f2fs_set_link (new_dir, new_entry, new_page, old_inode); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem); new_inode->i_ctime =CURRENT_TIME ;down_write (&F2FS_I (new_inode)->i_sem);
@@ -446,6 +443,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } } +down_write (&F2FS_I (old_inode)->i_sem); +file_lost_pino (old_inode); +up_write (&F2FS_I (old_inode)->i_sem); + old_inode->i_ctime =CURRENT_TIME ;mark_inode_dirty (old_inode);
@@ -455,9 +456,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,if (old_dir != new_dir) {f2fs_set_link (old_inode, old_dir_entry, old_dir_page, new_dir); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem);update_inode_page (old_inode); }else {kunmap (old_dir_page);
Signature · 1 line
1.8.5.2 (Apple Git-48)
Hi Jaegeuk,
Quoted 21 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, July 02, 2014 6:35 PM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH] f2fs: do checkpoint for the renamed inodeIf an inode is renamed, it should be registered as
file_lost_pinoto conduct checkpoint atf2fs_sync_file.
Otherwise, the inode cannot be recovered due to nodent_markin the following scenario.Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cut
Quoted 3 lines
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enterrecover_dentrydue to nodent_mark.
As we know CP is expensive, how about modifying checkpointed value directly in nat cache at step #3? So "b" could be fsynced with dent_mark at step #4.
Quoted 64 lines
The reason is like below.
- The nid of "a" is checkpointed during #2,f2fs_sync_file.
- The inode page for "b" produced by #3 is written withoutdent_markbysync_node_pages.So, this patch fixes this bug by assinging
file_lost_pinoto the "a"'s inode. If the pino is lost,f2fs_sync_fileconducts checkpoint, and then recovers the latest pino and its dentry information for further recovery.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/namei.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/f2fs/namei.c +4
-7@@ -411,9 +411,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, }f2fs_set_link (new_dir, new_entry, new_page, old_inode); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem); new_inode->i_ctime =CURRENT_TIME ;down_write (&F2FS_I (new_inode)->i_sem);@@ -446,6 +443,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } } +down_write (&F2FS_I (old_inode)->i_sem); +file_lost_pino (old_inode); +up_write (&F2FS_I (old_inode)->i_sem); + old_inode->i_ctime =CURRENT_TIME ;mark_inode_dirty (old_inode);@@ -455,9 +456,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,if (old_dir != new_dir) {f2fs_set_link (old_inode, old_dir_entry, old_dir_page, new_dir); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem);update_inode_page (old_inode); }else {kunmap (old_dir_page); --1.8.5.2 (Apple Git-48)
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Jaegeuk Kim
maintainerQuoted 23 lines · Chao Yu
Hi Jaegeuk,
Quoted 21 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, July 02, 2014 6:35 PM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH] f2fs: do checkpoint for the renamed inodeIf an inode is renamed, it should be registered as
file_lost_pinoto conduct checkpoint atf2fs_sync_file.
Otherwise, the inode cannot be recovered due to nodent_markin the following scenario.Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cut
Quoted 6 lines
Quoted 3 lines
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enterrecover_dentrydue to nodent_mark.As we know CP is expensive, how about modifying checkpointed value directly in nat cache at step #3? So "b" could be fsynced with
dent_markat step #4.
Yes, I also thought about that.
But, when handling the nat cache, one of my concerns was the lock granularity. Basically each nat cache entry should be covered by its node page lock, so it is a little bit complicate to do something easily in f2fs_rename.
So, this patch was to fix the bug with a naive approach. And we can write additional patch to enhance this too.
Thanks,
Quoted 65 lines
Quoted 65 lines
The reason is like below.
- The nid of "a" is checkpointed during #2,f2fs_sync_file.
- The inode page for "b" produced by #3 is written withoutdent_markbysync_node_pages.So, this patch fixes this bug by assinging
file_lost_pinoto the "a"'s inode. If the pino is lost,f2fs_sync_fileconducts checkpoint, and then recovers the latest pino and its dentry information for further recovery.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/namei.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/f2fs/namei.c +4
-7@@ -411,9 +411,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, }f2fs_set_link (new_dir, new_entry, new_page, old_inode); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem); new_inode->i_ctime =CURRENT_TIME ;down_write (&F2FS_I (new_inode)->i_sem);@@ -446,6 +443,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } } +down_write (&F2FS_I (old_inode)->i_sem); +file_lost_pino (old_inode); +up_write (&F2FS_I (old_inode)->i_sem); + old_inode->i_ctime =CURRENT_TIME ;mark_inode_dirty (old_inode);@@ -455,9 +456,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,if (old_dir != new_dir) {f2fs_set_link (old_inode, old_dir_entry, old_dir_page, new_dir); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem);update_inode_page (old_inode); }else {kunmap (old_dir_page); --1.8.5.2 (Apple Git-48)
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Signature · 8 lines
Jaegeuk Kim ------------------------------------------------------------------------------ Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft
Hi Jaegeuk,
Quoted 39 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, July 08, 2014 2:37 PM
To: Chao Yu
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev] [PATCH] f2fs: do checkpoint for the renamed inodeQuoted 23 lines · Chao Yu
Hi Jaegeuk,
Quoted 21 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, July 02, 2014 6:35 PM
To: [email protected]; [email protected]; [email protected]
Cc: Jaegeuk Kim
Subject: [f2fs-dev] [PATCH] f2fs: do checkpoint for the renamed inodeIf an inode is renamed, it should be registered as
file_lost_pinoto conduct checkpoint atf2fs_sync_file.
Otherwise, the inode cannot be recovered due to nodent_markin the following scenario.Note that, this scenario is from xfstests/322.
1. create "a"
2. fsync "a"
3. rename "a" to "b"
4. fsync "b"
5. Sudden power-cutQuoted 6 lines
Quoted 3 lines
After recovery is done, "b" should be seen.
However, the result shows "a", since the recovery procedure does not enterrecover_dentrydue to nodent_mark.As we know CP is expensive, how about modifying checkpointed value directly in nat cache at step #3? So "b" could be fsynced with
dent_markat step #4.
Quoted 7 lines
Yes, I also thought about that.
But, when handling the nat cache, one of my concerns was the lock granularity. Basically each nat cache entry should be covered by its node page lock, so it is a little bit complicate to do something easily inf2fs_rename.So, this patch was to fix the bug with a naive approach. And we can write additional patch to enhance this too.
Thanks for your explanation! :)
Regards,
Yu
Quoted 58 lines
Thanks,
Quoted 55 lines
Quoted 55 lines
The reason is like below.
- The nid of "a" is checkpointed during #2,f2fs_sync_file.
- The inode page for "b" produced by #3 is written withoutdent_markbysync_node_pages.So, this patch fixes this bug by assinging
file_lost_pinoto the "a"'s inode. If the pino is lost,f2fs_sync_fileconducts checkpoint, and then recovers the latest pino and its dentry information for further recovery.Signed-off-by Jaegeuk Kim <[email protected]>--- fs/f2fs/namei.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)fs/f2fs/namei.c +4
-7@@ -411,9 +411,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, }f2fs_set_link (new_dir, new_entry, new_page, old_inode); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem); new_inode->i_ctime =CURRENT_TIME ;down_write (&F2FS_I (new_inode)->i_sem);@@ -446,6 +443,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, } } +down_write (&F2FS_I (old_inode)->i_sem); +file_lost_pino (old_inode); +up_write (&F2FS_I (old_inode)->i_sem); + old_inode->i_ctime =CURRENT_TIME ;mark_inode_dirty (old_inode);@@ -455,9 +456,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,if (old_dir != new_dir) {f2fs_set_link (old_inode, old_dir_entry, old_dir_page, new_dir); -down_write (&F2FS_I (old_inode)->i_sem); -F2FS_I (old_inode)->i_pino = new_dir->i_ino; -up_write (&F2FS_I (old_inode)->i_sem);update_inode_page (old_inode); }else {kunmap (old_dir_page); --1.8.5.2 (Apple Git-48)
Quoted 13 lines
Quoted 10 lines
Quoted 10 lines
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel--
Jaegeuk Kim
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft