Skip to content

Commit 4b6f5d2

Browse files
Arjan van de VenLinus Torvalds
Arjan van de Ven
authored and
Linus Torvalds
committed
[PATCH] Make most file operations structs in fs/ const
This is a conversion to make the various file_operations structs in fs/ const. Basically a regexp job, with a few manual fixups The goal is both to increase correctness (harder to accidentally write to shared datastructures) and reducing the false sharing of cachelines with things that get dirty in .data (while .rodata is nicely read only and thus cache clean) Signed-off-by: Arjan van de Ven <arjan@infradead.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 99ac48f commit 4b6f5d2

Some content is hidden

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

139 files changed

+225
-225
lines changed

drivers/misc/ibmasm/ibmasmfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static struct super_operations ibmasmfs_s_ops = {
101101
.drop_inode = generic_delete_inode,
102102
};
103103

104-
static struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations;
104+
static const struct file_operations *ibmasmfs_dir_ops = &simple_dir_operations;
105105

106106
static struct file_system_type ibmasmfs_type = {
107107
.owner = THIS_MODULE,

fs/9p/v9fs_vfs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040
extern struct file_system_type v9fs_fs_type;
4141
extern struct address_space_operations v9fs_addr_operations;
42-
extern struct file_operations v9fs_file_operations;
43-
extern struct file_operations v9fs_dir_operations;
42+
extern const struct file_operations v9fs_file_operations;
43+
extern const struct file_operations v9fs_dir_operations;
4444
extern struct dentry_operations v9fs_dentry_operations;
4545

4646
struct inode *v9fs_get_inode(struct super_block *sb, int mode);

fs/9p/vfs_dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ int v9fs_dir_release(struct inode *inode, struct file *filp)
204204
return 0;
205205
}
206206

