svn commit: r242379 - in head: sbin/dumpfs sbin/growfs sbin/newfs sys/geom/label sys/ufs/ffs
Edward Tomasz Napierala
trasz at FreeBSD.org
Tue Oct 30 21:32:12 UTC 2012
Author: trasz
Date: Tue Oct 30 21:32:10 2012
New Revision: 242379
URL: http://svn.freebsd.org/changeset/base/242379
Log:
Fix problem with geom_label(4) not recognizing UFS labels on filesystems
extended using growfs(8). The problem here is that geom_label checks if
the filesystem size recorded in UFS superblock is equal to the provider
(i.e. device) size. This check cannot be removed due to backward
compatibility. On the other hand, in most cases growfs(8) cannot set
fs_size in the superblock to match the provider size, because, differently
from newfs(8), it cannot recompute cylinder group sizes.
To fix this problem, add another superblock field, fs_providersize, used
only for this purpose. The geom_label(4) will attach if either fs_size
(filesystem created with newfs(8)) or fs_providersize (filesystem expanded
using growfs(8)) matches the device size.
PR: kern/165962
Reviewed by: mckusick
Sponsored by: FreeBSD Foundation
Modified:
head/sbin/dumpfs/dumpfs.c
head/sbin/growfs/growfs.c
head/sbin/newfs/mkfs.c
head/sbin/newfs/newfs.c
head/sbin/newfs/newfs.h
head/sys/geom/label/g_label_ufs.c
head/sys/ufs/ffs/fs.h
Modified: head/sbin/dumpfs/dumpfs.c
==============================================================================
--- head/sbin/dumpfs/dumpfs.c Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sbin/dumpfs/dumpfs.c Tue Oct 30 21:32:10 2012 (r242379)
@@ -277,8 +277,9 @@ dumpfs(const char *name)
printf("unknown flags (%#x)", fsflags);
putchar('\n');
printf("fsmnt\t%s\n", afs.fs_fsmnt);
- printf("volname\t%s\tswuid\t%ju\n",
- afs.fs_volname, (uintmax_t)afs.fs_swuid);
+ printf("volname\t%s\tswuid\t%ju\tprovidersize\t%ju\n",
+ afs.fs_volname, (uintmax_t)afs.fs_swuid,
+ (uintmax_t)afs.fs_providersize);
printf("\ncs[].cs_(nbfree,ndir,nifree,nffree):\n\t");
afs.fs_csp = calloc(1, afs.fs_cssize);
if (bread(&disk, fsbtodb(&afs, afs.fs_csaddr), afs.fs_csp, afs.fs_cssize) == -1)
Modified: head/sbin/growfs/growfs.c
==============================================================================
--- head/sbin/growfs/growfs.c Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sbin/growfs/growfs.c Tue Oct 30 21:32:10 2012 (r242379)
@@ -1498,6 +1498,7 @@ main(int argc, char **argv)
}
sblock.fs_size = dbtofsb(&osblock, size / DEV_BSIZE);
+ sblock.fs_providersize = dbtofsb(&osblock, mediasize / DEV_BSIZE);
/*
* Are we really growing?
Modified: head/sbin/newfs/mkfs.c
==============================================================================
--- head/sbin/newfs/mkfs.c Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sbin/newfs/mkfs.c Tue Oct 30 21:32:10 2012 (r242379)
@@ -263,6 +263,7 @@ restart:
}
sblock.fs_fsbtodb = ilog2(sblock.fs_fsize / sectorsize);
sblock.fs_size = fssize = dbtofsb(&sblock, fssize);
+ sblock.fs_providersize = dbtofsb(&sblock, mediasize / sectorsize);
/*
* Before the filesystem is finally initialized, mark it
Modified: head/sbin/newfs/newfs.c
==============================================================================
--- head/sbin/newfs/newfs.c Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sbin/newfs/newfs.c Tue Oct 30 21:32:10 2012 (r242379)
@@ -94,6 +94,7 @@ int lflag; /* enable multilabel for fi
int nflag; /* do not create .snap directory */
int tflag; /* enable TRIM */
intmax_t fssize; /* file system size */
+off_t mediasize; /* device size */
int sectorsize; /* bytes/sector */
int realsectorsize; /* bytes/sector in hardware */
int fsize = 0; /* fragment size */
@@ -135,7 +136,6 @@ main(int argc, char *argv[])
char *cp, *special;
intmax_t reserved;
int ch, i, rval;
- off_t mediasize;
char part_name; /* partition name, default to full disk */
part_name = 'c';
Modified: head/sbin/newfs/newfs.h
==============================================================================
--- head/sbin/newfs/newfs.h Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sbin/newfs/newfs.h Tue Oct 30 21:32:10 2012 (r242379)
@@ -88,6 +88,7 @@ extern int lflag; /* enable multilabel
extern int nflag; /* do not create .snap directory */
extern int tflag; /* enable TRIM */
extern intmax_t fssize; /* file system size */
+extern off_t mediasize; /* device size */
extern int sectorsize; /* bytes/sector */
extern int realsectorsize; /* bytes/sector in hardware*/
extern int fsize; /* fragment size */
Modified: head/sys/geom/label/g_label_ufs.c
==============================================================================
--- head/sys/geom/label/g_label_ufs.c Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sys/geom/label/g_label_ufs.c Tue Oct 30 21:32:10 2012 (r242379)
@@ -90,7 +90,8 @@ g_label_ufs_taste_common(struct g_consum
pp->mediasize / fs->fs_fsize == fs->fs_old_size) {
/* Valid UFS1. */
} else if (fs->fs_magic == FS_UFS2_MAGIC && fs->fs_fsize > 0 &&
- pp->mediasize / fs->fs_fsize == fs->fs_size) {
+ ((pp->mediasize / fs->fs_fsize == fs->fs_size) ||
+ (pp->mediasize / fs->fs_fsize == fs->fs_providersize))) {
/* Valid UFS2. */
} else {
g_free(fs);
Modified: head/sys/ufs/ffs/fs.h
==============================================================================
--- head/sys/ufs/ffs/fs.h Tue Oct 30 21:10:06 2012 (r242378)
+++ head/sys/ufs/ffs/fs.h Tue Oct 30 21:32:10 2012 (r242379)
@@ -329,7 +329,8 @@ struct fs {
int32_t fs_old_cpc; /* cyl per cycle in postbl */
int32_t fs_maxbsize; /* maximum blocking factor permitted */
int64_t fs_unrefs; /* number of unreferenced inodes */
- int64_t fs_sparecon64[16]; /* old rotation block list head */
+ int64_t fs_providersize; /* size of underlying GEOM provider */
+ int64_t fs_sparecon64[15]; /* old rotation block list head */
int64_t fs_sblockloc; /* byte offset of standard superblock */
struct csum_total fs_cstotal; /* (u) cylinder summary information */
ufs_time_t fs_time; /* last time written */
More information about the svn-src-all
mailing list