diff options
author | pjd <pjd@FreeBSD.org> | 2005-02-27 23:07:47 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2005-02-27 23:07:47 +0000 |
commit | 668a0286708d7bde5d5f9e9076fa8ffe8ec62f34 (patch) | |
tree | f9b8b8d23d31087c21fbc78a229ae7d39ac1bfb1 /sbin/geom | |
parent | a8b71d95fab6042a43dfe6aa45b43537a7eb00ba (diff) | |
download | FreeBSD-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 'sbin/geom')
-rw-r--r-- | sbin/geom/class/concat/geom_concat.c | 9 | ||||
-rw-r--r-- | sbin/geom/class/label/geom_label.c | 8 | ||||
-rw-r--r-- | sbin/geom/class/mirror/geom_mirror.c | 4 | ||||
-rw-r--r-- | sbin/geom/class/raid3/geom_raid3.c | 10 | ||||
-rw-r--r-- | sbin/geom/class/shsec/geom_shsec.c | 10 | ||||
-rw-r--r-- | sbin/geom/class/stripe/geom_stripe.c | 10 |
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 5bb64ec..8fa5d64 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 b0dfcd1..16aa918 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 de24072..b7668b7 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 7f944c3..09d1f79 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 ae6594c..8a3509b 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 2ba362c..0320b27 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 { |