Skip to content

Commit

Permalink
[PATCH] mark struct inode_operations const 3
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 <arjan@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
fenrus75 authored and Linus Torvalds committed Feb 12, 2007
1 parent 92e1d5b commit c5ef1c4
Show file tree
Hide file tree
Showing 48 changed files with 103 additions and 103 deletions.
20 changes: 10 additions & 10 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct pid_entry {
int len;
char *name;
mode_t mode;
struct inode_operations *iop;
const struct inode_operations *iop;
const struct file_operations *fop;
union proc_op op;
};
Expand Down Expand Up @@ -352,7 +352,7 @@ static int proc_setattr(struct dentry *dentry, struct iattr *attr)
return error;
}

static struct inode_operations proc_def_inode_operations = {
static const struct inode_operations proc_def_inode_operations = {
.setattr = proc_setattr,
};

Expand Down Expand Up @@ -980,7 +980,7 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
return error;
}

static struct inode_operations proc_pid_link_inode_operations = {
static const struct inode_operations proc_pid_link_inode_operations = {
.readlink = proc_pid_readlink,
.follow_link = proc_pid_follow_link,
.setattr = proc_setattr,
Expand Down Expand Up @@ -1416,7 +1416,7 @@ static const struct file_operations proc_fd_operations = {
/*
* proc directories can do almost nothing..
*/
static struct inode_operations proc_fd_inode_operations = {
static const struct inode_operations proc_fd_inode_operations = {
.lookup = proc_lookupfd,
.setattr = proc_setattr,
};
Expand Down Expand Up @@ -1656,7 +1656,7 @@ static struct dentry *proc_attr_dir_lookup(struct inode *dir,
attr_dir_stuff, ARRAY_SIZE(attr_dir_stuff));
}

static struct inode_operations proc_attr_dir_inode_operations = {
static const struct inode_operations proc_attr_dir_inode_operations = {
.lookup = proc_attr_dir_lookup,
.getattr = pid_getattr,
.setattr = proc_setattr,
Expand All @@ -1682,7 +1682,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
return ERR_PTR(vfs_follow_link(nd,tmp));
}

static struct inode_operations proc_self_inode_operations = {
static const struct inode_operations proc_self_inode_operations = {
.readlink = proc_self_readlink,
.follow_link = proc_self_follow_link,
};
Expand Down Expand Up @@ -1835,7 +1835,7 @@ static int proc_pid_io_accounting(struct task_struct *task, char *buffer)
* Thread groups
*/
static const struct file_operations proc_task_operations;
static struct inode_operations proc_task_inode_operations;
static const struct inode_operations proc_task_inode_operations;

static struct pid_entry tgid_base_stuff[] = {
DIR("task", S_IRUGO|S_IXUGO, task),
Expand Down Expand Up @@ -1904,7 +1904,7 @@ static struct dentry *proc_tgid_base_lookup(struct inode *dir, struct dentry *de
tgid_base_stuff, ARRAY_SIZE(tgid_base_stuff));
}

static struct inode_operations proc_tgid_base_inode_operations = {
static const struct inode_operations proc_tgid_base_inode_operations = {
.lookup = proc_tgid_base_lookup,
.getattr = pid_getattr,
.setattr = proc_setattr,
Expand Down Expand Up @@ -2182,7 +2182,7 @@ static const struct file_operations proc_tid_base_operations = {
.readdir = proc_tid_base_readdir,
};

static struct inode_operations proc_tid_base_inode_operations = {
static const struct inode_operations proc_tid_base_inode_operations = {
.lookup = proc_tid_base_lookup,
.getattr = pid_getattr,
.setattr = proc_setattr,
Expand Down Expand Up @@ -2408,7 +2408,7 @@ static int proc_task_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
return 0;
}

static struct inode_operations proc_task_inode_operations = {
static const struct inode_operations proc_task_inode_operations = {
.lookup = proc_task_lookup,
.getattr = proc_task_getattr,
.setattr = proc_setattr,
Expand Down
6 changes: 3 additions & 3 deletions fs/proc/generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static int proc_getattr(struct vfsmount *mnt, struct dentry *dentry,
return 0;
}

static struct inode_operations proc_file_inode_operations = {
static const struct inode_operations proc_file_inode_operations = {
.setattr = proc_notify_change,
};

Expand Down Expand Up @@ -357,7 +357,7 @@ static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

static struct inode_operations proc_link_inode_operations = {
static const struct inode_operations proc_link_inode_operations = {
.readlink = generic_readlink,
.follow_link = proc_follow_link,
};
Expand Down Expand Up @@ -505,7 +505,7 @@ static const struct file_operations proc_dir_operations = {
/*
* proc directories can do almost nothing..
*/
static struct inode_operations proc_dir_inode_operations = {
static const struct inode_operations proc_dir_inode_operations = {
.lookup = proc_lookup,
.getattr = proc_getattr,
.setattr = proc_notify_change,
Expand Down
2 changes: 1 addition & 1 deletion fs/proc/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ static const struct file_operations proc_root_operations = {
/*
* proc root can do almost nothing..
*/
static struct inode_operations proc_root_inode_operations = {
static const struct inode_operations proc_root_inode_operations = {
.lookup = proc_root_lookup,
.getattr = proc_root_getattr,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/qnx4/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const struct file_operations qnx4_dir_operations =
.fsync = file_fsync,
};

struct inode_operations qnx4_dir_inode_operations =
const struct inode_operations qnx4_dir_inode_operations =
{
.lookup = qnx4_lookup,
#ifdef CONFIG_QNX4FS_RW
Expand Down
2 changes: 1 addition & 1 deletion fs/qnx4/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const struct file_operations qnx4_file_operations =
#endif
};

struct inode_operations qnx4_file_inode_operations =
const struct inode_operations qnx4_file_inode_operations =
{
#ifdef CONFIG_QNX4FS_RW
.truncate = qnx4_truncate,
Expand Down
2 changes: 1 addition & 1 deletion fs/ramfs/file-mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ const struct file_operations ramfs_file_operations = {
.llseek = generic_file_llseek,
};

struct inode_operations ramfs_file_inode_operations = {
const struct inode_operations ramfs_file_inode_operations = {
.getattr = simple_getattr,
};
2 changes: 1 addition & 1 deletion fs/ramfs/file-nommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const struct file_operations ramfs_file_operations = {
.llseek = generic_file_llseek,
};

struct inode_operations ramfs_file_inode_operations = {
const struct inode_operations ramfs_file_inode_operations = {
.setattr = ramfs_nommu_setattr,
.getattr = simple_getattr,
};
Expand Down
4 changes: 2 additions & 2 deletions fs/ramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define RAMFS_MAGIC 0x858458f6

static struct super_operations ramfs_ops;
static struct inode_operations ramfs_dir_inode_operations;
static const struct inode_operations ramfs_dir_inode_operations;

static struct backing_dev_info ramfs_backing_dev_info = {
.ra_pages = 0, /* No readahead */
Expand Down Expand Up @@ -143,7 +143,7 @@ static int ramfs_symlink(struct inode * dir, struct dentry *dentry, const char *
return error;
}

static struct inode_operations ramfs_dir_inode_operations = {
static const struct inode_operations ramfs_dir_inode_operations = {
.create = ramfs_create,
.lookup = simple_lookup,
.link = simple_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/ramfs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

extern const struct address_space_operations ramfs_aops;
extern const struct file_operations ramfs_file_operations;
extern struct inode_operations ramfs_file_inode_operations;
extern const struct inode_operations ramfs_file_inode_operations;
2 changes: 1 addition & 1 deletion fs/reiserfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1556,7 +1556,7 @@ const struct file_operations reiserfs_file_operations = {
.splice_write = generic_file_splice_write,
};

struct inode_operations reiserfs_file_inode_operations = {
const struct inode_operations reiserfs_file_inode_operations = {
.truncate = reiserfs_vfs_truncate_file,
.setattr = reiserfs_setattr,
.setxattr = reiserfs_setxattr,
Expand Down
6 changes: 3 additions & 3 deletions fs/reiserfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
/*
* directories can handle most operations...
*/
struct inode_operations reiserfs_dir_inode_operations = {
const struct inode_operations reiserfs_dir_inode_operations = {
//&reiserfs_dir_operations, /* default_file_ops */
.create = reiserfs_create,
.lookup = reiserfs_lookup,
Expand All @@ -1548,7 +1548,7 @@ struct inode_operations reiserfs_dir_inode_operations = {
* symlink operations.. same as page_symlink_inode_operations, with xattr
* stuff added
*/
struct inode_operations reiserfs_symlink_inode_operations = {
const struct inode_operations reiserfs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
Expand All @@ -1564,7 +1564,7 @@ struct inode_operations reiserfs_symlink_inode_operations = {
/*
* special file operations.. just xattr/acl stuff
*/
struct inode_operations reiserfs_special_inode_operations = {
const struct inode_operations reiserfs_special_inode_operations = {
.setattr = reiserfs_setattr,
.setxattr = reiserfs_setxattr,
.getxattr = reiserfs_getxattr,
Expand Down
2 changes: 1 addition & 1 deletion fs/romfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static const struct file_operations romfs_dir_operations = {
.readdir = romfs_readdir,
};

static struct inode_operations romfs_dir_inode_operations = {
static const struct inode_operations romfs_dir_inode_operations = {
.lookup = romfs_lookup,
};

Expand Down
4 changes: 2 additions & 2 deletions fs/smbfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const struct file_operations smb_dir_operations =
.open = smb_dir_open,
};

struct inode_operations smb_dir_inode_operations =
const struct inode_operations smb_dir_inode_operations =
{
.create = smb_create,
.lookup = smb_lookup,
Expand All @@ -54,7 +54,7 @@ struct inode_operations smb_dir_inode_operations =
.setattr = smb_notify_change,
};

struct inode_operations smb_dir_inode_operations_unix =
const struct inode_operations smb_dir_inode_operations_unix =
{
.create = smb_create,
.lookup = smb_lookup,
Expand Down
2 changes: 1 addition & 1 deletion fs/smbfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ const struct file_operations smb_file_operations =
.sendfile = smb_file_sendfile,
};

struct inode_operations smb_file_inode_operations =
const struct inode_operations smb_file_inode_operations =
{
.permission = smb_file_permission,
.getattr = smb_getattr,
Expand Down
8 changes: 4 additions & 4 deletions fs/smbfs/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ extern int smb_proc_link(struct smb_sb_info *server, struct dentry *dentry, stru
extern void smb_install_null_ops(struct smb_ops *ops);
/* dir.c */
extern const struct file_operations smb_dir_operations;
extern struct inode_operations smb_dir_inode_operations;
extern struct inode_operations smb_dir_inode_operations_unix;
extern const struct inode_operations smb_dir_inode_operations;
extern const struct inode_operations smb_dir_inode_operations_unix;
extern void smb_new_dentry(struct dentry *dentry);
extern void smb_renew_times(struct dentry *dentry);
/* cache.c */
Expand Down Expand Up @@ -65,7 +65,7 @@ extern int smb_notify_change(struct dentry *dentry, struct iattr *attr);
/* file.c */
extern const struct address_space_operations smb_file_aops;
extern const struct file_operations smb_file_operations;
extern struct inode_operations smb_file_inode_operations;
extern const struct inode_operations smb_file_inode_operations;
/* ioctl.c */
extern int smb_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg);
/* smbiod.c */
Expand All @@ -84,4 +84,4 @@ extern int smb_request_send_server(struct smb_sb_info *server);
extern int smb_request_recv(struct smb_sb_info *server);
/* symlink.c */
extern int smb_symlink(struct inode *inode, struct dentry *dentry, const char *oldname);
extern struct inode_operations smb_link_inode_operations;
extern const struct inode_operations smb_link_inode_operations;
2 changes: 1 addition & 1 deletion fs/smbfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static void smb_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
__putname(s);
}

struct inode_operations smb_link_inode_operations =
const struct inode_operations smb_link_inode_operations =
{
.readlink = generic_readlink,
.follow_link = smb_follow_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(err);
}

struct inode_operations sysfs_dir_inode_operations = {
const struct inode_operations sysfs_dir_inode_operations = {
.lookup = sysfs_lookup,
.setattr = sysfs_setattr,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/sysfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static struct backing_dev_info sysfs_backing_dev_info = {
.capabilities = BDI_CAP_NO_ACCT_DIRTY | BDI_CAP_NO_WRITEBACK,
};

static struct inode_operations sysfs_inode_operations ={
static const struct inode_operations sysfs_inode_operations ={
.setattr = sysfs_setattr,
};

Expand Down
2 changes: 1 addition & 1 deletion fs/sysfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *co
free_page((unsigned long)page);
}

struct inode_operations sysfs_symlink_inode_operations = {
const struct inode_operations sysfs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = sysfs_follow_link,
.put_link = sysfs_put_link,
Expand Down
4 changes: 2 additions & 2 deletions fs/sysfs/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ extern struct super_block * sysfs_sb;
extern const struct file_operations sysfs_dir_operations;
extern const struct file_operations sysfs_file_operations;
extern const struct file_operations bin_fops;
extern struct inode_operations sysfs_dir_inode_operations;
extern struct inode_operations sysfs_symlink_inode_operations;
extern const struct inode_operations sysfs_dir_inode_operations;
extern const struct inode_operations sysfs_symlink_inode_operations;

struct sysfs_symlink {
char * link_name;
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const struct file_operations sysv_file_operations = {
.sendfile = generic_file_sendfile,
};

struct inode_operations sysv_file_inode_operations = {
const struct inode_operations sysv_file_inode_operations = {
.truncate = sysv_truncate,
.getattr = sysv_getattr,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static inline void write3byte(struct sysv_sb_info *sbi,
}
}

static struct inode_operations sysv_symlink_inode_operations = {
static const struct inode_operations sysv_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = page_follow_link_light,
.put_link = page_put_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static int sysv_rename(struct inode * old_dir, struct dentry * old_dentry,
/*
* directories can handle most operations...
*/
struct inode_operations sysv_dir_inode_operations = {
const struct inode_operations sysv_dir_inode_operations = {
.create = sysv_create,
.lookup = sysv_lookup,
.link = sysv_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/sysv/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static void *sysv_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

struct inode_operations sysv_fast_symlink_inode_operations = {
const struct inode_operations sysv_fast_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = sysv_follow_link,
};
6 changes: 3 additions & 3 deletions fs/sysv/sysv.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ extern struct sysv_dir_entry *sysv_dotdot(struct inode *, struct page **);
extern ino_t sysv_inode_by_name(struct dentry *);


extern struct inode_operations sysv_file_inode_operations;
extern struct inode_operations sysv_dir_inode_operations;
extern struct inode_operations sysv_fast_symlink_inode_operations;
extern const struct inode_operations sysv_file_inode_operations;
extern const struct inode_operations sysv_dir_inode_operations;
extern const struct inode_operations sysv_fast_symlink_inode_operations;
extern const struct file_operations sysv_file_operations;
extern const struct file_operations sysv_dir_operations;
extern const struct address_space_operations sysv_aops;
Expand Down
2 changes: 1 addition & 1 deletion fs/udf/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,6 @@ const struct file_operations udf_file_operations = {
.sendfile = generic_file_sendfile,
};

struct inode_operations udf_file_inode_operations = {
const struct inode_operations udf_file_inode_operations = {
.truncate = udf_truncate,
};
2 changes: 1 addition & 1 deletion fs/udf/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ static int udf_rename (struct inode * old_dir, struct dentry * old_dentry,
return retval;
}

struct inode_operations udf_dir_inode_operations = {
const struct inode_operations udf_dir_inode_operations = {
.lookup = udf_lookup,
.create = udf_create,
.link = udf_link,
Expand Down
Loading

0 comments on commit c5ef1c4

Please sign in to comment.