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: constify struct ocfs2_lock_res_ops

"struct ocfs2_lock_res_ops" are not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increase overall security.

In order to do it, "struct ocfs2_lock_res" also needs to be adjusted to
this new const qualifier.

On a x86_64, with allmodconfig:
Before:
======
text data bss dec hex filename
83038 2632 400 86070 15036 fs/ocfs2/dlmglue.o

After:
=====
text data bss dec hex filename
83806 1992 272 86070 15036 fs/ocfs2/dlmglue.o

Link: https://lkml.kernel.org/r/43d3e2ae3a97d3cbe93d6ba6ce48ae5ec04d7526.1718382288.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.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
3ebe69c0 c8dab79f

+15 -15
+14 -14
fs/ocfs2/dlmglue.c
··· 221 221 */ 222 222 #define LOCK_TYPE_USES_LVB 0x2 223 223 224 - static struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { 224 + static const struct ocfs2_lock_res_ops ocfs2_inode_rw_lops = { 225 225 .get_osb = ocfs2_get_inode_osb, 226 226 .flags = 0, 227 227 }; 228 228 229 - static struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = { 229 + static const struct ocfs2_lock_res_ops ocfs2_inode_inode_lops = { 230 230 .get_osb = ocfs2_get_inode_osb, 231 231 .check_downconvert = ocfs2_check_meta_downconvert, 232 232 .set_lvb = ocfs2_set_meta_lvb, ··· 234 234 .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, 235 235 }; 236 236 237 - static struct ocfs2_lock_res_ops ocfs2_super_lops = { 237 + static const struct ocfs2_lock_res_ops ocfs2_super_lops = { 238 238 .flags = LOCK_TYPE_REQUIRES_REFRESH, 239 239 }; 240 240 241 - static struct ocfs2_lock_res_ops ocfs2_rename_lops = { 241 + static const struct ocfs2_lock_res_ops ocfs2_rename_lops = { 242 242 .flags = 0, 243 243 }; 244 244 245 - static struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = { 245 + static const struct ocfs2_lock_res_ops ocfs2_nfs_sync_lops = { 246 246 .flags = 0, 247 247 }; 248 248 249 - static struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = { 249 + static const struct ocfs2_lock_res_ops ocfs2_trim_fs_lops = { 250 250 .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, 251 251 }; 252 252 253 - static struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = { 253 + static const struct ocfs2_lock_res_ops ocfs2_orphan_scan_lops = { 254 254 .flags = LOCK_TYPE_REQUIRES_REFRESH|LOCK_TYPE_USES_LVB, 255 255 }; 256 256 257 - static struct ocfs2_lock_res_ops ocfs2_dentry_lops = { 257 + static const struct ocfs2_lock_res_ops ocfs2_dentry_lops = { 258 258 .get_osb = ocfs2_get_dentry_osb, 259 259 .post_unlock = ocfs2_dentry_post_unlock, 260 260 .downconvert_worker = ocfs2_dentry_convert_worker, 261 261 .flags = 0, 262 262 }; 263 263 264 - static struct ocfs2_lock_res_ops ocfs2_inode_open_lops = { 264 + static const struct ocfs2_lock_res_ops ocfs2_inode_open_lops = { 265 265 .get_osb = ocfs2_get_inode_osb, 266 266 .flags = 0, 267 267 }; 268 268 269 - static struct ocfs2_lock_res_ops ocfs2_flock_lops = { 269 + static const struct ocfs2_lock_res_ops ocfs2_flock_lops = { 270 270 .get_osb = ocfs2_get_file_osb, 271 271 .flags = 0, 272 272 }; 273 273 274 - static struct ocfs2_lock_res_ops ocfs2_qinfo_lops = { 274 + static const struct ocfs2_lock_res_ops ocfs2_qinfo_lops = { 275 275 .set_lvb = ocfs2_set_qinfo_lvb, 276 276 .get_osb = ocfs2_get_qinfo_osb, 277 277 .flags = LOCK_TYPE_REQUIRES_REFRESH | LOCK_TYPE_USES_LVB, 278 278 }; 279 279 280 - static struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = { 280 + static const struct ocfs2_lock_res_ops ocfs2_refcount_block_lops = { 281 281 .check_downconvert = ocfs2_check_refcount_downconvert, 282 282 .downconvert_worker = ocfs2_refcount_convert_worker, 283 283 .flags = 0, ··· 510 510 static void ocfs2_lock_res_init_common(struct ocfs2_super *osb, 511 511 struct ocfs2_lock_res *res, 512 512 enum ocfs2_lock_type type, 513 - struct ocfs2_lock_res_ops *ops, 513 + const struct ocfs2_lock_res_ops *ops, 514 514 void *priv) 515 515 { 516 516 res->l_type = type; ··· 553 553 unsigned int generation, 554 554 struct inode *inode) 555 555 { 556 - struct ocfs2_lock_res_ops *ops; 556 + const struct ocfs2_lock_res_ops *ops; 557 557 558 558 switch(type) { 559 559 case OCFS2_LOCK_TYPE_RW:
+1 -1
fs/ocfs2/ocfs2.h
··· 154 154 155 155 struct ocfs2_lock_res { 156 156 void *l_priv; 157 - struct ocfs2_lock_res_ops *l_ops; 157 + const struct ocfs2_lock_res_ops *l_ops; 158 158 159 159 160 160 struct list_head l_blocked_list;