All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: fix atgc bug on issue in 32bits platform
@ 2022-11-04  7:40 ` zhiguo.niu
  0 siblings, 0 replies; 6+ messages in thread
From: zhiguo.niu @ 2022-11-04  7:40 UTC (permalink / raw)
  To: jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: niuzhiguo84, zhiguo.niu

From: Zhiguo Niu <zhiguo.niu@unisoc.com>

There is bug on issue after atgc feature is enabled in
32bits platform as the following log:

F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
------------[ cut here ]------------
kernel BUG at fs/f2fs/gc.c:602!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
PC is at get_victim_by_default+0x13c0/0x1498
LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
....
[<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
[<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
[<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
[<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)

The reason is the 64bits key in struct rb_entry has __packed attibute
but has not in struct victim_entry, so the wrong key value got by
in f2fs_check_rb_tree_consistence, the following are the memory layouts
of struct rb_entry and struct victim_entry in 32bits platform:

struct rb_entry {
   [0] struct rb_node rb_node;
       union {
           struct {...};
  [12]     unsigned long long key;
       };
}
struct victim_entry {
   [0] struct rb_node rb_node;
       union {
           struct {...};
  [16]     struct victim_info vi;
       };
  [32] struct list_head list;
}

This patch fix this inconsistence layout of 64bits key between
struct rb_entry and struct victim_entry.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
 fs/f2fs/gc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index 19b956c2d697..9a03c6502b39 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -68,7 +68,7 @@ struct victim_entry {
 			unsigned int segno;		/* segment No. */
 		};
 		struct victim_info vi;	/* victim info */
-	};
+	} __packed;
 	struct list_head list;
 };
 
-- 
2.17.1


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

* [f2fs-dev] [PATCH] f2fs: fix atgc bug on issue in 32bits platform
@ 2022-11-04  7:40 ` zhiguo.niu
  0 siblings, 0 replies; 6+ messages in thread
From: zhiguo.niu @ 2022-11-04  7:40 UTC (permalink / raw)
  To: jaegeuk, chao, linux-f2fs-devel, linux-kernel; +Cc: zhiguo.niu, niuzhiguo84

From: Zhiguo Niu <zhiguo.niu@unisoc.com>

There is bug on issue after atgc feature is enabled in
32bits platform as the following log:

F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
------------[ cut here ]------------
kernel BUG at fs/f2fs/gc.c:602!
Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
PC is at get_victim_by_default+0x13c0/0x1498
LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
....
[<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
[<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
[<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
[<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)

The reason is the 64bits key in struct rb_entry has __packed attibute
but has not in struct victim_entry, so the wrong key value got by
in f2fs_check_rb_tree_consistence, the following are the memory layouts
of struct rb_entry and struct victim_entry in 32bits platform:

struct rb_entry {
   [0] struct rb_node rb_node;
       union {
           struct {...};
  [12]     unsigned long long key;
       };
}
struct victim_entry {
   [0] struct rb_node rb_node;
       union {
           struct {...};
  [16]     struct victim_info vi;
       };
  [32] struct list_head list;
}

This patch fix this inconsistence layout of 64bits key between
struct rb_entry and struct victim_entry.

Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>
---
 fs/f2fs/gc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h
index 19b956c2d697..9a03c6502b39 100644
--- a/fs/f2fs/gc.h
+++ b/fs/f2fs/gc.h
@@ -68,7 +68,7 @@ struct victim_entry {
 			unsigned int segno;		/* segment No. */
 		};
 		struct victim_info vi;	/* victim info */
-	};
+	} __packed;
 	struct list_head list;
 };
 
-- 
2.17.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: fix atgc bug on issue in 32bits platform
  2022-11-04  7:40 ` [f2fs-dev] " zhiguo.niu
@ 2022-11-07  1:25   ` Chao Yu
  -1 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-11-07  1:25 UTC (permalink / raw)
  To: zhiguo.niu, jaegeuk, linux-f2fs-devel, linux-kernel; +Cc: niuzhiguo84

