All of lore.kernel.org
 help / color / mirror / Atom feed
From: Liu Xue <liuxueliu.liu@huawei.com>
To: jaegeuk@kernel.org
Cc: Liu Xue <liuxueliu.liu@huawei.com>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH] f2fs-tools: calculate inode checksum and writeback
Date: Thu, 14 Jun 2018 11:10:22 +0800	[thread overview]
Message-ID: <1528945822-85289-1-git-send-email-liuxueliu.liu@huawei.com> (raw)

Calculate inode checksum and writeback when processing
sload or resize.

Signed-off-by: Xue Liu <liuxueliu.liu@huawei.com>
---
 fsck/fsck.h    | 1 +
 fsck/mount.c   | 6 ++++--
 fsck/segment.c | 2 +-
 fsck/xattr.c   | 3 +--
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/fsck/fsck.h b/fsck/fsck.h
index cbe7fc4..f90bcf9 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -221,6 +221,7 @@ int f2fs_resize(struct f2fs_sb_info *);
 int f2fs_sload(struct f2fs_sb_info *);
 
 /* segment.c */
+void write_inode(u64, struct f2fs_node *);
 void reserve_new_block(struct f2fs_sb_info *, block_t *,
 					struct f2fs_summary *, int);
 void new_data_block(struct f2fs_sb_info *, void *,
diff --git a/fsck/mount.c b/fsck/mount.c
index 0a30adb..87b6295 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1551,6 +1551,9 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
 
 		oldaddr = le32_to_cpu(node_blk->i.i_addr[ofs + ofs_in_node]);
 		node_blk->i.i_addr[ofs + ofs_in_node] = cpu_to_le32(newaddr);
+		if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM))
+			node_blk->i.i_inode_checksum =
+				cpu_to_le32(f2fs_inode_chksum(node_blk));
 	} else {
 		oldaddr = le32_to_cpu(node_blk->dn.addr[ofs_in_node]);
 		node_blk->dn.addr[ofs_in_node] = cpu_to_le32(newaddr);
@@ -1574,8 +1577,7 @@ void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid,
 		node_blk->i.i_ext.len = 0;
 
 		/* update inode block */
-		ret = dev_write_block(node_blk, ni.blk_addr);
-		ASSERT(ret >= 0);
+		write_inode(ni.blk_addr, node_blk);
 	}
 	free(node_blk);
 }
diff --git a/fsck/segment.c b/fsck/segment.c
index 4f8bdb4..50f0d73 100644
--- a/fsck/segment.c
+++ b/fsck/segment.c
@@ -16,7 +16,7 @@
 #include "fsck.h"
 #include "node.h"
 
-static void write_inode(u64 blkaddr, struct f2fs_node *inode)
+void write_inode(u64 blkaddr, struct f2fs_node *inode)
 {
 	if (c.feature & cpu_to_le32(F2FS_FEATURE_INODE_CHKSUM))
 		inode->i.i_inode_checksum =
diff --git a/fsck/xattr.c b/fsck/xattr.c
index 1d15d1b..7144a83 100644
--- a/fsck/xattr.c
+++ b/fsck/xattr.c
@@ -220,8 +220,7 @@ int f2fs_setxattr(struct f2fs_sb_info *sbi, nid_t ino, int index, const char *na
 	write_all_xattrs(sbi, inode, new_hsize, base_addr);
 
 	/* inode need update */
-	ret = dev_write_block(inode, ni.blk_addr);
-	ASSERT(ret >= 0);
+	write_inode(ni.blk_addr, inode);
 exit:
 	free(base_addr);
 	return error;
-- 
1.8.5.2


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

             reply	other threads:[~2018-06-14  3:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-14  3:10 Liu Xue [this message]
2018-06-19 12:59 ` [PATCH] f2fs-tools: calculate inode checksum and writeback Chao Yu
2019-05-24  7:28 Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1528945822-85289-1-git-send-email-liuxueliu.liu@huawei.com \
    --to=liuxueliu.liu@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.