Module Name: src
Committed By: reinoud
Date: Tue Jul 28 15:31:21 UTC 2009
Modified Files:
src/sys/fs/nilfs: nilfs_subr.c
Log Message:
Enhance/fix read support for sparse files.
Extents read in wich there were no mappings at all were defined would error
out and files beginning with a sparse area were erroring out.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_subr.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/fs/nilfs/nilfs_subr.c
diff -u src/sys/fs/nilfs/nilfs_subr.c:1.1 src/sys/fs/nilfs/nilfs_subr.c:1.2
--- src/sys/fs/nilfs/nilfs_subr.c:1.1 Sat Jul 18 16:31:42 2009
+++ src/sys/fs/nilfs/nilfs_subr.c Tue Jul 28 15:31:21 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.2 2009/07/28 15:31:21 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.1 2009/07/18 16:31:42 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_subr.c,v 1.2 2009/07/28 15:31:21 reinoud Exp $");
#endif /* not lint */
#include <sys/param.h>
@@ -284,10 +284,18 @@
break;
selected = i;
}
+
+ /* if selected key > lblocknr, its not mapped */
+ if (dkeys[selected] > lblocknr)
+ return 0;
+
/* overshooting? then not mapped */
if (selected == nilfs_rw16(btree_hdr->bn_nchildren))
return 0;
+ /* level should be > 1 or otherwise it should be a direct one */
+ assert(btree_hdr->bn_level > 1);
+
/* lookup in selected child */
assert(dkeys[selected] <= lblocknr);
error = nilfs_btree_lookup_level(node, lblocknr,
@@ -407,10 +415,12 @@
}
/* TODO / OPTI more translations in one go */
- error = EINVAL;
+ error = 0;
for (i = 0; i < blks; i++) {
vblocknr = l2vmap[i];
pblocknr = v2pmap + i;
+ *pblocknr = 0;
+
/* only translate valid vblocknrs */
if (vblocknr == 0)
continue;