Skip to contentSkip to conversation

master - Add support for raid0/raid0_meta raid types

PATCH Heinz Mauelshagen 1 participant 1 message Jun 10, 2015 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c2c0a029fe5fcb8585039073ca49c023d237a300
Commit:        c2c0a029fe5fcb8585039073ca49c023d237a300
Parent:        fd29c7f3a171174dcd47eb8b23ff42a145cdacc6
Author:        Heinz Mauelshagen <[email protected]>
AuthorDate:    Tue Jun 9 19:56:02 2015 +0200
Committer:     Heinz Mauelshagen <[email protected]>
CommitterDate: Tue Jun 9 19:56:02 2015 +0200

Add support for raid0/raid0_meta raid types

Supports creation of raid types raid0 and raid0_meta with 'lvcreate --type (raid0|raid0_meta) ...' based on functionality available in dm-raid target version 1.0.7

The raid0 type provides access via the MD raid0 personality without metadata devices

The raid0_meta type provides access via the MD raid0 personality _with_ metadata devices, i.e. it reserves space for rmeta devices which is e.g. useful for future functional enhancements supporting conversions between raid0 and raid4/5/6/10 to ensure metadata space on raid0_meta creation.

Conversion between striped/raid0/raid0_meta LVs with striped LVs being restricted to one stripe zone (i.e. no varying stripes) is possible with 'lvconvert --type (striped|raid0|raid0_meta) ...'

lvconvert-striped-raid0.sh provides various tests

---
 WHATS_NEW                        |    1 +
 daemons/lvmetad/Makefile.in      |    3 +-
 daemons/lvmpolld/Makefile.in     |    3 +-
 lib/activate/dev_manager.c       |   14 +-
 lib/cache/lvmetad.c              |    4 -
 lib/cache/lvmetad.h              |   12 +-
 lib/config/defaults.h            |    2 +
 lib/format_text/export.c         |    6 +-
 lib/metadata/lv.c                |    1 +
 lib/metadata/lv.h                |    4 +-
 lib/metadata/lv_manip.c          |  362 ++++++----
 lib/metadata/merge.c             |    2 +-
 lib/metadata/metadata-exported.h |   12 +-
 lib/metadata/raid_manip.c        | 1483 +++++++++++++++++++++++++++++++-------
 lib/metadata/segtype.h           |  133 +++-
 lib/raid/raid.c                  |  213 +++---
 lib/uuid/uuid.c                  |    2 +-
 libdm/libdm-deptree.c            |   70 ++-
 tools/lvchange.c                 |    2 +-
 tools/lvconvert.c                |   60 +-
 tools/lvcreate.c                 |   75 ++-
 21 files changed, 1843 insertions(+), 621 deletions(-)
WHATS_NEW +1 -0
index bfcc094..db48233 100644
@@ -8,6 +8,7 @@ Version 2.02.121 -
   Do not fail polling when poll LV not found (already finished or removed).
   Replace poll_get_copy_vg/lv fns with vg_read() and find_lv() in polldaemon.
   Close all device fds only in before sleep call in polldaemon.
+  Support for raid types raid0 and raid0_meta
 
 Version 2.02.120 - 15th May 2015
 ================================
daemons/lvmetad/Makefile.in +2 -1
index 765128c..f9b997e 100644
@@ -39,7 +39,8 @@ CFLAGS += $(EXTRA_EXEC_CFLAGS)
 
 lvmetad: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
 		    $(top_builddir)/libdaemon/server/libdaemonserver.a
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LVMLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
+	$(DL_LIBS) $(LVMLIBS) $(LIBS) -rdynamic
 
 # TODO: No idea. No idea how to test either.
 #ifneq ("$(CFLOW_CMD)", "")
daemons/lvmpolld/Makefile.in +2 -1
index 8ebbb90..55f3dad 100644
@@ -38,7 +38,8 @@ CFLAGS += $(DAEMON_CFLAGS)
 
 lvmpolld: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
 		    $(top_builddir)/libdaemon/server/libdaemonserver.a
-	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LVMLIBS) $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
+	$(DL_LIBS) $(LVMLIBS) $(LIBS)
 
 install_lvmpolld: lvmpolld
 	$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
lib/activate/dev_manager.c +11 -3
index 1171f4c..38d76c4 100644
@@ -2134,6 +2134,7 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
 			    !_add_lv_to_dtree(dm, dtree, seg_lv(seg, s), 0))
 				return_0;
 			if (seg_is_raid(seg) &&
+			    seg->meta_areas && seg_metalv(seg, s) &&
 			    !_add_lv_to_dtree(dm, dtree, seg_metalv(seg, s), 0))
 				return_0;
 		}
