|
|
|
[PATCH] Fix hostraid's file_metadata_areas | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
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 <djwong@xxxxxxxxxx>
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);
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Ataraid-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/ataraid-list
![]() |