* [PATCH 1/4] cmirrord add support_delay_clear option
2013-09-26 10:53 [PATCH 0/4] LVM/cmirrord support write improvement dongmao zhang
@ 2013-09-26 10:53 ` dongmao zhang
2013-09-26 10:53 ` [PATCH 2/4] cmirrord create new function _clog_flush dongmao zhang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: dongmao zhang @ 2013-09-26 10:53 UTC (permalink / raw)
To: lvm-devel
---
daemons/cmirrord/functions.c | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index f6e0918..17f588e 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -75,6 +75,7 @@ struct log_c {
FORCESYNC, /* Force a sync to happen */
} sync;
+ uint32_t support_delay_flush;
uint32_t state; /* current operational state of the log */
struct dm_list mark_list;
@@ -362,7 +363,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_pat
// 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;
@@ -373,6 +374,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
struct log_c *lc = NULL;
enum sync log_sync = DEFAULTSYNC;
uint32_t block_on_error = 0;
+ uint32_t support_delay_flush = 0;
int disk_log;
char disk_path[128];
@@ -431,6 +433,8 @@ static int _clog_ctr(char *uuid, uint64_t luid,
log_sync = NOSYNC;
else if (!strcmp(argv[i], "block_on_error"))
block_on_error = 1;
+ else if (!strcmp(argv[i], "support_delay_flush") && version > 2)
+ support_delay_flush = 1;
}
lc = dm_zalloc(sizeof(*lc));
@@ -451,6 +455,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
lc->log_dev_failed = 0;
strncpy(lc->uuid, uuid, DM_UUID_LEN);
lc->luid = luid;
+ lc->support_delay_flush = support_delay_flush;
if (get_log(lc->uuid, lc->luid) ||
get_pending_log(lc->uuid, lc->luid)) {
@@ -552,6 +557,8 @@ static int clog_ctr(struct dm_ulog_request *rq)
char *dev_size_str;
uint64_t device_size;
+ struct log_c *tmplc = NULL;
+
/* Sanity checks */
if (!rq->data_size) {
LOG_ERROR("Received constructor request with no data");
@@ -594,14 +601,17 @@ static int clog_ctr(struct dm_ulog_request *rq)
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 */
/* No returning data */
- if ((rq->version > 1) && !strcmp(argv[0], "clustered-disk"))
- rq->data_size = sprintf(rq->data, "%s", argv[1]) + 1;
- else
+ if ((rq->version > 1) && !strcmp(argv[0], "clustered-disk")) {
+ rq->data_size = sprintf(rq->data, "%s", argv[1]);
+ tmplc = get_pending_log(rq->uuid, rq->luid);
+ if (tmplc && tmplc->support_delay_flush)
+ rq->data_size += sprintf(rq->data + rq->data_size, " %s", "support_delay_flush") + 1;
+ } else
rq->data_size = 0;
if (r) {
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/4] cmirrord create new function _clog_flush
2013-09-26 10:53 [PATCH 0/4] LVM/cmirrord support write improvement dongmao zhang
2013-09-26 10:53 ` [PATCH 1/4] cmirrord add support_delay_clear option dongmao zhang
@ 2013-09-26 10:53 ` dongmao zhang
2013-09-26 10:53 ` [PATCH 3/4] add support_delay_flush to device-mapper dongmao zhang
2013-09-26 10:53 ` [PATCH 4/4] cluster LVM use flag DM_SUPPORT_DELAY_FLUSH dongmao zhang
3 siblings, 0 replies; 5+ messages in thread
From: dongmao zhang @ 2013-09-26 10:53 UTC (permalink / raw)
To: lvm-devel
_clog_flush is used by both clog_mark_region and clog_flush
---
daemons/cmirrord/functions.c | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index 17f588e..33e909f 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -1037,14 +1037,17 @@ static int clog_in_sync(struct dm_ulog_request *rq)
}
/*
- * clog_flush
- * @rq
+ * _clog_flush
+ * @lc
+ * @server
*
+ * real flush
+ *
+ * Returns: 0 on success, -EXXX on error
*/
-static int clog_flush(struct dm_ulog_request *rq, int server)
+static int _clog_flush(struct log_c *lc, int server)
{
int r = 0;
- struct log_c *lc = get_log(rq->uuid, rq->luid);
if (!lc)
return -EINVAL;
@@ -1057,10 +1060,10 @@ static int clog_flush(struct dm_ulog_request *rq, int server)
* if we are the server.
*/
if (server && (lc->disk_fd >= 0)) {
- r = rq->error = write_log(lc);
+ r = write_log(lc);
if (r)
LOG_ERROR("[%s] Error writing to disk log",
- SHORT_UUID(lc->uuid));
+ SHORT_UUID(lc->uuid));
else
LOG_DBG("[%s] Disk log written", SHORT_UUID(lc->uuid));
}
@@ -1068,6 +1071,21 @@ static int clog_flush(struct dm_ulog_request *rq, int server)
lc->touched = 0;
return r;
+}
+
+
+/*
+ * clog_flush
+ * @rq
+ *
+ */
+static int clog_flush(struct dm_ulog_request *rq, int server)
+{
+ int r = 0;
+ struct log_c *lc = get_log(rq->uuid, rq->luid);
+
+ r = rq->error = _clog_flush(lc, server);
+ return r;
}
@@ -1123,7 +1141,7 @@ static int mark_region(struct log_c *lc, uint64_t region, uint32_t who)
*
* 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 dm_ulog_request *rq, uint32_t originator, int server)
{
int r;
int count;
@@ -1149,6 +1167,12 @@ static int clog_mark_region(struct dm_ulog_request *rq, uint32_t originator)
rq->data_size = 0;
+ /*if kernel support delay clear flush, cmirrord could
+ *run flush immediatly after mark region*/
+
+ if(lc->support_delay_flush)
+ return _clog_flush(lc, server);
+
return 0;
}
@@ -1686,7 +1710,7 @@ int do_request(struct clog_request *rq, int server)
r = clog_flush(&rq->u_rq, server);
break;
case DM_ULOG_MARK_REGION:
- r = clog_mark_region(&rq->u_rq, rq->originator);
+ r = clog_mark_region(&rq->u_rq, rq->originator, server);
break;
case DM_ULOG_CLEAR_REGION:
r = clog_clear_region(&rq->u_rq, rq->originator);
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/4] add support_delay_flush to device-mapper
2013-09-26 10:53 [PATCH 0/4] LVM/cmirrord support write improvement dongmao zhang
2013-09-26 10:53 ` [PATCH 1/4] cmirrord add support_delay_clear option dongmao zhang
2013-09-26 10:53 ` [PATCH 2/4] cmirrord create new function _clog_flush dongmao zhang
@ 2013-09-26 10:53 ` dongmao zhang
2013-09-26 10:53 ` [PATCH 4/4] cluster LVM use flag DM_SUPPORT_DELAY_FLUSH dongmao zhang
3 siblings, 0 replies; 5+ messages in thread
From: dongmao zhang @ 2013-09-26 10:53 UTC (permalink / raw)
To: lvm-devel
---
libdm/libdevmapper.h | 3 +++
libdm/libdm-deptree.c | 8 ++++++++
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index b287eef..dab07d6 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -667,6 +667,9 @@ int dm_tree_node_add_mirror_target(struct dm_tree_node *node,
#define DM_BLOCK_ON_ERROR 0x00000004 /* On error, suspend I/O */
#define DM_CORELOG 0x00000008 /* In-memory log */
+/*for cluster raid1, delay flush to improve performance*/
+#define DM_SUPPORT_DELAY_FLUSH 0x00000010
+
int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
uint32_t region_size,
unsigned clustered,
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 752a44b..ff13b38 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -2054,6 +2054,7 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
char *params, size_t paramsize)
{
int block_on_error = 0;
+ int support_delay_flush;
int handle_errors = 0;
int dm_log_userspace = 0;
struct utsname uts;
@@ -2107,6 +2108,9 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
*/
if (KERNEL_VERSION(kmaj, kmin, krel) >= KERNEL_VERSION(2, 6, 31))
dm_log_userspace = 1;
+
+ if(seg->flags & DM_SUPPORT_DELAY_FLUSH)
+ support_delay_flush = 1;
}
/* Region size */
@@ -2164,6 +2168,10 @@ static int _mirror_emit_segment_line(struct dm_task *dmt, struct load_segment *s
if (block_on_error)
EMIT_PARAMS(pos, " block_on_error");
+ if (dm_log_userspace && support_delay_flush)
+ EMIT_PARAMS(pos, " support_delay_flush");
+
+
EMIT_PARAMS(pos, " %u ", seg->mirror_area_count);
if (_emit_areas_line(dmt, seg, params, paramsize, &pos) <= 0)
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 4/4] cluster LVM use flag DM_SUPPORT_DELAY_FLUSH
2013-09-26 10:53 [PATCH 0/4] LVM/cmirrord support write improvement dongmao zhang
` (2 preceding siblings ...)
2013-09-26 10:53 ` [PATCH 3/4] add support_delay_flush to device-mapper dongmao zhang
@ 2013-09-26 10:53 ` dongmao zhang
3 siblings, 0 replies; 5+ messages in thread
From: dongmao zhang @ 2013-09-26 10:53 UTC (permalink / raw)
To: lvm-devel
---
lib/mirror/mirrored.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/mirror/mirrored.c b/lib/mirror/mirrored.c
index c3eb27b..af69859 100644
--- a/lib/mirror/mirrored.c
+++ b/lib/mirror/mirrored.c
@@ -378,6 +378,10 @@ static int _add_log(struct dm_pool *mem, struct lv_segment *seg,
if (_block_on_error_available && !(seg->status & PVMOVE))
log_flags |= DM_BLOCK_ON_ERROR;
+ /*clustered log support delay flush*/
+ if(clustered)
+ log_flags |= DM_SUPPORT_DELAY_FLUSH;
+
return dm_tree_node_add_mirror_target_log(node, region_size, clustered, log_dlid, area_count, log_flags);
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 5+ messages in thread