dm-raid1-cluster_logging.patch
Subsystems (2)
RFC 1/1 dm-raid1-cluster_logging.patch
This patch is still pretty raw. Outside of general clean-up, the main area that needs work is the communications piece (dm-clog-tfr.c). For some log requests, we need only know that the request was received. It would be nice if I could use the ACK field in cn_msg and not have to wait for a full reply. There's lots of other work to be done in that area too. (Is linux-net the appropriate list for asking questions about connector?)
Comments welcome,
brassow
drivers/md/dm-clog-tfr.c new file +197 -0
@@ -0,0 +1,197 @@ +/* +* Copyright (C) 2006 Red Hat, Inc. +* +* This file is released under the LGPL. +*/ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <net/sock.h> +#include <linux/workqueue.h> +#include <linux/dm-clog-tfr.h> +#include <linux/connector.h> +#include "dm.h" +#define DM_MSG_PREFIX "mirror cluster log" + +#define RQ_TYPE (x) \ + ((x) == DM_CLOG_CTR) ? "DM_CLOG_CTR" : \ + ((x) == DM_CLOG_DTR) ? "DM_CLOG_DTR" : \ + ((x) == DM_CLOG_PRESUSPEND) ? "DM_CLOG_PRESUSPEND" : \ + ((x) == DM_CLOG_POSTSUSPEND) ? "DM_CLOG_POSTSUSPEND" : \ + ((x) == DM_CLOG_RESUME) ? "DM_CLOG_RESUME" : \ + ((x) == DM_CLOG_GET_REGION_SIZE) ? "DM_CLOG_GET_REGION_SIZE" : \ + ((x) == DM_CLOG_IS_CLEAN) ? "DM_CLOG_IS_CLEAN" : \ + ((x) == DM_CLOG_IN_SYNC) ? "DM_CLOG_IN_SYNC" : \ + ((x) == DM_CLOG_FLUSH) ? "DM_CLOG_FLUSH" : \ + ((x) == DM_CLOG_MARK_REGION) ? "DM_CLOG_MARK_REGION" : \ + ((x) == DM_CLOG_CLEAR_REGION) ? "DM_CLOG_CLEAR_REGION" : \ + ((x) == DM_CLOG_GET_RESYNC_WORK) ? "DM_CLOG_GET_RESYNC_WORK" : \ + ((x) == DM_CLOG_SET_REGION_SYNC) ? "DM_CLOG_SET_REGION_SYNC" : \ + ((x) == DM_CLOG_GET_SYNC_COUNT) ? "DM_CLOG_GET_SYNC_COUNT" : \ + ((x) == DM_CLOG_STATUS_INFO) ? "DM_CLOG_STATUS_INFO" : \ + ((x) == DM_CLOG_STATUS_TABLE) ? "DM_CLOG_STATUS_TABLE" : \ + NULL + +/* +* Pre-allocated space for speed +*/ +#define DM_CLOG_PREALLOCED_SIZE 512 +static struct cn_msg *prealloced_cn_msg =NULL ; +static struct clog_tfr *prealloced_clog_tfr =NULL ; + +static struct cb_id cn_clog_id = {0x4 ,0x1 }; +static DEFINE_MUTEX (_lock); +static DECLARE_COMPLETION (recv_complete); + +struct in_pkg { +int data_size; +char data[1024 ]; +}; + +struct in_pkg recieving; + +static int dm_clog_sendto_server (struct clog_tfr *tfr) +{ +int r; +int size; +struct cn_msg *msg = prealloced_cn_msg; + +if (tfr != prealloced_clog_tfr) { + size =sizeof (*msg) +sizeof (struct clog_tfr ) + tfr->data_size; + msg =kmalloc (size,GFP_NOIO ); +if (!msg) +return -ENOMEM ; +memcpy ((msg +1 ), tfr,sizeof (struct clog_tfr ) + tfr->data_size); + } + +memset (msg,0 ,sizeof (*msg)); + + msg->id.idx = cn_clog_id.idx; + msg->id.val = cn_clog_id.val; + msg->ack =0 ; + msg->seq =0 ; + msg->len =sizeof (struct clog_tfr ) + tfr->data_size; + + r =cn_netlink_send (msg,0 ,gfp_any ()); +if (msg != prealloced_cn_msg) +kfree (msg); + +return r; +} + +static void cn_clog_callback (void *data) +{ +struct cn_msg *msg = (struct cn_msg *)data; + +memcpy (recieving.data, msg->data, msg->len); + recieving.data_size = msg->len; +complete (&recv_complete); +} + +static int dm_clog_recvfrom_server (char *rdata,int *rdata_size) +{ +int r; +struct clog_tfr *tfr; + + r =wait_for_completion_timeout (&recv_complete,20 *HZ ); +if (!r) +return -ETIMEDOUT ; + + tfr = (struct clog_tfr *)recieving.data; +if (tfr->error) { +DMERR (" tfr->request_type = %s" ,RQ_TYPE (tfr->request_type)); +DMERR (" tfr->data_size = %d" , tfr->data_size); +DMERR (" tfr->error = %d" , tfr->error); + }else if (rdata) { +if (*rdata_size < tfr->data_size) +return -ENOSPC ; +memcpy (rdata, tfr->data, tfr->data_size); + *rdata_size = tfr->data_size; + } + +return tfr->error; +} + +/* +* dm_clog_consult_server +* @uuid: log's uuid (must be DM_UUID_LEN in size) +* @request_type: +* @data: data to tx to the server +* @data_size: size of data in bytes +* @rdata: place to put return data from server +* @rdata_size: value-result (amount of space given/amount of space used) +* +* Only one process at a time can communicate with the server. +* rdata_size is undefined on failure. +* +* Returns: 0 on success, -EXXX on failure +*/ +int dm_clog_consult_server (const char *uuid,int request_type, +char *data,int data_size, +char *rdata,int *rdata_size) +{ +int r =0 ; +int overhead_size =sizeof (struct clog_tfr *) +sizeof (struct cn_msg ); +struct clog_tfr *tfr = prealloced_clog_tfr; + +if (data_size > (DM_CLOG_PREALLOCED_SIZE - overhead_size)) { +DMINFO ("Size of tfr exceeds preallocated size" ); +/* FIXME: is kmalloc sufficient if we need this much space? */ + tfr =kmalloc (data_size +sizeof (*tfr),GFP_NOIO ); + } + +if (!tfr) +return -ENOMEM ; + +mutex_lock (&_lock); + +memset (tfr,0 , data_size +sizeof (*tfr)); +memcpy (tfr->uuid, uuid,DM_UUID_LEN ); + tfr->request_type = request_type; + tfr->data_size = data_size; +if (data && data_size) +memcpy (tfr->data, data, data_size); + + r =dm_clog_sendto_server (tfr); +if (r) +DMERR ("Unable to send cluster log request to server: %d" , r); +else + r =dm_clog_recvfrom_server (rdata, rdata_size); + +if (tfr != (struct clog_tfr *)prealloced_clog_tfr) +kfree (tfr); + +mutex_unlock (&_lock); + +if (r) +DMERR ("dm_clog_consult_server failed: %d" , r); + +return r; +} + +int dm_clog_tfr_init (void ) +{ +int r; +void *prealloced; + + prealloced =kmalloc (DM_CLOG_PREALLOCED_SIZE ,GFP_KERNEL ); +if (!prealloced) +return -ENOMEM ; + + prealloced_cn_msg = prealloced; + prealloced_clog_tfr = prealloced +sizeof (struct cn_msg ); + + r =cn_add_callback (&cn_clog_id,"clulog" , cn_clog_callback); +if (r) { +cn_del_callback (&cn_clog_id); +return r; + } + +return 0 ; +} + +void dm_clog_tfr_exit (void ) +{ +cn_del_callback (&cn_clog_id); +kfree (prealloced_cn_msg); +}
drivers/md/dm-clog.c new file +658 -0
658 lines not on this page · raw message
drivers/md/Kconfig +9 -0
@@ -241,6 +241,15 @@ config DM_MIRROR Allow volume managers to mirror logical volumes, also needed for live data migration tools such as 'pvmove'. +config DM_CLOG + tristate "Mirror cluster logging (EXPERIMENTAL)" + depends on DM_MIRROR && EXPERIMENTAL + ---help--- + Cluster logging allows mirroring to become cluster-aware. + Mirror devices can be used by multiple machines at the + same time. Note: this will not make your applications + cluster-aware. + config DM_ZERO tristate "Zero target (EXPERIMENTAL)" depends on BLK_DEV_DM && EXPERIMENTAL
drivers/md/Makefile +2 -0
@@ -7,6 +7,7 @@ dm-mod-objs := dm.o dm-table.o dm-target dm-multipath-objs := dm-hw-handler.o dm-path-selector.o dm-mpath.o dm-snapshot-objs := dm-snap.o dm-exception-store.o dm-mirror-objs := dm-log.o dm-raid1.o +dm-clulog-objs := dm-clog.o dm-clog-tfr.o md-mod-objs := md.o bitmap.o raid456-objs := raid5.o raid6algos.o raid6recov.o raid6tables.o \ raid6int1.o raid6int2.o raid6int4.o \
@@ -36,6 +37,7 @@ obj-$(CONFIG_DM_MULTIPATH) += dm-multipa obj-$(CONFIG_DM_MULTIPATH_EMC) += dm-emc.o obj-$(CONFIG_DM_SNAPSHOT) += dm-snapshot.o obj-$(CONFIG_DM_MIRROR) += dm-mirror.o +obj-$(CONFIG_DM_CLOG) += dm-clulog.o obj-$(CONFIG_DM_ZERO) += dm-zero.o quiet_cmd_unroll = UNROLL $@
include/linux/dm-clog-tfr.h new file +55 -0
55 lines not on this page · raw message