diff options
Diffstat (limited to 'lib/geom')
69 files changed, 372 insertions, 496 deletions
diff --git a/lib/geom/Makefile b/lib/geom/Makefile index 2a53278be92d..a6274d43e7e1 100644 --- a/lib/geom/Makefile +++ b/lib/geom/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - SUBDIR=${GEOM_CLASSES} .include "Makefile.inc" diff --git a/lib/geom/Makefile.classes b/lib/geom/Makefile.classes index d4e6f52e65ae..1852e35be15f 100644 --- a/lib/geom/Makefile.classes +++ b/lib/geom/Makefile.classes @@ -1,9 +1,7 @@ -# $FreeBSD$ - -.if !defined(COMPAT_32BIT) +.if !defined(COMPAT_libcompat) GEOM_CLASS_DIR?=/lib/geom .else -GEOM_CLASS_DIR?=/usr/lib32/geom +GEOM_CLASS_DIR?=/usr/lib${COMPAT_libcompat}/geom .endif GEOM_CLASSES= cache diff --git a/lib/geom/Makefile.inc b/lib/geom/Makefile.inc index 74597f8bcacd..35163127538d 100644 --- a/lib/geom/Makefile.inc +++ b/lib/geom/Makefile.inc @@ -1,5 +1,3 @@ -# $FreeBSD$ - .include <src.opts.mk> SHLIBDIR=${GEOM_CLASS_DIR} diff --git a/lib/geom/cache/Makefile b/lib/geom/cache/Makefile index e1ba031c9ffe..e307351c1de5 100644 --- a/lib/geom/cache/Makefile +++ b/lib/geom/cache/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= cache diff --git a/lib/geom/cache/Makefile.depend b/lib/geom/cache/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/cache/Makefile.depend +++ b/lib/geom/cache/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/cache/gcache.8 b/lib/geom/cache/gcache.8 index b0f1c7abf1f7..026c66b0966b 100644 --- a/lib/geom/cache/gcache.8 +++ b/lib/geom/cache/gcache.8 @@ -23,8 +23,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd January 3, 2010 .Dt GCACHE 8 .Os diff --git a/lib/geom/cache/geom_cache.c b/lib/geom/cache/geom_cache.c index 4e76da2ce7a8..7be54004f196 100644 --- a/lib/geom/cache/geom_cache.c +++ b/lib/geom/cache/geom_cache.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Ruslan Ermilov <ru@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <errno.h> #include <stdio.h> #include <stdint.h> diff --git a/lib/geom/concat/Makefile b/lib/geom/concat/Makefile index 3c370520a624..c9f9d0e38c75 100644 --- a/lib/geom/concat/Makefile +++ b/lib/geom/concat/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= concat diff --git a/lib/geom/concat/Makefile.depend b/lib/geom/concat/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/concat/Makefile.depend +++ b/lib/geom/concat/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/concat/gconcat.8 b/lib/geom/concat/gconcat.8 index 0aed6dbfb744..165f809ffba8 100644 --- a/lib/geom/concat/gconcat.8 +++ b/lib/geom/concat/gconcat.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd June 14, 2021 +.Dd January 23, 2025 .Dt GCONCAT 8 .Os .Sh NAME @@ -218,7 +216,6 @@ growfs /dev/concat/data .Xr loader.conf 5 , .Xr geom 8 , .Xr growfs 8 , -.Xr gvinum 8 , .Xr mount 8 , .Xr newfs 8 , .Xr sysctl 8 , diff --git a/lib/geom/concat/geom_concat.c b/lib/geom/concat/geom_concat.c index b8144274bf44..424f60ce0179 100644 --- a/lib/geom/concat/geom_concat.c +++ b/lib/geom/concat/geom_concat.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/eli/Makefile b/lib/geom/eli/Makefile index e36eece7a6e2..a22eacb9d7e8 100644 --- a/lib/geom/eli/Makefile +++ b/lib/geom/eli/Makefile @@ -1,15 +1,11 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc ${SRCTOP}/sys/geom/eli ${SRCTOP}/sys/crypto/sha2 +PACKAGE=geom +.PATH: ${SRCTOP}/sys/geom/eli GEOM_CLASS= eli SRCS= g_eli_crypto.c SRCS+= g_eli_hmac.c SRCS+= g_eli_key.c SRCS+= pkcs5v2.c -SRCS+= sha256c.c -SRCS+= sha512c.c LIBADD= md crypto diff --git a/lib/geom/eli/Makefile.depend b/lib/geom/eli/Makefile.depend index 3378fcd11dbc..8e5ef128814d 100644 --- a/lib/geom/eli/Makefile.depend +++ b/lib/geom/eli/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -10,7 +8,6 @@ DIRDEPS = \ lib/libcompiler_rt \ lib/libgeom \ lib/libmd \ - sbin/geom/core \ secure/lib/libcrypto \ diff --git a/lib/geom/eli/geli.8 b/lib/geom/eli/geli.8 index 1ad0c684642b..876caf67ab40 100644 --- a/lib/geom/eli/geli.8 +++ b/lib/geom/eli/geli.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd April 18, 2022 +.Dd April 24, 2024 .Dt GELI 8 .Os .Sh NAME @@ -853,6 +851,15 @@ This variable should be set in Specifies how many times the Master Key is overwritten with random values when it is destroyed. After this operation it is filled with zeros. +.It Va kern.geom.eli.use_uma_bytes +.Nm +must allocate a buffer for every write operation, used when performing +encryption. +This sysctl reports the maximum size in bytes for which geli will perform the +allocation using +.Xr uma 9 , +as opposed to +.Xr malloc 9 . .It Va kern.geom.eli.visible_passphrase : No 0 If set to 1, the passphrase entered on boot will be visible. This alternative should be used with caution as the entered @@ -865,11 +872,14 @@ Specifies how many kernel threads should be used for doing software cryptography. Its purpose is to increase performance on SMP systems. If set to 0, a CPU-pinned thread will be started for every active CPU. +Note that this variable must be set prior to attaching +.Nm +to a disk. .It Va kern.geom.eli.batch : No 0 When set to 1, can speed-up crypto operations by using batching. Batching reduces the number of interrupts by responding to a group of crypto requests with one interrupt. -The crypto card and the driver has to support this feature. +The crypto card and the driver have to support this feature. .It Va kern.geom.eli.key_cache_limit : No 8192 Specifies how many Data Keys to cache. The default limit @@ -886,13 +896,41 @@ Reports how many times we were looking up a Data Key and it was not in cache. This sysctl is not updated for providers that need fewer Data Keys than the limit specified in .Va kern.geom.eli.key_cache_limit . -.Va kern.geom.eli.unmapped_io +.It Va kern.geom.eli.unmapped_io Enable support for unmapped I/O buffers, currently implemented only on 64-bit platforms. This is an optimization which reduces the overhead of I/O processing. This variable is intended for debugging purposes and must be set in .Pa /boot/loader.conf . .El +.Sh PERFORMANCE CONSIDERATIONS +The default value of +.Va kern.geom.eli.threads +is usually good for a system with one SSD. +However, it may need to be lowered on systems with many disks, +so as to avoid creating too much thread-switching overhead. +On systems with more disks than CPUs, it's best to set this variable +to 1. +.Pp +.Nm +internally uses +.Xr malloc 9 +to allocate memory for operations larger than +.Va kern.geom.eli.use_uma_bytes , +but malloc is slow for allocations larger than +.Va vm.kmem_zmax . +So it's best to avoid writing more than +.Ms MAX(kern.geom.eli.use_uma_bytes, vm.kmem_zmax) +in a single write operation. +On systems that format +.Xr zfs 4 +on top of +.Nm , +the maximum write size can be controlled by +.Va vfs.zfs.vdev.aggregation_limit +and +.Va vfs.zfs.vdev.aggregation_limit_non_rotating +for HDDs and SSDs, respectively. .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. .Sh EXAMPLES @@ -1204,10 +1242,8 @@ after the first time a provider is attached and before it is initialized in this way. .Sh SEE ALSO .Xr crypto 4 , -.Xr gbde 4 , .Xr geom 4 , .Xr loader.conf 5 , -.Xr gbde 8 , .Xr geom 8 , .Xr crypto 9 .Sh HISTORY diff --git a/lib/geom/eli/geom_eli.c b/lib/geom/eli/geom_eli.c index 4c04a9256b5e..4dd1c5dea35d 100644 --- a/lib/geom/eli/geom_eli.c +++ b/lib/geom/eli/geom_eli.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2019 Pawel Jakub Dawidek <pawel@dawidek.net> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/mman.h> #include <sys/sysctl.h> @@ -571,27 +568,35 @@ eli_genkey_passphrase(struct gctl_req *req, struct g_eli_metadata *md, bool new, return (0); } -static unsigned char * -eli_genkey(struct gctl_req *req, struct g_eli_metadata *md, unsigned char *key, - bool new) +static bool +eli_init_key_hmac_ctx(struct gctl_req *req, struct hmac_ctx *ctx, bool new) { - struct hmac_ctx ctx; - bool nopassphrase; int nfiles; + bool nopassphrase; nopassphrase = gctl_get_int(req, new ? "nonewpassphrase" : "nopassphrase"); - g_eli_crypto_hmac_init(&ctx, NULL, 0); - - nfiles = eli_genkey_files(req, new, "keyfile", &ctx, NULL, 0); - if (nfiles == -1) - return (NULL); - else if (nfiles == 0 && nopassphrase) { + g_eli_crypto_hmac_init(ctx, NULL, 0); + nfiles = eli_genkey_files(req, new, "keyfile", ctx, NULL, 0); + if (nfiles == -1) { + return (false); + } else if (nfiles == 0 && nopassphrase) { gctl_error(req, "No key components given."); - return (NULL); + return (false); } + return (true); +} + +static unsigned char * +eli_genkey(struct gctl_req *req, const struct hmac_ctx *ctxtemplate, + struct g_eli_metadata *md, unsigned char *key, bool new) +{ + struct hmac_ctx ctx; + + memcpy(&ctx, ctxtemplate, sizeof(ctx)); + if (eli_genkey_passphrase(req, md, new, &ctx) == -1) return (NULL); @@ -600,6 +605,22 @@ eli_genkey(struct gctl_req *req, struct g_eli_metadata *md, unsigned char *key, return (key); } +static unsigned char * +eli_genkey_single(struct gctl_req *req, struct g_eli_metadata *md, + unsigned char *key, bool new) +{ + struct hmac_ctx ctx; + unsigned char *rkey; + + if (!eli_init_key_hmac_ctx(req, &ctx, new)) { + return (NULL); + } + rkey = eli_genkey(req, &ctx, md, key, new); + explicit_bzero(&ctx, sizeof(ctx)); + + return (rkey); +} + static int eli_metadata_read(struct gctl_req *req, const char *prov, struct g_eli_metadata *md) @@ -711,6 +732,7 @@ eli_init(struct gctl_req *req) intmax_t val; int error, i, nargs, nparams, param; const int one = 1; + struct hmac_ctx ctxtemplate; nargs = gctl_get_int(req, "nargs"); if (nargs <= 0) { @@ -844,6 +866,10 @@ eli_init(struct gctl_req *req) */ nparams = req->narg - nargs - 1; + /* Generate HMAC context template. */ + if (!eli_init_key_hmac_ctx(req, &ctxtemplate, true)) + return; + /* Create new child request for each provider and issue to kernel */ for (i = 0; i < nargs; i++) { r = gctl_get_handle(); @@ -885,7 +911,7 @@ eli_init(struct gctl_req *req) arc4random_buf(md.md_mkeys, sizeof(md.md_mkeys)); /* Generate user key. */ - if (eli_genkey(r, &md, key, true) == NULL) { + if (eli_genkey(r, &ctxtemplate, &md, key, true) == NULL) { /* * Error generating key - details added to geom request * by eli_genkey(). @@ -1009,6 +1035,7 @@ out: /* Clear the cached metadata, including keys. */ explicit_bzero(&md, sizeof(md)); + explicit_bzero(&ctxtemplate, sizeof(ctxtemplate)); } static void @@ -1020,6 +1047,7 @@ eli_attach(struct gctl_req *req) off_t mediasize; int i, nargs, nparams, param; const int one = 1; + struct hmac_ctx ctxtemplate; nargs = gctl_get_int(req, "nargs"); if (nargs <= 0) { @@ -1035,6 +1063,10 @@ eli_attach(struct gctl_req *req) */ nparams = req->narg - nargs - 1; + /* Generate HMAC context template. */ + if (!eli_init_key_hmac_ctx(req, &ctxtemplate, false)) + return; + /* Create new child request for each provider and issue to kernel */ for (i = 0; i < nargs; i++) { r = gctl_get_handle(); @@ -1064,7 +1096,7 @@ eli_attach(struct gctl_req *req) goto out; } - if (eli_genkey(r, &md, key, false) == NULL) { + if (eli_genkey(r, &ctxtemplate, &md, key, false) == NULL) { /* * Error generating key - details added to geom request * by eli_genkey(). @@ -1098,6 +1130,7 @@ out: /* Clear sensitive data from memory. */ explicit_bzero(cached_passphrase, sizeof(cached_passphrase)); + explicit_bzero(&ctxtemplate, sizeof(ctxtemplate)); } static void @@ -1295,7 +1328,7 @@ eli_setkey_attached(struct gctl_req *req, struct g_eli_metadata *md) old = md->md_iterations; /* Generate key for Master Key encryption. */ - if (eli_genkey(req, md, key, true) == NULL) { + if (eli_genkey_single(req, md, key, true) == NULL) { explicit_bzero(key, sizeof(key)); return; } @@ -1330,7 +1363,7 @@ eli_setkey_detached(struct gctl_req *req, const char *prov, } /* Generate key for Master Key decryption. */ - if (eli_genkey(req, md, key, false) == NULL) { + if (eli_genkey_single(req, md, key, false) == NULL) { explicit_bzero(key, sizeof(key)); return; } @@ -1387,8 +1420,14 @@ eli_setkey_detached(struct gctl_req *req, const char *prov, bcopy(mkey, mkeydst, sizeof(mkey)); explicit_bzero(mkey, sizeof(mkey)); + /* + * The previous eli_genkey() set cached_passphrase, we do not want to + * use that for the new passphrase so always prompt for it + */ + explicit_bzero(cached_passphrase, sizeof(cached_passphrase)); + /* Generate key for Master Key encryption. */ - if (eli_genkey(req, md, key, true) == NULL) { + if (eli_genkey_single(req, md, key, true) == NULL) { explicit_bzero(key, sizeof(key)); explicit_bzero(md, sizeof(*md)); return; @@ -1433,7 +1472,7 @@ eli_setkey(struct gctl_req *req) if (req->error == NULL || req->error[0] == '\0') { printf("Note, that the master key encrypted with old keys " - "and/or passphrase may still exists in a metadata backup " + "and/or passphrase may still exist in a metadata backup " "file.\n"); } } @@ -1534,7 +1573,7 @@ eli_resume(struct gctl_req *req) return; } - if (eli_genkey(req, &md, key, false) == NULL) { + if (eli_genkey_single(req, &md, key, false) == NULL) { explicit_bzero(key, sizeof(key)); return; } diff --git a/lib/geom/journal/Makefile b/lib/geom/journal/Makefile index 3be15a13a81e..b87e8283225b 100644 --- a/lib/geom/journal/Makefile +++ b/lib/geom/journal/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= journal SRCS+= geom_journal_ufs.c diff --git a/lib/geom/journal/Makefile.depend b/lib/geom/journal/Makefile.depend index 7c411851c451..9bf396c48894 100644 --- a/lib/geom/journal/Makefile.depend +++ b/lib/geom/journal/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -11,7 +9,6 @@ DIRDEPS = \ lib/libgeom \ lib/libmd \ lib/libufs \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/journal/geom_journal.c b/lib/geom/journal/geom_journal.c index 2a174c6e5b1c..85eb6f88ae84 100644 --- a/lib/geom/journal/geom_journal.c +++ b/lib/geom/journal/geom_journal.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/types.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/journal/geom_journal.h b/lib/geom/journal/geom_journal.h index 6725fe04001a..a3c7651cddb5 100644 --- a/lib/geom/journal/geom_journal.h +++ b/lib/geom/journal/geom_journal.h @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -24,8 +24,6 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * $FreeBSD$ */ #ifndef _GEOM_JOURNAL_H_ diff --git a/lib/geom/journal/geom_journal_ufs.c b/lib/geom/journal/geom_journal_ufs.c index 324be1748261..fc81663ec96a 100644 --- a/lib/geom/journal/geom_journal_ufs.c +++ b/lib/geom/journal/geom_journal_ufs.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <sys/disklabel.h> #include <sys/mount.h> diff --git a/lib/geom/journal/gjournal.8 b/lib/geom/journal/gjournal.8 index 6eb8cde821ae..f9959ffa0f3f 100644 --- a/lib/geom/journal/gjournal.8 +++ b/lib/geom/journal/gjournal.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd February 17, 2009 .Dt GJOURNAL 8 .Os @@ -63,7 +61,7 @@ The .Nm utility is used for journal configuration on the given GEOM provider. -The Journal and data may be stored on the same provider or on two separate +The journal and data may be stored on the same provider or on two separate providers. This is block level journaling, not file system level journaling, which means everything gets logged, e.g.\& for file systems, it journals both data and diff --git a/lib/geom/label/Makefile b/lib/geom/label/Makefile index 767924b78b61..823d5816be64 100644 --- a/lib/geom/label/Makefile +++ b/lib/geom/label/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= label diff --git a/lib/geom/label/Makefile.depend b/lib/geom/label/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/label/Makefile.depend +++ b/lib/geom/label/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/label/geom_label.c b/lib/geom/label/geom_label.c index f51e87ecb57d..1daf3df1c5c2 100644 --- a/lib/geom/label/geom_label.c +++ b/lib/geom/label/geom_label.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <stdio.h> diff --git a/lib/geom/label/glabel.8 b/lib/geom/label/glabel.8 index c426a06ea355..da958b52befd 100644 --- a/lib/geom/label/glabel.8 +++ b/lib/geom/label/glabel.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd March 12, 2017 +.Dd April 19, 2024 .Dt GLABEL 8 .Os .Sh NAME @@ -115,11 +113,11 @@ CD ISO9660 (directory EXT2FS (directory .Pa /dev/ext2fs/ ) . .It -REISERFS (directory -.Pa /dev/reiserfs/ ) . -.It NTFS (directory .Pa /dev/ntfs/ ) . +.It +Swap Linux (directory +.Pa /dev/swaplinux/ ) . .El .Pp Support for partition metadata is implemented for: @@ -139,14 +137,35 @@ e.g. .Pa /dev/diskid/DISK-6QG3Z026 . .Pp Generic labels created and managed solely by -.Xr glabel 8 +.Nm are created in the .Pa /dev/label/ directory. +Note that generic, automatic labels occupy some space on the device +and thus should not be added to a device already containing a file system. +In particular, +.Nm +reserves the last sector of the device to store the label information. +If the device already contains a file system, +.Nm +will overwrite the last sector, possibly damaging the file system, and the +file system may later overwrite the label sector. +Instead, create a label before initializing the file system, and initialize +that file system on the device created by +.Nm +under the +.Pa /dev/label/ +directory. +Then the file system will correctly account for the space occupied by the +generic label, +since the +.Nm +device will be one sector smaller than the device from which it was created. .Pp Note that for all label types, nested GEOM classes will cause additional device nodes to be created, with context-specific data appended to their -names. E.g. for every node like +names. +E.g. for every node like .Pa /dev/label/bigdisk there will be additional entries for any partitions which the device contains, like @@ -154,6 +173,17 @@ contains, like and .Pa /dev/label/bigdiskp1a . .Pp +.Nm +requires write access to a device to create, modify, and destroy +"automatic" labels. +It will fail to persist changes if they are applied while a file +system on the device is currently mounted. +To ensure that modifications are stored across a reboot, the file system +needs to be unmounted first. +If the device holds the system's root file system, entering into +single user mode and mounting in read-only mode is required to persist +the change. +.Pp The first argument to .Nm indicates an action to be performed: @@ -234,12 +264,13 @@ Most .Nm LABEL providers implement a .Xr sysctl 8 -flag and a tunable variable named in the above format. This flag -controls if the label provider will be active, tasting devices +flag and a tunable variable named in the above format. +This flag controls if the label provider will be active, tasting devices and creating label nodes in the -.Xr devfs 5 -tree. It is sometimes desirable to disable certain label types if -they conflict with other classes in complex GEOM topologies. +.Xr devfs 4 +tree. +It is sometimes desirable to disable certain label types if they +conflict with other classes in complex GEOM topologies. .El .Sh EXIT STATUS Exit status is 0 on success, and 1 if the command fails. diff --git a/lib/geom/mirror/Makefile b/lib/geom/mirror/Makefile index 553e44787d8b..cf0174ee0766 100644 --- a/lib/geom/mirror/Makefile +++ b/lib/geom/mirror/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= mirror diff --git a/lib/geom/mirror/Makefile.depend b/lib/geom/mirror/Makefile.depend index 7902e1927044..27e87393b549 100644 --- a/lib/geom/mirror/Makefile.depend +++ b/lib/geom/mirror/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -10,7 +8,6 @@ DIRDEPS = \ lib/libcompiler_rt \ lib/libgeom \ lib/libmd \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/mirror/geom_mirror.c b/lib/geom/mirror/geom_mirror.c index 2b1860eb7548..8b47592803d9 100644 --- a/lib/geom/mirror/geom_mirror.c +++ b/lib/geom/mirror/geom_mirror.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2009 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <err.h> #include <errno.h> diff --git a/lib/geom/mirror/gmirror.8 b/lib/geom/mirror/gmirror.8 index 44ea08bcf65b..aeffb2d948b1 100644 --- a/lib/geom/mirror/gmirror.8 +++ b/lib/geom/mirror/gmirror.8 @@ -22,15 +22,29 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd July 21, 2022 +.Dd January 23, 2025 .Dt GMIRROR 8 .Os .Sh NAME .Nm gmirror .Nd "control utility for mirrored devices" .Sh SYNOPSIS +To compile GEOM_MIRROR into your kernel, add the following lines to your +kernel configuration file: +.Bd -ragged -offset indent +.Cd "options GEOM_MIRROR" +.Ed +.Pp +Alternatively, to load the GEOM_MIRROR module at boot time, add the following +line to your +.Xr loader.conf 5 : +.Bd -literal -offset indent +geom_mirror_load="YES" +.Ed +.Pp +.No Usage of the Nm +utility: +.Pp .Nm .Cm label .Op Fl Fhnv @@ -422,7 +436,6 @@ there. .Xr geom 4 , .Xr dumpon 8 , .Xr geom 8 , -.Xr gvinum 8 , .Xr mount 8 , .Xr newfs 8 , .Xr savecore 8 , diff --git a/lib/geom/mountver/Makefile b/lib/geom/mountver/Makefile index 36c1e01e112a..6ea3705261c2 100644 --- a/lib/geom/mountver/Makefile +++ b/lib/geom/mountver/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= mountver diff --git a/lib/geom/mountver/Makefile.depend b/lib/geom/mountver/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/mountver/Makefile.depend +++ b/lib/geom/mountver/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/mountver/geom_mountver.c b/lib/geom/mountver/geom_mountver.c index 91e895e77a38..79e245377664 100644 --- a/lib/geom/mountver/geom_mountver.c +++ b/lib/geom/mountver/geom_mountver.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 Edward Tomasz Napierala <trasz@FreeBSD.org> * @@ -26,8 +26,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <stdint.h> #include <libgeom.h> diff --git a/lib/geom/mountver/gmountver.8 b/lib/geom/mountver/gmountver.8 index 96bf82ee30c0..70cdf83a8896 100644 --- a/lib/geom/mountver/gmountver.8 +++ b/lib/geom/mountver/gmountver.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd May 18, 2015 .Dt GMOUNTVER 8 .Os diff --git a/lib/geom/multipath/Makefile b/lib/geom/multipath/Makefile index 5a753e42d76d..1c7341145017 100644 --- a/lib/geom/multipath/Makefile +++ b/lib/geom/multipath/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= multipath diff --git a/lib/geom/multipath/Makefile.depend b/lib/geom/multipath/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/multipath/Makefile.depend +++ b/lib/geom/multipath/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/multipath/geom_multipath.c b/lib/geom/multipath/geom_multipath.c index 12f194ff762d..e4cb123594c3 100644 --- a/lib/geom/multipath/geom_multipath.c +++ b/lib/geom/multipath/geom_multipath.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2006 Mathew Jacob <mjacob@FreeBSD.org> * All rights reserved. @@ -26,8 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/multipath/gmultipath.8 b/lib/geom/multipath/gmultipath.8 index 7f0346e1c307..0f007196f7d4 100644 --- a/lib/geom/multipath/gmultipath.8 +++ b/lib/geom/multipath/gmultipath.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd March 17, 2022 .Dt GMULTIPATH 8 .Os diff --git a/lib/geom/nop/Makefile b/lib/geom/nop/Makefile index 9d8b69117466..294eeb4e7002 100644 --- a/lib/geom/nop/Makefile +++ b/lib/geom/nop/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= nop diff --git a/lib/geom/nop/Makefile.depend b/lib/geom/nop/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/nop/Makefile.depend +++ b/lib/geom/nop/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/nop/geom_nop.c b/lib/geom/nop/geom_nop.c index 0ba78f8d76f2..ee0cf4808f42 100644 --- a/lib/geom/nop/geom_nop.c +++ b/lib/geom/nop/geom_nop.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2006 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -27,8 +27,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdio.h> #include <stdint.h> #include <libgeom.h> diff --git a/lib/geom/nop/gnop.8 b/lib/geom/nop/gnop.8 index 67eef9e0a044..24293d143058 100644 --- a/lib/geom/nop/gnop.8 +++ b/lib/geom/nop/gnop.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd December 29, 2019 .Dt GNOP 8 .Os diff --git a/lib/geom/part/Makefile b/lib/geom/part/Makefile index e9631caf4d84..58390e299d6f 100644 --- a/lib/geom/part/Makefile +++ b/lib/geom/part/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= part diff --git a/lib/geom/part/Makefile.depend b/lib/geom/part/Makefile.depend index 29b9a504acf9..08cfc713d335 100644 --- a/lib/geom/part/Makefile.depend +++ b/lib/geom/part/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -10,7 +8,6 @@ DIRDEPS = \ lib/libcompiler_rt \ lib/libgeom \ lib/libutil \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/part/geom_part.c b/lib/geom/part/geom_part.c index 2d8f02053a69..cbbc81d3cc60 100644 --- a/lib/geom/part/geom_part.c +++ b/lib/geom/part/geom_part.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2007, 2008 Marcel Moolenaar * All rights reserved. @@ -27,10 +27,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/stat.h> -#include <sys/vtoc.h> #include <assert.h> #include <ctype.h> @@ -89,8 +86,7 @@ static _Noreturn void gpart_issue(struct gctl_req *, unsigned int); static void gpart_show(struct gctl_req *, unsigned int); static void gpart_show_geom(struct ggeom *, const char *, int); static int gpart_show_hasopt(struct gctl_req *, const char *, const char *); -static void gpart_write_partcode(struct ggeom *, int, void *, ssize_t); -static void gpart_write_partcode_vtoc8(struct ggeom *, int, void *); +static void gpart_write_partcode(struct gctl_req *, int, void *, ssize_t); static void gpart_print_error(const char *); static void gpart_backup(struct gctl_req *, unsigned int); static void gpart_restore(struct gctl_req *, unsigned int); @@ -1107,14 +1103,38 @@ gpart_bootfile_read(const char *bootfile, ssize_t *size) } static void -gpart_write_partcode(struct ggeom *gp, int idx, void *code, ssize_t size) +gpart_write_partcode(struct gctl_req *req, int idx, void *code, ssize_t size) { char dsf[128]; + struct gmesh mesh; + struct gclass *classp; + struct ggeom *gp; struct gprovider *pp; - const char *s; + const char *g, *s; char *buf; off_t bsize; - int fd; + int error, fd; + + s = gctl_get_ascii(req, "class"); + if (s == NULL) + abort(); + g = gctl_get_ascii(req, "arg0"); + if (g == NULL) + abort(); + error = geom_gettree_geom(&mesh, s, g, 0); + if (error != 0) + errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); + classp = find_class(&mesh, s); + if (classp == NULL) { + geom_deletetree(&mesh); + errx(EXIT_FAILURE, "Class %s not found.", s); + } + gp = find_geom(classp, g); + if (gp == NULL) + errx(EXIT_FAILURE, "No such geom: %s.", g); + s = find_geomcfg(gp, "scheme"); + if (s == NULL) + errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name); LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { s = find_provcfg(pp, "index"); @@ -1149,65 +1169,17 @@ gpart_write_partcode(struct ggeom *gp, int idx, void *code, ssize_t size) printf("partcode written to %s\n", pp->lg_name); } else errx(EXIT_FAILURE, "invalid partition index"); -} -static void -gpart_write_partcode_vtoc8(struct ggeom *gp, int idx, void *code) -{ - char dsf[128]; - struct gprovider *pp; - const char *s; - int installed, fd; - - installed = 0; - LIST_FOREACH(pp, &gp->lg_provider, lg_provider) { - s = find_provcfg(pp, "index"); - if (s == NULL) - continue; - if (idx != 0 && atoi(s) != idx) - continue; - snprintf(dsf, sizeof(dsf), "/dev/%s", pp->lg_name); - if (pp->lg_sectorsize != sizeof(struct vtoc8)) - errx(EXIT_FAILURE, "%s: unexpected sector " - "size (%d)\n", dsf, pp->lg_sectorsize); - if (pp->lg_mediasize < VTOC_BOOTSIZE) - continue; - fd = open(dsf, O_WRONLY); - if (fd == -1) - err(EXIT_FAILURE, "%s", dsf); - /* - * We ignore the first VTOC_BOOTSIZE bytes of boot code in - * order to avoid overwriting the label. - */ - if (lseek(fd, sizeof(struct vtoc8), SEEK_SET) != - sizeof(struct vtoc8)) - err(EXIT_FAILURE, "%s", dsf); - if (write(fd, (caddr_t)code + sizeof(struct vtoc8), - VTOC_BOOTSIZE - sizeof(struct vtoc8)) != VTOC_BOOTSIZE - - sizeof(struct vtoc8)) - err(EXIT_FAILURE, "%s", dsf); - installed++; - close(fd); - if (idx != 0 && atoi(s) == idx) - break; - } - if (installed == 0) - errx(EXIT_FAILURE, "%s: no partitions", gp->lg_name); - else - printf("partcode written to %s\n", - idx != 0 ? pp->lg_name: gp->lg_name); + geom_deletetree(&mesh); } static void gpart_bootcode(struct gctl_req *req, unsigned int fl) { - struct gmesh mesh; - struct gclass *classp; - struct ggeom *gp; - const char *g, *s; + const char *s; void *bootcode, *partcode; size_t bootsize, partsize; - int error, idx, vtoc8; + int error, idx; if (gctl_get_int(req, "nargs") != 1) errx(EXIT_FAILURE, "Invalid number of arguments."); @@ -1231,31 +1203,6 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) goto nopartcode; } - s = gctl_get_ascii(req, "class"); - if (s == NULL) - abort(); - g = gctl_get_ascii(req, "arg0"); - if (g == NULL) - abort(); - error = geom_gettree_geom(&mesh, s, g, 0); - if (error != 0) - errc(EXIT_FAILURE, error, "Cannot get GEOM tree"); - classp = find_class(&mesh, s); - if (classp == NULL) { - geom_deletetree(&mesh); - errx(EXIT_FAILURE, "Class %s not found.", s); - } - gp = find_geom(classp, g); - if (gp == NULL) - errx(EXIT_FAILURE, "No such geom: %s.", g); - s = find_geomcfg(gp, "scheme"); - if (s == NULL) - errx(EXIT_FAILURE, "Scheme not found for geom %s", gp->lg_name); - if (strcmp(s, "VTOC8") == 0) - vtoc8 = 1; - else - vtoc8 = 0; - if (gctl_has_param(req, GPART_PARAM_INDEX)) { idx = (int)gctl_get_intmax(req, GPART_PARAM_INDEX); if (idx < 1) @@ -1268,28 +1215,17 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl) if (gctl_has_param(req, GPART_PARAM_PARTCODE)) { s = gctl_get_ascii(req, GPART_PARAM_PARTCODE); - if (vtoc8 != 0) - partsize = VTOC_BOOTSIZE; - else - partsize = 1024 * 1024; /* Arbitrary limit. */ + partsize = 1024 * 1024; /* Arbitrary limit. */ partcode = gpart_bootfile_read(s, &partsize); error = gctl_delete_param(req, GPART_PARAM_PARTCODE); if (error) errc(EXIT_FAILURE, error, "internal error"); - if (vtoc8 == 0) { - if (idx == 0) - errx(EXIT_FAILURE, "missing -i option"); - gpart_write_partcode(gp, idx, partcode, partsize); - } else { - if (partsize != VTOC_BOOTSIZE) - errx(EXIT_FAILURE, "invalid bootcode"); - gpart_write_partcode_vtoc8(gp, idx, partcode); - } + if (idx == 0) + errx(EXIT_FAILURE, "missing -i option"); + gpart_write_partcode(req, idx, partcode, partsize); free(partcode); } - geom_deletetree(&mesh); - nopartcode: if (bootcode != NULL) gpart_issue(req, fl); diff --git a/lib/geom/part/gpart.8 b/lib/geom/part/gpart.8 index 4dbe45b9953e..f76c1d9d5d6c 100644 --- a/lib/geom/part/gpart.8 +++ b/lib/geom/part/gpart.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd January 26, 2022 +.Dd February 11, 2025 .Dt GPART 8 .Os .Sh NAME @@ -221,7 +219,7 @@ MBR bootcode contains Volume Serial Number by default, and .Nm tries to preserve it when installing new bootstrap code. This option skips preservation to help with some versions of -.Xr boot0 8 +.Xr boot0cfg 8 that do not support Volume Serial Number. .It Fl b Ar bootcode Embed bootstrap code from the file @@ -544,14 +542,16 @@ See Several partitioning schemes are supported by the .Nm utility: -.Bl -tag -width ".Cm VTOC8" +.Bl -tag -width ".Cm BSD64" .It Cm APM Apple Partition Map, used by PowerPC(R) Macintosh(R) computers. Requires the .Cd GEOM_PART_APM kernel option. .It Cm BSD -Traditional BSD disklabel, usually used to subdivide MBR partitions. +Traditional BSD +.Xr disklabel 8 , +usually used to subdivide MBR partitions. .Po This scheme can also be used as the sole partitioning method, without an MBR. @@ -564,7 +564,9 @@ Requires the .Cm GEOM_PART_BSD kernel option. .It Cm BSD64 -64-bit implementation of BSD disklabel used in DragonFlyBSD to subdivide MBR +64-bit implementation of BSD disklabel used in +.Dx +to subdivide MBR or GPT partitions. Requires the .Cm GEOM_PART_BSD64 @@ -595,15 +597,6 @@ The option enables backward compatibility for partition names in the EBR scheme. It also prevents any type of actions on such partitions. -.It Cm VTOC8 -Sun's SMI Volume Table Of Contents, used by -.Tn SPARC64 -and -.Tn UltraSPARC -computers. -Requires the -.Cm GEOM_PART_VTOC8 -kernel option. .El .Pp See @@ -676,36 +669,27 @@ A partition dedicated to swap space. The scheme-specific types are .Qq Li "!FreeBSD-swap" -for APM, +for APM, and .Qq Li "!516e7cb5-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0901 for VTOC8. +for GPT. .It Cm freebsd-ufs A .Fx partition that contains a UFS or UFS2 filesystem. The scheme-specific types are .Qq Li "!FreeBSD-UFS" -for APM, +for APM, and .Qq Li "!516e7cb6-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0902 for VTOC8. -.It Cm freebsd-vinum -A -.Fx -partition that contains a Vinum volume. -The scheme-specific types are -.Qq Li "!FreeBSD-Vinum" -for APM, -.Qq Li "!516e7cb8-6ecf-11d6-8ff8-00022d09712b" -for GPT, and tag 0x0903 for VTOC8. +for GPT. .It Cm freebsd-zfs A .Fx partition that contains a ZFS volume. The scheme-specific types are .Qq Li "!FreeBSD-ZFS" -for APM, +for APM, and .Qq Li "!516e7cba-6ecf-11d6-8ff8-00022d09712b" -for GPT, and 0x0904 for VTOC8. +for GPT. .El .Pp Other symbolic names that can be used with the @@ -770,50 +754,67 @@ See .Sx CAVEATS section below. .It Cm dragonfly-label32 -A DragonFlyBSD partition subdivided into filesystems with a +A +.Dx +partition subdivided into filesystems with a .Bx disklabel. The scheme-specific type is .Qq Li "!9d087404-1ca5-11dc-8817-01301bb8a9f5" for GPT. .It Cm dragonfly-label64 -A DragonFlyBSD partition subdivided into filesystems with a +A +.Dx +partition subdivided into filesystems with a disklabel64. The scheme-specific type is .Qq Li "!3d48ce54-1d16-11dc-8696-01301bb8a9f5" for GPT. .It Cm dragonfly-legacy -A legacy partition type used in DragonFlyBSD. +A legacy partition type used in +.Dx . The scheme-specific type is .Qq Li "!bd215ab2-1d16-11dc-8696-01301bb8a9f5" for GPT. .It Cm dragonfly-ccd -A DragonFlyBSD partition used with Concatenated Disk driver. +A +.Dx +partition used with Concatenated Disk driver. The scheme-specific type is .Qq Li "!dbd5211b-1ca5-11dc-8817-01301bb8a9f5" for GPT. .It Cm dragonfly-hammer -A DragonFlyBSD partition that contains a Hammer filesystem. +A +.Dx +partition that contains a Hammer filesystem. The scheme-specific type is .Qq Li "!61dc63ac-6e38-11dc-8513-01301bb8a9f5" for GPT. .It Cm dragonfly-hammer2 -A DragonFlyBSD partition that contains a Hammer2 filesystem. +A +.Dx +partition that contains a Hammer2 filesystem. The scheme-specific type is .Qq Li "!5cbb9ad1-862d-11dc-a94d-01301bb8a9f5" for GPT. .It Cm dragonfly-swap -A DragonFlyBSD partition dedicated to swap space. +A +.Dx +partition dedicated to swap space. The scheme-specific type is .Qq Li "!9d58fdbd-1ca5-11dc-8817-01301bb8a9f5" for GPT. .It Cm dragonfly-ufs -A DragonFlyBSD partition that contains an UFS1 filesystem. +A +.Dx +partition that contains an UFS1 filesystem. The scheme-specific type is .Qq Li "!9d94ce7c-1ca5-11dc-8817-01301bb8a9f5" for GPT. .It Cm dragonfly-vinum -A DragonFlyBSD partition used with Logical Volume Manager. +A +.Dx +partition used with Logical Volume Manager. The scheme-specific type is .Qq Li "!9dd4478f-1ca5-11dc-8817-01301bb8a9f5" for GPT. @@ -904,32 +905,44 @@ The scheme-specific type is .Qq Li "!5808c8aa-7e8f-42e0-85d2-e1e90434cfb3" for GPT. .It Cm netbsd-ccd -A NetBSD partition used with Concatenated Disk driver. +A +.Nx +partition used with Concatenated Disk driver. The scheme-specific type is .Qq Li "!2db519c4-b10f-11dc-b99b-0019d1879648" for GPT. .It Cm netbsd-cgd -An encrypted NetBSD partition. +An encrypted +.Nx +partition. The scheme-specific type is .Qq Li "!2db519ec-b10f-11dc-b99b-0019d1879648" for GPT. .It Cm netbsd-ffs -A NetBSD partition that contains an UFS filesystem. +A +.Nx +partition that contains an UFS filesystem. The scheme-specific type is .Qq Li "!49f48d5a-b10e-11dc-b99b-0019d1879648" for GPT. .It Cm netbsd-lfs -A NetBSD partition that contains an LFS filesystem. +A +.Nx +partition that contains an LFS filesystem. The scheme-specific type is .Qq Li "!49f48d82-b10e-11dc-b99b-0019d1879648" for GPT. .It Cm netbsd-raid -A NetBSD partition used in a software RAID configuration. +A +.Nx +partition used in a software RAID configuration. The scheme-specific type is .Qq Li "!49f48daa-b10e-11dc-b99b-0019d1879648" for GPT. .It Cm netbsd-swap -A NetBSD partition dedicated to swap space. +A +.Nx +partition dedicated to swap space. The scheme-specific type is .Qq Li "!49f48d32-b10e-11dc-b99b-0019d1879648" for GPT. @@ -986,6 +999,11 @@ A illumos/Solaris partition dedicated to reserved space. The scheme-specific type is .Qq Li "!6a945a3b-1dd2-11b2-99a6-080020736631" for GPT. +.It Cm u-boot-env +A raw partition dedicated to U-Boot for storing its environment. +The scheme-specific type is +.Qq Li "!3de21764-95bd-54bd-a5c3-4abe786f38a8" +for GPT. .It Cm vmware-vmfs A partition that contains a VMware File System (VMFS). The scheme-specific types are @@ -1163,18 +1181,6 @@ After all pools are detected, .Pa /boot/loader is started from the first one found set as bootable. .Pp -The VTOC8 scheme does not support embedding bootstrap code. -Instead, the 8 KBytes bootstrap code image -.Pa /boot/boot1 -should be written with the -.Cm gpart bootcode -command with the -.Fl p Ar bootcode -option to all sufficiently large VTOC8 partitions. -To do this the -.Fl i Ar index -option could be omitted. -.Pp The APM scheme also does not support embedding bootstrap code. Instead, the 800 KBytes bootstrap code image .Pa /boot/boot1.hfs @@ -1273,7 +1279,7 @@ GEOM class. The default value is shown next to each variable. .Bl -tag -width indent .It Va kern.geom.part.allow_nesting : No 0 -By default, some schemes (currently BSD, BSD64 and VTOC8) do not permit +By default, some schemes (currently BSD and BSD64) do not permit further nested partitioning. This variable overrides this restriction and allows arbitrary nesting (except within partitions created at offset 0). @@ -1396,7 +1402,7 @@ sizes of up to 256 kB. .Pp Finally, we create and format an 8 GB .Cm freebsd-ufs -partition for the root filesystem, leaving the rest of the slice free +partition for the root filesystem, leaving the rest of the device free for additional filesystems: .Bd -literal -offset indent /sbin/gpart add -s 8G -t freebsd-ufs ada0 @@ -1410,12 +1416,12 @@ using a traditional .Bx disklabel. .Pp -First, we create the partition table and a single 64 GB partition, -then we mark that partition active (bootable) and install the -first-stage boot loader: +First, we create the partition table as well as a single partition 64 GB in +size and an alignment of 4 kB, then we mark that partition active (bootable) +and install the first-stage boot loader: .Bd -literal -offset indent /sbin/gpart create -s MBR ada0 -/sbin/gpart add -t freebsd -s 64G ada0 +/sbin/gpart add -t freebsd -s 64G -a 4k ada0 /sbin/gpart set -a active -i 1 ada0 /sbin/gpart bootcode -b /boot/boot0 ada0 .Ed @@ -1442,32 +1448,6 @@ label: .Bd -literal -offset indent /sbin/gpart bootcode -b /boot/boot ada0s1 .Ed -.Ss VTOC8 -.Pp -Create a VTOC8 scheme on -.Pa da0 : -.Bd -literal -offset indent -/sbin/gpart create -s VTOC8 da0 -.Ed -.Pp -Create a 512MB-sized -.Cm freebsd-ufs -partition to contain a UFS filesystem from which the system can boot. -.Bd -literal -offset indent -/sbin/gpart add -s 512M -t freebsd-ufs da0 -.Ed -.Pp -Create a 15GB-sized -.Cm freebsd-ufs -partition to contain a UFS filesystem and aligned on 4KB boundaries: -.Bd -literal -offset indent -/sbin/gpart add -s 15G -t freebsd-ufs -a 4k da0 -.Ed -.Pp -After creating all required partitions, embed bootstrap code into them: -.Bd -literal -offset indent -/sbin/gpart bootcode -p /boot/boot1 da0 -.Ed .Ss Deleting Partitions and Destroying the Partitioning Scheme If a .Em "Device busy" @@ -1496,7 +1476,6 @@ This is equivalent to the previous example: /sbin/gpart destroy -F da0 .Ed .Ss Backup and Restore -.Pp Create a backup of the partition table from .Pa da0 : .Bd -literal -offset indent diff --git a/lib/geom/raid/Makefile b/lib/geom/raid/Makefile index 75d2ac7e25b7..b84121126ca1 100644 --- a/lib/geom/raid/Makefile +++ b/lib/geom/raid/Makefile @@ -1,10 +1,5 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= raid -LIBADD= md - .include <bsd.lib.mk> diff --git a/lib/geom/raid/Makefile.depend b/lib/geom/raid/Makefile.depend index 7902e1927044..27e87393b549 100644 --- a/lib/geom/raid/Makefile.depend +++ b/lib/geom/raid/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -10,7 +8,6 @@ DIRDEPS = \ lib/libcompiler_rt \ lib/libgeom \ lib/libmd \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/raid/geom_raid.c b/lib/geom/raid/geom_raid.c index efb356f6a7e3..f73b42e91e85 100644 --- a/lib/geom/raid/geom_raid.c +++ b/lib/geom/raid/geom_raid.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2010 Alexander Motin <mav@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/raid/graid.8 b/lib/geom/raid/graid.8 index e11648659495..4ef0cd22e703 100644 --- a/lib/geom/raid/graid.8 +++ b/lib/geom/raid/graid.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd April 4, 2013 +.Dd January 23, 2025 .Dt GRAID 8 .Os .Sh NAME @@ -277,7 +275,7 @@ NVIDIA metadata format does not support volumes above 2TiB. .Sh SYSCTL VARIABLES The following .Xr sysctl 8 -variable can be used to control the behavior of the +variables can be used to control the behavior of the .Nm RAID GEOM class. .Bl -tag -width indent @@ -309,8 +307,7 @@ Enable taste for specific metadata or transformation module. Exit status is 0 on success, and non-zero if the command fails. .Sh SEE ALSO .Xr geom 4 , -.Xr geom 8 , -.Xr gvinum 8 +.Xr geom 8 .Sh HISTORY The .Nm diff --git a/lib/geom/raid3/Makefile b/lib/geom/raid3/Makefile index 2fdf4e8f8167..f2d9a9233c16 100644 --- a/lib/geom/raid3/Makefile +++ b/lib/geom/raid3/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= raid3 diff --git a/lib/geom/raid3/Makefile.depend b/lib/geom/raid3/Makefile.depend index 7902e1927044..27e87393b549 100644 --- a/lib/geom/raid3/Makefile.depend +++ b/lib/geom/raid3/Makefile.depend @@ -1,8 +1,6 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ @@ -10,7 +8,6 @@ DIRDEPS = \ lib/libcompiler_rt \ lib/libgeom \ lib/libmd \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/raid3/geom_raid3.c b/lib/geom/raid3/geom_raid3.c index 17d3187d5cf4..4967cec75448 100644 --- a/lib/geom/raid3/geom_raid3.c +++ b/lib/geom/raid3/geom_raid3.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/raid3/graid3.8 b/lib/geom/raid3/graid3.8 index 426c94d17521..e1bcdac17f99 100644 --- a/lib/geom/raid3/graid3.8 +++ b/lib/geom/raid3/graid3.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd January 15, 2012 +.Dd January 23, 2025 .Dt GRAID3 8 .Os .Sh NAME @@ -238,7 +236,6 @@ graid3 insert -n 0 data da5 .Sh SEE ALSO .Xr geom 4 , .Xr geom 8 , -.Xr gvinum 8 , .Xr mount 8 , .Xr newfs 8 , .Xr umount 8 diff --git a/lib/geom/shsec/Makefile b/lib/geom/shsec/Makefile index f86df6c9af42..493ea5d15acd 100644 --- a/lib/geom/shsec/Makefile +++ b/lib/geom/shsec/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= shsec diff --git a/lib/geom/shsec/Makefile.depend b/lib/geom/shsec/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/shsec/Makefile.depend +++ b/lib/geom/shsec/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/shsec/geom_shsec.c b/lib/geom/shsec/geom_shsec.c index 308a53b7f9d3..227bdcf39b7d 100644 --- a/lib/geom/shsec/geom_shsec.c +++ b/lib/geom/shsec/geom_shsec.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/shsec/gshsec.8 b/lib/geom/shsec/gshsec.8 index dcfd2b397909..d4477de3a71e 100644 --- a/lib/geom/shsec/gshsec.8 +++ b/lib/geom/shsec/gshsec.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd October 1, 2013 .Dt GSHSEC 8 .Os @@ -118,7 +116,6 @@ detected and connected, making the secret available via the device. .Sh SEE ALSO .Xr geom 4 , -.Xr gbde 8 , .Xr geom 8 , .Xr newfs 8 .Sh HISTORY diff --git a/lib/geom/stripe/Makefile b/lib/geom/stripe/Makefile index bbea1901749e..762df5f3c872 100644 --- a/lib/geom/stripe/Makefile +++ b/lib/geom/stripe/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= stripe diff --git a/lib/geom/stripe/Makefile.depend b/lib/geom/stripe/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/stripe/Makefile.depend +++ b/lib/geom/stripe/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/stripe/geom_stripe.c b/lib/geom/stripe/geom_stripe.c index 175ddada2e33..da3a726db370 100644 --- a/lib/geom/stripe/geom_stripe.c +++ b/lib/geom/stripe/geom_stripe.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2004-2005 Pawel Jakub Dawidek <pjd@FreeBSD.org> * All rights reserved. @@ -26,9 +26,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> diff --git a/lib/geom/stripe/gstripe.8 b/lib/geom/stripe/gstripe.8 index f1f34fe10609..6fd486355a2e 100644 --- a/lib/geom/stripe/gstripe.8 +++ b/lib/geom/stripe/gstripe.8 @@ -22,9 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" -.Dd May 21, 2004 +.Dd January 23, 2025 .Dt GSTRIPE 8 .Os .Sh NAME @@ -229,7 +227,6 @@ for .Xr loader.conf 5 , .Xr ccdconfig 8 , .Xr geom 8 , -.Xr gvinum 8 , .Xr mount 8 , .Xr newfs 8 , .Xr sysctl 8 , diff --git a/lib/geom/union/Makefile b/lib/geom/union/Makefile index cb8b09dc7eca..e2027125c6d1 100644 --- a/lib/geom/union/Makefile +++ b/lib/geom/union/Makefile @@ -1,7 +1,4 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc +PACKAGE=geom GEOM_CLASS= union diff --git a/lib/geom/union/Makefile.depend b/lib/geom/union/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/union/Makefile.depend +++ b/lib/geom/union/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/union/geom_union.c b/lib/geom/union/geom_union.c index 2e0843d35899..e1542e4b891c 100644 --- a/lib/geom/union/geom_union.c +++ b/lib/geom/union/geom_union.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2022 Marshall Kirk McKusick <mckusick@mckusick.com> * diff --git a/lib/geom/union/gunion.8 b/lib/geom/union/gunion.8 index 732a803657d8..5cb20e975b21 100644 --- a/lib/geom/union/gunion.8 +++ b/lib/geom/union/gunion.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd January 19, 2022 .Dt GUNION 8 .Os diff --git a/lib/geom/virstor/Makefile b/lib/geom/virstor/Makefile index dfbe0aeddc47..63ea8e5ad31c 100644 --- a/lib/geom/virstor/Makefile +++ b/lib/geom/virstor/Makefile @@ -1,7 +1,5 @@ -# $FreeBSD$ - -PACKAGE=runtime -.PATH: ${.CURDIR:H:H}/misc ${SRCTOP}/sys/geom/virstor +PACKAGE=geom +.PATH: ${SRCTOP}/sys/geom/virstor GEOM_CLASS= virstor diff --git a/lib/geom/virstor/Makefile.depend b/lib/geom/virstor/Makefile.depend index fb5f86e931fb..0dd05cace3c0 100644 --- a/lib/geom/virstor/Makefile.depend +++ b/lib/geom/virstor/Makefile.depend @@ -1,15 +1,12 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ - gnu/lib/csu \ include \ include/xlocale \ lib/${CSU_DIR} \ lib/libc \ lib/libcompiler_rt \ lib/libgeom \ - sbin/geom/core \ .include <dirdeps.mk> diff --git a/lib/geom/virstor/geom_virstor.c b/lib/geom/virstor/geom_virstor.c index bd8da7337a55..5f5087e99213 100644 --- a/lib/geom/virstor/geom_virstor.c +++ b/lib/geom/virstor/geom_virstor.c @@ -1,5 +1,5 @@ /*- - * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * SPDX-License-Identifier: BSD-2-Clause * * Copyright (c) 2005 Ivan Voras <ivoras@freebsd.org> * @@ -25,9 +25,6 @@ * SUCH DAMAGE. */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/param.h> #include <errno.h> #include <paths.h> @@ -160,8 +157,7 @@ virstor_label(struct gctl_req *req) char param[32]; int hardcode, nargs, error; struct virstor_map_entry *map; - size_t total_chunks; /* We'll run out of memory if - this needs to be bigger. */ + size_t total_chunks, write_max_map_entries; unsigned int map_chunks; /* Chunks needed by the map (map size). */ size_t map_size; /* In bytes. */ ssize_t written; @@ -199,27 +195,6 @@ virstor_label(struct gctl_req *req) return; } - if (md.md_chunk_size % MAXPHYS != 0) { - /* XXX: This is not strictly needed, but it's convenient to - * impose some limitations on it, so why not MAXPHYS. */ - size_t new_size = rounddown(md.md_chunk_size, MAXPHYS); - if (new_size < md.md_chunk_size) - new_size += MAXPHYS; - fprintf(stderr, "Resizing chunk size to be a multiple of " - "MAXPHYS (%d kB).\n", MAXPHYS / 1024); - fprintf(stderr, "New chunk size: %zu kB\n", new_size / 1024); - md.md_chunk_size = new_size; - } - - if (md.md_virsize % md.md_chunk_size != 0) { - off_t chunk_count = md.md_virsize / md.md_chunk_size; - md.md_virsize = chunk_count * md.md_chunk_size; - fprintf(stderr, "Resizing virtual size to be a multiple of " - "chunk size.\n"); - fprintf(stderr, "New virtual size: %zu MB\n", - (size_t)(md.md_virsize/(1024 * 1024))); - } - msize = secsize = 0; for (i = 1; i < (unsigned)nargs; i++) { snprintf(param, sizeof(param), "arg%u", i); @@ -244,11 +219,20 @@ virstor_label(struct gctl_req *req) } if (md.md_chunk_size % secsize != 0) { - fprintf(stderr, "Error: chunk size is not a multiple of sector " - "size."); - gctl_error(req, "Chunk size (in bytes) must be multiple of %u.", - (unsigned int)secsize); - return; + size_t new_size = roundup(md.md_chunk_size, secsize); + fprintf(stderr, "Resizing chunk size to be a multiple of " + "sector size (%zu bytes).\n", secsize); + fprintf(stderr, "New chunk size: %zu kB\n", new_size / 1024); + md.md_chunk_size = new_size; + } + + if (md.md_virsize % md.md_chunk_size != 0) { + off_t chunk_count = md.md_virsize / md.md_chunk_size; + md.md_virsize = chunk_count * md.md_chunk_size; + fprintf(stderr, "Resizing virtual size to be a multiple of " + "chunk size.\n"); + fprintf(stderr, "New virtual size: %zu MB\n", + (size_t)(md.md_virsize / (1024 * 1024))); } total_chunks = md.md_virsize / md.md_chunk_size; @@ -328,28 +312,56 @@ virstor_label(struct gctl_req *req) sprintf(param, "%s%s", _PATH_DEV, name); fd = open(param, O_RDWR); } - if (fd < 0) + if (fd < 0) { gctl_error(req, "Cannot open provider %s to write map", name); + return; + } - /* Do it with calloc because there might be a need to set up chunk flags - * in the future */ - map = calloc(total_chunks, sizeof(*map)); + /* + * Initialize and write the map. Don't malloc the whole map at once, + * in case it's large. Use calloc because there might be a need to set + * up chunk flags in the future. + */ + write_max_map_entries = 1024 * 1024 / sizeof(*map); + if (write_max_map_entries > total_chunks) + write_max_map_entries = total_chunks; + map = calloc(write_max_map_entries, sizeof(*map)); if (map == NULL) { gctl_error(req, "Out of memory (need %zu bytes for allocation map)", - map_size); + write_max_map_entries * sizeof(*map)); + close(fd); + return; } - - written = pwrite(fd, map, map_size, 0); - free(map); - if ((size_t)written != map_size) { - if (verbose) { - fprintf(stderr, "\nTried to write %zu, written %zd (%s)\n", - map_size, written, strerror(errno)); + for (size_t chunk = 0; chunk < total_chunks; + chunk += write_max_map_entries) { + size_t bytes_to_write, entries_to_write; + + entries_to_write = total_chunks - chunk; + if (entries_to_write > write_max_map_entries) + entries_to_write = write_max_map_entries; + bytes_to_write = entries_to_write * sizeof(*map); + for (size_t off = 0; off < bytes_to_write; off += written) { + written = write(fd, ((char *)map) + off, + bytes_to_write - off); + if (written < 0) { + if (verbose) { + fprintf(stderr, + "\nError writing map at offset " + "%zu of %zu: %s\n", + chunk * sizeof(*map) + off, + map_size, strerror(errno)); + } + gctl_error(req, + "Error writing out allocation map!"); + free(map); + close(fd); + return; + } } - gctl_error(req, "Error writing out allocation map!"); - return; } + free(map); + map = NULL; close (fd); if (verbose) diff --git a/lib/geom/virstor/gvirstor.8 b/lib/geom/virstor/gvirstor.8 index 3d93e5baa2ae..436b60bef02c 100644 --- a/lib/geom/virstor/gvirstor.8 +++ b/lib/geom/virstor/gvirstor.8 @@ -22,8 +22,6 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.\" $FreeBSD$ -.\" .Dd October 1, 2013 .Dt GVIRSTOR 8 .Os |