add patch mm-retry-writepages-on-ENOMEM-when-doing-an-data-int
[ext4-patch-queue.git] / constify-static-data-that-is-never-modified
blobdcede57a2a702fa0889afb4fc8d1b3548fd3cc5e
1 ext4: constify static data that is never modified
3 From: Eric Biggers <ebiggers@google.com>
5 Constify static data in ext4 that is never (intentionally) modified so
6 that it is placed in .rodata and benefits from memory protection.
8 Signed-off-by: Eric Biggers <ebiggers@google.com>
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 ---
11  fs/ext4/ext4.h    | 4 ++--
12  fs/ext4/mballoc.c | 2 +-
13  fs/ext4/super.c   | 5 +++--
14  fs/ext4/sysfs.c   | 8 ++++----
15  fs/ext4/xattr.c   | 2 +-
16  5 files changed, 11 insertions(+), 10 deletions(-)
18 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
19 index f493af666591..55f41bb14a5f 100644
20 --- a/fs/ext4/ext4.h
21 +++ b/fs/ext4/ext4.h
22 @@ -2366,7 +2366,7 @@ static inline void ext4_update_dx_flag(struct inode *inode)
23         if (!ext4_has_feature_dir_index(inode->i_sb))
24                 ext4_clear_inode_flag(inode, EXT4_INODE_INDEX);
25  }
26 -static unsigned char ext4_filetype_table[] = {
27 +static const unsigned char ext4_filetype_table[] = {
28         DT_UNKNOWN, DT_REG, DT_DIR, DT_CHR, DT_BLK, DT_FIFO, DT_SOCK, DT_LNK
29  };
31 @@ -3050,7 +3050,7 @@ extern int ext4_handle_dirty_dirent_node(handle_t *handle,
32                                          struct inode *inode,
33                                          struct buffer_head *bh);
34  #define S_SHIFT 12
35 -static unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
36 +static const unsigned char ext4_type_by_mode[S_IFMT >> S_SHIFT] = {
37         [S_IFREG >> S_SHIFT]    = EXT4_FT_REG_FILE,
38         [S_IFDIR >> S_SHIFT]    = EXT4_FT_DIR,
39         [S_IFCHR >> S_SHIFT]    = EXT4_FT_CHRDEV,
40 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
41 index 354dc1a894c2..dbe51301c2bb 100644
42 --- a/fs/ext4/mballoc.c
43 +++ b/fs/ext4/mballoc.c
44 @@ -357,7 +357,7 @@ static struct kmem_cache *ext4_free_data_cachep;
45  #define NR_GRPINFO_CACHES 8
46  static struct kmem_cache *ext4_groupinfo_caches[NR_GRPINFO_CACHES];
48 -static const char *ext4_groupinfo_slab_names[NR_GRPINFO_CACHES] = {
49 +static const char * const ext4_groupinfo_slab_names[NR_GRPINFO_CACHES] = {
50         "ext4_groupinfo_1k", "ext4_groupinfo_2k", "ext4_groupinfo_4k",
51         "ext4_groupinfo_8k", "ext4_groupinfo_16k", "ext4_groupinfo_32k",
52         "ext4_groupinfo_64k", "ext4_groupinfo_128k"
53 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
54 index 2e03a0a88d92..b3af13f808f1 100644
55 --- a/fs/ext4/super.c
56 +++ b/fs/ext4/super.c
57 @@ -1210,7 +1210,7 @@ static const struct fscrypt_operations ext4_cryptops = {
58  #endif
60  #ifdef CONFIG_QUOTA
61 -static char *quotatypes[] = INITQFNAMES;
62 +static const char * const quotatypes[] = INITQFNAMES;
63  #define QTYPE2NAME(t) (quotatypes[t])
65  static int ext4_write_dquot(struct dquot *dquot);
66 @@ -1424,7 +1424,8 @@ static ext4_fsblk_t get_sb_block(void **data)
67  }
69  #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
70 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
71 +static const char deprecated_msg[] =
72 +       "Mount option \"%s\" will be removed by %s\n"
73         "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
75  #ifdef CONFIG_QUOTA
76 diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
77 index 42145be5c6b4..d74dc5f81a04 100644
78 --- a/fs/ext4/sysfs.c
79 +++ b/fs/ext4/sysfs.c
80 @@ -34,7 +34,7 @@ typedef enum {
81         ptr_ext4_super_block_offset,
82  } attr_ptr_t;
84 -static const char *proc_dirname = "fs/ext4";
85 +static const char proc_dirname[] = "fs/ext4";
86  static struct proc_dir_entry *ext4_proc_root;
88  struct ext4_attr {
89 @@ -375,7 +375,7 @@ static const struct file_operations ext4_seq_##name##_fops = { \
90  PROC_FILE_SHOW_DEFN(es_shrinker_info);
91  PROC_FILE_SHOW_DEFN(options);
93 -static struct ext4_proc_files {
94 +static const struct ext4_proc_files {
95         const char *name;
96         const struct file_operations *fops;
97  } proc_files[] = {
98 @@ -388,7 +388,7 @@ static struct ext4_proc_files {
99  int ext4_register_sysfs(struct super_block *sb)
101         struct ext4_sb_info *sbi = EXT4_SB(sb);
102 -       struct ext4_proc_files *p;
103 +       const struct ext4_proc_files *p;
104         int err;
106         sbi->s_kobj.kset = &ext4_kset;
107 @@ -412,7 +412,7 @@ int ext4_register_sysfs(struct super_block *sb)
108  void ext4_unregister_sysfs(struct super_block *sb)
110         struct ext4_sb_info *sbi = EXT4_SB(sb);
111 -       struct ext4_proc_files *p;
112 +       const struct ext4_proc_files *p;
114         if (sbi->s_proc) {
115                 for (p = proc_files; p->name; p++)
116 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
117 index 67636acf7624..9ab8f334233b 100644
118 --- a/fs/ext4/xattr.c
119 +++ b/fs/ext4/xattr.c
120 @@ -81,7 +81,7 @@ static void ext4_xattr_rehash(struct ext4_xattr_header *,
121  static int ext4_xattr_list(struct dentry *dentry, char *buffer,
122                            size_t buffer_size);
124 -static const struct xattr_handler *ext4_xattr_handler_map[] = {
125 +static const struct xattr_handler * const ext4_xattr_handler_map[] = {
126         [EXT4_XATTR_INDEX_USER]              = &ext4_xattr_user_handler,
127  #ifdef CONFIG_EXT4_FS_POSIX_ACL
128         [EXT4_XATTR_INDEX_POSIX_ACL_ACCESS]  = &posix_acl_access_xattr_handler,
129 -- 
130 2.12.0