On 2022/11/4 15:40, zhiguo.niu wrote:
> From: Zhiguo Niu <zhiguo.niu@unisoc.com>
> 
> There is bug on issue after atgc feature is enabled in
> 32bits platform as the following log:
> 
> F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
> ------------[ cut here ]------------
> kernel BUG at fs/f2fs/gc.c:602!
> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
> PC is at get_victim_by_default+0x13c0/0x1498
> LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
> ....
> [<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
> [<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
> [<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
> [<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
> 
> The reason is the 64bits key in struct rb_entry has __packed attibute
> but has not in struct victim_entry, so the wrong key value got by
> in f2fs_check_rb_tree_consistence, the following are the memory layouts
> of struct rb_entry and struct victim_entry in 32bits platform:
> 
> struct rb_entry {
>     [0] struct rb_node rb_node;
>         union {
>             struct {...};
>    [12]     unsigned long long key;
>         };
> }
> struct victim_entry {
>     [0] struct rb_node rb_node;
>         union {
>             struct {...};
>    [16]     struct victim_info vi;
>         };
>    [32] struct list_head list;
> }

Shouldn't we add __packed for struct victim_entry?

> 
> This patch fix this inconsistence layout of 64bits key between
> struct rb_entry and struct victim_entry.
> 

Fixes: 093749e296e2 ("f2fs: support age threshold based garbage collection")

> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>


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

* Re: [f2fs-dev] [PATCH] f2fs: fix atgc bug on issue in 32bits platform
@ 2022-11-07  1:25   ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-11-07  1:25 UTC (permalink / raw)
  To: zhiguo.niu, jaegeuk, linux-f2fs-devel, linux-kernel; +Cc: niuzhiguo84

On 2022/11/4 15:40, zhiguo.niu wrote:
> From: Zhiguo Niu <zhiguo.niu@unisoc.com>
> 
> There is bug on issue after atgc feature is enabled in
> 32bits platform as the following log:
> 
> F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
> ------------[ cut here ]------------
> kernel BUG at fs/f2fs/gc.c:602!
> Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
> PC is at get_victim_by_default+0x13c0/0x1498
> LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
> ....
> [<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
> [<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
> [<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
> [<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
> 
> The reason is the 64bits key in struct rb_entry has __packed attibute
> but has not in struct victim_entry, so the wrong key value got by
> in f2fs_check_rb_tree_consistence, the following are the memory layouts
> of struct rb_entry and struct victim_entry in 32bits platform:
> 
> struct rb_entry {
>     [0] struct rb_node rb_node;
>         union {
>             struct {...};
>    [12]     unsigned long long key;
>         };
> }
> struct victim_entry {
>     [0] struct rb_node rb_node;
>         union {
>             struct {...};
>    [16]     struct victim_info vi;
>         };
>    [32] struct list_head list;
> }

Shouldn't we add __packed for struct victim_entry?

> 
> This patch fix this inconsistence layout of 64bits key between
> struct rb_entry and struct victim_entry.
> 

Fixes: 093749e296e2 ("f2fs: support age threshold based garbage collection")

> Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com>



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: fix atgc bug on issue in 32bits platform
       [not found]   ` <CAHJ8P3KGTJgvde2V-75XNcZHzbQrkFzDN5sY9r75rp8JBGC_PA@mail.gmail.com>
@ 2022-11-07 14:51       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-11-07 14:51 UTC (permalink / raw)
  To: Zhiguo Niu; +Cc: zhiguo.niu, jaegeuk, linux-f2fs-devel, linux-kernel

On 2022/11/7 13:04, Zhiguo Niu wrote:
> Dear Chao
> 
> Chao Yu <chao@kernel.org <mailto:chao@kernel.org>> 于2022年11月7日周一 09:25写道:
> 
>     On 2022/11/4 15:40, zhiguo.niu wrote:
>      > From: Zhiguo Niu <zhiguo.niu@unisoc.com <mailto:zhiguo.niu@unisoc.com>>
>      >
>      > There is bug on issue after atgc feature is enabled in
>      > 32bits platform as the following log:
>      >
>      > F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
>      > ------------[ cut here ]------------
>      > kernel BUG at fs/f2fs/gc.c:602!
>      > Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
>      > PC is at get_victim_by_default+0x13c0/0x1498
>      > LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
>      > ....
>      > [<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
>      > [<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
>      > [<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
>      > [<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
>      >
>      > The reason is the 64bits key in struct rb_entry has __packed attibute
>      > but has not in struct victim_entry, so the wrong key value got by
>      > in f2fs_check_rb_tree_consistence, the following are the memory layouts
>      > of struct rb_entry and struct victim_entry in 32bits platform:
>      >
>      > struct rb_entry {
>      >     [0] struct rb_node rb_node;
>      >         union {
>      >             struct {...};
>      >    [12]     unsigned long long key;
>      >         };
>      > }
>      > struct victim_entry {
>      >     [0] struct rb_node rb_node;
>      >         union {
>      >             struct {...};
>      >    [16]     struct victim_info vi;
>      >         };
>      >    [32] struct list_head list;
>      > }
> 
>     Shouldn't we add __packed for struct victim_entry?
> 
>   I try to keep it consistent with struct rb_entry (__packed is only added to union for 64bits key),
> victim_entry.vi.mtime is used to store the key, and rb_entry.key is used to verify the key,
> so make sure that the memory offsets of the 64 bits key in these two structures are the same.
> Other members of victim_entry, such as list, i think there is no problem because of it storaged and loaded
> are both based on struct victim_entry

I'm not sure, there will be any further update in struct rb_node and
struct list_head later, so, IMO, it will be more safe to add __packed to
align all fields in structure to byte.

Thanks,

> 
>      >
>      > This patch fix this inconsistence layout of 64bits key between
>      > struct rb_entry and struct victim_entry.
>      >
> 
>     Fixes: 093749e296e2 ("f2fs: support age threshold based garbage collection")
> 
>      > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com <mailto:zhiguo.niu@unisoc.com>>
> 

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

* Re: [f2fs-dev] [PATCH] f2fs: fix atgc bug on issue in 32bits platform
@ 2022-11-07 14:51       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2022-11-07 14:51 UTC (permalink / raw)
  To: Zhiguo Niu; +Cc: jaegeuk, zhiguo.niu, linux-kernel, linux-f2fs-devel

On 2022/11/7 13:04, Zhiguo Niu wrote:
> Dear Chao
> 
> Chao Yu <chao@kernel.org <mailto:chao@kernel.org>> 于2022年11月7日周一 09:25写道:
> 
>     On 2022/11/4 15:40, zhiguo.niu wrote:
>      > From: Zhiguo Niu <zhiguo.niu@unisoc.com <mailto:zhiguo.niu@unisoc.com>>
>      >
>      > There is bug on issue after atgc feature is enabled in
>      > 32bits platform as the following log:
>      >
>      > F2FS-fs (dm-x): inconsistent rbtree, cur(3470333575168) next(3320009719808)
>      > ------------[ cut here ]------------
>      > kernel BUG at fs/f2fs/gc.c:602!
>      > Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
>      > PC is at get_victim_by_default+0x13c0/0x1498
>      > LR is at f2fs_check_rb_tree_consistence+0xc4/0xd4
>      > ....
>      > [<c04d98b0>] (get_victim_by_default) from [<c04d4f44>] (f2fs_gc+0x220/0x6cc)
>      > [<c04d4f44>] (f2fs_gc) from [<c04d4780>] (gc_thread_func+0x2ac/0x708)
>      > [<c04d4780>] (gc_thread_func) from [<c015c774>] (kthread+0x1a8/0x1b4)
>      > [<c015c774>] (kthread) from [<c01010b4>] (ret_from_fork+0x14/0x20)
>      >
>      > The reason is the 64bits key in struct rb_entry has __packed attibute
>      > but has not in struct victim_entry, so the wrong key value got by
>      > in f2fs_check_rb_tree_consistence, the following are the memory layouts
>      > of struct rb_entry and struct victim_entry in 32bits platform:
>      >
>      > struct rb_entry {
>      >     [0] struct rb_node rb_node;
>      >         union {
>      >             struct {...};
>      >    [12]     unsigned long long key;
>      >         };
>      > }
>      > struct victim_entry {
>      >     [0] struct rb_node rb_node;
>      >         union {
>      >             struct {...};
>      >    [16]     struct victim_info vi;
>      >         };
>      >    [32] struct list_head list;
>      > }
> 
>     Shouldn't we add __packed for struct victim_entry?
> 
>   I try to keep it consistent with struct rb_entry (__packed is only added to union for 64bits key),
> victim_entry.vi.mtime is used to store the key, and rb_entry.key is used to verify the key,
> so make sure that the memory offsets of the 64 bits key in these two structures are the same.
> Other members of victim_entry, such as list, i think there is no problem because of it storaged and loaded
> are both based on struct victim_entry

I'm not sure, there will be any further update in struct rb_node and
struct list_head later, so, IMO, it will be more safe to add __packed to
align all fields in structure to byte.

Thanks,

> 
>      >
>      > This patch fix this inconsistence layout of 64bits key between
>      > struct rb_entry and struct victim_entry.
>      >
> 
>     Fixes: 093749e296e2 ("f2fs: support age threshold based garbage collection")
> 
>      > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com <mailto:zhiguo.niu@unisoc.com>>
> 


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2022-11-07 14:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04  7:40 [PATCH] f2fs: fix atgc bug on issue in 32bits platform zhiguo.niu
2022-11-04  7:40 ` [f2fs-dev] " zhiguo.niu
2022-11-07  1:25 ` Chao Yu
2022-11-07  1:25   ` [f2fs-dev] " Chao Yu
     [not found]   ` <CAHJ8P3KGTJgvde2V-75XNcZHzbQrkFzDN5sY9r75rp8JBGC_PA@mail.gmail.com>
2022-11-07 14:51     ` Chao Yu
2022-11-07 14:51       ` [f2fs-dev] " Chao Yu

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.