svn commit: r234406 - in stable/9/sys: conf geom/part modules/geom/geom_part modules/geom/geom_part/geom_part_ldm

Andrey V. Elsukov ae at FreeBSD.org
Wed Apr 18 04:59:48 UTC 2012


Author: ae
Date: Wed Apr 18 04:59:47 2012
New Revision: 234406
URL: http://svn.freebsd.org/changeset/base/234406

Log:
  MFC r233176:
    Add new GEOM_PART_LDM module that implements the Logical Disk Manager
    scheme. The LDM is a logical volume manager for MS Windows NT and it
    is also known as dynamic volumes. It supports about 2000 partitions
    and also provides the capability for software RAID implementations.
  
    This version implements only partitioning scheme capability and based
    on the linux-ntfs project documentation and several publications across
    the Web. NOTE: JBOD, RAID0 and RAID5 volumes aren't supported.
  
    An access to the LDM metadata is read-only. When LDM is on the disk
    partitioned with MBR we can also destroy metadata. For the GPT
    partitioned disks destroy action is not supported.
  
  MFC r233177:
    Connect geom_part_ldm module to the build.
  
  MFC r233178:
    Connect geom_part_ldm to the kernel build.
  
  MFC r233181:
    Add CTLFLAG_TUN to sysctls.
  
  MFC r233651:
    Do proper cleanup for the GPT case when an error occurs.
  
  MFC r233652:
    VMDB offset should be greater than logical volume size only for MBR.

Added:
  stable/9/sys/geom/part/g_part_ldm.c
     - copied, changed from r233176, head/sys/geom/part/g_part_ldm.c
  stable/9/sys/modules/geom/geom_part/geom_part_ldm/
     - copied from r233177, head/sys/modules/geom/geom_part/geom_part_ldm/
Modified:
  stable/9/sys/conf/NOTES
  stable/9/sys/conf/files
  stable/9/sys/conf/options
  stable/9/sys/modules/geom/geom_part/Makefile
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/conf/   (props changed)

Modified: stable/9/sys/conf/NOTES
==============================================================================
--- stable/9/sys/conf/NOTES	Wed Apr 18 04:39:37 2012	(r234405)
+++ stable/9/sys/conf/NOTES	Wed Apr 18 04:59:47 2012	(r234406)
@@ -159,6 +159,7 @@ options 	GEOM_PART_BSD		# BSD disklabel
 options 	GEOM_PART_EBR		# Extended Boot Records
 options 	GEOM_PART_EBR_COMPAT	# Backward compatible partition names
 options 	GEOM_PART_GPT		# GPT partitioning
+options 	GEOM_PART_LDM		# Logical Disk Manager
 options 	GEOM_PART_MBR		# MBR partitioning
 options 	GEOM_PART_PC98		# PC-9800 disk partitioning
 options 	GEOM_PART_VTOC8		# SMI VTOC8 disk label

Modified: stable/9/sys/conf/files
==============================================================================
--- stable/9/sys/conf/files	Wed Apr 18 04:39:37 2012	(r234405)
+++ stable/9/sys/conf/files	Wed Apr 18 04:59:47 2012	(r234406)
@@ -2241,6 +2241,7 @@ geom/part/g_part_apm.c		optional geom_pa
 geom/part/g_part_bsd.c		optional geom_part_bsd
 geom/part/g_part_ebr.c		optional geom_part_ebr
 geom/part/g_part_gpt.c		optional geom_part_gpt
+geom/part/g_part_ldm.c		optional geom_part_ldm
 geom/part/g_part_mbr.c		optional geom_part_mbr
 geom/part/g_part_pc98.c		optional geom_part_pc98
 geom/part/g_part_vtoc8.c	optional geom_part_vtoc8

Modified: stable/9/sys/conf/options
==============================================================================
--- stable/9/sys/conf/options	Wed Apr 18 04:39:37 2012	(r234405)
+++ stable/9/sys/conf/options	Wed Apr 18 04:59:47 2012	(r234406)
@@ -101,6 +101,7 @@ GEOM_PART_BSD	opt_geom.h
 GEOM_PART_EBR	opt_geom.h
 GEOM_PART_EBR_COMPAT	opt_geom.h
 GEOM_PART_GPT	opt_geom.h
+GEOM_PART_LDM	opt_geom.h
 GEOM_PART_MBR	opt_geom.h
 GEOM_PART_PC98	opt_geom.h
 GEOM_PART_VTOC8	opt_geom.h

