Skip to content

Commit 92e1d5b

Browse files
fenrus75Linus Torvalds
authored andcommitted
[PATCH] mark struct inode_operations const 2
Many struct inode_operations in the kernel can be "const". Marking them const moves these to the .rodata section, which avoids false sharing with potential dirty data. In addition it'll catch accidental writes at compile time to these shared resources. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 754661f commit 92e1d5b

54 files changed

Lines changed: 105 additions & 105 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎fs/gfs2/ops_inode.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
11151115
return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er);
11161116
}
11171117

1118-
struct inode_operations gfs2_file_iops = {
1118+
const struct inode_operations gfs2_file_iops = {
11191119
.permission = gfs2_permission,
11201120
.setattr = gfs2_setattr,
11211121
.getattr = gfs2_getattr,
@@ -1125,7 +1125,7 @@ struct inode_operations gfs2_file_iops = {
11251125
.removexattr = gfs2_removexattr,
11261126
};
11271127

1128-
struct inode_operations gfs2_dev_iops = {
1128+
const struct inode_operations gfs2_dev_iops = {
11291129
.permission = gfs2_permission,
11301130
.setattr = gfs2_setattr,
11311131
.getattr = gfs2_getattr,
@@ -1135,7 +1135,7 @@ struct inode_operations gfs2_dev_iops = {
11351135
.removexattr = gfs2_removexattr,
11361136
};
11371137

1138-
struct inode_operations gfs2_dir_iops = {
1138+
const struct inode_operations gfs2_dir_iops = {
11391139
.create = gfs2_create,
11401140
.lookup = gfs2_lookup,
11411141
.link = gfs2_link,
@@ -1154,7 +1154,7 @@ struct inode_operations gfs2_dir_iops = {
11541154
.removexattr = gfs2_removexattr,
11551155
};
11561156

1157-
struct inode_operations gfs2_symlink_iops = {
1157+
const struct inode_operations gfs2_symlink_iops = {
11581158
.readlink = gfs2_readlink,
11591159
.follow_link = gfs2_follow_link,
11601160
.permission = gfs2_permission,

‎fs/gfs2/ops_inode.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
#include <linux/fs.h>
1414

15-
extern struct inode_operations gfs2_file_iops;
16-
extern struct inode_operations gfs2_dir_iops;
17-
extern struct inode_operations gfs2_symlink_iops;
18-
extern struct inode_operations gfs2_dev_iops;
15+
extern const struct inode_operations gfs2_file_iops;
16+
extern const struct inode_operations gfs2_dir_iops;
17+
extern const struct inode_operations gfs2_symlink_iops;
18+
extern const struct inode_operations gfs2_dev_iops;
1919

2020
#endif /* __OPS_INODE_DOT_H__ */

‎fs/hfs/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ const struct file_operations hfs_dir_operations = {
320320
.release = hfs_dir_release,
321321
};
322322

323-
struct inode_operations hfs_dir_inode_operations = {
323+
const struct inode_operations hfs_dir_inode_operations = {
324324
.create = hfs_create,
325325
.lookup = hfs_lookup,
326326
.unlink = hfs_unlink,

‎fs/hfs/hfs_fs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qst
170170

171171
/* dir.c */
172172
extern const struct file_operations hfs_dir_operations;
173-
extern struct inode_operations hfs_dir_inode_operations;
173+
extern const struct inode_operations hfs_dir_inode_operations;
174174

175175
/* extent.c */
176176
extern int hfs_ext_keycmp(const btree_key *, const btree_key *);

‎fs/hfs/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "btree.h"
1919

2020
static const struct file_operations hfs_file_operations;
21-
static struct inode_operations hfs_file_inode_operations;
21+
static const struct inode_operations hfs_file_inode_operations;
2222

2323
/*================ Variable-like macros ================*/
2424

@@ -612,7 +612,7 @@ static const struct file_operations hfs_file_operations = {
612612
.release = hfs_file_release,
613613
};
614614

615-
static struct inode_operations hfs_file_inode_operations = {
615+
static const struct inode_operations hfs_file_inode_operations = {
616616
.lookup = hfs_file_lookup,
617617
.truncate = hfs_file_truncate,
618618
.setattr = hfs_inode_setattr,

‎fs/hfsplus/dir.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
471471
return res;
472472
}
473473

474-
struct inode_operations hfsplus_dir_inode_operations = {
474+
const struct inode_operations hfsplus_dir_inode_operations = {
475475
.lookup = hfsplus_lookup,
476476
.create = hfsplus_create,
477477
.link = hfsplus_link,

‎fs/hfsplus/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,10 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
268268
return 0;
269269
}
270270

271-
extern struct inode_operations hfsplus_dir_inode_operations;
271+
extern const struct inode_operations hfsplus_dir_inode_operations;
272272
extern struct file_operations hfsplus_dir_operations;
273273

274-
static struct inode_operations hfsplus_file_inode_operations = {
274+
static const struct inode_operations hfsplus_file_inode_operations = {
275275
.lookup = hfsplus_file_lookup,
276276
.truncate = hfsplus_file_truncate,
277277
.permission = hfsplus_permission,

‎fs/hostfs/hostfs_kern.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ static int append = 0;
5252

5353
#define HOSTFS_SUPER_MAGIC 0x00c0ffee
5454

55-
static struct inode_operations hostfs_iops;
56-
static struct inode_operations hostfs_dir_iops;
55+
static const struct inode_operations hostfs_iops;
56+
static const struct inode_operations hostfs_dir_iops;
5757
static const struct address_space_operations hostfs_link_aops;
5858

5959
#ifndef MODULE
@@ -880,7 +880,7 @@ int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
880880
return(0);
881881
}
882882

883-
static struct inode_operations hostfs_iops = {
883+
static const struct inode_operations hostfs_iops = {
884884
.create = hostfs_create,
885885
.link = hostfs_link,
886886
.unlink = hostfs_unlink,
@@ -894,7 +894,7 @@ static struct inode_operations hostfs_iops = {
894894
.getattr = hostfs_getattr,
895895
};
896896

897-
static struct inode_operations hostfs_dir_iops = {
897+
static const struct inode_operations hostfs_dir_iops = {
898898
.create = hostfs_create,
899899
.lookup = hostfs_lookup,
900900
.link = hostfs_link,

‎fs/hpfs/file.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const struct file_operations hpfs_file_ops =
132132
.sendfile = generic_file_sendfile,
133133
};
134134

135-
struct inode_operations hpfs_file_iops =
135+
const struct inode_operations hpfs_file_iops =
136136
{
137137
.truncate = hpfs_truncate,
138138
.setattr = hpfs_notify_change,

‎fs/hpfs/hpfs_fn.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ void hpfs_set_ea(struct inode *, struct fnode *, char *, char *, int);
266266

267267
int hpfs_file_fsync(struct file *, struct dentry *, int);
268268
extern const struct file_operations hpfs_file_ops;
269-
extern struct inode_operations hpfs_file_iops;
269+
extern const struct inode_operations hpfs_file_iops;
270270
extern const struct address_space_operations hpfs_aops;
271271

272272
/* inode.c */
@@ -302,7 +302,7 @@ void hpfs_decide_conv(struct inode *, unsigned char *, unsigned);
302302

303303
/* namei.c */
304304

305-
extern struct inode_operations hpfs_dir_iops;
305+
extern const struct inode_operations hpfs_dir_iops;
306306
extern const struct address_space_operations hpfs_symlink_aops;
307307

308308
static inline struct hpfs_inode_info *hpfs_i(struct inode *inode)

0 commit comments

Comments
 (0)