207-
struct file_operations v9fs_dir_operations = {
207+
const struct file_operations v9fs_dir_operations = {
208208
.read = generic_read_dir,
209209
.readdir = v9fs_dir_readdir,
210210
.open = v9fs_file_open,

fs/9p/vfs_file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ v9fs_file_write(struct file *filp, const char __user * data,
266266
return total;
267267
}
268268

269-
struct file_operations v9fs_file_operations = {
269+
const struct file_operations v9fs_file_operations = {
270270
.llseek = generic_file_llseek,
271271
.read = v9fs_file_read,
272272
.write = v9fs_file_write,

fs/adfs/adfs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void __adfs_error(struct super_block *sb, const char *function,
8585

8686
/* dir_*.c */
8787
extern struct inode_operations adfs_dir_inode_operations;
88-
extern struct file_operations adfs_dir_operations;
88+
extern const struct file_operations adfs_dir_operations;
8989
extern struct dentry_operations adfs_dentry_operations;
9090
extern struct adfs_dir_ops adfs_f_dir_ops;
9191
extern struct adfs_dir_ops adfs_fplus_dir_ops;
@@ -94,7 +94,7 @@ extern int adfs_dir_update(struct super_block *sb, struct object_info *obj);
9494

9595
/* file.c */
9696
extern struct inode_operations adfs_file_inode_operations;
97-
extern struct file_operations adfs_file_operations;
97+
extern const struct file_operations adfs_file_operations;
9898

9999
static inline __u32 signed_asl(__u32 val, signed int shift)
100100
{

fs/adfs/dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ adfs_dir_lookup_byname(struct inode *inode, struct qstr *name, struct object_inf
196196
return ret;
197197
}
198198

199-
struct file_operations adfs_dir_operations = {
199+
const struct file_operations adfs_dir_operations = {
200200
.read = generic_read_dir,
201201
.readdir = adfs_readdir,
202202
.fsync = file_fsync,

fs/adfs/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#include "adfs.h"
2727

28-
struct file_operations adfs_file_operations = {
28+
const struct file_operations adfs_file_operations = {
2929
.llseek = generic_file_llseek,
3030
.read = generic_file_read,
3131
.mmap = generic_file_mmap,

fs/affs/affs.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ extern void affs_dir_truncate(struct inode *);
192192
extern struct inode_operations affs_file_inode_operations;
193193
extern struct inode_operations affs_dir_inode_operations;
194194
extern struct inode_operations affs_symlink_inode_operations;
195-
extern struct file_operations affs_file_operations;
196-
extern struct file_operations affs_file_operations_ofs;
197-
extern struct file_operations affs_dir_operations;
195+
extern const struct file_operations affs_file_operations;
196+
extern const struct file_operations affs_file_operations_ofs;
197+
extern const struct file_operations affs_dir_operations;
198198
extern struct address_space_operations affs_symlink_aops;
199199
extern struct address_space_operations affs_aops;
200200
extern struct address_space_operations affs_aops_ofs;

fs/affs/dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
static int affs_readdir(struct file *, void *, filldir_t);
1919

20-
struct file_operations affs_dir_operations = {
20+
const struct file_operations affs_dir_operations = {
2121
.read = generic_read_dir,
2222
.readdir = affs_readdir,
2323
.fsync = file_fsync,

fs/affs/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static struct buffer_head *affs_get_extblock_slow(struct inode *inode, u32 ext);
2525
static int affs_file_open(struct inode *inode, struct file *filp);
2626
static int affs_file_release(struct inode *inode, struct file *filp);
2727

28-
struct file_operations affs_file_operations = {
28+
const struct file_operations affs_file_operations = {
2929
.llseek = generic_file_llseek,
3030
.read = generic_file_read,
3131
.write = generic_file_write,

fs/afs/dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static int afs_d_delete(struct dentry *dentry);
3232
static int afs_dir_lookup_filldir(void *_cookie, const char *name, int nlen,
3333
loff_t fpos, ino_t ino, unsigned dtype);
3434

35-
struct file_operations afs_dir_file_operations = {
35+
const struct file_operations afs_dir_file_operations = {
3636
.open = afs_dir_open,
3737
.readdir = afs_dir_readdir,
3838
};

fs/afs/internal.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ extern struct cachefs_index_def afs_cache_cell_index_def;
6464
* dir.c
6565
*/
6666
extern struct inode_operations afs_dir_inode_operations;
67-
extern struct file_operations afs_dir_file_operations;
67+
extern const struct file_operations afs_dir_file_operations;
6868

6969
/*
7070
* file.c
@@ -105,7 +105,7 @@ extern struct cachefs_netfs afs_cache_netfs;
105105
* mntpt.c
106106
*/
107107
extern struct inode_operations afs_mntpt_inode_operations;
108-
extern struct file_operations afs_mntpt_file_operations;
108+
extern const struct file_operations afs_mntpt_file_operations;
109109
extern struct afs_timer afs_mntpt_expiry_timer;
110110
extern struct afs_timer_ops afs_mntpt_expiry_timer_ops;
111111
extern unsigned long afs_mntpt_expiry_timeout;

fs/afs/mntpt.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
3232
static int afs_mntpt_open(struct inode *inode, struct file *file);
3333
static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd);
3434

35-
struct file_operations afs_mntpt_file_operations = {
35+
const struct file_operations afs_mntpt_file_operations = {
3636
.open = afs_mntpt_open,
3737
};
3838

fs/afs/proc.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static struct seq_operations afs_proc_cells_ops = {
3737
.show = afs_proc_cells_show,
3838
};
3939

40-
static struct file_operations afs_proc_cells_fops = {
40+
static const struct file_operations afs_proc_cells_fops = {
4141
.open = afs_proc_cells_open,
4242
.read = seq_read,
4343
.write = afs_proc_cells_write,
@@ -53,7 +53,7 @@ static ssize_t afs_proc_rootcell_write(struct file *file,
5353
const char __user *buf,
5454
size_t size, loff_t *_pos);
5555

56-
static struct file_operations afs_proc_rootcell_fops = {
56+
static const struct file_operations afs_proc_rootcell_fops = {
5757
.open = afs_proc_rootcell_open,
5858
.read = afs_proc_rootcell_read,
5959
.write = afs_proc_rootcell_write,
@@ -77,7 +77,7 @@ static struct seq_operations afs_proc_cell_volumes_ops = {
7777
.show = afs_proc_cell_volumes_show,
7878
};
7979

80-
static struct file_operations afs_proc_cell_volumes_fops = {
80+
static const struct file_operations afs_proc_cell_volumes_fops = {
8181
.open = afs_proc_cell_volumes_open,
8282
.read = seq_read,
8383
.llseek = seq_lseek,
@@ -101,7 +101,7 @@ static struct seq_operations afs_proc_cell_vlservers_ops = {
101101
.show = afs_proc_cell_vlservers_show,
102102
};
103103

104-
static struct file_operations afs_proc_cell_vlservers_fops = {
104+
static const struct file_operations afs_proc_cell_vlservers_fops = {
105105
.open = afs_proc_cell_vlservers_open,
106106
.read = seq_read,
107107
.llseek = seq_lseek,
@@ -124,7 +124,7 @@ static struct seq_operations afs_proc_cell_servers_ops = {
124124
.show = afs_proc_cell_servers_show,
125125
};
126126

127-
static struct file_operations afs_proc_cell_servers_fops = {
127+
static const struct file_operations afs_proc_cell_servers_fops = {
128128
.open = afs_proc_cell_servers_open,
129129
.read = seq_read,
130130
.llseek = seq_lseek,

fs/autofs/autofs_i.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ struct autofs_dir_ent *autofs_expire(struct super_block *,struct autofs_sb_info
146146

147147
extern struct inode_operations autofs_root_inode_operations;
148148
extern struct inode_operations autofs_symlink_inode_operations;
149-
extern struct file_operations autofs_root_operations;
149+
extern const struct file_operations autofs_root_operations;
150150

151151
/* Initializing function */
152152

fs/autofs/root.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static int autofs_root_rmdir(struct inode *,struct dentry *);
2626
static int autofs_root_mkdir(struct inode *,struct dentry *,int);
2727
static int autofs_root_ioctl(struct inode *, struct file *,unsigned int,unsigned long);
2828

29-
struct file_operations autofs_root_operations = {
29+
const struct file_operations autofs_root_operations = {
3030
.read = generic_read_dir,
3131
.readdir = autofs_root_readdir,
3232
.ioctl = autofs_root_ioctl,

fs/autofs4/autofs_i.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ extern struct inode_operations autofs4_dir_inode_operations;
176176
extern struct inode_operations autofs4_root_inode_operations;
177177
extern struct inode_operations autofs4_indirect_root_inode_operations;
178178
extern struct inode_operations autofs4_direct_root_inode_operations;
179-
extern struct file_operations autofs4_dir_operations;
180-
extern struct file_operations autofs4_root_operations;
179+
extern const struct file_operations autofs4_dir_operations;
180+
extern const struct file_operations autofs4_root_operations;
181181

182182
/* Initializing function */
183183

fs/autofs4/root.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ static int autofs4_root_readdir(struct file * filp, void * dirent, filldir_t fil
3232
static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *);
3333
static void *autofs4_follow_link(struct dentry *, struct nameidata *);
3434

35-
struct file_operations autofs4_root_operations = {
35+
const struct file_operations autofs4_root_operations = {
3636
.open = dcache_dir_open,
3737
.release = dcache_dir_close,
3838
.read = generic_read_dir,
3939
.readdir = autofs4_root_readdir,
4040
.ioctl = autofs4_root_ioctl,
4141
};
4242

43-
struct file_operations autofs4_dir_operations = {
43+
const struct file_operations autofs4_dir_operations = {
4444
.open = autofs4_dir_open,
4545
.release = autofs4_dir_close,
4646
.read = generic_read_dir,

fs/bad_inode.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static int return_EIO(void)
2222

2323
#define EIO_ERROR ((void *) (return_EIO))
2424

25-
static struct file_operations bad_file_ops =
25+
static const struct file_operations bad_file_ops =
2626
{
2727
.llseek = EIO_ERROR,
2828
.aio_read = EIO_ERROR,

fs/befs/linuxvfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const struct super_operations befs_sops = {
6464
/* slab cache for befs_inode_info objects */
6565
static kmem_cache_t *befs_inode_cachep;
6666

67-
static struct file_operations befs_dir_operations = {
67+
static const struct file_operations befs_dir_operations = {
6868
.read = generic_read_dir,
6969
.readdir = befs_readdir,
7070
};

fs/bfs/bfs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ static inline struct bfs_inode_info *BFS_I(struct inode *inode)
4949

5050
/* file.c */
5151
extern struct inode_operations bfs_file_inops;
52-
extern struct file_operations bfs_file_operations;
52+
extern const struct file_operations bfs_file_operations;
5353
extern struct address_space_operations bfs_aops;
5454

5555
/* dir.c */
5656
extern struct inode_operations bfs_dir_inops;
57-
extern struct file_operations bfs_dir_operations;
57+
extern const struct file_operations bfs_dir_operations;
5858

5959
#endif /* _FS_BFS_BFS_H */

fs/bfs/dir.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static int bfs_readdir(struct file * f, void * dirent, filldir_t filldir)
7070
return 0;
7171
}
7272

73-
struct file_operations bfs_dir_operations = {
73+
const struct file_operations bfs_dir_operations = {
7474
.read = generic_read_dir,
7575
.readdir = bfs_readdir,
7676
.fsync = file_fsync,

fs/bfs/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#define dprintf(x...)
1818
#endif
1919

20-
struct file_operations bfs_file_operations = {
20+
const struct file_operations bfs_file_operations = {
2121
.llseek = generic_file_llseek,
2222
.read = generic_file_read,
2323
.write = generic_file_write,

fs/binfmt_misc.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer,
600600
return count;
601601
}
602602

603-
static struct file_operations bm_entry_operations = {
603+
static const struct file_operations bm_entry_operations = {
604604
.read = bm_entry_read,
605605
.write = bm_entry_write,
606606
};
@@ -668,7 +668,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
668668
return count;
669669
}
670670

671-
static struct file_operations bm_register_operations = {
671+
static const struct file_operations bm_register_operations = {
672672
.write = bm_register_write,
673673
};
674674

@@ -715,7 +715,7 @@ static ssize_t bm_status_write(struct file * file, const char __user * buffer,
715715
return count;
716716
}
717717

718-
static struct file_operations bm_status_operations = {
718+
static const struct file_operations bm_status_operations = {
719719
.read = bm_status_read,
720720
.write = bm_status_write,
721721
};

fs/block_dev.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ struct address_space_operations def_blk_aops = {
10871087
.direct_IO = blkdev_direct_IO,
10881088
};
10891089

1090-
struct file_operations def_blk_fops = {
1090+
const struct file_operations def_blk_fops = {
10911091
.open = blkdev_open,
10921092
.release = blkdev_close,
10931093
.llseek = block_llseek,

fs/char_dev.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ static void cdev_purge(struct cdev *cdev)
406406
* is contain the open that then fills in the correct operations
407407
* depending on the special file...
408408
*/
409-
struct file_operations def_chr_fops = {
409+
const struct file_operations def_chr_fops = {
410410
.open = chrdev_open,
411411
};
412412

fs/cifs/cifsfs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ struct inode_operations cifs_symlink_inode_ops = {
583583
#endif
584584
};
585585

586-
struct file_operations cifs_file_ops = {
586+
const struct file_operations cifs_file_ops = {
587587
.read = do_sync_read,
588588
.write = do_sync_write,
589589
.readv = generic_file_readv,
@@ -607,7 +607,7 @@ struct file_operations cifs_file_ops = {
607607
#endif /* CONFIG_CIFS_EXPERIMENTAL */
608608
};
609609

610-
struct file_operations cifs_file_direct_ops = {
610+
const struct file_operations cifs_file_direct_ops = {
611611
/* no mmap, no aio, no readv -
612612
BB reevaluate whether they can be done with directio, no cache */
613613
.read = cifs_user_read,
@@ -626,7 +626,7 @@ struct file_operations cifs_file_direct_ops = {
626626
.dir_notify = cifs_dir_notify,
627627
#endif /* CONFIG_CIFS_EXPERIMENTAL */
628628
};
629-
struct file_operations cifs_file_nobrl_ops = {
629+
const struct file_operations cifs_file_nobrl_ops = {
630630
.read = do_sync_read,
631631
.write = do_sync_write,
632632
.readv = generic_file_readv,
@@ -649,7 +649,7 @@ struct file_operations cifs_file_nobrl_ops = {
649649
#endif /* CONFIG_CIFS_EXPERIMENTAL */
650650
};
651651

652-
struct file_operations cifs_file_direct_nobrl_ops = {
652+
const struct file_operations cifs_file_direct_nobrl_ops = {
653653
/* no mmap, no aio, no readv -
654654
BB reevaluate whether they can be done with directio, no cache */
655655
.read = cifs_user_read,
@@ -668,7 +668,7 @@ struct file_operations cifs_file_direct_nobrl_ops = {
668668
#endif /* CONFIG_CIFS_EXPERIMENTAL */
669669
};
670670

671-
struct file_operations cifs_dir_ops = {
671+
const struct file_operations cifs_dir_ops = {
672672
.readdir = cifs_readdir,
673673
.release = cifs_closedir,
674674
.read = generic_read_dir,

fs/cifs/cifsfs.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ extern struct inode_operations cifs_file_inode_ops;
6161
extern struct inode_operations cifs_symlink_inode_ops;
6262

6363
/* Functions related to files and directories */
64-
extern struct file_operations cifs_file_ops;
65-
extern struct file_operations cifs_file_direct_ops; /* if directio mount */
66-
extern struct file_operations cifs_file_nobrl_ops;
67-
extern struct file_operations cifs_file_direct_nobrl_ops; /* if directio mount */
64+
extern const struct file_operations cifs_file_ops;
65+
extern const struct file_operations cifs_file_direct_ops; /* if directio mount */
66+
extern const struct file_operations cifs_file_nobrl_ops;
67+
extern const struct file_operations cifs_file_direct_nobrl_ops; /* if directio mount */
6868
extern int cifs_open(struct inode *inode, struct file *file);
6969
extern int cifs_close(struct inode *inode, struct file *file);
7070
extern int cifs_closedir(struct inode *inode, struct file *file);
@@ -76,7 +76,7 @@ extern int cifs_lock(struct file *, int, struct file_lock *);
7676
extern int cifs_fsync(struct file *, struct dentry *, int);
7777
extern int cifs_flush(struct file *);
7878
extern int cifs_file_mmap(struct file * , struct vm_area_struct *);
79-
extern struct file_operations cifs_dir_ops;
79+
extern const struct file_operations cifs_dir_ops;
8080
extern int cifs_dir_open(struct inode *inode, struct file *file);
8181
extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir);
8282
extern int cifs_dir_notify(struct file *, unsigned long arg);

0 commit comments

Comments
 (0)