Copied and modified: stable/9/sys/geom/part/g_part_ldm.c (from r233176, head/sys/geom/part/g_part_ldm.c)
==============================================================================
--- head/sys/geom/part/g_part_ldm.c	Mon Mar 19 13:14:44 2012	(r233176, copy source)
+++ stable/9/sys/geom/part/g_part_ldm.c	Wed Apr 18 04:59:47 2012	(r234406)
@@ -56,8 +56,8 @@ static SYSCTL_NODE(_kern_geom_part, OID_
 
 static u_int ldm_debug = 0;
 TUNABLE_INT("kern.geom.part.ldm.debug", &ldm_debug);
-SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, debug, CTLFLAG_RW,
-    &ldm_debug, 0, "Debug level");
+SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, debug,
+    CTLFLAG_RW | CTLFLAG_TUN, &ldm_debug, 0, "Debug level");
 
 /*
  * This allows access to mirrored LDM volumes. Since we do not
@@ -65,8 +65,8 @@ SYSCTL_UINT(_kern_geom_part_ldm, OID_AUT
  */
 static u_int show_mirrors = 0;
 TUNABLE_INT("kern.geom.part.ldm.show_mirrors", &show_mirrors);
-SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, show_mirrors, CTLFLAG_RW,
-    &show_mirrors, 0, "Show mirrored volumes");
+SYSCTL_UINT(_kern_geom_part_ldm, OID_AUTO, show_mirrors,
+    CTLFLAG_RW | CTLFLAG_TUN, &show_mirrors, 0, "Show mirrored volumes");
 
 #define	LDM_DEBUG(lvl, fmt, ...)	do {				\
 	if (ldm_debug >= (lvl)) {					\
@@ -495,7 +495,7 @@ ldm_privhdr_check(struct ldm_db *db, str
 		g_free(buf);
 		if (hdr.start > last ||
 		    hdr.start + hdr.size - 1 > last ||
-		    (hdr.start + hdr.size - 1 > hdr.db_offset && is_gpt) ||
+		    (hdr.start + hdr.size - 1 > hdr.db_offset && !is_gpt) ||
 		    hdr.db_size != LDM_DB_SIZE ||
 		    hdr.db_offset + LDM_DB_SIZE - 1 > last ||
 		    hdr.th_offset[0] >= LDM_DB_SIZE ||
@@ -1371,14 +1371,15 @@ g_part_ldm_read(struct g_part_table *bas
 	/* Read and parse LDM private headers. */
 	error = ldm_privhdr_check(&db, cp, table->is_gpt);
 	if (error != 0)
-		return (error);
+		goto gpt_cleanup;
 	basetable->gpt_first = table->is_gpt ? 0: db.ph.start;
 	basetable->gpt_last = basetable->gpt_first + db.ph.size - 1;
 	table->db_offset = db.ph.db_offset;
 	/* Make additional checks for GPT */
 	if (table->is_gpt) {
-		if (ldm_gpt_check(&db, cp) != 0)
-			return (ENXIO);
+		error = ldm_gpt_check(&db, cp);
+		if (error != 0)
+			goto gpt_cleanup;
 		/*
 		 * Now we should reset database offset to zero, because our
 		 * consumer cp is attached to the ms-ldm-metadata partition
@@ -1389,12 +1390,25 @@ g_part_ldm_read(struct g_part_table *bas
 	/* Read and parse LDM TOC headers. */
 	error = ldm_tochdr_check(&db, cp);
 	if (error != 0)
-		return (error);
+		goto gpt_cleanup;
 	/* Read and parse LDM VMDB header. */
 	error = ldm_vmdbhdr_check(&db, cp);
 	if (error != 0)
-		return (error);
+		goto gpt_cleanup;
 	error = ldm_vmdb_parse(&db, cp);
+	/*
+	 * For the GPT case we must detach and destroy
+	 * second consumer before return.
+	 */
+gpt_cleanup:
+	if (table->is_gpt) {
+		g_topology_lock();
+		g_access(cp, -1, 0, 0);
+		g_detach(cp);
+		g_destroy_consumer(cp);
+		g_topology_unlock();
+		cp = cp2;
+	}
 	if (error != 0)
 		return (error);
 	/* Search current disk in the disk list. */
@@ -1408,15 +1422,6 @@ g_part_ldm_read(struct g_part_table *bas
 		ldm_vmdb_free(&db);
 		return (ENXIO);
 	}
-	if (table->is_gpt) {
-		/* Second consumer is no longer needed. */
-		g_topology_lock();
-		g_access(cp, -1, 0, 0);
-		g_detach(cp);
-		g_destroy_consumer(cp);
-		g_topology_unlock();
-		cp = cp2;
-	}
 	index = 1;
 	LIST_FOREACH(vol, &db.volumes, entry) {
 		LIST_FOREACH(comp, &vol->components, entry) {

Modified: stable/9/sys/modules/geom/geom_part/Makefile
==============================================================================
--- stable/9/sys/modules/geom/geom_part/Makefile	Wed Apr 18 04:39:37 2012	(r234405)
+++ stable/9/sys/modules/geom/geom_part/Makefile	Wed Apr 18 04:59:47 2012	(r234406)
@@ -4,6 +4,7 @@ SUBDIR=	geom_part_apm \
 	geom_part_bsd \
 	geom_part_ebr \
 	geom_part_gpt \
+	geom_part_ldm \
 	geom_part_mbr \
 	geom_part_pc98 \
 	geom_part_vtoc8


More information about the svn-src-stable-9 mailing list