Skip to content

Commit

Permalink
btrfs: constify structs with op functions or static definitions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Sterba committed Feb 16, 2015
1 parent f749303 commit e8c9f18
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion fs/btrfs/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions fs/btrfs/compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/extent_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/lzo.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ static int lzo_decompress(struct list_head *ws, unsigned char *data_in,
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,
Expand Down
2 changes: 2 additions & 0 deletions fs/btrfs/props.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,5 @@ static const char *prop_compression_extract(struct inode *inode)

return NULL;
}


2 changes: 1 addition & 1 deletion fs/btrfs/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion fs/btrfs/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static int zlib_decompress(struct list_head *ws, unsigned char *data_in,
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,
Expand Down

0 comments on commit e8c9f18

Please sign in to comment.