@@ -1,4 +1,4 @@
-/* $NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $ */
+/* $NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: buf.c,v 1.12 2004/06/20 22:20:18 jmc Exp $");
+__RCSID("$NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -66,10 +66,12 @@
TAILQ_HEAD(buftailhead,buf) buftail;
int
-bread(int fd, struct fs *fs, daddr_t blkno, int size, struct buf **bpp)
+bread(struct vnode *vp, daddr_t blkno, int size, struct kauth_cred *u1 __unused,
+ int u2 __unused, struct buf **bpp)
{
off_t offset;
ssize_t rv;
+ struct fs *fs = vp->fs;
assert (fs != NULL);
assert (bpp != NULL);
@@ -77,7 +79,7 @@
if (debug & DEBUG_BUF_BREAD)
printf("bread: fs %p blkno %lld size %d\n",
fs, (long long)blkno, size);
- *bpp = getblk(fd, fs, blkno, size);
+ *bpp = getblk(vp, blkno, size, 0, 0);
offset = (*bpp)->b_blkno * sectorsize; /* XXX */
if (debug & DEBUG_BUF_BREAD)
printf("bread: bp %p blkno %lld offset %lld bcount %ld\n",
@@ -101,7 +103,7 @@
}
void
-brelse(struct buf *bp)
+brelse(struct buf *bp, int u1 __unused)
{
assert (bp != NULL);
@@ -180,12 +182,16 @@
}
struct buf *
-getblk(int fd, struct fs *fs, daddr_t blkno, int size)
+getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused,
+ int u2 __unused)
{
static int buftailinitted;
struct buf *bp;
void *n;
+ int fd = vp->fd;
+ struct fs *fs = vp->fs;
+ blkno += vp->offset;
assert (fs != NULL);
if (debug & DEBUG_BUF_GETBLK)
printf("getblk: fs %p blkno %lld size %d\n", fs,
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.2 2001/11/02 03:12:49 lukem Exp $ */
+/* $NetBSD: buf.h,v 1.3 2013/01/26 00:19:39 christos Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,6 +41,28 @@
#include <sys/param.h>
#include <sys/queue.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <time.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <err.h>
+
+struct componentname {
+ char *cn_nameptr;
+ size_t cn_namelen;
+};
+
+struct vnode {
+ int fd;
+ void *fs;
+ void *v_data;
+ int offset;
+};
+
+#define vput(a) ((void)(a))
+
struct buf {
void * b_data;
long b_bufsize;
@@ -54,12 +76,41 @@
};
void bcleanup(void);
-int bread(int, struct fs *, daddr_t, int, struct buf **);
-void brelse(struct buf *);
+int bread(struct vnode *, daddr_t, int, struct kauth_cred *,
+ int, struct buf **);
+void brelse(struct buf *, int);
int bwrite(struct buf *);
-struct buf * getblk(int, struct fs *, daddr_t, int);
+struct buf * getblk(struct vnode *, daddr_t, int, int, int);
#define bdwrite(bp) bwrite(bp)
#define clrbuf(bp) memset((bp)->b_data, 0, (u_int)(bp)->b_bcount)
+
+#define B_MODIFY 0
+#define BC_AGE 0
+
+#define min(a, b) MIN((a), (b))
+#define microtime(tv) gettimeofday((tv), NULL)
+#define KASSERT(a)
+#define IO_SYNC 1
+
+struct pool {
+ size_t size;
+};
+
+#define pool_init(p, s, a1, a2, a3, a4, a5, a6) (p)->size = (s)
+#define pool_get(p, f) malloc((p)->size)
+#define pool_put(p, a) free(a)
+#define pool_destroy(p)
+
+#define MALLOC_DECLARE(a)
+#define malloc_type_attach(a)
+#define malloc_type_detach(a)
+
+#define mutex_enter(m)
+#define mutex_exit(m)
+#define mutex_init(m, t, i)
+#define mutex_destroy(m)
+
+#define desiredvnodes 10000
#endif /* _FFS_BUF_H */
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_alloc.c,v 1.20 2013/01/22 09:39:19 dholland Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.21 2013/01/26 00:19:39 christos Exp $ */
/* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
/*
@@ -47,7 +47,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_alloc.c,v 1.20 2013/01/22 09:39:19 dholland Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.21 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -304,19 +304,20 @@
int error, frags, allocsiz, i;
struct fs *fs = ip->i_fs;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize)
return (0);
- error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)),
- (int)fs->fs_cgsize, &bp);
+ error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+ NULL, 0, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic(cgp, needswap) ||
(cgp->cg_cs.cs_nbfree == 0 && size == fs->fs_bsize)) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
if (size == fs->fs_bsize) {
@@ -339,7 +340,7 @@
* allocated, and hacked up
*/
if (cgp->cg_cs.cs_nbfree == 0) {
- brelse(bp);
+ brelse(bp, 0);
return (0);
}
bno = ffs_alloccgblk(ip, bp, bpref);
@@ -439,6 +440,7 @@
int i, error, cg, blk, frags, bbase;
struct fs *fs = ip->i_fs;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
if (size > fs->fs_bsize || fragoff(fs, size) != 0 ||
fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) {
@@ -451,15 +453,15 @@
(unsigned long long)ip->i_number);
return;
}
- error = bread(ip->i_fd, ip->i_fs, fsbtodb(fs, cgtod(fs, cg)),
- (int)fs->fs_cgsize, &bp);
+ error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize,
+ NULL, 0, &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgp = (struct cg *)bp->b_data;
if (!cg_chkmagic(cgp, needswap)) {
- brelse(bp);
+ brelse(bp, 0);
return;
}
cgbno = dtogd(fs, bno);
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_balloc.c,v 1.14 2013/01/22 09:39:19 dholland Exp $ */
+/* $NetBSD: ffs_balloc.c,v 1.15 2013/01/26 00:19:39 christos Exp $ */
/* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */
/*
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_balloc.c,v 1.14 2013/01/22 09:39:19 dholland Exp $");
+__RCSID("$NetBSD: ffs_balloc.c,v 1.15 2013/01/26 00:19:39 christos Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -95,6 +95,7 @@
int32_t *allocblk, allociblk[UFS_NIADDR + 1];
int32_t *allocib;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
lbn = lblkno(fs, offset);
size = blkoff(fs, offset) + bufsize;
@@ -138,10 +139,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- fs->fs_bsize, bpp);
+ error = bread(&vp, lbn, fs->fs_bsize, NULL, 0,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -164,10 +165,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- osize, bpp);
+ error = bread(&vp, lbn, osize, NULL, 0,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -194,7 +195,7 @@
if (error)
return (error);
if (bpp != NULL) {
- bp = getblk(ip->i_fd, ip->i_fs, lbn, nsize);
+ bp = getblk(&vp, lbn, nsize, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@@ -232,7 +233,7 @@
return error;
nb = newb;
*allocblk++ = nb;
- bp = getblk(ip->i_fd, ip->i_fs, indirs[1].in_lbn, fs->fs_bsize);
+ bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@@ -250,10 +251,10 @@
*/
for (i = 1;;) {
- error = bread(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize, &bp);
+ error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, 0,
+ &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap = (int32_t *)bp->b_data;
@@ -262,20 +263,19 @@
break;
i++;
if (nb != 0) {
- brelse(bp);
+ brelse(bp, 0);
continue;
}
if (pref == 0)
pref = ffs_blkpref_ufs1(ip, lbn, 0, (int32_t *)0);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize);
+ nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@@ -284,7 +284,7 @@
*/
if ((error = bwrite(nbp)) != 0) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap[indirs[i - 1].in_off] = ufs_rw32(nb, needswap);
@@ -300,13 +300,13 @@
pref = ffs_blkpref_ufs1(ip, lbn, indirs[num].in_off, &bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
- nbp = getblk(ip->i_fd, ip->i_fs, lbn, fs->fs_bsize);
+ nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@@ -320,11 +320,11 @@
bwrite(bp);
return (0);
}
- brelse(bp);
+ brelse(bp, 0);
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn, (int)fs->fs_bsize, &nbp);
+ error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, 0, &nbp);
if (error) {
- brelse(nbp);
+ brelse(nbp, 0);
return error;
}
*bpp = nbp;
@@ -346,6 +346,7 @@
int64_t *allocblk, allociblk[UFS_NIADDR + 1];
int64_t *allocib;
const int needswap = UFS_FSNEEDSWAP(fs);
+ struct vnode vp = { ip->i_fd, ip->i_fs, NULL, 0 };
lbn = lblkno(fs, offset);
size = blkoff(fs, offset) + bufsize;
@@ -389,10 +390,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- fs->fs_bsize, bpp);
+ error = bread(&vp, lbn, fs->fs_bsize, NULL, 0,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -415,10 +416,10 @@
*/
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn,
- osize, bpp);
+ error = bread(&vp, lbn, osize, NULL, 0,
+ bpp);
if (error) {
- brelse(*bpp);
+ brelse(*bpp, 0);
return (error);
}
}
@@ -445,7 +446,7 @@
if (error)
return (error);
if (bpp != NULL) {
- bp = getblk(ip->i_fd, ip->i_fs, lbn, nsize);
+ bp = getblk(&vp, lbn, nsize, 0, 0);
bp->b_blkno = fsbtodb(fs, newb);
clrbuf(bp);
*bpp = bp;
@@ -483,7 +484,7 @@
return error;
nb = newb;
*allocblk++ = nb;
- bp = getblk(ip->i_fd, ip->i_fs, indirs[1].in_lbn, fs->fs_bsize);
+ bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0);
bp->b_blkno = fsbtodb(fs, nb);
clrbuf(bp);
/*
@@ -501,10 +502,10 @@
*/
for (i = 1;;) {
- error = bread(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize, &bp);
+ error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, 0,
+ &bp);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap = (int64_t *)bp->b_data;
@@ -513,20 +514,19 @@
break;
i++;
if (nb != 0) {
- brelse(bp);
+ brelse(bp, 0);
continue;
}
if (pref == 0)
pref = ffs_blkpref_ufs2(ip, lbn, 0, (int64_t *)0);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
- nbp = getblk(ip->i_fd, ip->i_fs, indirs[i].in_lbn,
- fs->fs_bsize);
+ nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
/*
@@ -535,7 +535,7 @@
*/
if ((error = bwrite(nbp)) != 0) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
bap[indirs[i - 1].in_off] = ufs_rw64(nb, needswap);
@@ -551,13 +551,13 @@
pref = ffs_blkpref_ufs2(ip, lbn, indirs[num].in_off, &bap[0]);
error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize, &newb);
if (error) {
- brelse(bp);
+ brelse(bp, 0);
return error;
}
nb = newb;
*allocblk++ = nb;
if (bpp != NULL) {
- nbp = getblk(ip->i_fd, ip->i_fs, lbn, fs->fs_bsize);
+ nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0);
nbp->b_blkno = fsbtodb(fs, nb);
clrbuf(nbp);
*bpp = nbp;
@@ -571,11 +571,11 @@
bwrite(bp);
return (0);
}
- brelse(bp);
+ brelse(bp, 0);
if (bpp != NULL) {
- error = bread(ip->i_fd, ip->i_fs, lbn, (int)fs->fs_bsize, &nbp);
+ error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, 0, &nbp);
if (error) {
- brelse(nbp);
+ brelse(nbp, 0);
return error;
}
*bpp = nbp;