@@ -2303,9 +2304,15 @@ int add_areas_line(struct dev_manager *dm, struct lv_segment *seg,
 					return_0;
 				continue;
 			}
-			if (!(dlid = build_dm_uuid(dm->mem, seg_metalv(seg, s), NULL)))
-				return_0;
-			if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_metale(seg, s)))
+
+			if (seg->meta_areas && seg_metalv(seg, s)) {
+				if (!(dlid = build_dm_uuid(dm->mem, seg_metalv(seg, s), NULL)))
+					return_0;
+				if (!dm_tree_node_add_target_area(node, NULL, dlid, extent_size * seg_metale(seg, s)))
+					return_0;
+
+			/* One for metadata area */
+			} else if (!dm_tree_node_add_null_area(node, 0))
 				return_0;
 
 			if (!(dlid = build_dm_uuid(dm->mem, seg_lv(seg, s), NULL)))
@@ -2632,6 +2639,7 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
 					  laopts, NULL))
 			return_0;
 		if (seg_is_raid(seg) &&
+		    seg->meta_areas && seg_metalv(seg, s) &&
 		    !_add_new_lv_to_dtree(dm, dtree, seg_metalv(seg, s),
 					  laopts, NULL))
 			return_0;
lib/cache/lvmetad.c +0 -4
index dd1219b..73a382c 100644
@@ -46,10 +46,6 @@ void lvmetad_init(struct cmd_context *cmd)
 	if (!_lvmetad_use && !access(getenv("LVM_LVMETAD_PIDFILE") ? : LVMETAD_PIDFILE, F_OK))
 		log_warn("WARNING: lvmetad is running but disabled."
 			 " Restart lvmetad before enabling it!");
-
-	if (_lvmetad_connected)
-		log_debug(INTERNAL_ERROR "Refreshing lvmetad global handle while connection with the daemon is active");
-
 	_lvmetad_cmd = cmd;
 }
 
