Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/lfs Split lfs from ufs, part 1: cut and paste 15000 ...
details: https://anonhg.NetBSD.org/src/rev/05b3b3cf4e43
branches: trunk
changeset: 787198:05b3b3cf4e43
user: dholland <dholland%NetBSD.org@localhost>
date: Thu Jun 06 00:40:55 2013 +0000
description:
Split lfs from ufs, part 1: cut and paste 15000 lines of ufs as "ulfs".
These are verbatim copies except that I've preserved the ufs rcsids
for reference. Also,
ufs/quota.h -> ulfs_quotacommon.h
ufs/ufs_quota.h -> ulfs_quota.h
Splitting lfs from ufs was ok'd by core some years ago. This is not
from my original tree, which became unmergeable after the several sets
of quota changes; I've done the work over again over the last couple
days.
diffstat:
sys/ufs/lfs/README.wc | 20 +
sys/ufs/lfs/ulfs_bmap.c | 406 ++++++++
sys/ufs/lfs/ulfs_bswap.h | 81 +
sys/ufs/lfs/ulfs_dinode.h | 181 +++
sys/ufs/lfs/ulfs_dir.h | 161 +++
sys/ufs/lfs/ulfs_dirhash.c | 1172 +++++++++++++++++++++++
sys/ufs/lfs/ulfs_dirhash.h | 130 ++
sys/ufs/lfs/ulfs_extattr.c | 1597 ++++++++++++++++++++++++++++++++
sys/ufs/lfs/ulfs_extattr.h | 129 ++
sys/ufs/lfs/ulfs_extern.h | 214 ++++
sys/ufs/lfs/ulfs_ihash.c | 192 +++
sys/ufs/lfs/ulfs_inode.c | 312 ++++++
sys/ufs/lfs/ulfs_inode.h | 305 ++++++
sys/ufs/lfs/ulfs_lookup.c | 1539 +++++++++++++++++++++++++++++++
sys/ufs/lfs/ulfs_quota.c | 996 ++++++++++++++++++++
sys/ufs/lfs/ulfs_quota.h | 146 ++
sys/ufs/lfs/ulfs_quota1.c | 904 ++++++++++++++++++
sys/ufs/lfs/ulfs_quota1.h | 105 ++
sys/ufs/lfs/ulfs_quota1_subr.c | 90 +
sys/ufs/lfs/ulfs_quota2.c | 1560 +++++++++++++++++++++++++++++++
sys/ufs/lfs/ulfs_quota2.h | 129 ++
sys/ufs/lfs/ulfs_quota2_subr.c | 129 ++
sys/ufs/lfs/ulfs_quotacommon.h | 106 ++
sys/ufs/lfs/ulfs_readwrite.c | 547 +++++++++++
sys/ufs/lfs/ulfs_rename.c | 1058 +++++++++++++++++++++
sys/ufs/lfs/ulfs_vfsops.c | 290 +++++
sys/ufs/lfs/ulfs_vnops.c | 1980 ++++++++++++++++++++++++++++++++++++++++
sys/ufs/lfs/ulfs_wapbl.c | 166 +++
sys/ufs/lfs/ulfs_wapbl.h | 179 +++
sys/ufs/lfs/ulfsmount.h | 204 ++++
30 files changed, 15028 insertions(+), 0 deletions(-)
diffs (truncated from 15148 to 300 lines):
diff -r 6340768d455b -r 05b3b3cf4e43 sys/ufs/lfs/README.wc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/lfs/README.wc Thu Jun 06 00:40:55 2013 +0000
@@ -0,0 +1,20 @@
+Line counts.
+
+(Part of the premise of splitting lfs from ufs is that in the long run
+the size of a standalone lfs will be substantially smaller than the
+size of lfs plus the size of ufs. This file is for keeping track of
+this proposition.)
+
+As of 20130604 (before the split):
+ .h .c total
+lfs 1467 13858 15325
+ufs 2056 12919 14975
+
+As of 20130605 (copied all ufs files verbatim):
+
+lfs-native 1467 13858 15325
+lfs-ulfs 2070 12938 15008
+lfs-total 3537 26796 30333
+
+A few extra lines appeared copying ufs because I preserved a copy of
+the old rcsids.
diff -r 6340768d455b -r 05b3b3cf4e43 sys/ufs/lfs/ulfs_bmap.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/ufs/lfs/ulfs_bmap.c Thu Jun 06 00:40:55 2013 +0000
@@ -0,0 +1,406 @@
+/* $NetBSD: ulfs_bmap.c,v 1.1 2013/06/06 00:40:55 dholland Exp $ */
+/* from NetBSD: ufs_bmap.c,v 1.50 2013/01/22 09:39:18 dholland Exp */
+
+/*
+ * Copyright (c) 1989, 1991, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * 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.
+ *
+ * @(#)ufs_bmap.c 8.8 (Berkeley) 8/11/95
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: ulfs_bmap.c,v 1.1 2013/06/06 00:40:55 dholland Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/resourcevar.h>
+#include <sys/trace.h>
+#include <sys/fstrans.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <ufs/ufs/inode.h>
+#include <ufs/ufs/ufsmount.h>
+#include <ufs/ufs/ufs_extern.h>
+#include <ufs/ufs/ufs_bswap.h>
+
+static bool
+ufs_issequential(const struct ufsmount *ump, daddr_t daddr0, daddr_t daddr1)
+{
+
+ /* for ufs, blocks in a hole is not 'contiguous'. */
+ if (daddr0 == 0)
+ return false;
+
+ return (daddr0 + ump->um_seqinc == daddr1);
+}
+
+/*
+ * Bmap converts the logical block number of a file to its physical block
+ * number on the disk. The conversion is done by using the logical block
+ * number to index into the array of block pointers described by the dinode.
+ */
+int
+ufs_bmap(void *v)
+{
+ struct vop_bmap_args /* {
+ struct vnode *a_vp;
+ daddr_t a_bn;
+ struct vnode **a_vpp;
+ daddr_t *a_bnp;
+ int *a_runp;
+ } */ *ap = v;
+ int error;
+
+ /*
+ * Check for underlying vnode requests and ensure that logical
+ * to physical mapping is requested.
+ */
+ if (ap->a_vpp != NULL)
+ *ap->a_vpp = VTOI(ap->a_vp)->i_devvp;
+ if (ap->a_bnp == NULL)
+ return (0);
+
+ fstrans_start(ap->a_vp->v_mount, FSTRANS_SHARED);
+ error = ufs_bmaparray(ap->a_vp, ap->a_bn, ap->a_bnp, NULL, NULL,
+ ap->a_runp, ufs_issequential);
+ fstrans_done(ap->a_vp->v_mount);
+ return error;
+}
+
+/*
+ * Indirect blocks are now on the vnode for the file. They are given negative
+ * logical block numbers. Indirect blocks are addressed by the negative
+ * address of the first data block to which they point. Double indirect blocks
+ * are addressed by one less than the address of the first indirect block to
+ * which they point. Triple indirect blocks are addressed by one less than
+ * the address of the first double indirect block to which they point.
+ *
+ * ufs_bmaparray does the bmap conversion, and if requested returns the
+ * array of logical blocks which must be traversed to get to a block.
+ * Each entry contains the offset into that block that gets you to the
+ * next block and the disk address of the block (if it is assigned).
+ */
+
+int
+ufs_bmaparray(struct vnode *vp, daddr_t bn, daddr_t *bnp, struct indir *ap,
+ int *nump, int *runp, ufs_issequential_callback_t is_sequential)
+{
+ struct inode *ip;
+ struct buf *bp, *cbp;
+ struct ufsmount *ump;
+ struct mount *mp;
+ struct indir a[UFS_NIADDR + 1], *xap;
+ daddr_t daddr;
+ daddr_t metalbn;
+ int error, maxrun = 0, num;
+
+ ip = VTOI(vp);
+ mp = vp->v_mount;
+ ump = ip->i_ump;
+#ifdef DIAGNOSTIC
+ if ((ap != NULL && nump == NULL) || (ap == NULL && nump != NULL))
+ panic("ufs_bmaparray: invalid arguments");
+#endif
+
+ if (runp) {
+ /*
+ * XXX
+ * If MAXBSIZE is the largest transfer the disks can handle,
+ * we probably want maxrun to be 1 block less so that we
+ * don't create a block larger than the device can handle.
+ */
+ *runp = 0;
+ maxrun = MAXPHYS / mp->mnt_stat.f_iosize - 1;
+ }
+
+ if (bn >= 0 && bn < UFS_NDADDR) {
+ if (nump != NULL)
+ *nump = 0;
+ if (ump->um_fstype == UFS1)
+ daddr = ufs_rw32(ip->i_ffs1_db[bn],
+ UFS_MPNEEDSWAP(ump));
+ else
+ daddr = ufs_rw64(ip->i_ffs2_db[bn],
+ UFS_MPNEEDSWAP(ump));
+ *bnp = blkptrtodb(ump, daddr);
+ /*
+ * Since this is FFS independent code, we are out of
+ * scope for the definitions of BLK_NOCOPY and
+ * BLK_SNAP, but we do know that they will fall in
+ * the range 1..um_seqinc, so we use that test and
+ * return a request for a zeroed out buffer if attempts
+ * are made to read a BLK_NOCOPY or BLK_SNAP block.
+ */
+ if ((ip->i_flags & (SF_SNAPSHOT | SF_SNAPINVAL)) == SF_SNAPSHOT
+ && daddr > 0 &&
+ daddr < ump->um_seqinc) {
+ *bnp = -1;
+ } else if (*bnp == 0) {
+ if ((ip->i_flags & (SF_SNAPSHOT | SF_SNAPINVAL))
+ == SF_SNAPSHOT) {
+ *bnp = blkptrtodb(ump, bn * ump->um_seqinc);
+ } else {
+ *bnp = -1;
+ }
+ } else if (runp) {
+ if (ump->um_fstype == UFS1) {
+ for (++bn; bn < UFS_NDADDR && *runp < maxrun &&
+ is_sequential(ump,
+ ufs_rw32(ip->i_ffs1_db[bn - 1],
+ UFS_MPNEEDSWAP(ump)),
+ ufs_rw32(ip->i_ffs1_db[bn],
+ UFS_MPNEEDSWAP(ump)));
+ ++bn, ++*runp);
+ } else {
+ for (++bn; bn < UFS_NDADDR && *runp < maxrun &&
+ is_sequential(ump,
+ ufs_rw64(ip->i_ffs2_db[bn - 1],
+ UFS_MPNEEDSWAP(ump)),
+ ufs_rw64(ip->i_ffs2_db[bn],
+ UFS_MPNEEDSWAP(ump)));
+ ++bn, ++*runp);
+ }
+ }
+ return (0);
+ }
+
+ xap = ap == NULL ? a : ap;
+ if (!nump)
+ nump = #
+ if ((error = ufs_getlbns(vp, bn, xap, nump)) != 0)
+ return (error);
+
+ num = *nump;
+
+ /* Get disk address out of indirect block array */
+ if (ump->um_fstype == UFS1)
+ daddr = ufs_rw32(ip->i_ffs1_ib[xap->in_off],
+ UFS_MPNEEDSWAP(ump));
+ else
+ daddr = ufs_rw64(ip->i_ffs2_ib[xap->in_off],
+ UFS_MPNEEDSWAP(ump));
+
+ for (bp = NULL, ++xap; --num; ++xap) {
+ /*
+ * Exit the loop if there is no disk address assigned yet and
+ * the indirect block isn't in the cache, or if we were
+ * looking for an indirect block and we've found it.
+ */
+
+ metalbn = xap->in_lbn;
+ if (metalbn == bn)
+ break;
+ if (daddr == 0) {
+ mutex_enter(&bufcache_lock);
+ cbp = incore(vp, metalbn);
+ mutex_exit(&bufcache_lock);
+ if (cbp == NULL)
+ break;
+ }
+
+ /*
+ * If we get here, we've either got the block in the cache
+ * or we have a disk address for it, go fetch it.
+ */
+ if (bp)
+ brelse(bp, 0);
+
+ xap->in_exists = 1;
+ bp = getblk(vp, metalbn, mp->mnt_stat.f_iosize, 0, 0);
+ if (bp == NULL) {
+
+ /*
+ * getblk() above returns NULL only iff we are
+ * pagedaemon. See the implementation of getblk
+ * for detail.
+ */
+
+ return (ENOMEM);
+ }
+ if (bp->b_oflags & (BO_DONE | BO_DELWRI)) {
+ trace(TR_BREADHIT, pack(vp, size), metalbn);
+ }
+#ifdef DIAGNOSTIC
+ else if (!daddr)
+ panic("ufs_bmaparray: indirect block not in cache");
+#endif
+ else {
+ trace(TR_BREADMISS, pack(vp, size), metalbn);
+ bp->b_blkno = blkptrtodb(ump, daddr);
+ bp->b_flags |= B_READ;
+ BIO_SETPRIO(bp, BPRIO_TIMECRITICAL);
+ VOP_STRATEGY(vp, bp);
+ curlwp->l_ru.ru_inblock++; /* XXX */
+ if ((error = biowait(bp)) != 0) {
+ brelse(bp, 0);
+ return (error);
+ }
+ }
Home |
Main Index |
Thread Index |
Old Index