Skip to content

Commit

Permalink
[PATCH] mark struct inode_operations const 1
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 9c2e08c commit 754661f
Show file tree
Hide file tree
Showing 57 changed files with 100 additions and 100 deletions.
2 changes: 1 addition & 1 deletion arch/powerpc/platforms/cell/spufs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static int spufs_dir_close(struct inode *inode, struct file *file)
return dcache_dir_close(inode, file);
}

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

Expand Down
16 changes: 8 additions & 8 deletions fs/9p/vfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
#include "v9fs_vfs.h"
#include "fid.h"

static struct inode_operations v9fs_dir_inode_operations;
static struct inode_operations v9fs_dir_inode_operations_ext;
static struct inode_operations v9fs_file_inode_operations;
static struct inode_operations v9fs_symlink_inode_operations;
static const struct inode_operations v9fs_dir_inode_operations;
static const struct inode_operations v9fs_dir_inode_operations_ext;
static const struct inode_operations v9fs_file_inode_operations;
static const struct inode_operations v9fs_symlink_inode_operations;

/**
* unixmode2p9mode - convert unix mode bits to plan 9
Expand Down Expand Up @@ -1303,7 +1303,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
return retval;
}

static struct inode_operations v9fs_dir_inode_operations_ext = {
static const struct inode_operations v9fs_dir_inode_operations_ext = {
.create = v9fs_vfs_create,
.lookup = v9fs_vfs_lookup,
.symlink = v9fs_vfs_symlink,
Expand All @@ -1318,7 +1318,7 @@ static struct inode_operations v9fs_dir_inode_operations_ext = {
.setattr = v9fs_vfs_setattr,
};

static struct inode_operations v9fs_dir_inode_operations = {
static const struct inode_operations v9fs_dir_inode_operations = {
.create = v9fs_vfs_create,
.lookup = v9fs_vfs_lookup,
.unlink = v9fs_vfs_unlink,
Expand All @@ -1330,12 +1330,12 @@ static struct inode_operations v9fs_dir_inode_operations = {
.setattr = v9fs_vfs_setattr,
};

static struct inode_operations v9fs_file_inode_operations = {
static const struct inode_operations v9fs_file_inode_operations = {
.getattr = v9fs_vfs_getattr,
.setattr = v9fs_vfs_setattr,
};

static struct inode_operations v9fs_symlink_inode_operations = {
static const struct inode_operations v9fs_symlink_inode_operations = {
.readlink = v9fs_vfs_readlink,
.follow_link = v9fs_vfs_follow_link,
.put_link = v9fs_vfs_put_link,
Expand Down
4 changes: 2 additions & 2 deletions fs/adfs/adfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void __adfs_error(struct super_block *sb, const char *function,
*/

/* dir_*.c */
extern struct inode_operations adfs_dir_inode_operations;
extern const struct inode_operations adfs_dir_inode_operations;
extern const struct file_operations adfs_dir_operations;
extern struct dentry_operations adfs_dentry_operations;
extern struct adfs_dir_ops adfs_f_dir_ops;
Expand All @@ -93,7 +93,7 @@ extern struct adfs_dir_ops adfs_fplus_dir_ops;
extern int adfs_dir_update(struct super_block *sb, struct object_info *obj);

/* file.c */
extern struct inode_operations adfs_file_inode_operations;
extern const struct inode_operations adfs_file_inode_operations;
extern const struct file_operations adfs_file_operations;

