summaryrefslogtreecommitdiffstats
path: root/xlators/storage/bd_map/src/bd_map.h
diff options
context:
space:
mode:
authorM. Mohan Kumar <mohan@in.ibm.com>2012-11-29 21:46:05 +0530
committerVijay Bellur <vbellur@redhat.com>2012-11-29 09:35:20 -0800
commitee968619cf936f0e25299beb1996abc27ed3dc72 (patch)
tree746bba7ee5bc04a367ee0eb949cff1870f8c0fed /xlators/storage/bd_map/src/bd_map.h
parentb90b2c17b6b678e5aa1440a62b7588f8b7c52947 (diff)
xlators: Add Block Device(BD) backend translator
Add a new server storage xlator 'bd mapper'. Intention of this xlator is to add block device backend support to gluster. It exports block devices as regular files to the gluster client. The immediate goal of this translator is to use logical volumes to store VM images and expose them as files to QEMU/KVM. Given Volume group is represented as directory and its logical volumes as files. By exporting LUNs/LVs as regular files, it becomes possible to: * Associate each VM to a LV/LUN * Use file system commands like cp to take copy of VM images * Create linked clones of VM by doing LV snapshot at server side * Implement thin provisioning by developing a qcow2 translator As of now this patchset maps only logical volumes. BD Mapper volume file specifies which Volume group to export to the client. BD xlator exports the volume group as a directory and all logical volumes under that as regular files. BD xlator uses lvm2-devel APIs for getting the list of Volume Groups and Logical Volumes in the system. The eventual goal of this work is to support thin provisioning, snapshot, copy etc of VM images seamlessly in glusterfs storage environment BUG: 805138 Change-Id: I13b69d39d7fd199c101c8e9e4f2cf10772bdc3dd Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com> Reviewed-on: http://review.gluster.org/3551 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/storage/bd_map/src/bd_map.h')
-rw-r--r--xlators/storage/bd_map/src/bd_map.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/xlators/storage/bd_map/src/bd_map.h b/xlators/storage/bd_map/src/bd_map.h
new file mode 100644
index 00000000..974ec928
--- /dev/null
+++ b/xlators/storage/bd_map/src/bd_map.h
@@ -0,0 +1,75 @@
+/*
+ BD translator - Exports Block devices on server side as regular
+ files to client
+
+ Copyright IBM, Corp. 2012
+
+ This file is part of GlusterFS.
+
+ Author:
+ M. Mohan Kumar <mohan@in.ibm.com>
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#ifndef _BD_MAP_H
+#define _BD_MAP_H
+
+#ifndef _CONFIG_H
+#define _CONFIG_H
+#include "config.h"
+#endif
+
+#include "xlator.h"
+#include "mem-types.h"
+
+#define BD_XLATOR "block device mapper xlator"
+
+#define BACKEND_VG "vg"
+
+enum gf_bd_mem_types_ {
+ gf_bd_fd = gf_common_mt_end + 1,
+ gf_bd_private,
+ gf_bd_entry,
+ gf_bd_attr,
+ gf_bd_mt_end
+};
+
+/*
+ * Each BD/LV is represented by this data structure
+ * Usually root entry will have only children and there is no sibling for that
+ * All other entries may have children and/or sibling entries
+ * If an entry is a Volume Group it will have child (. & .. and Logical
+ * Volumes) and also other Volume groups will be a sibling for this
+ */
+typedef struct bd_entry {
+ struct list_head child; /* List to child */
+ struct list_head sibling; /* List of siblings */
+ struct bd_entry *parent;/* Parent of this node */
+ struct bd_entry *link; /* Link to actual entry, if its . or .. */
+ char name[NAME_MAX];
+ struct iatt *attr;
+ int refcnt;
+ uint64_t size;
+ pthread_rwlock_t lock;
+} bd_entry_t;
+
+
+/**
+ * bd_fd - internal structure common to file and directory fd's
+ */
+typedef struct bd_fd {
+ bd_entry_t *entry;
+ bd_entry_t *p_entry; /* Parent entry */
+} bd_fd_t;
+
+typedef struct bd_priv {
+ lvm_t handle;
+ pthread_rwlock_t lock;
+ char *vg;
+} bd_priv_t;
+
+#endif