Skip to content

Commit

Permalink
[PATCH] mark struct inode_operations const 2
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
fenrus75 authored and Linus Torvalds committed Feb 12, 2007
1 parent 754661f commit 92e1d5b
Show file tree
Hide file tree
Showing 54 changed files with 105 additions and 105 deletions.
8 changes: 4 additions & 4 deletions fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ static int gfs2_removexattr(struct dentry *dentry, const char *name)
return gfs2_ea_remove(GFS2_I(dentry->d_inode), &er);
}

struct inode_operations gfs2_file_iops = {
const struct inode_operations gfs2_file_iops = {
.permission = gfs2_permission,
.setattr = gfs2_setattr,
.getattr = gfs2_getattr,
Expand All @@ -1125,7 +1125,7 @@ struct inode_operations gfs2_file_iops = {
.removexattr = gfs2_removexattr,
};

struct inode_operations gfs2_dev_iops = {
const struct inode_operations gfs2_dev_iops = {
.permission = gfs2_permission,
.setattr = gfs2_setattr,
.getattr = gfs2_getattr,
Expand All @@ -1135,7 +1135,7 @@ struct inode_operations gfs2_dev_iops = {
.removexattr = gfs2_removexattr,
};

struct inode_operations gfs2_dir_iops = {
const struct inode_operations gfs2_dir_iops = {
.create = gfs2_create,
.lookup = gfs2_lookup,
.link = gfs2_link,
Expand All @@ -1154,7 +1154,7 @@ struct inode_operations gfs2_dir_iops = {
.removexattr = gfs2_removexattr,
};

struct inode_operations gfs2_symlink_iops = {
const struct inode_operations gfs2_symlink_iops = {
.readlink = gfs2_readlink,
.follow_link = gfs2_follow_link,
.permission = gfs2_permission,
Expand Down
8 changes: 4 additions & 4 deletions fs/gfs2/ops_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

#include <linux/fs.h>

extern struct inode_operations gfs2_file_iops;
extern struct inode_operations gfs2_dir_iops;
extern struct inode_operations gfs2_symlink_iops;
extern struct inode_operations gfs2_dev_iops;
extern const struct inode_operations gfs2_file_iops;
extern const struct inode_operations gfs2_dir_iops;
extern const struct inode_operations gfs2_symlink_iops;
extern const struct inode_operations gfs2_dev_iops;

#endif /* __OPS_INODE_DOT_H__ */
2 changes: 1 addition & 1 deletion fs/hfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const struct file_operations hfs_dir_operations = {
.release = hfs_dir_release,
};

struct inode_operations hfs_dir_inode_operations = {
const struct inode_operations hfs_dir_inode_operations = {
.create = hfs_create,
.lookup = hfs_lookup,
.unlink = hfs_unlink,
Expand Down
2 changes: 1 addition & 1 deletion fs/hfs/hfs_fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ extern void hfs_cat_build_key(struct super_block *, btree_key *, u32, struct qst

/* dir.c */
extern const struct file_operations hfs_dir_operations;
extern struct inode_operations hfs_dir_inode_operations;
extern const struct inode_operations hfs_dir_inode_operations;

/* extent.c */
extern int hfs_ext_keycmp(const btree_key *, const btree_key *);
Expand Down
4 changes: 2 additions & 2 deletions fs/hfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "btree.h"

static const struct file_operations hfs_file_operations;
static struct inode_operations hfs_file_inode_operations;
static const struct inode_operations hfs_file_inode_operations;

/*================ Variable-like macros ================*/

Expand Down Expand Up @@ -612,7 +612,7 @@ static const struct file_operations hfs_file_operations = {
.release = hfs_file_release,
};

static struct inode_operations hfs_file_inode_operations = {
static const struct inode_operations hfs_file_inode_operations = {
.lookup = hfs_file_lookup,
.truncate = hfs_file_truncate,
.setattr = hfs_inode_setattr,
Expand Down
2 changes: 1 addition & 1 deletion fs/hfsplus/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry,
return res;
}

struct inode_operations hfsplus_dir_inode_operations = {
const struct inode_operations hfsplus_dir_inode_operations = {
.lookup = hfsplus_lookup,
.create = hfsplus_create,
.link = hfsplus_link,
Expand Down
4 changes: 2 additions & 2 deletions fs/hfsplus/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
return 0;
}

extern struct inode_operations hfsplus_dir_inode_operations;
extern const struct inode_operations hfsplus_dir_inode_operations;
extern struct file_operations hfsplus_dir_operations;

static struct inode_operations hfsplus_file_inode_operations = {
static const struct inode_operations hfsplus_file_inode_operations = {
.lookup = hfsplus_file_lookup,
.truncate = hfsplus_file_truncate,
.permission = hfsplus_permission,
Expand Down
8 changes: 4 additions & 4 deletions fs/hostfs/hostfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ static int append = 0;

#define HOSTFS_SUPER_MAGIC 0x00c0ffee

static struct inode_operations hostfs_iops;
static struct inode_operations hostfs_dir_iops;
static const struct inode_operations hostfs_iops;
static const struct inode_operations hostfs_dir_iops;
static const struct address_space_operations hostfs_link_aops;

#ifndef MODULE
Expand Down Expand Up @@ -880,7 +880,7 @@ int hostfs_getattr(struct vfsmount *mnt, struct dentry *dentry,
return(0);
}

static struct inode_operations hostfs_iops = {
static const struct inode_operations hostfs_iops = {
.create = hostfs_create,
.link = hostfs_link,
.unlink = hostfs_unlink,
Expand All @@ -894,7 +894,7 @@ static struct inode_operations hostfs_iops = {
.getattr = hostfs_getattr,
};

static struct inode_operations hostfs_dir_iops = {
static const struct inode_operations hostfs_dir_iops = {
.create = hostfs_create,
.lookup = hostfs_lookup,
.link = hostfs_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const struct file_operations hpfs_file_ops =
.sendfile = generic_file_sendfile,
};

struct inode_operations hpfs_file_iops =
const struct inode_operations hpfs_file_iops =
{
.truncate = hpfs_truncate,
.setattr = hpfs_notify_change,
Expand Down
4 changes: 2 additions & 2 deletions fs/hpfs/hpfs_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ void hpfs_set_ea(struct inode *, struct fnode *, char *, char *, int);

int hpfs_file_fsync(struct file *, struct dentry *, int);
extern const struct file_operations hpfs_file_ops;
extern struct inode_operations hpfs_file_iops;
extern const struct inode_operations hpfs_file_iops;
extern const struct address_space_operations hpfs_aops;

/* inode.c */
Expand Down Expand Up @@ -302,7 +302,7 @@ void hpfs_decide_conv(struct inode *, unsigned char *, unsigned);

/* namei.c */

extern struct inode_operations hpfs_dir_iops;
extern const struct inode_operations hpfs_dir_iops;
extern const struct address_space_operations hpfs_symlink_aops;

static inline struct hpfs_inode_info *hpfs_i(struct inode *inode)
Expand Down
2 changes: 1 addition & 1 deletion fs/hpfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry,
return err;
}

struct inode_operations hpfs_dir_iops =
const struct inode_operations hpfs_dir_iops =
{
.create = hpfs_create,
.lookup = hpfs_lookup,
Expand Down
6 changes: 3 additions & 3 deletions fs/hppfs/hppfs_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static struct dentry *hppfs_lookup(struct inode *ino, struct dentry *dentry,
return(ERR_PTR(err));
}

static struct inode_operations hppfs_file_iops = {
static const struct inode_operations hppfs_file_iops = {
};

static ssize_t read_proc(struct file *file, char __user *buf, ssize_t count,
Expand Down Expand Up @@ -693,11 +693,11 @@ static void* hppfs_follow_link(struct dentry *dentry, struct nameidata *nd)
return ret;
}

static struct inode_operations hppfs_dir_iops = {
static const struct inode_operations hppfs_dir_iops = {
.lookup = hppfs_lookup,
};

static struct inode_operations hppfs_link_iops = {
static const struct inode_operations hppfs_link_iops = {
.readlink = hppfs_readlink,
.follow_link = hppfs_follow_link,
};
Expand Down
8 changes: 4 additions & 4 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
static struct super_operations hugetlbfs_ops;
static const struct address_space_operations hugetlbfs_aops;
const struct file_operations hugetlbfs_file_operations;
static struct inode_operations hugetlbfs_dir_inode_operations;
static struct inode_operations hugetlbfs_inode_operations;
static const struct inode_operations hugetlbfs_dir_inode_operations;
static const struct inode_operations hugetlbfs_inode_operations;

static struct backing_dev_info hugetlbfs_backing_dev_info = {
.ra_pages = 0, /* No readahead */
Expand Down Expand Up @@ -563,7 +563,7 @@ const struct file_operations hugetlbfs_file_operations = {
.get_unmapped_area = hugetlb_get_unmapped_area,
};

static struct inode_operations hugetlbfs_dir_inode_operations = {
static const struct inode_operations hugetlbfs_dir_inode_operations = {
.create = hugetlbfs_create,
.lookup = simple_lookup,
.link = simple_link,
Expand All @@ -576,7 +576,7 @@ static struct inode_operations hugetlbfs_dir_inode_operations = {
.setattr = hugetlbfs_setattr,
};

static struct inode_operations hugetlbfs_inode_operations = {
static const struct inode_operations hugetlbfs_inode_operations = {
.setattr = hugetlbfs_setattr,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/isofs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const struct file_operations isofs_dir_operations =
/*
* directories can handle most operations...
*/
struct inode_operations isofs_dir_inode_operations =
const struct inode_operations isofs_dir_inode_operations =
{
.lookup = isofs_lookup,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/isofs/isofs.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ isofs_normalize_block_and_offset(struct iso_directory_record* de,
}
}

extern struct inode_operations isofs_dir_inode_operations;
extern const struct inode_operations isofs_dir_inode_operations;
extern const struct file_operations isofs_dir_operations;
extern const struct address_space_operations isofs_symlink_aops;
extern struct export_operations isofs_export_ops;
8 changes: 4 additions & 4 deletions fs/jffs/inode-v23.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ static int jffs_remove(struct inode *dir, struct dentry *dentry, int type);

static struct super_operations jffs_ops;
static const struct file_operations jffs_file_operations;
static struct inode_operations jffs_file_inode_operations;
static const struct inode_operations jffs_file_inode_operations;
static const struct file_operations jffs_dir_operations;
static struct inode_operations jffs_dir_inode_operations;
static const struct inode_operations jffs_dir_inode_operations;
static const struct address_space_operations jffs_address_operations;

struct kmem_cache *node_cache = NULL;
Expand Down Expand Up @@ -1642,7 +1642,7 @@ static const struct file_operations jffs_file_operations =
};


static struct inode_operations jffs_file_inode_operations =
static const struct inode_operations jffs_file_inode_operations =
{
.lookup = jffs_lookup, /* lookup */
.setattr = jffs_setattr,
Expand All @@ -1655,7 +1655,7 @@ static const struct file_operations jffs_dir_operations =
};


static struct inode_operations jffs_dir_inode_operations =
static const struct inode_operations jffs_dir_inode_operations =
{
.create = jffs_create,
.lookup = jffs_lookup,
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const struct file_operations jffs2_dir_operations =
};


struct inode_operations jffs2_dir_inode_operations =
const struct inode_operations jffs2_dir_inode_operations =
{
.create = jffs2_create,
.lookup = jffs2_lookup,
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const struct file_operations jffs2_file_operations =

/* jffs2_file_inode_operations */

struct inode_operations jffs2_file_inode_operations =
const struct inode_operations jffs2_file_inode_operations =
{
.permission = jffs2_permission,
.setattr = jffs2_setattr,
Expand Down
6 changes: 3 additions & 3 deletions fs/jffs2/os-linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c);

/* dir.c */
extern const struct file_operations jffs2_dir_operations;
extern struct inode_operations jffs2_dir_inode_operations;
extern const struct inode_operations jffs2_dir_inode_operations;

/* file.c */
extern const struct file_operations jffs2_file_operations;
extern struct inode_operations jffs2_file_inode_operations;
extern const struct inode_operations jffs2_file_inode_operations;
extern const struct address_space_operations jffs2_file_address_operations;
int jffs2_fsync(struct file *, struct dentry *, int);
int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg);
Expand All @@ -166,7 +166,7 @@ int jffs2_do_readpage_unlock (struct inode *inode, struct page *pg);
int jffs2_ioctl(struct inode *, struct file *, unsigned int, unsigned long);

/* symlink.c */
extern struct inode_operations jffs2_symlink_inode_operations;
extern const struct inode_operations jffs2_symlink_inode_operations;

/* fs.c */
int jffs2_setattr (struct dentry *, struct iattr *);
Expand Down
2 changes: 1 addition & 1 deletion fs/jffs2/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

static void *jffs2_follow_link(struct dentry *dentry, struct nameidata *nd);

struct inode_operations jffs2_symlink_inode_operations =
const struct inode_operations jffs2_symlink_inode_operations =
{
.readlink = generic_readlink,
.follow_link = jffs2_follow_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int jfs_release(struct inode *inode, struct file *file)
return 0;
}

struct inode_operations jfs_file_inode_operations = {
const struct inode_operations jfs_file_inode_operations = {
.truncate = jfs_truncate,
.setxattr = jfs_setxattr,
.getxattr = jfs_getxattr,
Expand Down
6 changes: 3 additions & 3 deletions fs/jfs/jfs_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ extern void jfs_set_inode_flags(struct inode *);
extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);

extern const struct address_space_operations jfs_aops;
extern struct inode_operations jfs_dir_inode_operations;
extern const struct inode_operations jfs_dir_inode_operations;
extern const struct file_operations jfs_dir_operations;
extern struct inode_operations jfs_file_inode_operations;
extern const struct inode_operations jfs_file_inode_operations;
extern const struct file_operations jfs_file_operations;
extern struct inode_operations jfs_symlink_inode_operations;
extern const struct inode_operations jfs_symlink_inode_operations;
extern struct dentry_operations jfs_ci_dentry_operations;
#endif /* _H_JFS_INODE */
2 changes: 1 addition & 1 deletion fs/jfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ struct dentry *jfs_get_parent(struct dentry *dentry)
return parent;
}

struct inode_operations jfs_dir_inode_operations = {
const struct inode_operations jfs_dir_inode_operations = {
.create = jfs_create,
.lookup = jfs_lookup,
.link = jfs_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/jfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static void *jfs_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

struct inode_operations jfs_symlink_inode_operations = {
const struct inode_operations jfs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = jfs_follow_link,
.setxattr = jfs_setxattr,
Expand Down
2 changes: 1 addition & 1 deletion fs/libfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const struct file_operations simple_dir_operations = {
.fsync = simple_sync_file,
};

struct inode_operations simple_dir_inode_operations = {
const struct inode_operations simple_dir_inode_operations = {
.lookup = simple_lookup,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/minix/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const struct file_operations minix_file_operations = {
.sendfile = generic_file_sendfile,
};

struct inode_operations minix_file_inode_operations = {
const struct inode_operations minix_file_inode_operations = {
.truncate = minix_truncate,
.getattr = minix_getattr,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static const struct address_space_operations minix_aops = {
.bmap = minix_bmap
};

static struct inode_operations minix_symlink_inode_operations = {
static const struct inode_operations minix_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
Expand Down
Loading

0 comments on commit 92e1d5b

Please sign in to comment.