lib/cache/lvmetad.h +5 -7
index 395bc41..6769f76 100644
@@ -29,7 +29,8 @@ typedef int (*activation_handler) (struct cmd_context *cmd,
 
 #ifdef LVMETAD_SUPPORT
 /*
- * Sets up a global handle for our process.
+ * Initialise the communication with lvmetad. Normally called by
+ * lvmcache_init. Sets up a global handle for our process.
  */
 void lvmetad_init(struct cmd_context *);
 
@@ -58,9 +59,7 @@ int lvmetad_socket_present(void);
 
 /*
  * Check whether lvmetad is active (where active means both that it is running
- * and that we have a working connection with it). It opens new connection
- * with lvmetad in the process when lvmetad is supposed to be used and the
- * connection is not open yet.
+ * and that we have a working connection with it).
  */
 int lvmetad_active(void);
 
@@ -71,9 +70,8 @@ int lvmetad_active(void);
 void lvmetad_connect_or_warn(void);
 
 /*
- * Drop connection to lvmetad. A subsequent lvmetad_connect_or_warn or
- * lvmetad_active will re-establish the connection (possibly at a
- * different socket path).
+ * Drop connection to lvmetad. A subsequent lvmetad_init() will re-establish
+ * the connection (possibly at a different socket path).
  */
 void lvmetad_disconnect(void);
 
lib/config/defaults.h +2 -0
index 6793d01..3b6a877 100644
@@ -60,7 +60,9 @@
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
 #define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
 #define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
+#define DEFAULT_RAID_MAX_IMAGES 64 /* limited by kernel failed devices bitfield in superblock (raid4/5/6 max 253) */
 #define DEFAULT_RAID_FAULT_POLICY "warn"
+#define DEFAULT_RAID_STRIPE_SIZE	(64 * 2)
 
 #define DEFAULT_DMEVENTD_RAID_LIB "libdevmapper-event-lvm2raid.so"
 #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
lib/format_text/export.c +3 -3
index 018772e..b340fc8 100644
@@ -590,14 +590,14 @@ int out_areas(struct formatter *f, const struct lv_segment *seg,
 
 			/* RAID devices are laid-out in metadata/data pairs */
 			if (!lv_is_raid_image(seg_lv(seg, s)) ||
-			    !lv_is_raid_metadata(seg_metalv(seg, s))) {
+			    (seg->meta_areas && seg_metalv(seg, s) && !lv_is_raid_metadata(seg_metalv(seg, s)))) {
 				log_error("RAID segment has non-RAID areas");
 				return 0;
 			}
 
 			outf(f, "\"%s\", \"%s\"%s",
-			     seg_metalv(seg, s)->name, seg_lv(seg, s)->name,
-			     (s == seg->area_count - 1) ? "" : ",");
+			     (seg->meta_areas && seg_metalv(seg, s)) ? seg_metalv(seg, s)->name : "-",
+			     seg_lv(seg, s)->name, (s == seg->area_count - 1) ? "" : ",");
 
 			break;
 		case AREA_UNASSIGNED:
lib/metadata/lv.c +1 -0
index 10ce906..5329b91 100644
@@ -533,6 +533,7 @@ int lv_raid_image_in_sync(const struct logical_volume *lv)
 
 	if ((seg = first_seg(lv)))
 		raid_seg = get_only_segment_using_this_lv(seg->lv);
+
 	if (!raid_seg) {
 		log_error("Failed to find RAID segment for %s", lv->name);
 		return 0;
lib/metadata/lv.h +2 -2
index 4475085..3031196 100644
@@ -35,8 +35,8 @@ struct logical_volume {
 	int32_t major;
 	int32_t minor;
 
-	uint64_t size;		/* Sectors */
-	uint32_t le_count;
+	uint64_t size;		/* Sectors visible */
+	uint32_t le_count;	/* Logical extents visible */
 
 	uint32_t origin_count;
 	uint32_t external_count;
lib/metadata/lv_manip.c +221 -141

712 lines not on this page · raw message

lib/metadata/merge.c +1 -1
index 7fd5a07..2b1c42d 100644
@@ -412,7 +412,7 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
 				continue;
 			if (lv == seg_lv(seg, s))
 				seg_found++;
-			if (seg_is_raid(seg) && (lv == seg_metalv(seg, s)))
+			if (seg_is_raid(seg) && seg->meta_areas && (lv == seg_metalv(seg, s)))
 				seg_found++;
 		}
 		if (seg_is_replicator_dev(seg)) {
lib/metadata/metadata-exported.h +10 -2
index 0e52153..9ed411a 100644
@@ -1109,6 +1109,9 @@ struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
 /* --  metadata/replicator_manip.c */
 
 /* ++  metadata/raid_manip.c */
+uint32_t raid_rmeta_extents_delta(struct cmd_context *cmd,
+				  uint32_t rimage_extents_cur, uint32_t rimage_extents_new,
+				  uint32_t region_size, uint32_t extent_size);
 int lv_is_raid_with_tracking(const struct logical_volume *lv);
 uint32_t lv_raid_image_count(const struct logical_volume *lv);
 int lv_raid_change_image_count(struct logical_volume *lv,
@@ -1118,8 +1121,13 @@ int lv_raid_split(struct logical_volume *lv, const char *split_name,
 int lv_raid_split_and_track(struct logical_volume *lv,
 			    struct dm_list *splittable_pvs);
 int lv_raid_merge(struct logical_volume *lv);
-int lv_raid_reshape(struct logical_volume *lv,
-		    const struct segment_type *new_segtype);
+int lv_raid_convert(struct logical_volume *lv,
+		    const struct segment_type *new_segtype,
+		    int yes, int force,
+		    const unsigned image_count,
+		    const unsigned stripes,
+		    const unsigned new_stripe_size,
+		    struct dm_list *allocate_pvs);
 int lv_raid_replace(struct logical_volume *lv, struct dm_list *remove_pvs,
 		    struct dm_list *allocate_pvs);
 int lv_raid_remove_missing(struct logical_volume *lv);
lib/metadata/raid_manip.c +1223 -250

1,665 lines not on this page · raw message

lib/metadata/segtype.h +100 -33

170 lines not on this page · raw message

lib/raid/raid.c +112 -101

281 lines not on this page · raw message

lib/uuid/uuid.c +1 -1
index c85b822..67162dd 100644

Lines of this file are not shown. View the raw message.

libdm/libdm-deptree.c +49 -21

70 lines not on this page · raw message

tools/lvchange.c +1 -1
index e790ea0..0b5178d 100644

Lines of this file are not shown. View the raw message.

tools/lvconvert.c +32 -28

60 lines not on this page · raw message

tools/lvcreate.c +59 -16

75 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.