diff options
author | Anand Jain <Anand.Jain@oracle.com> | 2014-07-30 08:04:08 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-09-17 16:37:58 -0400 |
commit | 98b3d389eb473f28ef69547c0a9f72041c4c40e6 (patch) | |
tree | 50cb465af49f0c2ebe023f34c3599310d6da4956 /fs | |
parent | 3f4b57e09d6cbd97f92311a801e1b83992506dcd (diff) |
btrfs: code optimize: BTRFS_ATTR could handle the mode
All that uses BTRFS_ATTR want mode to be set at 0444 so just do
it at the define. And few spacing alignments.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/sysfs.c | 14 | ||||
-rw-r--r-- | fs/btrfs/sysfs.h | 11 |
2 files changed, 14 insertions, 11 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index e6a851b9ae34..a1c10886d9f2 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -242,7 +242,7 @@ static ssize_t global_rsv_size_show(struct kobject *kobj, | |||
242 | struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; | 242 | struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; |
243 | return btrfs_show_u64(&block_rsv->size, &block_rsv->lock, buf); | 243 | return btrfs_show_u64(&block_rsv->size, &block_rsv->lock, buf); |
244 | } | 244 | } |
245 | BTRFS_ATTR(global_rsv_size, 0444, global_rsv_size_show); | 245 | BTRFS_ATTR(global_rsv_size, global_rsv_size_show); |
246 | 246 | ||
247 | static ssize_t global_rsv_reserved_show(struct kobject *kobj, | 247 | static ssize_t global_rsv_reserved_show(struct kobject *kobj, |
248 | struct kobj_attribute *a, char *buf) | 248 | struct kobj_attribute *a, char *buf) |
@@ -251,7 +251,7 @@ static ssize_t global_rsv_reserved_show(struct kobject *kobj, | |||
251 | struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; | 251 | struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; |
252 | return btrfs_show_u64(&block_rsv->reserved, &block_rsv->lock, buf); | 252 | return btrfs_show_u64(&block_rsv->reserved, &block_rsv->lock, buf); |
253 | } | 253 | } |
254 | BTRFS_ATTR(global_rsv_reserved, 0444, global_rsv_reserved_show); | 254 | BTRFS_ATTR(global_rsv_reserved, global_rsv_reserved_show); |
255 | 255 | ||
256 | #define to_space_info(_kobj) container_of(_kobj, struct btrfs_space_info, kobj) | 256 | #define to_space_info(_kobj) container_of(_kobj, struct btrfs_space_info, kobj) |
257 | #define to_raid_kobj(_kobj) container_of(_kobj, struct raid_kobject, kobj) | 257 | #define to_raid_kobj(_kobj) container_of(_kobj, struct raid_kobject, kobj) |
@@ -306,7 +306,7 @@ static ssize_t btrfs_space_info_show_##field(struct kobject *kobj, \ | |||
306 | struct btrfs_space_info *sinfo = to_space_info(kobj); \ | 306 | struct btrfs_space_info *sinfo = to_space_info(kobj); \ |
307 | return btrfs_show_u64(&sinfo->field, &sinfo->lock, buf); \ | 307 | return btrfs_show_u64(&sinfo->field, &sinfo->lock, buf); \ |
308 | } \ | 308 | } \ |
309 | BTRFS_ATTR(field, 0444, btrfs_space_info_show_##field) | 309 | BTRFS_ATTR(field, btrfs_space_info_show_##field) |
310 | 310 | ||
311 | static ssize_t btrfs_space_info_show_total_bytes_pinned(struct kobject *kobj, | 311 | static ssize_t btrfs_space_info_show_total_bytes_pinned(struct kobject *kobj, |
312 | struct kobj_attribute *a, | 312 | struct kobj_attribute *a, |
@@ -325,7 +325,7 @@ SPACE_INFO_ATTR(bytes_reserved); | |||
325 | SPACE_INFO_ATTR(bytes_may_use); | 325 | SPACE_INFO_ATTR(bytes_may_use); |
326 | SPACE_INFO_ATTR(disk_used); | 326 | SPACE_INFO_ATTR(disk_used); |
327 | SPACE_INFO_ATTR(disk_total); | 327 | SPACE_INFO_ATTR(disk_total); |
328 | BTRFS_ATTR(total_bytes_pinned, 0444, btrfs_space_info_show_total_bytes_pinned); | 328 | BTRFS_ATTR(total_bytes_pinned, btrfs_space_info_show_total_bytes_pinned); |
329 | 329 | ||
330 | static struct attribute *space_info_attrs[] = { | 330 | static struct attribute *space_info_attrs[] = { |
331 | BTRFS_ATTR_PTR(flags), | 331 | BTRFS_ATTR_PTR(flags), |
@@ -411,7 +411,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj, | |||
411 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize); | 411 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize); |
412 | } | 412 | } |
413 | 413 | ||
414 | BTRFS_ATTR(nodesize, 0444, btrfs_nodesize_show); | 414 | BTRFS_ATTR(nodesize, btrfs_nodesize_show); |
415 | 415 | ||
416 | static ssize_t btrfs_sectorsize_show(struct kobject *kobj, | 416 | static ssize_t btrfs_sectorsize_show(struct kobject *kobj, |
417 | struct kobj_attribute *a, char *buf) | 417 | struct kobj_attribute *a, char *buf) |
@@ -421,7 +421,7 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj, | |||
421 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize); | 421 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize); |
422 | } | 422 | } |
423 | 423 | ||
424 | BTRFS_ATTR(sectorsize, 0444, btrfs_sectorsize_show); | 424 | BTRFS_ATTR(sectorsize, btrfs_sectorsize_show); |
425 | 425 | ||
426 | static ssize_t btrfs_clone_alignment_show(struct kobject *kobj, | 426 | static ssize_t btrfs_clone_alignment_show(struct kobject *kobj, |
427 | struct kobj_attribute *a, char *buf) | 427 | struct kobj_attribute *a, char *buf) |
@@ -431,7 +431,7 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj, | |||
431 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize); | 431 | return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->sectorsize); |
432 | } | 432 | } |
433 | 433 | ||
434 | BTRFS_ATTR(clone_alignment, 0444, btrfs_clone_alignment_show); | 434 | BTRFS_ATTR(clone_alignment, btrfs_clone_alignment_show); |
435 | 435 | ||
436 | static struct attribute *btrfs_attrs[] = { | 436 | static struct attribute *btrfs_attrs[] = { |
437 | BTRFS_ATTR_PTR(label), | 437 | BTRFS_ATTR_PTR(label), |
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index ac46df37504c..531b11ee9124 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h | |||
@@ -21,15 +21,18 @@ enum btrfs_feature_set { | |||
21 | } | 21 | } |
22 | 22 | ||
23 | #define BTRFS_ATTR_RW(_name, _mode, _show, _store) \ | 23 | #define BTRFS_ATTR_RW(_name, _mode, _show, _store) \ |
24 | static struct kobj_attribute btrfs_attr_##_name = \ | 24 | static struct kobj_attribute btrfs_attr_##_name = \ |
25 | __INIT_KOBJ_ATTR(_name, _mode, _show, _store) | 25 | __INIT_KOBJ_ATTR(_name, _mode, _show, _store) |
26 | #define BTRFS_ATTR(_name, _mode, _show) \ | 26 | |
27 | BTRFS_ATTR_RW(_name, _mode, _show, NULL) | 27 | #define BTRFS_ATTR(_name, _show) \ |
28 | BTRFS_ATTR_RW(_name, 0444, _show, NULL) | ||
29 | |||
28 | #define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr) | 30 | #define BTRFS_ATTR_PTR(_name) (&btrfs_attr_##_name.attr) |
29 | 31 | ||
30 | #define BTRFS_RAID_ATTR(_name, _show) \ | 32 | #define BTRFS_RAID_ATTR(_name, _show) \ |
31 | static struct kobj_attribute btrfs_raid_attr_##_name = \ | 33 | static struct kobj_attribute btrfs_raid_attr_##_name = \ |
32 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) | 34 | __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) |
35 | |||
33 | #define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr) | 36 | #define BTRFS_RAID_ATTR_PTR(_name) (&btrfs_raid_attr_##_name.attr) |
34 | 37 | ||
35 | 38 | ||