[PATCH] Fix hostraid's file_metadata_areas

"Darrick J. Wong" <[email protected]>
Newsgroups gmane.linux.ataraid
Organization IBM LTC
Message-ID <[email protected]>
Hi there,

It seems that one can only call file_metadata once per drive.  The
current file_metadata_areas calls it thrice, leading to garbage being
written out when dmraid -rD is invoked.

The attached patch fixes this condition by only calling file_metadata
once for the entire blob of metadata.

--D

Signed-off-by: Darrick J. Wong <[email protected]>

_______________________________________________
Ataraid-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/ataraid-list
v11-asr-meta_1.patch (text/x-patch, 1.8 KB)
diff -Naurp v11.orig/lib/format/ataraid/asr.c v11-asr-meta/lib/format/ataraid/asr.c
--- v11.orig/lib/format/ataraid/asr.c	2006-02-17 09:26:44.000000000 -0800
+++ v11-asr-meta/lib/format/ataraid/asr.c	2006-07-10 18:53:10.000000000 -0700
@@ -384,29 +384,26 @@ static void file_metadata_areas(struct l
 				void *meta)
 {
 	struct asr *asr = meta;
-	
-	/*
-	 * NOTE: We could probably just register the last 17 sectors
-	 * of the drive in one big operation...
-	 */
+	uint64_t start = asr->rb.raidtbl;
+	uint8_t *buf;
 
-	/* Register the reserved block. */
-	file_metadata(lc, handler, di->path, &asr->rb, ASR_DISK_BLOCK_SIZE,
-		      ASR_CONFIGOFFSET);
-
-	/* Register the raid table. */
-	file_metadata(lc, handler, di->path, &asr->rt, ASR_DISK_BLOCK_SIZE,
-		      (uint64_t)asr->rb.raidtbl * ASR_DISK_BLOCK_SIZE);
+	/* Read the metadata off the disk and save it. */
+	if (!(buf = dbg_malloc((di->sectors - start) *
+			       ASR_DISK_BLOCK_SIZE)))
+		LOG_ERR(lc, , "Unable to allocate memory.");
+
+	if (!read_file(lc, handler, di->path, buf,
+		       (di->sectors - start) * ASR_DISK_BLOCK_SIZE,
+		       start * ASR_DISK_BLOCK_SIZE)) {
+		dbg_free(buf);
+		LOG_ERR(lc, , "Unable to read metadata.");
+	}
 
-	/*
-	 * Register the rest of the config table.  We need to register
-	 * all the space (i.e. maxelm), not just what we're using now.
-	 */
-	file_metadata(lc, handler, di->path, &asr->rt.ent[7],
-		      (asr->rt.maxelm-7) *
-		      sizeof(struct asr_raid_configline),
-		      (uint64_t)(asr->rb.raidtbl+1) *
-		      ASR_DISK_BLOCK_SIZE);
+	file_metadata(lc, handler, di->path, buf,
+		      (di->sectors - start) * ASR_DISK_BLOCK_SIZE,
+		      start * ASR_DISK_BLOCK_SIZE);
+
+	dbg_free(buf);
 
 	/* Record the device size if -D was specified. */
 	file_dev_size(lc, handler, di);
signature.asc (application/pgp-signature, 191 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFEswVra6vRYYgWQuURAiDoAJ4i8zdTuLBRbHjHYRGklIkXxuqKVACdHba5
PwuvoZdB6vwqG/vsjtFWskk=
=vLb0
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.