summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJia Guo <guojia12@huawei.com>2018-12-28 03:32:35 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-28 15:11:45 -0500
commit874b1ef0ef5117c071f431fdebbf388eccbcc1f2 (patch)
tree60243ad32200db49d61ef6cf56e0a96525438bf3 /fs
parenta9ee3a63dbfff5237bc682b88c02d91a3c798e35 (diff)
ocfs2: optimize the reading of heartbeat data
Reading heartbeat data from lowest node rather than from zero, in cases where the node is not defined from zero, can reduce the number of sectors read. Here is a simple test data obtained with 'iostat -dmx dm-5 2', with two nodes in the cluster, node number 10, 20, respectively. Before optimization: Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util dm-5 0.00 0.00 0.50 0.50 0.01 0.00 11.00 0.00 1.00 1.00 1.00 1.50 0.15 After the optimization: Device: rrqm/s wrqm/s r/s w/s rMB/s wMB/s avgrq-sz avgqu-sz await r_await w_await svctm %util dm-5 0.00 0.00 0.50 0.50 0.00 0.00 6.00 0.00 0.50 1.00 0.00 0.50 0.05 Link: http://lkml.kernel.org/r/99fe4988-69ac-3615-a218-3042fe6fbe72@huawei.com Signed-off-by: Jia Guo <guojia12@huawei.com> Reviewed-by: Jun Piao <piaojun@huawei.com> Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com> Acked-by: Joseph Qi <jiangqi903@gmail.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <ge.changwei@h3c.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 9b2ed62dd638..f3c20b279eb2 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -582,9 +582,10 @@ bail:
582} 582}
583 583
584static int o2hb_read_slots(struct o2hb_region *reg, 584static int o2hb_read_slots(struct o2hb_region *reg,
585 unsigned int begin_slot,
585 unsigned int max_slots) 586 unsigned int max_slots)
586{ 587{
587 unsigned int current_slot=0; 588 unsigned int current_slot = begin_slot;
588 int status; 589 int status;
589 struct o2hb_bio_wait_ctxt wc; 590 struct o2hb_bio_wait_ctxt wc;
590 struct bio *bio; 591 struct bio *bio;
@@ -1093,9 +1094,14 @@ static int o2hb_highest_node(unsigned long *nodes, int numbits)
1093 return find_last_bit(nodes, numbits); 1094 return find_last_bit(nodes, numbits);
1094} 1095}
1095 1096
1097static int o2hb_lowest_node(unsigned long *nodes, int numbits)
1098{
1099 return find_first_bit(nodes, numbits);
1100}
1101
1096static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) 1102static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
1097{ 1103{
1098 int i, ret, highest_node; 1104 int i, ret, highest_node, lowest_node;
1099 int membership_change = 0, own_slot_ok = 0; 1105 int membership_change = 0, own_slot_ok = 0;
1100 unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)]; 1106 unsigned long configured_nodes[BITS_TO_LONGS(O2NM_MAX_NODES)];
1101 unsigned long live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; 1107 unsigned long live_node_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)];
@@ -1120,7 +1126,8 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
1120 } 1126 }
1121 1127
1122 highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES); 1128 highest_node = o2hb_highest_node(configured_nodes, O2NM_MAX_NODES);
1123 if (highest_node >= O2NM_MAX_NODES) { 1129 lowest_node = o2hb_lowest_node(configured_nodes, O2NM_MAX_NODES);
1130 if (highest_node >= O2NM_MAX_NODES || lowest_node >= O2NM_MAX_NODES) {
1124 mlog(ML_NOTICE, "o2hb: No configured nodes found!\n"); 1131 mlog(ML_NOTICE, "o2hb: No configured nodes found!\n");
1125 ret = -EINVAL; 1132 ret = -EINVAL;
1126 goto bail; 1133 goto bail;
@@ -1130,7 +1137,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
1130 * yet. Of course, if the node definitions have holes in them 1137 * yet. Of course, if the node definitions have holes in them
1131 * then we're reading an empty slot anyway... Consider this 1138 * then we're reading an empty slot anyway... Consider this
1132 * best-effort. */ 1139 * best-effort. */
1133 ret = o2hb_read_slots(reg, highest_node + 1); 1140 ret = o2hb_read_slots(reg, lowest_node, highest_node + 1);
1134 if (ret < 0) { 1141 if (ret < 0) {
1135 mlog_errno(ret); 1142 mlog_errno(ret);
1136 goto bail; 1143 goto bail;
@@ -1801,7 +1808,7 @@ static int o2hb_populate_slot_data(struct o2hb_region *reg)
1801 struct o2hb_disk_slot *slot; 1808 struct o2hb_disk_slot *slot;
1802 struct o2hb_disk_heartbeat_block *hb_block; 1809 struct o2hb_disk_heartbeat_block *hb_block;
1803 1810
1804 ret = o2hb_read_slots(reg, reg->hr_blocks); 1811 ret = o2hb_read_slots(reg, 0, reg->hr_blocks);
1805 if (ret) 1812 if (ret)
1806 goto out; 1813 goto out;
1807 1814