summaryrefslogtreecommitdiffstats
path: root/sys/geom/label
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/label
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/label')
-rw-r--r--sys/geom/label/g_label.c16
-rw-r--r--sys/geom/label/g_label.h12
2 files changed, 25 insertions, 3 deletions
diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c
index a2f6dbd..c8908c0 100644
--- a/sys/geom/label/g_label.c
+++ b/sys/geom/label/g_label.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+ * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -238,6 +238,20 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused)
pp->name);
break;
}
+
+ /*
+ * Backward compatibility:
+ */
+ /*
+ * There was no md_provsize field in earlier versions of
+ * metadata.
+ */
+ if (md.md_version < 2)
+ md.md_provsize = pp->mediasize;
+
+ if (md.md_provsize != pp->mediasize)
+ break;
+
g_label_create(NULL, mp, pp, md.md_label, G_LABEL_DIR,
pp->mediasize - pp->sectorsize);
} while (0);
diff --git a/sys/geom/label/g_label.h b/sys/geom/label/g_label.h
index a084831..2d17bbc 100644
--- a/sys/geom/label/g_label.h
+++ b/sys/geom/label/g_label.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
+ * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -34,7 +34,12 @@
#define G_LABEL_CLASS_NAME "LABEL"
#define G_LABEL_MAGIC "GEOM::LABEL"
-#define G_LABEL_VERSION 1
+/*
+ * Version history:
+ * 1 - Initial version number.
+ * 2 - Added md_provsize field to metadata.
+ */
+#define G_LABEL_VERSION 2
#define G_LABEL_DIR "label"
#ifdef _KERNEL
@@ -68,6 +73,7 @@ struct g_label_metadata {
char md_magic[16]; /* Magic value. */
uint32_t md_version; /* Version number. */
char md_label[16]; /* Label. */
+ uint64_t md_provsize; /* Provider's size. */
};
static __inline void
label_metadata_encode(const struct g_label_metadata *md, u_char *data)
@@ -76,6 +82,7 @@ label_metadata_encode(const struct g_label_metadata *md, u_char *data)
bcopy(md->md_magic, data, sizeof(md->md_magic));
le32enc(data + 16, md->md_version);
bcopy(md->md_label, data + 20, sizeof(md->md_label));
+ le64enc(data + 36, md->md_provsize);
}
static __inline void
label_metadata_decode(const u_char *data, struct g_label_metadata *md)
@@ -84,5 +91,6 @@ label_metadata_decode(const u_char *data, struct g_label_metadata *md)
bcopy(data, md->md_magic, sizeof(md->md_magic));
md->md_version = le32dec(data + 16);
bcopy(data + 20, md->md_label, sizeof(md->md_label));
+ md->md_provsize = le64dec(data + 36);
}
#endif /* _G_LABEL_H_ */
OpenPOWER on IntegriCloud