aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2014-01-15 07:00:54 -0500
committerChris Mason <clm@fb.com>2014-01-28 16:20:38 -0500
commit26b47ff65bcdff8473b87680d8f876c66208087b (patch)
treeae3b44171edfed95b63efd89f86b993216c0d203 /fs/btrfs/ctree.h
parentffcfaf81795471be3c07d6e3143bff31edca5d5a (diff)
Btrfs: change the members' order of btrfs_space_info structure to reduce the cache miss
It is better that the position of the lock is close to the data which is protected by it, because they may be in the same cache line, we will load less cache lines when we access them. So we rearrange the members' position of btrfs_space_info structure to make the lock be closer to the its data. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Reviewed-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h29
1 files changed, 15 insertions, 14 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 52c96db0ec0a..84d4c052fcd9 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1105,7 +1105,7 @@ struct btrfs_qgroup_limit_item {
1105} __attribute__ ((__packed__)); 1105} __attribute__ ((__packed__));
1106 1106
1107struct btrfs_space_info { 1107struct btrfs_space_info {
1108 u64 flags; 1108 spinlock_t lock;
1109 1109
1110 u64 total_bytes; /* total bytes in the space, 1110 u64 total_bytes; /* total bytes in the space,
1111 this doesn't take mirrors into account */ 1111 this doesn't take mirrors into account */
@@ -1115,14 +1115,25 @@ struct btrfs_space_info {
1115 transaction finishes */ 1115 transaction finishes */
1116 u64 bytes_reserved; /* total bytes the allocator has reserved for 1116 u64 bytes_reserved; /* total bytes the allocator has reserved for
1117 current allocations */ 1117 current allocations */
1118 u64 bytes_readonly; /* total bytes that are read only */
1119
1120 u64 bytes_may_use; /* number of bytes that may be used for 1118 u64 bytes_may_use; /* number of bytes that may be used for
1121 delalloc/allocations */ 1119 delalloc/allocations */
1120 u64 bytes_readonly; /* total bytes that are read only */
1121
1122 unsigned int full:1; /* indicates that we cannot allocate any more
1123 chunks for this space */
1124 unsigned int chunk_alloc:1; /* set if we are allocating a chunk */
1125
1126 unsigned int flush:1; /* set if we are trying to make space */
1127
1128 unsigned int force_alloc; /* set if we need to force a chunk
1129 alloc for this space */
1130
1122 u64 disk_used; /* total bytes used on disk */ 1131 u64 disk_used; /* total bytes used on disk */
1123 u64 disk_total; /* total bytes on disk, takes mirrors into 1132 u64 disk_total; /* total bytes on disk, takes mirrors into
1124 account */ 1133 account */
1125 1134
1135 u64 flags;
1136
1126 /* 1137 /*
1127 * bytes_pinned is kept in line with what is actually pinned, as in 1138 * bytes_pinned is kept in line with what is actually pinned, as in
1128 * we've called update_block_group and dropped the bytes_used counter 1139 * we've called update_block_group and dropped the bytes_used counter
@@ -1135,21 +1146,11 @@ struct btrfs_space_info {
1135 */ 1146 */
1136 struct percpu_counter total_bytes_pinned; 1147 struct percpu_counter total_bytes_pinned;
1137 1148
1138 unsigned int full:1; /* indicates that we cannot allocate any more
1139 chunks for this space */
1140 unsigned int chunk_alloc:1; /* set if we are allocating a chunk */
1141
1142 unsigned int flush:1; /* set if we are trying to make space */
1143
1144 unsigned int force_alloc; /* set if we need to force a chunk
1145 alloc for this space */
1146
1147 struct list_head list; 1149 struct list_head list;
1148 1150
1151 struct rw_semaphore groups_sem;
1149 /* for block groups in our same type */ 1152 /* for block groups in our same type */
1150 struct list_head block_groups[BTRFS_NR_RAID_TYPES]; 1153 struct list_head block_groups[BTRFS_NR_RAID_TYPES];
1151 spinlock_t lock;
1152 struct rw_semaphore groups_sem;
1153 wait_queue_head_t wait; 1154 wait_queue_head_t wait;
1154 1155
1155 struct kobject kobj; 1156 struct kobject kobj;