summaryrefslogtreecommitdiffstats
path: root/sys/geom/shsec
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/shsec
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/shsec')
-rw-r--r--sys/geom/shsec/g_shsec.c9
-rw-r--r--sys/geom/shsec/g_shsec.h6
2 files changed, 14 insertions, 1 deletions
diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c
index 5bc1ba8..acfa8fb 100644
--- a/sys/geom/shsec/g_shsec.c
+++ b/sys/geom/shsec/g_shsec.c
@@ -660,8 +660,17 @@ g_shsec_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
pp->name);
return (NULL);
}
+ /*
+ * Backward compatibility:
+ */
+ /* There was no md_provsize field in earlier versions of metadata. */
+ if (md.md_version < 1)
+ md.md_provsize = pp->mediasize;
+
if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0)
return (NULL);
+ if (md.md_provsize != pp->mediasize)
+ return (NULL);
/*
* Let's check if device already exists.
diff --git a/sys/geom/shsec/g_shsec.h b/sys/geom/shsec/g_shsec.h
index 08b8a29..af2e8a7 100644
--- a/sys/geom/shsec/g_shsec.h
+++ b/sys/geom/shsec/g_shsec.h
@@ -37,8 +37,9 @@
/*
* Version history:
* 0 - Initial version number.
+ * 1 - Added md_provsize field to metadata.
*/
-#define G_SHSEC_VERSION 0
+#define G_SHSEC_VERSION 1
#ifdef _KERNEL
#define G_SHSEC_BFLAG_FIRST 0x1
@@ -85,6 +86,7 @@ struct g_shsec_metadata {
uint16_t md_no; /* Disk number. */
uint16_t md_all; /* Number of all disks. */
char md_provider[16]; /* Hardcoded provider. */
+ uint64_t md_provsize; /* Provider's size. */
};
static __inline void
shsec_metadata_encode(const struct g_shsec_metadata *md, u_char *data)
@@ -97,6 +99,7 @@ shsec_metadata_encode(const struct g_shsec_metadata *md, u_char *data)
le16enc(data + 40, md->md_no);
le16enc(data + 42, md->md_all);
bcopy(md->md_provider, data + 44, sizeof(md->md_provider));
+ le64enc(data + 60, md->md_provsize);
}
static __inline void
shsec_metadata_decode(const u_char *data, struct g_shsec_metadata *md)
@@ -109,5 +112,6 @@ shsec_metadata_decode(const u_char *data, struct g_shsec_metadata *md)
md->md_no = le16dec(data + 40);
md->md_all = le16dec(data + 42);
bcopy(data + 44, md->md_provider, sizeof(md->md_provider));
+ md->md_provsize = le64dec(data + 60);
}
#endif /* _G_SHSEC_H_ */
OpenPOWER on IntegriCloud