static inline __u32 signed_asl(__u32 val, signed int shift)
Expand Down
2 changes: 1 addition & 1 deletion fs/adfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ adfs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
/*
* directories can handle most operations...
*/
struct inode_operations adfs_dir_inode_operations = {
const struct inode_operations adfs_dir_inode_operations = {
.lookup = adfs_lookup,
.setattr = adfs_notify_change,
};
2 changes: 1 addition & 1 deletion fs/adfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ const struct file_operations adfs_file_operations = {
.sendfile = generic_file_sendfile,
};

struct inode_operations adfs_file_inode_operations = {
const struct inode_operations adfs_file_inode_operations = {
.setattr = adfs_notify_change,
};
6 changes: 3 additions & 3 deletions fs/affs/affs.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ extern void affs_dir_truncate(struct inode *);

/* jump tables */

extern struct inode_operations affs_file_inode_operations;
extern struct inode_operations affs_dir_inode_operations;
extern struct inode_operations affs_symlink_inode_operations;
extern const struct inode_operations affs_file_inode_operations;
extern const struct inode_operations affs_dir_inode_operations;
extern const struct inode_operations affs_symlink_inode_operations;
extern const struct file_operations affs_file_operations;
extern const struct file_operations affs_file_operations_ofs;
extern const struct file_operations affs_dir_operations;
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const struct file_operations affs_dir_operations = {
/*
* directories can handle most operations...
*/
struct inode_operations affs_dir_inode_operations = {
const struct inode_operations affs_dir_inode_operations = {
.create = affs_create,
.lookup = affs_lookup,
.link = affs_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const struct file_operations affs_file_operations = {
.sendfile = generic_file_sendfile,
};

struct inode_operations affs_file_inode_operations = {
const struct inode_operations affs_file_inode_operations = {
.truncate = affs_truncate,
.setattr = affs_notify_change,
};
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "affs.h"

extern struct inode_operations affs_symlink_inode_operations;
extern const struct inode_operations affs_symlink_inode_operations;
extern struct timezone sys_tz;

void
Expand Down
2 changes: 1 addition & 1 deletion fs/affs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const struct address_space_operations affs_symlink_aops = {
.readpage = affs_symlink_readpage,
};

struct inode_operations affs_symlink_inode_operations = {
const struct inode_operations affs_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/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const struct file_operations afs_dir_file_operations = {
.readdir = afs_dir_readdir,
};

struct inode_operations afs_dir_inode_operations = {
const struct inode_operations afs_dir_inode_operations = {
.lookup = afs_dir_lookup,
.getattr = afs_inode_getattr,
#if 0 /* TODO */
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static int afs_file_readpage(struct file *file, struct page *page);
static void afs_file_invalidatepage(struct page *page, unsigned long offset);
static int afs_file_releasepage(struct page *page, gfp_t gfp_flags);

struct inode_operations afs_file_inode_operations = {
const struct inode_operations afs_file_inode_operations = {
.getattr = afs_inode_getattr,
};

Expand Down
6 changes: 3 additions & 3 deletions fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ extern struct cachefs_index_def afs_cache_cell_index_def;
/*
* dir.c
*/
extern struct inode_operations afs_dir_inode_operations;
extern const struct inode_operations afs_dir_inode_operations;
extern const struct file_operations afs_dir_file_operations;

/*
* file.c
*/
extern const struct address_space_operations afs_fs_aops;
extern struct inode_operations afs_file_inode_operations;
extern const struct inode_operations afs_file_inode_operations;

#ifdef AFS_CACHING_SUPPORT
extern int afs_cache_get_page_cookie(struct page *page,
Expand Down Expand Up @@ -104,7 +104,7 @@ extern struct cachefs_netfs afs_cache_netfs;
/*
* mntpt.c
*/
extern struct inode_operations afs_mntpt_inode_operations;
extern const struct inode_operations afs_mntpt_inode_operations;
extern const struct file_operations afs_mntpt_file_operations;
extern struct afs_timer afs_mntpt_expiry_timer;
extern struct afs_timer_ops afs_mntpt_expiry_timer_ops;
Expand Down
2 changes: 1 addition & 1 deletion fs/afs/mntpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const struct file_operations afs_mntpt_file_operations = {
.open = afs_mntpt_open,
};

struct inode_operations afs_mntpt_inode_operations = {
const struct inode_operations afs_mntpt_inode_operations = {
.lookup = afs_mntpt_lookup,
.follow_link = afs_mntpt_follow_link,
.readlink = page_readlink,
Expand Down
4 changes: 2 additions & 2 deletions fs/autofs/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info

/* Operations structures */

extern struct inode_operations autofs_root_inode_operations;
extern struct inode_operations autofs_symlink_inode_operations;
extern const struct inode_operations autofs_root_inode_operations;
extern const struct inode_operations autofs_symlink_inode_operations;
extern const struct file_operations autofs_root_operations;

/* Initializing function */
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const struct file_operations autofs_root_operations = {
.ioctl = autofs_root_ioctl,
};

struct inode_operations autofs_root_inode_operations = {
const struct inode_operations autofs_root_inode_operations = {
.lookup = autofs_root_lookup,
.unlink = autofs_root_unlink,
.symlink = autofs_root_symlink,
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static void *autofs_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

struct inode_operations autofs_symlink_inode_operations = {
const struct inode_operations autofs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = autofs_follow_link
};
10 changes: 5 additions & 5 deletions fs/autofs4/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ int autofs4_expire_multi(struct super_block *, struct vfsmount *,

/* Operations structures */

extern struct inode_operations autofs4_symlink_inode_operations;
extern struct inode_operations autofs4_dir_inode_operations;
extern struct inode_operations autofs4_root_inode_operations;
extern struct inode_operations autofs4_indirect_root_inode_operations;
extern struct inode_operations autofs4_direct_root_inode_operations;
extern const struct inode_operations autofs4_symlink_inode_operations;
extern const struct inode_operations autofs4_dir_inode_operations;
extern const struct inode_operations autofs4_root_inode_operations;
extern const struct inode_operations autofs4_indirect_root_inode_operations;
extern const struct inode_operations autofs4_direct_root_inode_operations;
extern const struct file_operations autofs4_dir_operations;
extern const struct file_operations autofs4_root_operations;

Expand Down
6 changes: 3 additions & 3 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ const struct file_operations autofs4_dir_operations = {
.readdir = autofs4_dir_readdir,
};

struct inode_operations autofs4_indirect_root_inode_operations = {
const struct inode_operations autofs4_indirect_root_inode_operations = {
.lookup = autofs4_lookup,
.unlink = autofs4_dir_unlink,
.symlink = autofs4_dir_symlink,
.mkdir = autofs4_dir_mkdir,
.rmdir = autofs4_dir_rmdir,
};

struct inode_operations autofs4_direct_root_inode_operations = {
const struct inode_operations autofs4_direct_root_inode_operations = {
.lookup = autofs4_lookup,
.unlink = autofs4_dir_unlink,
.mkdir = autofs4_dir_mkdir,
.rmdir = autofs4_dir_rmdir,
.follow_link = autofs4_follow_link,
};

struct inode_operations autofs4_dir_inode_operations = {
const struct inode_operations autofs4_dir_inode_operations = {
.lookup = autofs4_lookup,
.unlink = autofs4_dir_unlink,
.symlink = autofs4_dir_symlink,
Expand Down
2 changes: 1 addition & 1 deletion fs/autofs4/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void *autofs4_follow_link(struct dentry *dentry, struct nameidata *nd)
return NULL;
}

struct inode_operations autofs4_symlink_inode_operations = {
const struct inode_operations autofs4_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = autofs4_follow_link
};
2 changes: 1 addition & 1 deletion fs/bad_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static int bad_inode_removexattr(struct dentry *dentry, const char *name)
return -EIO;
}

static struct inode_operations bad_inode_ops =
static const struct inode_operations bad_inode_ops =
{
.create = bad_inode_create,
.lookup = bad_inode_lookup,
Expand Down
4 changes: 2 additions & 2 deletions fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static const struct file_operations befs_dir_operations = {
.readdir = befs_readdir,
};

static struct inode_operations befs_dir_inode_operations = {
static const struct inode_operations befs_dir_inode_operations = {
.lookup = befs_lookup,
};

Expand All @@ -78,7 +78,7 @@ static const struct address_space_operations befs_aops = {
.bmap = befs_bmap,
};

static struct inode_operations befs_symlink_inode_operations = {
static const struct inode_operations befs_symlink_inode_operations = {
.readlink = generic_readlink,
.follow_link = befs_follow_link,
.put_link = befs_put_link,
Expand Down
4 changes: 2 additions & 2 deletions fs/bfs/bfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode)


/* file.c */
extern struct inode_operations bfs_file_inops;
extern const struct inode_operations bfs_file_inops;
extern const struct file_operations bfs_file_operations;
extern const struct address_space_operations bfs_aops;

/* dir.c */
extern struct inode_operations bfs_dir_inops;
extern const struct inode_operations bfs_dir_inops;
extern const struct file_operations bfs_dir_operations;

#endif /* _FS_BFS_BFS_H */
2 changes: 1 addition & 1 deletion fs/bfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int bfs_rename(struct inode * old_dir, struct dentry * old_dentry,
return error;
}

struct inode_operations bfs_dir_inops = {
const struct inode_operations bfs_dir_inops = {
.create = bfs_create,
.lookup = bfs_lookup,
.link = bfs_link,
Expand Down
2 changes: 1 addition & 1 deletion fs/bfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ const struct address_space_operations bfs_aops = {
.bmap = bfs_bmap,
};

struct inode_operations bfs_file_inops;
const struct inode_operations bfs_file_inops;
6 changes: 3 additions & 3 deletions fs/cifs/cifsfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ static struct file_system_type cifs_fs_type = {
.kill_sb = kill_anon_super,
/* .fs_flags */
};
struct inode_operations cifs_dir_inode_ops = {
const struct inode_operations cifs_dir_inode_ops = {
.create = cifs_create,
.lookup = cifs_lookup,
.getattr = cifs_getattr,
Expand All @@ -555,7 +555,7 @@ struct inode_operations cifs_dir_inode_ops = {
#endif
};

struct inode_operations cifs_file_inode_ops = {
const struct inode_operations cifs_file_inode_ops = {
/* revalidate:cifs_revalidate, */
.setattr = cifs_setattr,
.getattr = cifs_getattr, /* do we need this anymore? */
Expand All @@ -569,7 +569,7 @@ struct inode_operations cifs_file_inode_ops = {
#endif
};

struct inode_operations cifs_symlink_inode_ops = {
const struct inode_operations cifs_symlink_inode_ops = {
.readlink = generic_readlink,
.follow_link = cifs_follow_link,
.put_link = cifs_put_link,
Expand Down
6 changes: 3 additions & 3 deletions fs/cifs/cifsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern void cifs_delete_inode(struct inode *);
/* extern void cifs_write_inode(struct inode *); *//* BB not needed yet */

/* Functions related to inodes */
extern struct inode_operations cifs_dir_inode_ops;
extern const struct inode_operations cifs_dir_inode_ops;
extern int cifs_create(struct inode *, struct dentry *, int,
struct nameidata *);
extern struct dentry * cifs_lookup(struct inode *, struct dentry *,
Expand All @@ -58,8 +58,8 @@ extern int cifs_revalidate(struct dentry *);
extern int cifs_getattr(struct vfsmount *, struct dentry *, struct kstat *);
extern int cifs_setattr(struct dentry *, struct iattr *);

extern struct inode_operations cifs_file_inode_ops;
extern struct inode_operations cifs_symlink_inode_ops;
extern const struct inode_operations cifs_file_inode_ops;
extern const struct inode_operations cifs_symlink_inode_ops;

/* Functions related to files and directories */
extern const struct file_operations cifs_file_ops;
Expand Down
2 changes: 1 addition & 1 deletion fs/coda/cnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static inline int coda_fideq(struct CodaFid *fid1, struct CodaFid *fid2)
return memcmp(fid1, fid2, sizeof(*fid1)) == 0;
}

static struct inode_operations coda_symlink_inode_operations = {
static const struct inode_operations coda_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/coda/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static struct dentry_operations coda_dentry_operations =
.d_delete = coda_dentry_delete,
};

struct inode_operations coda_dir_inode_operations =
const struct inode_operations coda_dir_inode_operations =
{
.create = coda_create,
.lookup = coda_lookup,
Expand Down
Loading

0 comments on commit 754661f

Please sign in to comment.