btrfs: constify structs with op functions or static definitions
authorDavid Sterba <dsterba@suse.cz>
Fri, 2 Jan 2015 17:23:10 +0000 (18:23 +0100)
committerDavid Sterba <dsterba@suse.cz>
Mon, 16 Feb 2015 17:48:44 +0000 (18:48 +0100)
There are some op tables that can be easily made const, similarly the
sysfs feature and raid tables. This is motivated by PaX CONSTIFY plugin.

Signed-off-by: David Sterba <dsterba@suse.cz>
fs/btrfs/compression.c
fs/btrfs/compression.h
fs/btrfs/disk-io.c
fs/btrfs/extent_io.h
fs/btrfs/lzo.c
fs/btrfs/props.c
fs/btrfs/sysfs.c
fs/btrfs/transaction.c
fs/btrfs/volumes.c
fs/btrfs/zlib.c

index e9df8862012c6291be4ff802918ba15a6dda6744..e7a94f8cdfd71e63c7715440f9c9be448dc267ae 100644 (file)
@@ -750,7 +750,7 @@ static int comp_num_workspace[BTRFS_COMPRESS_TYPES];
 static atomic_t comp_alloc_workspace[BTRFS_COMPRESS_TYPES];
 static wait_queue_head_t comp_workspace_wait[BTRFS_COMPRESS_TYPES];
 
-static struct btrfs_compress_op *btrfs_compress_op[] = {
+static const struct btrfs_compress_op * const btrfs_compress_op[] = {
        &btrfs_zlib_compress,
        &btrfs_lzo_compress,
 };
index d181f70caae01471ca80e181818a833b41f057de..13a4dc0436c9d3072b401312b3d3bf82a789ae4e 100644 (file)
@@ -77,7 +77,7 @@ struct btrfs_compress_op {
                          size_t srclen, size_t destlen);
 };
 
-extern struct btrfs_compress_op btrfs_zlib_compress;
-extern struct btrfs_compress_op btrfs_lzo_compress;
+extern const struct btrfs_compress_op btrfs_zlib_compress;
+extern const struct btrfs_compress_op btrfs_lzo_compress;
 
 #endif
index ed5dcfe52f918f8290d9faf86d79948c2be81223..83671f847c7cb3af59da7bab2dc9368b589784a2 100644 (file)
@@ -54,7 +54,7 @@
 #include <asm/cpufeature.h>
 #endif
 
-static struct extent_io_ops btree_extent_io_ops;
+static const struct extent_io_ops btree_extent_io_ops;
 static void end_workqueue_fn(struct btrfs_work *work);
 static void free_fs_root(struct btrfs_root *root);
 static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info,
@@ -4287,7 +4287,7 @@ static int btrfs_cleanup_transaction(struct btrfs_root *root)
        return 0;
 }
 
-static struct extent_io_ops btree_extent_io_ops = {
+static const struct extent_io_ops btree_extent_io_ops = {
        .readpage_end_io_hook = btree_readpage_end_io_hook,
        .readpage_io_failed_hook = btree_io_failed_hook,
        .submit_bio_hook = btree_submit_bio_hook,
index 695b0ccfb7553e786f4c9634d3a86c0263c86321..c668f36898d3a4c2dd2e0e18456dd2cfa6c55747 100644 (file)
@@ -97,7 +97,7 @@ struct extent_io_tree {
        u64 dirty_bytes;
        int track_uptodate;
        spinlock_t lock;
-       struct extent_io_ops *ops;
+       const struct extent_io_ops *ops;
 };
 
 struct extent_state {
index 617553cdb7d3b36b1b8ca6a87b28526c5a060b4d..a2f0513477313fb6edbc4f898df70262eda96aef 100644 (file)
@@ -434,7 +434,7 @@ out:
        return ret;
 }
 
-struct btrfs_compress_op btrfs_lzo_compress = {
+const struct btrfs_compress_op btrfs_lzo_compress = {
        .alloc_workspace        = lzo_alloc_workspace,
        .free_workspace         = lzo_free_workspace,
        .compress_pages         = lzo_compress_pages,
index 129b1dd28527135f2d3e33f0f3441d246f4b9235..dca137b04095fc509390b2c02d4ca6ad1752ee74 100644 (file)
@@ -425,3 +425,5 @@ static const char *prop_compression_extract(struct inode *inode)
 
        return NULL;
 }
+
+
index 94edb0a2a026652b6cb017f45cc5e1ef9d521277..e8a4c86d274d5c82cda9fc7ac40c6974f429ece8 100644 (file)
@@ -459,7 +459,7 @@ static inline struct btrfs_fs_info *to_fs_info(struct kobject *kobj)
 static char btrfs_unknown_feature_names[3][NUM_FEATURE_BITS][13];
 static struct btrfs_feature_attr btrfs_feature_attrs[3][NUM_FEATURE_BITS];
 
-static u64 supported_feature_masks[3] = {
+static const u64 supported_feature_masks[3] = {
        [FEAT_COMPAT]    = BTRFS_FEATURE_COMPAT_SUPP,
        [FEAT_COMPAT_RO] = BTRFS_FEATURE_COMPAT_RO_SUPP,
        [FEAT_INCOMPAT]  = BTRFS_FEATURE_INCOMPAT_SUPP,
index 038fcf6051e001a9e2f876468b9b4f91956f6e45..dde9d285308ecb3a0f67ac192d150654e76d67fa 100644 (file)
@@ -35,7 +35,7 @@
 
 #define BTRFS_ROOT_TRANS_TAG 0
 
-static unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {
+static const unsigned int btrfs_blocked_trans_types[TRANS_STATE_MAX] = {
        [TRANS_STATE_RUNNING]           = 0U,
        [TRANS_STATE_BLOCKED]           = (__TRANS_USERSPACE |
                                           __TRANS_START),
index cd4d1315aaa92d43476a9e86c521e94a04519d0e..33ed9df08a9cfaa8851e85e7610de00aaec36ae1 100644 (file)
@@ -4131,7 +4131,7 @@ static int btrfs_cmp_device_info(const void *a, const void *b)
        return 0;
 }
 
-static struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
+static const struct btrfs_raid_attr btrfs_raid_array[BTRFS_NR_RAID_TYPES] = {
        [BTRFS_RAID_RAID10] = {
                .sub_stripes    = 2,
                .dev_stripes    = 1,
index fb22fd8d8fb8fad73cb4d2b63d4d525da3eea876..82990b8f872b6d455be25196ee88a97eb82bd932 100644 (file)
@@ -403,7 +403,7 @@ next:
        return ret;
 }
 
-struct btrfs_compress_op btrfs_zlib_compress = {
+const struct btrfs_compress_op btrfs_zlib_compress = {
        .alloc_workspace        = zlib_alloc_workspace,
        .free_workspace         = zlib_free_workspace,
        .compress_pages         = zlib_compress_pages,