aboutsummaryrefslogtreecommitdiff
path: root/sbin/geom
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2005-02-27 23:07:47 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2005-02-27 23:07:47 +0000
commite68909854c57b224cc06c261dc23dbe3b21d7f88 (patch)
treef9b8b8d23d31087c21fbc78a229ae7d39ac1bfb1 /sbin/geom
parent8045ce213d178a8c7c07fe50b650bb41a2350408 (diff)
downloadsrc-e68909854c57b224cc06c261dc23dbe3b21d7f88.tar.gz
src-e68909854c57b224cc06c261dc23dbe3b21d7f88.zip
- 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
Notes
Notes: svn path=/head/; revision=142727
Diffstat (limited to 'sbin/geom')
-rw-r--r--sbin/geom/class/concat/geom_concat.c9
-rw-r--r--sbin/geom/class/label/geom_label.c8
-rw-r--r--sbin/geom/class/mirror/geom_mirror.c4
-rw-r--r--sbin/geom/class/raid3/geom_raid3.c10
-rw-r--r--sbin/geom/class/shsec/geom_shsec.c10
-rw-r--r--sbin/geom/class/stripe/geom_stripe.c10
6 files changed, 36 insertions, 15 deletions
diff --git a/sbin/geom/class/concat/geom_concat.c b/sbin/geom/class/concat/geom_concat.c
index 5bb64ec52dab..8fa5d64d9f88 100644
--- a/sbin/geom/class/concat/geom_concat.c
+++ b/sbin/geom/class/concat/geom_concat.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
@@ -180,6 +180,13 @@ concat_label(struct gctl_req *req)
name += strlen(_PATH_DEV);
strlcpy(md.md_provider, name, sizeof(md.md_provider));
}
+ md.md_provsize = g_get_mediasize(name);
+ if (md.md_provsize == 0) {
+ fprintf(stderr, "Can't get mediasize of %s: %s.\n",
+ name, strerror(errno));
+ gctl_error(req, "Not fully done.");
+ continue;
+ }
concat_metadata_encode(&md, sector);
error = g_metadata_store(name, sector, sizeof(sector));
if (error != 0) {
diff --git a/sbin/geom/class/label/geom_label.c b/sbin/geom/class/label/geom_label.c
index b0dfcd1920b4..16aa918b7c37 100644
--- a/sbin/geom/class/label/geom_label.c
+++ b/sbin/geom/class/label/geom_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
@@ -149,6 +149,12 @@ label_label(struct gctl_req *req)
return;
}
strlcpy(md.md_label, label, sizeof(md.md_label));
+ md.md_provsize = g_get_mediasize(name);
+ if (md.md_provsize == 0) {
+ gctl_error(req, "Can't get mediasize of %s: %s.", name,
+ strerror(errno));
+ return;
+ }
/*
* Ok, store metadata.
diff --git a/sbin/geom/class/mirror/geom_mirror.c b/sbin/geom/class/mirror/geom_mirror.c
index de24072621cb..b7668b7c4bc3 100644
--- a/sbin/geom/class/mirror/geom_mirror.c
+++ b/sbin/geom/class/mirror/geom_mirror.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
@@ -268,6 +268,8 @@ mirror_label(struct gctl_req *req)
md.md_did = arc4random();
md.md_priority = i - 1;
+ md.md_provsize = g_get_mediasize(str);
+ assert(md.md_provsize != 0);
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));
else {
diff --git a/sbin/geom/class/raid3/geom_raid3.c b/sbin/geom/class/raid3/geom_raid3.c
index 7f944c316798..09d1f7939d65 100644
--- a/sbin/geom/class/raid3/geom_raid3.c
+++ b/sbin/geom/class/raid3/geom_raid3.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
@@ -265,14 +265,16 @@ raid3_label(struct gctl_req *req)
snprintf(param, sizeof(param), "arg%u", i);
str = gctl_get_asciiparam(req, param);
- msize = g_get_mediasize(str) - g_get_sectorsize(str);
- if (mediasize < msize) {
+ msize = g_get_mediasize(str);
+ ssize = g_get_sectorsize(str);
+ if (mediasize < msize - ssize) {
fprintf(stderr,
"warning: %s: only %jd bytes from %jd bytes used.\n",
- str, (intmax_t)mediasize, (intmax_t)msize);
+ str, (intmax_t)mediasize, (intmax_t)(msize - ssize));
}
md.md_no = i - 1;
+ md.md_provsize = msize;
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));
else {
diff --git a/sbin/geom/class/shsec/geom_shsec.c b/sbin/geom/class/shsec/geom_shsec.c
index ae6594ce0c09..8a3509bf31f3 100644
--- a/sbin/geom/class/shsec/geom_shsec.c
+++ b/sbin/geom/class/shsec/geom_shsec.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2005 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
@@ -181,14 +181,16 @@ shsec_label(struct gctl_req *req)
snprintf(param, sizeof(param), "arg%u", i);
name = gctl_get_asciiparam(req, param);
- msize = g_get_mediasize(name) - g_get_sectorsize(name);
- if (compsize < msize) {
+ msize = g_get_mediasize(name);
+ ssize = g_get_sectorsize(name);
+ if (compsize < msize - ssize) {
fprintf(stderr,
"warning: %s: only %jd bytes from %jd bytes used.\n",
- name, (intmax_t)compsize, (intmax_t)msize);
+ name, (intmax_t)compsize, (intmax_t)(msize - ssize));
}
md.md_no = i - 1;
+ md.md_provsize = msize;
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));
else {
diff --git a/sbin/geom/class/stripe/geom_stripe.c b/sbin/geom/class/stripe/geom_stripe.c
index 2ba362c3fe25..0320b27ef9ac 100644
--- a/sbin/geom/class/stripe/geom_stripe.c
+++ b/sbin/geom/class/stripe/geom_stripe.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
@@ -210,14 +210,16 @@ stripe_label(struct gctl_req *req)
snprintf(param, sizeof(param), "arg%u", i);
name = gctl_get_asciiparam(req, param);
- msize = g_get_mediasize(name) - g_get_sectorsize(name);
- if (compsize < msize) {
+ msize = g_get_mediasize(name);
+ ssize = g_get_sectorsize(name);
+ if (compsize < msize - ssize) {
fprintf(stderr,
"warning: %s: only %jd bytes from %jd bytes used.\n",
- name, (intmax_t)compsize, (intmax_t)msize);
+ name, (intmax_t)compsize, (intmax_t)(msize - ssize));
}
md.md_no = i - 1;
+ md.md_provsize = msize;
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));
else {