svn commit: r246284 - in stable/9: sbin/dumpfs sbin/growfs sbin/newfs sys/geom/label sys/ufs/ffs
Edward Tomasz Napierala
trasz at FreeBSD.org
Sun Feb 3 12:17:51 UTC 2013
Author: trasz
Date: Sun Feb 3 12:17:49 2013
New Revision: 246284
URL: http://svnweb.freebsd.org/changeset/base/246284
Log:
MFC r242379:
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:
stable/9/sbin/dumpfs/dumpfs.c
stable/9/sbin/growfs/growfs.c
stable/9/sbin/newfs/mkfs.c
stable/9/sbin/newfs/newfs.c
stable/9/sbin/newfs/newfs.h
stable/9/sys/geom/label/g_label_ufs.c
stable/9/sys/ufs/ffs/fs.h
Directory Properties:
stable/9/sbin/dumpfs/ (props changed)
stable/9/sbin/growfs/ (props changed)
stable/9/sbin/newfs/ (props changed)
stable/9/sys/ (props changed)
Modified: stable/9/sbin/dumpfs/dumpfs.c
==============================================================================
--- stable/9/sbin/dumpfs/dumpfs.c Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sbin/dumpfs/dumpfs.c Sun Feb 3 12:17:49 2013 (r246284)
@@ -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: stable/9/sbin/growfs/growfs.c
==============================================================================
--- stable/9/sbin/growfs/growfs.c Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sbin/growfs/growfs.c Sun Feb 3 12:17:49 2013 (r246284)
@@ -1504,6 +1504,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: stable/9/sbin/newfs/mkfs.c
==============================================================================
--- stable/9/sbin/newfs/mkfs.c Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sbin/newfs/mkfs.c Sun Feb 3 12:17:49 2013 (r246284)
@@ -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: stable/9/sbin/newfs/newfs.c
==============================================================================
--- stable/9/sbin/newfs/newfs.c Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sbin/newfs/newfs.c Sun Feb 3 12:17:49 2013 (r246284)
@@ -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: stable/9/sbin/newfs/newfs.h
==============================================================================
--- stable/9/sbin/newfs/newfs.h Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sbin/newfs/newfs.h Sun Feb 3 12:17:49 2013 (r246284)
@@ -87,6 +87,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: stable/9/sys/geom/label/g_label_ufs.c
==============================================================================
--- stable/9/sys/geom/label/g_label_ufs.c Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sys/geom/label/g_label_ufs.c Sun Feb 3 12:17:49 2013 (r246284)
@@ -86,7 +86,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: stable/9/sys/ufs/ffs/fs.h
==============================================================================
--- stable/9/sys/ufs/ffs/fs.h Sun Feb 3 10:26:24 2013 (r246283)
+++ stable/9/sys/ufs/ffs/fs.h Sun Feb 3 12:17:49 2013 (r246284)
@@ -332,7 +332,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-stable-9
mailing list