Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/nilfs Pullup changes from the write implementation:
details: https://anonhg.NetBSD.org/src/rev/9d9ac848c24a
branches: trunk
changeset: 755831:9d9ac848c24a
user: reinoud <reinoud%NetBSD.org@localhost>
date: Thu Jun 24 12:15:46 2010 +0000
description:
Pullup changes from the write implementation:
- remove unnessisary check that would prevent it from mounting newer nilfs
images. A field has been added in the segment summary.
- store blocks of files on their virtual block number
diffstat:
sys/fs/nilfs/nilfs_subr.c | 24 +++++++++++----------
sys/fs/nilfs/nilfs_vnops.c | 50 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 51 insertions(+), 23 deletions(-)
diffs (157 lines):
diff -r 8c39bbbd6027 -r 9d9ac848c24a sys/fs/nilfs/nilfs_subr.c
--- a/sys/fs/nilfs/nilfs_subr.c Thu Jun 24 10:39:35 2010 +0000
+++ b/sys/fs/nilfs/nilfs_subr.c Thu Jun 24 12:15:46 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.4 2009/07/29 17:06:57 reinoud Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.5 2010/06/24 12:15:46 reinoud Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_subr.c,v 1.4 2009/07/29 17:06:57 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_subr.c,v 1.5 2010/06/24 12:15:46 reinoud Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -60,6 +60,10 @@
#define VTOI(vnode) ((struct nilfs_node *) (vnode)->v_data)
+/* forwards */
+static int nilfs_btree_lookup(struct nilfs_node *node, uint64_t lblocknr,
+ uint64_t *vblocknr);
+
/* basic calculators */
uint64_t nilfs_get_segnum_of_block(struct nilfs_device *nilfsdev,
uint64_t blocknr)
@@ -145,7 +149,13 @@
nilfs_bread(struct nilfs_node *node, uint64_t blocknr,
struct kauth_cred *cred, int flags, struct buf **bpp)
{
- return bread(node->vnode, blocknr, node->nilfsdev->blocksize,
+ uint64_t vblocknr;
+ int error;
+
+ error = nilfs_btree_lookup(node, blocknr, &vblocknr);
+ if (error)
+ return error;
+ return bread(node->vnode, vblocknr, node->nilfsdev->blocksize,
cred, flags, bpp);
}
@@ -481,14 +491,6 @@
/* TODO check segment summary checksum */
/* TODO check data checksum */
- /* adjust our walking point if we have an odd size */
- if (segsum_struct_size != nilfs_rw32(ri->segsum.ss_bytes)) {
- printf("nilfs: WARNING encountered segsum_struct size %d in "
- "pseg %"PRIu64"\n",
- nilfs_rw32(ri->segsum.ss_bytes), ri->pseg);
- /* XXX report as an error? */
- }
-
out:
if (bp)
brelse(bp, BC_AGE);
diff -r 8c39bbbd6027 -r 9d9ac848c24a sys/fs/nilfs/nilfs_vnops.c
--- a/sys/fs/nilfs/nilfs_vnops.c Thu Jun 24 10:39:35 2010 +0000
+++ b/sys/fs/nilfs/nilfs_vnops.c Thu Jun 24 12:15:46 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.5 2010/06/24 07:54:46 hannken Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.6 2010/06/24 12:15:46 reinoud Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.5 2010/06/24 07:54:46 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.6 2010/06/24 12:15:46 reinoud Exp $");
#endif /* not lint */
@@ -318,9 +318,8 @@
/* --------------------------------------------------------------------- */
/*
- * `Special' bmap functionality that translates all incomming requests to
- * translate to vop_strategy() calls with the same blocknumbers effectively
- * not translating at all.
+ * bmap functionality that translates logical block numbers to the virtual
+ * block numbers to be stored on the vnode itself.
*/
int
@@ -339,23 +338,51 @@
daddr_t bn = ap->a_bn; /* origional */
int *runp = ap->a_runp;
struct nilfs_node *node = VTOI(vp);
+ uint64_t *l2vmap;
uint32_t blocksize;
+ int blks, run, error;
DPRINTF(TRANSLATE, ("nilfs_bmap() called\n"));
/* XXX could return `-1' to indicate holes/zero's */
blocksize = node->nilfsdev->blocksize;
+ blks = MAXPHYS / blocksize;
- /* translate 1:1 */
- *bnp = bn;
+ /* get mapping memory */
+ l2vmap = malloc(sizeof(uint64_t) * blks, M_TEMP, M_WAITOK);
+
+ /* get virtual block numbers for the vnode's buffer span */
+ error = nilfs_btree_nlookup(node, bn, blks, l2vmap);
+ if (error) {
+ free(l2vmap, M_TEMP);
+ return error;
+ }
+
+ /* store virtual blocks on our own vp */
if (vpp)
*vpp = vp;
- /* set runlength to maximum */
+ /* start at virt[0] */
+ *bnp = l2vmap[0];
+
+ /* get runlength */
+ run = 1;
+ while ((run < blks) && (l2vmap[run] == *bnp + run))
+ run++;
+
+ /* set runlength */
if (runp)
- *runp = MAXPHYS / blocksize;
+ *runp = run;
+
+ DPRINTF(TRANSLATE, ("\tstart %"PRIu64" -> %"PRIu64" run %d\n",
+ bn, *bnp, run));
+
+ /* mark not translated on virtual block number 0 */
+ if (*bnp == 0)
+ *bnp = -1;
/* return success */
+ free(l2vmap, M_TEMP);
return 0;
}
@@ -395,9 +422,8 @@
v2pmap = malloc(sizeof(uint64_t) * blks, M_TEMP, M_WAITOK);
/* get virtual block numbers for the vnode's buffer span */
- error = nilfs_btree_nlookup(node, from, blks, l2vmap);
- if (error)
- goto out;
+ for (i = 0; i < blks; i++)
+ l2vmap[i] = from + i;
/* translate virtual block numbers to physical block numbers */
error = nilfs_nvtop(node, blks, l2vmap, v2pmap);
Home |
Main Index |
Thread Index |
Old Index