Patchwork [33/37] tune2fs: Rewrite extended attribute block checksums

login
register
mail settings
Submitter Darrick J. Wong
Date Sept. 1, 2011, 12:38 a.m.
Message ID <20110901003843.1176.69266.stgit@elm3c44.beaverton.ibm.com>
Download mbox | patch
Permalink /patch/112785/
State Changes Requested
Headers show

Comments

Darrick J. Wong - Sept. 1, 2011, 12:38 a.m.
When enabling metadata checksums, rewrite separate extended attribute blocks.

Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
 misc/tune2fs.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 5663e49..60c1a6a 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -589,11 +589,13 @@  errcode_t rewrite_directory(ext2_filsys fs, ext2_ino_t dir,
  */
 static void rewrite_inodes(ext2_filsys fs)
 {
+	char		*ea_buf;
 	char		buf[EXT2_INODE_CORE_SIZE(fs->super)];
 	struct ext2_inode_large *inode = (struct ext2_inode_large *)buf;
 	ext2_inode_scan	scan;
 	errcode_t	retval;
 	ext2_ino_t	ino;
+	blk64_t		file_acl_block;
 
 	if (fs->super->s_creator_os != EXT2_OS_LINUX)
 		return;
@@ -604,6 +606,12 @@  static void rewrite_inodes(ext2_filsys fs)
 		exit(1);
 	}
 
+	retval = ext2fs_get_mem(fs->blocksize, &ea_buf);
+	if (retval) {
+		com_err("set_csum", retval, "while allocating memory");
+		exit(1);
+	}
+
 	do {
 		retval = ext2fs_get_next_inode(scan, &ino, inode);
 		if (retval) {
@@ -633,7 +641,25 @@  static void rewrite_inodes(ext2_filsys fs)
 				exit(1);
 			}
 		}
+
+		file_acl_block = ext2fs_file_acl_block(inode);
+		if (!file_acl_block)
+			continue;
+		retval = ext2fs_read_ext_attr2(fs, file_acl_block, ea_buf);
+		if (retval) {
+			com_err("rewrite_eablock", retval,
+				"while rewriting extended attribute");
+			exit(1);
+		}
+		retval = ext2fs_write_ext_attr2(fs, file_acl_block, ea_buf);
+		if (retval) {
+			com_err("rewrite_eablock", retval,
+				"while rewriting extended attribute");
+			exit(1);
+		}
 	} while (ino);
+
+	ext2fs_free_mem(&ea_buf);
 	ext2fs_close_inode_scan(scan);
 }