Skip to contentSkip to conversation

btrfs-progs: Avoid uninitialized data in output of btrfs-convert

PATCH Applied Zhao Lei 2 participants 5 messages Sep 8, 2015 – Sep 9, 2015 Btrfs file system

lore
Share & tools
lore

Zhao Lei

author
#0 lore raw

cover btrfs-progs: Avoid uninitialized data in output of btrfs-convert

sequence, transid and reserved field of inode was write to disk with uninitizlized value, this patchset fixed it, also fixed some other typo.

Zhao Lei (3):
btrfs-progs: fix set_get typo of btrfs_inode_item->sequence
btrfs-progs: Avoid uninitialized data in output of btrfs-convert
btrfs-progs: add ext2fs_close_inode_scan to copy_inodes

 btrfs-convert.c | 5 +++++
 ctree.h         | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.5.1
author
#1 lore raw

PATCH 1/3 btrfs-progs: fix set_get typo of btrfs_inode_item->sequence

s/generation/sequence
for BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, ...)

---
 ctree.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ctree.h +1 -1
index bcad2b9..2061e1e 100644
@@ -1423,7 +1423,7 @@ BTRFS_SETGET_FUNCS(inode_flags, struct btrfs_inode_item, flags, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_generation,
 			 struct btrfs_inode_item, generation, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence,
-			 struct btrfs_inode_item, generation, 64);
+			 struct btrfs_inode_item, sequence, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_size,
 			 struct btrfs_inode_item, size, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes,
Signature · 1 line
1.8.5.1
author
#2 lore raw

PATCH 2/3 btrfs-progs: Avoid uninitialized data in output of btrfs-convert

In reply to Zhao Lei

sequence, transid and reserved field of inode was write to disk with uninitizlized value, this patch fixed it.

---
 btrfs-convert.c | 4 ++++
 ctree.h         | 2 ++
 2 files changed, 6 insertions(+)
btrfs-convert.c +4 -0
index f4fc650..934f4dc 100644
@@ -1016,6 +1016,8 @@ static int copy_inode_item(struct btrfs_inode_item *dst,
 			   struct ext2_inode *src, u32 blocksize)
 {
 	btrfs_set_stack_inode_generation(dst, 1);
+	btrfs_set_stack_inode_sequence(dst, 0);
+	btrfs_set_stack_inode_transid(dst, 1);
 	btrfs_set_stack_inode_size(dst, src->i_size);
 	btrfs_set_stack_inode_nbytes(dst, 0);
 	btrfs_set_stack_inode_block_group(dst, 0);
@@ -1052,6 +1054,8 @@ static int copy_inode_item(struct btrfs_inode_item *dst,
 				new_decode_dev(src->i_block[1]));
 		}
 	}
+	memset(&dst->reserved, 0, sizeof(dst->reserved));
+
 	return 0;
 }
 
ctree.h +2 -0
index 2061e1e..c57f9ca 100644
@@ -1424,6 +1424,8 @@ BTRFS_SETGET_STACK_FUNCS(stack_inode_generation,
 			 struct btrfs_inode_item, generation, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence,
 			 struct btrfs_inode_item, sequence, 64);
+BTRFS_SETGET_STACK_FUNCS(stack_inode_transid,
+			 struct btrfs_inode_item, transid, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_size,
 			 struct btrfs_inode_item, size, 64);
 BTRFS_SETGET_STACK_FUNCS(stack_inode_nbytes,
Signature · 1 line
1.8.5.1
author
#3 lore raw

PATCH 3/3 btrfs-progs: add ext2fs_close_inode_scan to copy_inodes

In reply to Zhao Lei

We need use ext2fs_close_inode_scan to release relative resource get from ext2fs_open_inode_scan() in copy_inodes()

---
 btrfs-convert.c | 1 +
 1 file changed, 1 insertion(+)
btrfs-convert.c +1 -0
index 934f4dc..e7f3c9e 100644
@@ -1186,6 +1186,7 @@ static int copy_inodes(struct btrfs_root *root, ext2_filsys ext2_fs,
 	}
 	ret = btrfs_commit_transaction(trans, root);
 	BUG_ON(ret);
+	ext2fs_close_inode_scan(ext2_scan);
 
 	return ret;
 }
Signature · 1 line
1.8.5.1
Applied
#4 lore raw
In reply to Zhao Lei
Quoted 8 lines · Zhao Lei

sequence, transid and reserved field of inode was write to disk with uninitizlized value, this patchset fixed it, also fixed some other typo.

Zhao Lei (3):
btrfs-progs: fix set_get typo of btrfs_inode_item->sequence
btrfs-progs: Avoid uninitialized data in output of btrfs-convert
btrfs-progs: add ext2fs_close_inode_scan to copy_inodes

Applied, thanks.