lvm2/cmirrord_improvment_performance.patch

162 lines
4.8 KiB
Diff

Index: LVM2.2.02.111/daemons/cmirrord/cluster.c
===================================================================
--- LVM2.2.02.111.orig/daemons/cmirrord/cluster.c
+++ LVM2.2.02.111/daemons/cmirrord/cluster.c
@@ -358,6 +358,10 @@ static int handle_cluster_response(struc
/* FIXME: Ensure memcpy cannot explode */
memcpy(orig_rq, rq, sizeof(*rq) + rq->u_rq.data_size);
+ /* make sure the response of DM_ULOG_FLUSH has no payload */
+ if (orig_rq->u_rq.request_type == DM_ULOG_FLUSH)
+ orig_rq->u_rq.data_size = 0;
+
r = kernel_send(&orig_rq->u_rq);
if (r)
LOG_ERROR("Failed to send response to kernel");
Index: LVM2.2.02.111/daemons/cmirrord/functions.c
===================================================================
--- LVM2.2.02.111.orig/daemons/cmirrord/functions.c
+++ LVM2.2.02.111/daemons/cmirrord/functions.c
@@ -374,7 +374,7 @@ static int find_disk_path(char *major_mi
// return r ? -errno : 0;
}
-static int _clog_ctr(char *uuid, uint64_t luid,
+static int _clog_ctr(char *uuid, uint64_t luid, uint32_t version,
int argc, char **argv, uint64_t device_size)
{
int i;
@@ -443,6 +443,8 @@ static int _clog_ctr(char *uuid, uint64_
log_sync = NOSYNC;
else if (!strcmp(argv[i], "block_on_error"))
block_on_error = 1;
+ else if (!strcmp(argv[i], "integrated_flush") && version > 2)
+ LOG_PRINT("support integrated_flush");
}
lc = dm_zalloc(sizeof(*lc));
@@ -608,7 +610,7 @@ static int clog_ctr(struct dm_ulog_reque
return -EINVAL;
}
- r = _clog_ctr(rq->uuid, rq->luid, argc - 1, argv + 1, device_size);
+ r = _clog_ctr(rq->uuid, rq->luid, rq->version, argc - 1, argv + 1, device_size);
/* We join the CPG when we resume */
@@ -1053,12 +1055,14 @@ static int clog_in_sync(struct dm_ulog_r
return 0;
}
+static int _clog_mark_region(struct log_c * lc, struct dm_ulog_request *rq, uint32_t originator);
+
/*
* clog_flush
* @rq
*
*/
-static int clog_flush(struct dm_ulog_request *rq, int server)
+static int clog_flush(struct dm_ulog_request *rq, uint32_t originator, int server)
{
int r = 0;
struct log_c *lc = get_log(rq->uuid, rq->luid);
@@ -1069,6 +1073,15 @@ static int clog_flush(struct dm_ulog_req
if (!lc->touched)
return 0;
+ /* flush has payload to mark region */
+ if(rq->data_size) {
+ r = _clog_mark_region(lc, rq, originator);
+ if (r) {
+ LOG_ERROR("mark region failed in integrated flush");
+ return r;
+ }
+ }
+
/*
* Do the actual flushing of the log only
* if we are the server.
@@ -1131,25 +1144,11 @@ static int mark_region(struct log_c *lc,
return 0;
}
-/*
- * clog_mark_region
- * @rq
- *
- * rq may contain more than one mark request. We
- * can determine the number from the 'data_size' field.
- *
- * Returns: 0 on success, -EXXX on failure
- */
-static int clog_mark_region(struct dm_ulog_request *rq, uint32_t originator)
+static int _clog_mark_region(struct log_c * lc, struct dm_ulog_request *rq, uint32_t originator)
{
int r;
int count;
uint64_t *region;
- struct log_c *lc = get_log(rq->uuid, rq->luid);
-
- if (!lc)
- return -EINVAL;
-
if (rq->data_size % sizeof(uint64_t)) {
LOG_ERROR("Bad data size given for mark_region request");
return -EINVAL;
@@ -1169,6 +1168,25 @@ static int clog_mark_region(struct dm_ul
return 0;
}
+/*
+ * clog_mark_region
+ * @rq
+ *
+ * rq may contain more than one mark request. We
+ * can determine the number from the 'data_size' field.
+ *
+ * Returns: 0 on success, -EXXX on failure
+ */
+static int clog_mark_region(struct dm_ulog_request *rq, uint32_t originator)
+{
+ struct log_c *lc = get_log(rq->uuid, rq->luid);
+
+ if (!lc)
+ return -EINVAL;
+
+ return _clog_mark_region(lc, rq, originator);
+}
+
static int clear_region(struct log_c *lc, uint64_t region, uint32_t who)
{
int other_matches = 0;
@@ -1700,7 +1718,7 @@ int do_request(struct clog_request *rq,
r = clog_in_sync(&rq->u_rq);
break;
case DM_ULOG_FLUSH:
- r = clog_flush(&rq->u_rq, server);
+ r = clog_flush(&rq->u_rq, rq->originator, server);
break;
case DM_ULOG_MARK_REGION:
r = clog_mark_region(&rq->u_rq, rq->originator);
Index: LVM2.2.02.111/libdm/libdm-deptree.c
===================================================================
--- LVM2.2.02.111.orig/libdm/libdm-deptree.c
+++ LVM2.2.02.111/libdm/libdm-deptree.c
@@ -2254,10 +2254,12 @@ static int _mirror_emit_segment_line(str
return_0;
}
- if (dm_log_userspace)
- EMIT_PARAMS(pos, "userspace %u %s clustered-%s",
- log_parm_count, seg->uuid, logtype);
- else
+ /* for cluster raid1, use integrated flush to improve performance */
+ if (dm_log_userspace) {
+ log_parm_count ++; /* for integrated_flush */
+ EMIT_PARAMS(pos, "userspace %u %s %s clustered-%s",
+ log_parm_count, seg->uuid, "integrated_flush", logtype);
+ } else
EMIT_PARAMS(pos, "%s %u", logtype, log_parm_count);
if (seg->log)