summaryrefslogtreecommitdiffstats
path: root/sys/ufs/ffs/ffs_alloc.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2013-02-16 15:11:40 +0000
committermckusick <mckusick@FreeBSD.org>2013-02-16 15:11:40 +0000
commit14a3096b0ed2a943ad439e15527d1bf0dfb58c60 (patch)
treec0802e6eebb0c4a1110f6f00c6885cd5829d0881 /sys/ufs/ffs/ffs_alloc.c
parentc04f4382b34d7ae4606db6e725d3613fd952a0e4 (diff)
downloadFreeBSD-src-14a3096b0ed2a943ad439e15527d1bf0dfb58c60.zip
FreeBSD-src-14a3096b0ed2a943ad439e15527d1bf0dfb58c60.tar.gz
The UFS2 filesystem allocates new blocks of inodes as they are needed.
When a cylinder group runs short of inodes, a new block for inodes is allocated, zero'ed, and written to the disk. The zero'ed inodes must be on the disk before the cylinder group can be updated to claim them. If the cylinder group claiming the new inodes were written before the zero'ed block of inodes, the system could crash with the filesystem in an unrecoverable state. Rather than adding a soft updates dependency to ensure that the new inode block is written before it is claimed by the cylinder group map, we just do a barrier write of the zero'ed inode block to ensure that it will get written before the updated cylinder group map can be written. This change should only slow down bulk loading of newly created filesystems since that is the primary time that new inode blocks need to be created. Reported by: Robert Watson Reviewed by: kib Tested by: Peter Holm
Diffstat (limited to 'sys/ufs/ffs/ffs_alloc.c')
-rw-r--r--sys/ufs/ffs/ffs_alloc.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c
index d462cbb..abe4073 100644
--- a/sys/ufs/ffs/ffs_alloc.c
+++ b/sys/ufs/ffs/ffs_alloc.c
@@ -1861,7 +1861,6 @@ gotit:
/*
* Check to see if we need to initialize more inodes.
*/
- ibp = NULL;
if (fs->fs_magic == FS_UFS2_MAGIC &&
ipref + INOPB(fs) > cgp->cg_initediblk &&
cgp->cg_initediblk < cgp->cg_niblk) {
@@ -1874,6 +1873,16 @@ gotit:
dp2->di_gen = arc4random() / 2 + 1;
dp2++;
}
+ /*
+ * Rather than adding a soft updates dependency to ensure
+ * that the new inode block is written before it is claimed
+ * by the cylinder group map, we just do a barrier write
+ * here. The barrier write will ensure that the inode block
+ * gets written before the updated cylinder group map can be
+ * written. The barrier write should only slow down bulk
+ * loading of newly created filesystems.
+ */
+ babarrierwrite(ibp);
cgp->cg_initediblk += INOPB(fs);
}
UFS_LOCK(ump);
@@ -1892,8 +1901,6 @@ gotit:
if (DOINGSOFTDEP(ITOV(ip)))
softdep_setup_inomapdep(bp, ip, cg * fs->fs_ipg + ipref, mode);
bdwrite(bp);
- if (ibp != NULL)
- bawrite(ibp);
return ((ino_t)(cg * fs->fs_ipg + ipref));
}
OpenPOWER on IntegriCloud