diff options
author | Chao Yu <chao2.yu@samsung.com> | 2014-03-11 01:37:38 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2014-03-11 03:31:06 -0400 |
commit | 28cdce0459ccea71ea734d7903d39910d1c6a05d (patch) | |
tree | cbd61d6fc5b1984297b92a5434839261a70af1c1 /fs/f2fs | |
parent | d653788a43475eb3cdfcfaa60fb53451878944cf (diff) |
f2fs: recover inline xattr data in roll-forward process
Previously we do not recover inline xattr data of inode after power-cut, so
inline xattr data may be lost.
We should recover the data during the roll-forward process.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Diffstat (limited to 'fs/f2fs')
-rw-r--r-- | fs/f2fs/node.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index c415cec041b7..e72b2585de68 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
@@ -1493,6 +1493,37 @@ void recover_node_page(struct f2fs_sb_info *sbi, struct page *page, | |||
1493 | clear_node_page_dirty(page); | 1493 | clear_node_page_dirty(page); |
1494 | } | 1494 | } |
1495 | 1495 | ||
1496 | void recover_inline_xattr(struct inode *inode, struct page *page) | ||
1497 | { | ||
1498 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | ||
1499 | void *src_addr, *dst_addr; | ||
1500 | size_t inline_size; | ||
1501 | struct page *ipage; | ||
1502 | struct f2fs_inode *ri; | ||
1503 | |||
1504 | if (!is_inode_flag_set(F2FS_I(inode), FI_INLINE_XATTR)) | ||
1505 | return; | ||
1506 | |||
1507 | if (!IS_INODE(page)) | ||
1508 | return; | ||
1509 | |||
1510 | ri = F2FS_INODE(page); | ||
1511 | if (!(ri->i_inline & F2FS_INLINE_XATTR)) | ||
1512 | return; | ||
1513 | |||
1514 | ipage = get_node_page(sbi, inode->i_ino); | ||
1515 | f2fs_bug_on(IS_ERR(ipage)); | ||
1516 | |||
1517 | dst_addr = inline_xattr_addr(ipage); | ||
1518 | src_addr = inline_xattr_addr(page); | ||
1519 | inline_size = inline_xattr_size(inode); | ||
1520 | |||
1521 | memcpy(dst_addr, src_addr, inline_size); | ||
1522 | |||
1523 | update_inode(inode, ipage); | ||
1524 | f2fs_put_page(ipage, 1); | ||
1525 | } | ||
1526 | |||
1496 | bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) | 1527 | bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) |
1497 | { | 1528 | { |
1498 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | 1529 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
@@ -1500,6 +1531,8 @@ bool recover_xattr_data(struct inode *inode, struct page *page, block_t blkaddr) | |||
1500 | nid_t new_xnid = nid_of_node(page); | 1531 | nid_t new_xnid = nid_of_node(page); |
1501 | struct node_info ni; | 1532 | struct node_info ni; |
1502 | 1533 | ||
1534 | recover_inline_xattr(inode, page); | ||
1535 | |||
1503 | if (ofs_of_node(page) != XATTR_NODE_OFFSET) | 1536 | if (ofs_of_node(page) != XATTR_NODE_OFFSET) |
1504 | return false; | 1537 | return false; |
1505 | 1538 | ||