Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocfs2: use flexible array in 'struct ocfs2_recovery_map'

Turn 'rm_entries' in 'struct ocfs2_recovery_map' into a flexible array.

The advantages are:
- save the size of a pointer when the new undo structure is allocated
- avoid some always ugly pointer arithmetic to get the address of
'rm_entries'
- avoid an indirection when the array is accessed

While at it, use struct_size() to compute the size of the new undo
structure.

Link: https://lkml.kernel.org/r/c645911ffd2720fce5e344c17de642518cd0db52.1689533270.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Gang He <ghe@suse.com>
Cc: Jun Piao <piaojun@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Christophe JAILLET and committed by
Andrew Morton
cb2273a4 2e106e56

+2 -5
+1 -4
fs/ocfs2/journal.c
··· 178 178 osb->recovery_thread_task = NULL; 179 179 init_waitqueue_head(&osb->recovery_event); 180 180 181 - rm = kzalloc(sizeof(struct ocfs2_recovery_map) + 182 - osb->max_slots * sizeof(unsigned int), 181 + rm = kzalloc(struct_size(rm, rm_entries, osb->max_slots), 183 182 GFP_KERNEL); 184 183 if (!rm) { 185 184 mlog_errno(-ENOMEM); 186 185 return -ENOMEM; 187 186 } 188 187 189 - rm->rm_entries = (unsigned int *)((char *)rm + 190 - sizeof(struct ocfs2_recovery_map)); 191 188 osb->recovery_map = rm; 192 189 193 190 return 0;
+1 -1
fs/ocfs2/journal.h
··· 29 29 30 30 struct ocfs2_recovery_map { 31 31 unsigned int rm_used; 32 - unsigned int *rm_entries; 32 + unsigned int rm_entries[]; 33 33 }; 34 34 35 35