btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/1 btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
Initialize all filed of btrfs_inode_item to zero in order to prevent having some garbage, especially for flags field.
--- check/mode-common.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
check/mode-common.c +1 -5
@@ -379,18 +379,14 @@ int insert_inode_item(struct btrfs_trans_handle *trans,time_t now =time (NULL );int ret; +memset (&ii,0 ,sizeof (ii));btrfs_set_stack_inode_size (&ii, size);btrfs_set_stack_inode_nbytes (&ii, nbytes);btrfs_set_stack_inode_nlink (&ii, nlink);btrfs_set_stack_inode_mode (&ii, mode);btrfs_set_stack_inode_generation (&ii, trans->transid); -btrfs_set_stack_timespec_nsec (&ii.atime,0 );btrfs_set_stack_timespec_sec (&ii.ctime, now); -btrfs_set_stack_timespec_nsec (&ii.ctime,0 );btrfs_set_stack_timespec_sec (&ii.mtime, now); -btrfs_set_stack_timespec_nsec (&ii.mtime,0 ); -btrfs_set_stack_timespec_sec (&ii.otime,0 ); -btrfs_set_stack_timespec_nsec (&ii.otime,0 ); ret =btrfs_insert_inode (trans, root, ino, &ii);ASSERT (!ret);
Signature · 1 line
2.14.4
Quoted 2 lines · Misono Tomohiro
Initialize all filed of
btrfs_inode_itemto zero in order to prevent having some garbage, especially for flags field.
Have you observed in practice or is it a matter of precaution?
Quoted 5 lines · David Sterba
Quoted 2 lines · Misono Tomohiro
Initialize all filed of
btrfs_inode_itemto zero in order to prevent having some garbage, especially for flags field.Have you observed in practice or is it a matter of precaution?
I saw failure of fsck-test/010 in yesterday's devel branch and made this patch. It turned out that root cause was wrong flag comparison in btrfs check.
(https://www.mail-archive.com/[email protected]/msg77758.html)
With Su's fix, failure of fsck-test/010 is also gone without this patch, but it is better to initialize the variables anyway.
Quoted 7 lines · Misono Tomohiro
Quoted 5 lines · David Sterba
Quoted 2 lines · Misono Tomohiro
Initialize all filed of
btrfs_inode_itemto zero in order to prevent having some garbage, especially for flags field.Have you observed in practice or is it a matter of precaution?
Quoted 8 lines
I saw failure of fsck-test/010 in yesterday's devel branch and made this patch. It turned out that root cause was wrong flag comparison in btrfs check.
(https://www.mail-archive.com/[email protected]/msg77758.html)With Su's fix, failure of fsck-test/010 is also gone without this patch, but it is better to initialize the variables anyway.
Agreed. I saw odd flags reported by btrfs check too. The callers of insert_inode_item() don't set inode flags manully.
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html