summaryrefslogtreecommitdiffstats
path: root/sys/geom/raid3/g_raid3.h
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2005-02-27 23:07:47 +0000
committerpjd <pjd@FreeBSD.org>2005-02-27 23:07:47 +0000
commit668a0286708d7bde5d5f9e9076fa8ffe8ec62f34 (patch)
treef9b8b8d23d31087c21fbc78a229ae7d39ac1bfb1 /sys/geom/raid3/g_raid3.h
parenta8b71d95fab6042a43dfe6aa45b43537a7eb00ba (diff)
downloadFreeBSD-src-668a0286708d7bde5d5f9e9076fa8ffe8ec62f34.zip
FreeBSD-src-668a0286708d7bde5d5f9e9076fa8ffe8ec62f34.tar.gz
- Add md_provsize field to metadata, which will help with
shared-last-sector problem. After this change, even if there is more than one provider with the same last sector, the proper one will be chosen based on its size. It still doesn't fix the 'c' partition problem (when da0s1 can be confused with da0s1c) and situation when 'a' partition starts at offset 0 (then da0s1a can be confused with da0s1 and da0s1c). One can use '-h' option there, when creating device or avoid sharing last sector. Actually, when providers share the same last sector and their size is equal, they provide exactly the same data, so the name (da0s1, da0s1a, da0s1c) isn't important at all. - Provide backward compatibility. - Update copyright's year. MFC after: 1 week
Diffstat (limited to 'sys/geom/raid3/g_raid3.h')
-rw-r--r--sys/geom/raid3/g_raid3.h48
1 files changed, 45 insertions, 3 deletions
diff --git a/sys/geom/raid3/g_raid3.h b/sys/geom/raid3/g_raid3.h
index 3c11d4e..0f4ac18 100644
--- a/sys/geom/raid3/g_raid3.h
+++ b/sys/geom/raid3/g_raid3.h
@@ -41,8 +41,9 @@
* 1 - Added 'round-robin reading' algorithm.
* 2 - Added 'verify reading' algorithm.
* 3 - Added md_genid field to metadata.
+ * 4 - Added md_provsize field to metadata.
*/
-#define G_RAID3_VERSION 3
+#define G_RAID3_VERSION 4
#define G_RAID3_DISK_FLAG_DIRTY 0x0000000000000001ULL
#define G_RAID3_DISK_FLAG_SYNCHRONIZING 0x0000000000000002ULL
@@ -235,6 +236,7 @@ struct g_raid3_metadata {
uint64_t md_mflags; /* Additional device flags. */
uint64_t md_dflags; /* Additional disk flags. */
char md_provider[16]; /* Hardcoded provider. */
+ uint64_t md_provsize; /* Provider's size. */
u_char md_hash[16]; /* MD5 hash. */
};
static __inline void
@@ -256,10 +258,11 @@ raid3_metadata_encode(struct g_raid3_metadata *md, u_char *data)
le64enc(data + 72, md->md_mflags);
le64enc(data + 80, md->md_dflags);
bcopy(md->md_provider, data + 88, 16);
+ le64enc(data + 104, md->md_provsize);
MD5Init(&ctx);
- MD5Update(&ctx, data, 104);
+ MD5Update(&ctx, data, 112);
MD5Final(md->md_hash, &ctx);
- bcopy(md->md_hash, data + 104, 16);
+ bcopy(md->md_hash, data + 112, 16);
}
static __inline int
raid3_metadata_decode_v0v1v2(const u_char *data, struct g_raid3_metadata *md)
@@ -283,6 +286,11 @@ raid3_metadata_decode_v0v1v2(const u_char *data, struct g_raid3_metadata *md)
MD5Final(md->md_hash, &ctx);
if (bcmp(md->md_hash, data + 100, 16) != 0)
return (EINVAL);
+
+ /* New fields. */
+ md->md_genid = 0;
+ md->md_provsize = 0;
+
return (0);
}
static __inline int
@@ -308,6 +316,36 @@ raid3_metadata_decode_v3(const u_char *data, struct g_raid3_metadata *md)
MD5Final(md->md_hash, &ctx);
if (bcmp(md->md_hash, data + 104, 16) != 0)
return (EINVAL);
+
+ /* New fields. */
+ md->md_provsize = 0;
+
+ return (0);
+}
+static __inline int
+raid3_metadata_decode_v4(const u_char *data, struct g_raid3_metadata *md)
+{
+ MD5_CTX ctx;
+
+ bcopy(data + 20, md->md_name, 16);
+ md->md_id = le32dec(data + 36);
+ md->md_no = le16dec(data + 40);
+ md->md_all = le16dec(data + 42);
+ md->md_genid = le32dec(data + 44);
+ md->md_syncid = le32dec(data + 48);
+ md->md_mediasize = le64dec(data + 52);
+ md->md_sectorsize = le32dec(data + 60);
+ md->md_sync_offset = le64dec(data + 64);
+ md->md_mflags = le64dec(data + 72);
+ md->md_dflags = le64dec(data + 80);
+ bcopy(data + 88, md->md_provider, 16);
+ md->md_provsize = le64dec(data + 104);
+ bcopy(data + 112, md->md_hash, 16);
+ MD5Init(&ctx);
+ MD5Update(&ctx, data, 112);
+ MD5Final(md->md_hash, &ctx);
+ if (bcmp(md->md_hash, data + 112, 16) != 0)
+ return (EINVAL);
return (0);
}
static __inline int
@@ -326,6 +364,9 @@ raid3_metadata_decode(const u_char *data, struct g_raid3_metadata *md)
case 3:
error = raid3_metadata_decode_v3(data, md);
break;
+ case 4:
+ error = raid3_metadata_decode_v4(data, md);
+ break;
default:
error = EINVAL;
break;
@@ -376,6 +417,7 @@ raid3_metadata_dump(const struct g_raid3_metadata *md)
}
printf("\n");
printf("hcprovider: %s\n", md->md_provider);
+ printf(" provsize: %ju\n", (uintmax_t)md->md_provsize);
bzero(hash, sizeof(hash));
for (i = 0; i < 16; i++) {
hash[i * 2] = hex[md->md_hash[i] >> 4];
OpenPOWER on IntegriCloud