@@ -3478,6 +3478,8 @@ int f2fs_pin_file_control(struct inode *inode, bool inc);
void f2fs_set_inode_flags(struct inode *inode);
bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page);
void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page);
+int f2fs_inode_chksum_get(struct f2fs_sb_info *sbi, struct inode *inode,
+ u32 *chksum);
struct inode *f2fs_iget(struct super_block *sb, unsigned long ino);
struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino);
int f2fs_try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink);
@@ -204,6 +204,27 @@ void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page)
ri->i_inode_checksum = cpu_to_le32(f2fs_inode_chksum(sbi, page));
}
+int f2fs_inode_chksum_get(struct f2fs_sb_info *sbi,
+ struct inode *inode, u32 *chksum)
+{
+ struct page *ipage;
+ struct f2fs_inode_info *fi = F2FS_I(inode);
+ struct f2fs_inode *ri;
+
+ if (!f2fs_sb_has_inode_chksum(sbi) ||
+ !f2fs_has_extra_attr(inode) ||
+ !F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_inode_checksum))
+ return -EOPNOTSUPP;
+
+ ipage = f2fs_get_node_page(sbi, inode->i_ino);
+ if (IS_ERR(ipage))
+ return PTR_ERR(ipage);
+
+ *chksum = f2fs_inode_chksum(sbi, ipage);
+ f2fs_put_page(ipage, true);
+ return 0;
+}
+
static bool sanity_check_compress_inode(struct inode *inode,
struct f2fs_inode *ri)
{
Signed-off-by: Sheng Yong <shengyong@oppo.com> --- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/inode.c | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+)