All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
       [not found] <cover.1528339598.git.misono.tomohiro@jp.fujitsu.com>
@ 2018-06-07  2:49 ` Misono Tomohiro
  2018-06-07 12:22   ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Misono Tomohiro @ 2018-06-07  2:49 UTC (permalink / raw)
  To: linux-btrfs

Initialize all filed of btrfs_inode_item to zero in order to prevent
having some garbage, especially for flags field.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
---
 check/mode-common.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/check/mode-common.c b/check/mode-common.c
index db9e4299..15e2bbd1 100644
--- a/check/mode-common.c
+++ b/check/mode-common.c
@@ -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);
-- 
2.14.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
  2018-06-07  2:49 ` [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item() Misono Tomohiro
@ 2018-06-07 12:22   ` David Sterba
  2018-06-08  0:43     ` Misono Tomohiro
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2018-06-07 12:22 UTC (permalink / raw)
  To: Misono Tomohiro; +Cc: linux-btrfs

On Thu, Jun 07, 2018 at 11:49:58AM +0900, Misono Tomohiro wrote:
> Initialize all filed of btrfs_inode_item to zero in order to prevent
> having some garbage, especially for flags field.

Have you observed in practice or is it a matter of precaution?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
  2018-06-07 12:22   ` David Sterba
@ 2018-06-08  0:43     ` Misono Tomohiro
  2018-06-08  9:04       ` Su Yue
  0 siblings, 1 reply; 4+ messages in thread
From: Misono Tomohiro @ 2018-06-08  0:43 UTC (permalink / raw)
  To: dsterba, linux-btrfs

On 2018/06/07 21:22, David Sterba wrote:
> On Thu, Jun 07, 2018 at 11:49:58AM +0900, Misono Tomohiro wrote:
>> Initialize all filed of btrfs_inode_item to 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/linux-btrfs@vger.kernel.org/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.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item()
  2018-06-08  0:43     ` Misono Tomohiro
@ 2018-06-08  9:04       ` Su Yue
  0 siblings, 0 replies; 4+ messages in thread
From: Su Yue @ 2018-06-08  9:04 UTC (permalink / raw)
  To: Misono Tomohiro, dsterba, linux-btrfs



On 06/08/2018 08:43 AM, Misono Tomohiro wrote:
> On 2018/06/07 21:22, David Sterba wrote:
>> On Thu, Jun 07, 2018 at 11:49:58AM +0900, Misono Tomohiro wrote:
>>> Initialize all filed of btrfs_inode_item to 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/linux-btrfs@vger.kernel.org/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.

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-06-08  8:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <cover.1528339598.git.misono.tomohiro@jp.fujitsu.com>
2018-06-07  2:49 ` [PATCH] btrfs-progs: check: Initialize all filed of btrfs_inode_item in insert_inode_item() Misono Tomohiro
2018-06-07 12:22   ` David Sterba
2018-06-08  0:43     ` Misono Tomohiro
2018-06-08  9:04       ` Su Yue

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.