diff options
author | trasz <trasz@FreeBSD.org> | 2012-11-18 19:01:00 +0000 |
---|---|---|
committer | trasz <trasz@FreeBSD.org> | 2012-11-18 19:01:00 +0000 |
commit | 9376662aac53d43f14e729f78bc36cddffaf65e2 (patch) | |
tree | aad050f0d9d8920fe7e8eb861938cb9c8347119e /sbin/growfs | |
parent | 5bb0933cf1cda47a3d3a201d7c18c19beee0c55d (diff) | |
download | FreeBSD-src-9376662aac53d43f14e729f78bc36cddffaf65e2.zip FreeBSD-src-9376662aac53d43f14e729f78bc36cddffaf65e2.tar.gz |
Make it possible to resize filesystems mounted read-write, using newly
introduced UFS write suspension mechanism.
Reviewed by: kib, mckusick
Sponsored by: FreeBSD Foundation
Diffstat (limited to 'sbin/growfs')
-rw-r--r-- | sbin/growfs/growfs.8 | 6 | ||||
-rw-r--r-- | sbin/growfs/growfs.c | 30 |
2 files changed, 29 insertions, 7 deletions
diff --git a/sbin/growfs/growfs.8 b/sbin/growfs/growfs.8 index 92508da..682cf44 100644 --- a/sbin/growfs/growfs.8 +++ b/sbin/growfs/growfs.8 @@ -115,11 +115,17 @@ The .Nm utility first appeared in .Fx 4.4 . +The ability to resize mounted filesystems was added in +.Fx 10.0 . .Sh AUTHORS .An Christoph Herrmann Aq chm@FreeBSD.org .An Thomas-Henning von Kamptz Aq tomsoft@FreeBSD.org .An The GROWFS team Aq growfs@Tomsoft.COM .An Edward Tomasz Napierala Aq trasz@FreeBSD.org +.Sh CAVEATS +.Pp +When expanding a file system mounted read-write, any writes to that file system +will be temporarily suspended until the expansion is finished. .Sh BUGS Normally .Nm diff --git a/sbin/growfs/growfs.c b/sbin/growfs/growfs.c index ad837a8..042aada 100644 --- a/sbin/growfs/growfs.c +++ b/sbin/growfs/growfs.c @@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$"); #include <inttypes.h> #include <limits.h> #include <mntopts.h> +#include <paths.h> #include <stdlib.h> #include <stdint.h> #include <string.h> @@ -1525,8 +1526,9 @@ main(int argc, char **argv) if (yflag == 0 && Nflag == 0) { if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) - errx(1, "%s is mounted read-write on %s", - statfsp->f_mntfromname, statfsp->f_mntonname); + printf("Device is mounted read-write; resizing will " + "result in temporary write suspension for %s.\n", + statfsp->f_mntonname); printf("It's strongly recommended to make a backup " "before growing the file system.\n" "OK to grow filesystem on %s", device); @@ -1555,9 +1557,18 @@ main(int argc, char **argv) if (Nflag) { fso = -1; } else { - fso = open(device, O_WRONLY); - if (fso < 0) - err(1, "%s", device); + if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) { + fso = open(_PATH_UFSSUSPEND, O_RDWR); + if (fso == -1) + err(1, "unable to open %s", _PATH_UFSSUSPEND); + error = ioctl(fso, UFSSUSPEND, &statfsp->f_fsid); + if (error != 0) + err(1, "UFSSUSPEND"); + } else { + fso = open(device, O_WRONLY); + if (fso < 0) + err(1, "%s", device); + } } /* @@ -1627,12 +1638,17 @@ main(int argc, char **argv) close(fsi); if (fso > -1) { + if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) == 0) { + error = ioctl(fso, UFSRESUME); + if (error != 0) + err(1, "UFSRESUME"); + } error = close(fso); if (error != 0) err(1, "close"); + if (statfsp != NULL && (statfsp->f_flags & MNT_RDONLY) != 0) + mount_reload(statfsp); } - if (statfsp != NULL) - mount_reload(statfsp); DBG_CLOSE; |