f2fs: enable recover_xattr_data to avoid cp when fsync after operating xattr
PATCH 2/2 f2fs: enable recover_xattr_data to avoid cp when fsync after operating xattr
Now if we call fsync() after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.
--- fs/f2fs/f2fs.h | 3 +-- fs/f2fs/file.c | 3 --- fs/f2fs/node.c | 28 ++++++++++++++++------------ fs/f2fs/node.h | 2 +- fs/f2fs/recovery.c | 4 +++- fs/f2fs/xattr.c | 3 --- 6 files changed, 21 insertions(+), 22 deletions(-)
fs/f2fs/f2fs.h +1 -2
@@ -301,7 +301,6 @@ struct f2fs_inode_info {f2fs_hash_t chash;/* hash value of given file name */ unsigned int clevel;/* maximum level of given file name */ nid_t i_xattr_nid;/* node id that contains xattrs */ -unsigned long long xattr_ver;/* cp version of xattr modification */ struct extent_info ext;/* in-memory extent cache entry */ struct inode_entry *dirty_dir;/* the pointer of dirty dir */
@@ -1391,7 +1390,7 @@ bool alloc_nid(struct f2fs_sb_info *, nid_t *);void alloc_nid_done (struct f2fs_sb_info *,nid_t );void alloc_nid_failed (struct f2fs_sb_info *,nid_t );void recover_inline_xattr (struct inode *,struct page *); -void recover_xattr_data (struct inode *,struct page *,block_t ); +int recover_xattr_data (struct inode *,struct page *,block_t );int recover_inode_page (struct f2fs_sb_info *,struct page *);int restore_node_summary (struct f2fs_sb_info *,unsigned int ,struct f2fs_summary_block *);
fs/f2fs/file.c +0 -3
@@ -129,8 +129,6 @@ static inline bool need_do_checkpoint(struct inode *inode) need_cp = true; else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino)) need_cp = true; - else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi))) - need_cp = true; else if (test_opt(sbi, FASTBOOT)) need_cp = true; else if (sbi->active_logs == 2)
@@ -156,7 +154,6 @@ static void try_to_fix_pino(struct inode *inode)nid_t pino;down_write (&fi->i_sem); - fi->xattr_ver =0 ;if (file_wrong_pino (inode) && inode->i_nlink ==1 &&get_parent_ino (inode, &pino)) { fi->i_pino = pino;
fs/f2fs/node.c +16 -12
@@ -863,9 +863,6 @@ int truncate_xattr_node(struct inode *inode, struct page *page)F2FS_I (inode)->i_xattr_nid =0 ; -/* need to do checkpoint during fsync */ -F2FS_I (inode)->xattr_ver =cur_cp_version (F2FS_CKPT (sbi)); -set_new_dnode (&dn, inode, page, npage, nid);if (page)
@@ -1655,12 +1652,13 @@ update_inode:f2fs_put_page (ipage,1 ); } -void recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) +int recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) {struct f2fs_sb_info *sbi =F2FS_I_SB (inode);nid_t prev_xnid =F2FS_I (inode)->i_xattr_nid;nid_t new_xnid =nid_of_node (page);struct node_info ni; +struct page *xpage;/* 1: invalidate the previous xattr nid */ if (!prev_xnid)
@@ -1674,21 +1672,27 @@ void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)set_node_addr (sbi, &ni,NULL_ADDR , false); recover_xnid: -/* 2: allocate new xattr nid */ +/* 2: update xattr nid in inode */ +remove_free_nid (NM_I (sbi), new_xnid); +F2FS_I (inode)->i_xattr_nid = new_xnid;if (unlikely (!inc_valid_node_count (sbi, inode)))f2fs_bug_on (sbi,1 ); +update_inode_page (inode); + +/* 3: update and make xattr node page dirty */ + xpage =grab_cache_page (NODE_MAPPING (sbi), new_xnid); +if (!xpage) +return -ENOMEM ; + +memcpy (F2FS_NODE (xpage),F2FS_NODE (page),PAGE_CACHE_SIZE ); -remove_free_nid (NM_I (sbi), new_xnid);get_node_info (sbi, new_xnid, &ni); ni.ino = inode->i_ino;set_node_addr (sbi, &ni,NEW_ADDR , false); -F2FS_I (inode)->i_xattr_nid = new_xnid; +set_page_dirty (xpage); +f2fs_put_page (xpage,1 ); -/* 3: update xattr blkaddr */ -refresh_sit_entry (sbi,NEW_ADDR , blkaddr); -set_node_addr (sbi, &ni, blkaddr, false); - -update_inode_page (inode); +return 0 ; }int recover_inode_page (struct f2fs_sb_info *sbi,struct page *page)
fs/f2fs/node.h +1 -1
@@ -300,7 +300,7 @@ static inline bool IS_DNODE(struct page *node_page)unsigned int ofs =ofs_of_node (node_page);if (f2fs_has_xattr_block (ofs)) -return false; +return true;if (ofs ==3 || ofs ==4 +NIDS_PER_BLOCK || ofs ==5 +2 *NIDS_PER_BLOCK )
fs/f2fs/recovery.c +3 -1
@@ -346,7 +346,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,if (IS_INODE (page)) {recover_inline_xattr (inode, page); }else if (f2fs_has_xattr_block (ofs_of_node (page))) { -recover_xattr_data (inode, page, blkaddr); + err =recover_xattr_data (inode, page, blkaddr); +if (!err) + recovered++; goto out; }
fs/f2fs/xattr.c +0 -3
@@ -391,9 +391,6 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, sizeof(struct node_footer));set_page_dirty (xpage);f2fs_put_page (xpage,1 ); - -/* need to checkpoint during fsync */ -F2FS_I (inode)->xattr_ver =cur_cp_version (F2FS_CKPT (sbi));return 0 ; }
Signature · 1 line
2.2.1
Jaegeuk Kim
maintainerHi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.
You're trying to change the writing policy as xattr blocks are written into WARM_NODE area instead of COLD_NODE area.
I don't think xattrs are frequently changed between each fsync calls.
How do you think?
Thanks,
Quoted 162 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/f2fs.h | 3 +-- fs/f2fs/file.c | 3 --- fs/f2fs/node.c | 28 ++++++++++++++++------------ fs/f2fs/node.h | 2 +- fs/f2fs/recovery.c | 4 +++- fs/f2fs/xattr.c | 3 --- 6 files changed, 21 insertions(+), 22 deletions(-)fs/f2fs/f2fs.h +1
-2@@ -301,7 +301,6 @@ struct f2fs_inode_info {f2fs_hash_t chash;/* hash value of given file name */ unsigned int clevel;/* maximum level of given file name */ nid_t i_xattr_nid;/* node id that contains xattrs */ -unsigned long long xattr_ver;/* cp version of xattr modification */ struct extent_info ext;/* in-memory extent cache entry */ struct inode_entry *dirty_dir;/* the pointer of dirty dir */ @@ -1391,7 +1390,7 @@ bool alloc_nid(struct f2fs_sb_info *, nid_t *);void alloc_nid_done (struct f2fs_sb_info *,nid_t );void alloc_nid_failed (struct f2fs_sb_info *,nid_t );void recover_inline_xattr (struct inode *,struct page *); -void recover_xattr_data (struct inode *,struct page *,block_t ); +int recover_xattr_data (struct inode *,struct page *,block_t );int recover_inode_page (struct f2fs_sb_info *,struct page *);int restore_node_summary (struct f2fs_sb_info *,unsigned int ,struct f2fs_summary_block *);fs/f2fs/file.c +0
-3@@ -129,8 +129,6 @@ static inline bool need_do_checkpoint(struct inode *inode) need_cp = true; else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino)) need_cp = true; - else if (F2FS_I(inode)->xattr_ver == cur_cp_version(F2FS_CKPT(sbi))) - need_cp = true; else if (test_opt(sbi, FASTBOOT)) need_cp = true; else if (sbi->active_logs == 2)@@ -156,7 +154,6 @@ static void try_to_fix_pino(struct inode *inode)nid_t pino;down_write (&fi->i_sem); - fi->xattr_ver =0 ;if (file_wrong_pino (inode) && inode->i_nlink ==1 &&get_parent_ino (inode, &pino)) { fi->i_pino = pino;fs/f2fs/node.c +16
-12@@ -863,9 +863,6 @@ int truncate_xattr_node(struct inode *inode, struct page *page)F2FS_I (inode)->i_xattr_nid =0 ; -/* need to do checkpoint during fsync */ -F2FS_I (inode)->xattr_ver =cur_cp_version (F2FS_CKPT (sbi)); -set_new_dnode (&dn, inode, page, npage, nid);if (page)@@ -1655,12 +1652,13 @@ update_inode:f2fs_put_page (ipage,1 ); } -void recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) +int recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) {struct f2fs_sb_info *sbi =F2FS_I_SB (inode);nid_t prev_xnid =F2FS_I (inode)->i_xattr_nid;nid_t new_xnid =nid_of_node (page);struct node_info ni; +struct page *xpage;/* 1: invalidate the previous xattr nid */ if (!prev_xnid)@@ -1674,21 +1672,27 @@ void recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr)set_node_addr (sbi, &ni,NULL_ADDR , false); recover_xnid: -/* 2: allocate new xattr nid */ +/* 2: update xattr nid in inode */ +remove_free_nid (NM_I (sbi), new_xnid); +F2FS_I (inode)->i_xattr_nid = new_xnid;if (unlikely (!inc_valid_node_count (sbi, inode)))f2fs_bug_on (sbi,1 ); +update_inode_page (inode); + +/* 3: update and make xattr node page dirty */ + xpage =grab_cache_page (NODE_MAPPING (sbi), new_xnid); +if (!xpage) +return -ENOMEM ; + +memcpy (F2FS_NODE (xpage),F2FS_NODE (page),PAGE_CACHE_SIZE ); -remove_free_nid (NM_I (sbi), new_xnid);get_node_info (sbi, new_xnid, &ni); ni.ino = inode->i_ino;set_node_addr (sbi, &ni,NEW_ADDR , false); -F2FS_I (inode)->i_xattr_nid = new_xnid; +set_page_dirty (xpage); +f2fs_put_page (xpage,1 ); -/* 3: update xattr blkaddr */ -refresh_sit_entry (sbi,NEW_ADDR , blkaddr); -set_node_addr (sbi, &ni, blkaddr, false); - -update_inode_page (inode); +return 0 ; }int recover_inode_page (struct f2fs_sb_info *sbi,struct page *page)fs/f2fs/node.h +1
-1@@ -300,7 +300,7 @@ static inline bool IS_DNODE(struct page *node_page)unsigned int ofs =ofs_of_node (node_page);if (f2fs_has_xattr_block (ofs)) -return false; +return true;if (ofs ==3 || ofs ==4 +NIDS_PER_BLOCK || ofs ==5 +2 *NIDS_PER_BLOCK )fs/f2fs/recovery.c +3
-1@@ -346,7 +346,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,if (IS_INODE (page)) {recover_inline_xattr (inode, page); }else if (f2fs_has_xattr_block (ofs_of_node (page))) { -recover_xattr_data (inode, page, blkaddr); + err =recover_xattr_data (inode, page, blkaddr); +if (!err) + recovered++; goto out; }fs/f2fs/xattr.c +0
-3@@ -391,9 +391,6 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize, sizeof(struct node_footer));set_page_dirty (xpage);f2fs_put_page (xpage,1 ); - -/* need to checkpoint during fsync */ -F2FS_I (inode)->xattr_ver =cur_cp_version (F2FS_CKPT (sbi));return 0 ; }Signature · 1 line
2.2.1
Hi Jaegeuk,
Quoted 18 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrHi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.
Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when fsync() is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.
Thanks,
Yu
Jaegeuk Kim
maintainerQuoted 26 lines · Chao Yu
Hi Jaegeuk,
Quoted 18 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrHi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered by inline_xattr, it doesn't trigger checkpoint.
Let me know, if I'm missing something.
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e., space_for_roll_forward())
And, I don't want to search cold node chain.
Thanks,
Quoted 3 lines
Thanks,
Yu
Hi Jaegeuk,
Quoted 44 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Sunday, January 11, 2015 1:32 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrQuoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsyncafter
Quoted 18 lines
Quoted 12 lines
operating xattr
Hi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.
Quoted 4 lines
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered byinline_xattr, it doesn't trigger checkpoint.
Agree, that's a good solution.
Quoted 6 lines
Let me know, if I'm missing something.
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e.,
space_for_roll_forward())
And, I don't want to search cold node chain.
OK, if we keep writing policy and recovery procedure as it is, then, shouldn't our recover_xattr_data be dropped because it will be not used from any call path? How do you think of below patch?
Quoted 1 line
From
4fee238292aa0198a1530492afbd529e84e83141Mon Sep 17 00:00:00 2001
From: Chao Yu <[email protected]>
Date: Mon, 12 Jan 2015 17:25:44 +0800
Subject: [PATCH] f2fs: drop recover_xattr_data
Because xattr node will be written to cold node segment, so in current procedure it's wrong that we try to find and recover it from warm node chain in recover_xattr_data.
Let's drop this related function and invoking.
--- fs/f2fs/f2fs.h | 1 - fs/f2fs/node.c | 36 ------------------------------------ fs/f2fs/recovery.c | 8 ++------ 3 files changed, 2 insertions(+), 43 deletions(-)
fs/f2fs/f2fs.h +0 -1
@@ -1392,7 +1392,6 @@ bool alloc_nid(struct f2fs_sb_info *, nid_t *);void alloc_nid_done (struct f2fs_sb_info *,nid_t );void alloc_nid_failed (struct f2fs_sb_info *,nid_t );void recover_inline_xattr (struct inode *,struct page *); -void recover_xattr_data (struct inode *,struct page *,block_t );int recover_inode_page (struct f2fs_sb_info *,struct page *);int restore_node_summary (struct f2fs_sb_info *,unsigned int ,struct f2fs_summary_block *);
fs/f2fs/node.c +0 -36
@@ -1656,42 +1656,6 @@ update_inode:f2fs_put_page (ipage,1 ); } -void recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) -{ -struct f2fs_sb_info *sbi =F2FS_I_SB (inode); -nid_t prev_xnid =F2FS_I (inode)->i_xattr_nid; -nid_t new_xnid =nid_of_node (page); -struct node_info ni; - -/* 1: invalidate the previous xattr nid */ -if (!prev_xnid) - goto recover_xnid; - -/* Deallocate node address */ -get_node_info (sbi, prev_xnid, &ni); -f2fs_bug_on (sbi, ni.blk_addr ==NULL_ADDR ); -invalidate_blocks (sbi, ni.blk_addr); -dec_valid_node_count (sbi, inode); -set_node_addr (sbi, &ni,NULL_ADDR , false); - -recover_xnid: -/* 2: allocate new xattr nid */ -if (unlikely (!inc_valid_node_count (sbi, inode))) -f2fs_bug_on (sbi,1 ); - -remove_free_nid (NM_I (sbi), new_xnid); -get_node_info (sbi, new_xnid, &ni); - ni.ino = inode->i_ino; -set_node_addr (sbi, &ni,NEW_ADDR , false); -F2FS_I (inode)->i_xattr_nid = new_xnid; - -/* 3: update xattr blkaddr */ -refresh_sit_entry (sbi,NEW_ADDR , blkaddr); -set_node_addr (sbi, &ni, blkaddr, false); - -update_inode_page (inode); -} -int recover_inode_page (struct f2fs_sb_info *sbi,struct page *page) {struct f2fs_inode *src, *dst;
fs/f2fs/recovery.c +2 -6
@@ -342,13 +342,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,struct node_info ni;int err =0 , recovered =0 ; -/* step 1: recover xattr */ -if (IS_INODE (page)) { +/* step 1: recover inline xattr */ +if (IS_INODE (page))recover_inline_xattr (inode, page); - }else if (f2fs_has_xattr_block (ofs_of_node (page))) { -recover_xattr_data (inode, page, blkaddr); - goto out; - }/* step 2: recover inline data */ if (recover_inline_data (inode, page))
Signature · 1 line
2.2.1
Quoted 6 lines
Thanks,
Quoted 3 lines
Thanks,
Yu
Jaegeuk Kim
maintainerQuoted 56 lines · Chao Yu
Hi Jaegeuk,
Quoted 44 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Sunday, January 11, 2015 1:32 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrQuoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsyncafter
Quoted 18 lines
Quoted 12 lines
operating xattr
Hi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.Quoted 4 lines
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered byinline_xattr, it doesn't trigger checkpoint.Agree, that's a good solution.
Quoted 3 lines
Let me know, if I'm missing something.
Quoted 7 lines
Quoted 3 lines
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e.,
space_for_roll_forward())
And, I don't want to search cold node chain.OK, if we keep writing policy and recovery procedure as it is, then, shouldn't our
recover_xattr_databe dropped because it will be not used from any call path? How do you think of below patch?
Hi Chao,
Nice catch.
But, IIRC, this code was remained for backward compatibility, since long time ago, xattr blocks were written into the warm node chain.
So, I couldn't remove this.
Thanks,
Quoted 108 lines
Quoted 2 lines
From
4fee238292aa0198a1530492afbd529e84e83141Mon Sep 17 00:00:00 2001From: Chao Yu <[email protected]>
Date: Mon, 12 Jan 2015 17:25:44 +0800
Subject: [PATCH] f2fs: droprecover_xattr_dataBecause xattr node will be written to cold node segment, so in current procedure it's wrong that we try to find and recover it from warm node chain in
recover_xattr_data.Let's drop this related function and invoking.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/f2fs.h | 1 - fs/f2fs/node.c | 36 ------------------------------------ fs/f2fs/recovery.c | 8 ++------ 3 files changed, 2 insertions(+), 43 deletions(-)fs/f2fs/f2fs.h +0
-1@@ -1392,7 +1392,6 @@ bool alloc_nid(struct f2fs_sb_info *, nid_t *);void alloc_nid_done (struct f2fs_sb_info *,nid_t );void alloc_nid_failed (struct f2fs_sb_info *,nid_t );void recover_inline_xattr (struct inode *,struct page *); -void recover_xattr_data (struct inode *,struct page *,block_t );int recover_inode_page (struct f2fs_sb_info *,struct page *);int restore_node_summary (struct f2fs_sb_info *,unsigned int ,struct f2fs_summary_block *);fs/f2fs/node.c +0
-36@@ -1656,42 +1656,6 @@ update_inode:f2fs_put_page (ipage,1 ); } -void recover_xattr_data (struct inode *inode,struct page *page,block_t blkaddr) -{ -struct f2fs_sb_info *sbi =F2FS_I_SB (inode); -nid_t prev_xnid =F2FS_I (inode)->i_xattr_nid; -nid_t new_xnid =nid_of_node (page); -struct node_info ni; - -/* 1: invalidate the previous xattr nid */ -if (!prev_xnid) - goto recover_xnid; - -/* Deallocate node address */ -get_node_info (sbi, prev_xnid, &ni); -f2fs_bug_on (sbi, ni.blk_addr ==NULL_ADDR ); -invalidate_blocks (sbi, ni.blk_addr); -dec_valid_node_count (sbi, inode); -set_node_addr (sbi, &ni,NULL_ADDR , false); - -recover_xnid: -/* 2: allocate new xattr nid */ -if (unlikely (!inc_valid_node_count (sbi, inode))) -f2fs_bug_on (sbi,1 ); - -remove_free_nid (NM_I (sbi), new_xnid); -get_node_info (sbi, new_xnid, &ni); - ni.ino = inode->i_ino; -set_node_addr (sbi, &ni,NEW_ADDR , false); -F2FS_I (inode)->i_xattr_nid = new_xnid; - -/* 3: update xattr blkaddr */ -refresh_sit_entry (sbi,NEW_ADDR , blkaddr); -set_node_addr (sbi, &ni, blkaddr, false); - -update_inode_page (inode); -} -int recover_inode_page (struct f2fs_sb_info *sbi,struct page *page) {struct f2fs_inode *src, *dst;fs/f2fs/recovery.c +2
-6@@ -342,13 +342,9 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,struct node_info ni;int err =0 , recovered =0 ; -/* step 1: recover xattr */ -if (IS_INODE (page)) { +/* step 1: recover inline xattr */ +if (IS_INODE (page))recover_inline_xattr (inode, page); - }else if (f2fs_has_xattr_block (ofs_of_node (page))) { -recover_xattr_data (inode, page, blkaddr); - goto out; - }/* step 2: recover inline data */ if (recover_inline_data (inode, page))Signature · 1 line
2.2.1Quoted 6 lines
Thanks,
Quoted 3 lines
Thanks,
Yu
Hi Jaegeuk,
Quoted 75 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 14, 2015 8:22 AM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrQuoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Sunday, January 11, 2015 1:32 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsyncafter
Quoted 11 lines
Quoted 11 lines
operating xattr
Quoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp whenfsync
Quoted 37 lines
Quoted 27 lines
after
Quoted 18 lines
Quoted 12 lines
operating xattr
Hi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.Quoted 4 lines
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered byinline_xattr, it doesn't trigger checkpoint.Agree, that's a good solution.
Quoted 3 lines
Let me know, if I'm missing something.
Quoted 7 lines
Quoted 3 lines
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e.,
space_for_roll_forward())
And, I don't want to search cold node chain.OK, if we keep writing policy and recovery procedure as it is, then, shouldn't our
recover_xattr_databe dropped because it will be not used from any call path? How do you think of below patch?
Quoted 5 lines
Hi Chao,
Nice catch.
But, IIRC, this code was remained for backward compatibility, since long time ago, xattr blocks were written into the warm node chain.
Ah, I got it, thanks for your explanation! :)
How do you think of adding some comments on these codes, because this can help developers understand it well and not to submit the wrong fix patch like me again.
Thanks,
Quoted 3 lines
So, I couldn't remove this.
Thanks,
Jaegeuk Kim
maintainerHi Chao,
Quoted 79 lines · Chao Yu
Hi Jaegeuk,
Quoted 77 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 14, 2015 8:22 AM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrQuoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Sunday, January 11, 2015 1:32 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsyncafter
Quoted 11 lines
Quoted 11 lines
operating xattr
Quoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp whenfsync
Quoted 37 lines
Quoted 27 lines
after
Quoted 18 lines
Quoted 12 lines
operating xattr
Hi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.Quoted 4 lines
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered byinline_xattr, it doesn't trigger checkpoint.Agree, that's a good solution.
Quoted 3 lines
Let me know, if I'm missing something.
Quoted 7 lines
Quoted 3 lines
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e.,
space_for_roll_forward())
And, I don't want to search cold node chain.OK, if we keep writing policy and recovery procedure as it is, then, shouldn't our
recover_xattr_databe dropped because it will be not used from any call path? How do you think of below patch?Hi Chao,
Quoted 7 lines
Quoted 3 lines
Nice catch.
But, IIRC, this code was remained for backward compatibility, since long time ago, xattr blocks were written into the warm node chain.Ah, I got it, thanks for your explanation! :)
How do you think of adding some comments on these codes, because this can help developers understand it well and not to submit the wrong fix patch like me again.
Something like this?
Quoted 1 line
From
6b609421e4f9f52de26554300aae62de33e0703aMon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Thu, 22 Jan 2015 14:48:28 -0800
Subject: [PATCH] f2fs: leave comment for code readability
During the recovery, any xattr blocks should not be found, since they are written into cold log, not the warm node chain.
--- fs/f2fs/recovery.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/f2fs/recovery.c +4 -0
@@ -346,6 +346,10 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,if (IS_INODE (page)) {recover_inline_xattr (inode, page); }else if (f2fs_has_xattr_block (ofs_of_node (page))) { +/* +* Deprecated; xattr blocks should be found from cold log. +* But, we should remain this for backward compatibility. +*/ recover_xattr_data (inode, page, blkaddr); goto out; }
Signature · 1 line
2.1.1
Chao Yu
Reviewed-byHi Jaegeuk,
Quoted 98 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, January 23, 2015 7:13 AM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsync after operating xattrHi Chao,
Quoted 8 lines · Chao Yu
Hi Jaegeuk,
Quoted 6 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 14, 2015 8:22 AM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enablerecover_xattr_datato avoid cp when fsyncafter
Quoted 10 lines
Quoted 10 lines
operating xattr
Quoted 7 lines · Chao Yu
Hi Jaegeuk,
Quoted 5 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Sunday, January 11, 2015 1:32 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected];Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enable
recover_xattr_datato avoid cp whenfsync
Quoted 11 lines
Quoted 11 lines
after
Quoted 10 lines
Quoted 10 lines
operating xattr
Quoted 7 lines · Chao Yu
Hi Jaegeuk,
Quoted 5 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, January 07, 2015 3:44 AM
To: Chao Yu
Cc: Changman Lee; [email protected];Quoted 53 lines
Quoted 52 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Subject: Re: [f2fs-dev][PATCH 2/2] f2fs: enable
recover_xattr_datato avoid cp whenfsync
Quoted 37 lines
Quoted 27 lines
after
Quoted 18 lines
Quoted 12 lines
operating xattr
Hi Chao,
Quoted 6 lines · Chao Yu
Now if we call
fsync()after we update the xattr date belongs to the file, f2fs will do checkpoint to keep data.
This can cause low performance because checkpoint block most operation and write lots of blocks. So we'd better to avoid doing checkpoint by writing modified xattr node page to warm node segment, and then it can be recovered when we mount this device later on.Quoted 5 lines
You're trying to change the writing policy as xattr blocks are written into
WARM_NODEarea instead ofCOLD_NODEarea.
I don't think xattrs are frequently changed between each fsync calls.How do you think?
Quoted 7 lines
I'm not sure whether there is a scenario that setxattr and fsync are invoked alternately, but if there is, our performance will decrease obviously.
If you don't want to change writing policy, how about writing xattr node with fsync flag into cold node segment when
fsync()is called, then try to recover it from cold node chain when recovery after abnormally pow-cut, this way can avoid cp frequently in above scenario.Quoted 4 lines
Firt of all, I don't think this scenario is frequent enough that we have to break the exisiting writing and recovery procedures.
Moreover, if xattr entries are covered byinline_xattr, it doesn't trigger checkpoint.Agree, that's a good solution.
Quoted 3 lines
Let me know, if I'm missing something.
Quoted 7 lines
Quoted 3 lines
If you try to change the recovery procedure, it needs to think about the disk full condition. (i.e.,
space_for_roll_forward())
And, I don't want to search cold node chain.OK, if we keep writing policy and recovery procedure as it is, then, shouldn't our
recover_xattr_databe dropped because it will be not used from any call path? How do you think of below patch?Hi Chao,
Nice catch.
But, IIRC, this code was remained for backward compatibility, since long time ago, xattr blocks were written into the warm node chain.
Quoted 5 lines
Quoted 3 lines
Ah, I got it, thanks for your explanation! :)
How do you think of adding some comments on these codes, because this can help developers understand it well and not to submit the wrong fix patch like me again.Something like this?
It's good, this is what I wanted.
Thanks for your work! :)
Quoted 10 lines
From
6b609421e4f9f52de26554300aae62de33e0703aMon Sep 17 00:00:00 2001
From: Jaegeuk Kim <[email protected]>
Date: Thu, 22 Jan 2015 14:48:28 -0800
Subject: [PATCH] f2fs: leave comment for code readabilityDuring the recovery, any xattr blocks should not be found, since they are written into cold log, not the warm node chain.
Signed-off-by Jaegeuk Kim <[email protected]>
Thanks,
Yu
Quoted 21 lines
--- fs/f2fs/recovery.c | 4 ++++ 1 file changed, 4 insertions(+)fs/f2fs/recovery.c +4
-1@@ -346,6 +346,10 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,if (IS_INODE (page)) {recover_inline_xattr (inode, page); }else if (f2fs_has_xattr_block (ofs_of_node (page))) { +/* +* Deprecated; xattr blocks should be found from cold log. +* But, we should remain this for backward compatibility. +*/ recover_xattr_data (inode, page, blkaddr); goto out; } --2.1.1