CVS commit: src/sys/fs/nilfs

2020-03-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Mar 21 13:39:31 UTC 2020

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c

Log Message:
Fix use-after-free issue!


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/sys/fs/nilfs/nilfs_subr.c:1.15
--- src/sys/fs/nilfs/nilfs_subr.c:1.14	Sun Mar 29 14:12:28 2015
+++ src/sys/fs/nilfs/nilfs_subr.c	Sat Mar 21 13:39:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.14 2015/03/29 14:12:28 riastradh Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.15 2020/03/21 13:39:31 reinoud Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include 
 #ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_subr.c,v 1.14 2015/03/29 14:12:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_subr.c,v 1.15 2020/03/21 13:39:31 reinoud Exp $");
 #endif /* not lint */
 
 #include 
@@ -230,6 +230,7 @@ nilfs_btree_lookup_level(struct nilfs_no
 	dptrs = dkeys + NILFS_BTREE_NODE_NCHILDREN_MAX(nilfsdev->blocksize);
 
 	assert((btree_hdr->bn_flags & NILFS_BTREE_NODE_ROOT) == 0);
+	assert((btree_hdr->bn_level == level));
 
 	/* select matching child XXX could use binary search */
 	selected = 0;
@@ -253,7 +254,7 @@ nilfs_btree_lookup_level(struct nilfs_no
 	brelse(bp, BC_AGE);
 
 	return nilfs_btree_lookup_level(node, lblocknr,
-			child_btree_blk, btree_hdr->bn_level-1, vblocknr);
+			child_btree_blk, level-1, vblocknr);
 }
 
 
@@ -686,9 +687,10 @@ nilfs_get_node_raw(struct nilfs_device *
 
 	/* fixup inode size for system nodes */
 	if ((ino < NILFS_USER_INO) && (ino != NILFS_ROOT_INO)) {
-		DPRINTF(VOLUMES, ("NEED TO GET my size for inode %"PRIu64"\n",
+		DPRINTF(VOLUMES, ("NEED TO GET my size for inode %"PRIu64"?\n",
 			ino));
 		/* for now set it to maximum, -1 is illegal */
+		DPRINTF(VOLUMES, ("  current size of inode is %"PRIu64"\n", inode->i_size));
 		inode->i_size = nilfs_rw64(((uint64_t) -2));
 	}
 



CVS commit: src/sys/fs/nilfs

2020-03-21 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Mar 21 13:38:29 UTC 2020

Modified Files:
src/sys/fs/nilfs: nilfs.h

Log Message:
Compile in the DPRINTF debug macro's on DEBUG kernels


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/nilfs/nilfs.h

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.h
diff -u src/sys/fs/nilfs/nilfs.h:1.5 src/sys/fs/nilfs/nilfs.h:1.6
--- src/sys/fs/nilfs/nilfs.h:1.5	Wed Oct 15 09:05:46 2014
+++ src/sys/fs/nilfs/nilfs.h	Sat Mar 21 13:38:29 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs.h,v 1.5 2014/10/15 09:05:46 hannken Exp $ */
+/* $NetBSD: nilfs.h,v 1.6 2020/03/21 13:38:29 reinoud Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -66,7 +66,7 @@ extern int nilfs_verbose;
 /* initial value of nilfs_verbose */
 #define NILFS_DEBUGGING		0
 
-#ifdef NILFS_DEBUG
+#ifdef DEBUG
 #define DPRINTF(name, arg) { \
 		if (nilfs_verbose & NILFS_DEBUG_##name) {\
 			printf arg;\



CVS commit: src/sys/fs/nilfs

2015-03-29 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Mar 29 14:12:28 UTC 2015

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c nilfs_subr.h nilfs_vnops.c

Log Message:
Complete removal of cred argument from bread in nilfs.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/nilfs/nilfs_subr.h
cvs rdiff -u -r1.30 -r1.31 src/sys/fs/nilfs/nilfs_vnops.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.13 src/sys/fs/nilfs/nilfs_subr.c:1.14
--- src/sys/fs/nilfs/nilfs_subr.c:1.13	Sat Mar 28 19:24:05 2015
+++ src/sys/fs/nilfs/nilfs_subr.c	Sun Mar 29 14:12:28 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.13 2015/03/28 19:24:05 maxv Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.14 2015/03/29 14:12:28 riastradh 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.13 2015/03/28 19:24:05 maxv Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.14 2015/03/29 14:12:28 riastradh Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -128,7 +128,7 @@ crc32_le(uint32_t crc, const uint8_t *bu
 /* dev reading */
 static int
 nilfs_dev_bread(struct nilfs_device *nilfsdev, uint64_t blocknr,
-	struct kauth_cred *cred, int flags, struct buf **bpp)
+	int flags, struct buf **bpp)
 {
 	int blk2dev = nilfsdev-blocksize / DEV_BSIZE;
 
@@ -140,7 +140,7 @@ nilfs_dev_bread(struct nilfs_device *nil
 /* read on a node */
 int
 nilfs_bread(struct nilfs_node *node, uint64_t blocknr,
-	struct kauth_cred *cred, int flags, struct buf **bpp)
+	int flags, struct buf **bpp)
 {
 	struct nilfs_device *nilfsdev = node-nilfsdev;
 	uint64_t vblocknr, pblockno;
@@ -155,7 +155,7 @@ nilfs_bread(struct nilfs_node *node, uin
 		error = nilfs_nvtop(node, 1, vblocknr, pblockno);
 		if (error)
 			return error;
-		return nilfs_dev_bread(nilfsdev, pblockno, cred, flags, bpp);
+		return nilfs_dev_bread(nilfsdev, pblockno, flags, bpp);
 	}
 
 	return bread(node-vnode, vblocknr, node-nilfsdev-blocksize,
@@ -181,7 +181,7 @@ nilfs_get_segment_log(struct nilfs_devic
 		if (*bpp)
 			brelse(*bpp, BC_AGE);
 		/* read in block */
-		error = nilfs_dev_bread(nilfsdev, *blocknr, NOCRED, 0, bpp);
+		error = nilfs_dev_bread(nilfsdev, *blocknr, 0, bpp);
 		if (error)
 			return error;
 	}
@@ -217,7 +217,7 @@ nilfs_btree_lookup_level(struct nilfs_no
 		return error;
 
 	/* get our block */
-	error = nilfs_dev_bread(nilfsdev, btree_blknr, NOCRED, 0, bp);
+	error = nilfs_dev_bread(nilfsdev, btree_blknr, 0, bp);
 	if (error) {
 		return error;
 	}
@@ -388,7 +388,7 @@ nilfs_vtop(struct nilfs_device *nilfsdev
 	nilfs_mdt_trans(nilfsdev-dat_mdt, vblocknr,
 		ldatblknr, entry_in_block);
 
-	error = nilfs_bread(nilfsdev-dat_node, ldatblknr, NOCRED, 0, bp);
+	error = nilfs_bread(nilfsdev-dat_node, ldatblknr, 0, bp);
 	if (error) {
 		printf(vtop: can't read in DAT block %PRIu64!\n, ldatblknr);
 		return error;
@@ -803,7 +803,7 @@ dirhash_fill(struct nilfs_node *dir_node
 
 	blocknr = diroffset / blocksize;
 	blkoff  = diroffset % blocksize;
-	error = nilfs_bread(dir_node, blocknr, NOCRED, 0, bp);
+	error = nilfs_bread(dir_node, blocknr, 0, bp);
 	if (error) {
 		dirh-flags |= DIRH_BROKEN;
 		dirhash_purge_entries(dirh);
@@ -815,8 +815,7 @@ dirhash_fill(struct nilfs_node *dir_node
 		if (blkoff = blocksize) {
 			blkoff = 0; blocknr++;
 			brelse(bp, BC_AGE);
-			error = nilfs_bread(dir_node, blocknr, NOCRED, 0,
-	bp);
+			error = nilfs_bread(dir_node, blocknr, 0, bp);
 			if (error) {
 dirh-flags |= DIRH_BROKEN;
 dirhash_purge_entries(dirh);
@@ -900,7 +899,7 @@ nilfs_lookup_name_in_dir(struct vnode *d
 
 		blocknr = diroffset / blocksize;
 		blkoff  = diroffset % blocksize;
-		error = nilfs_bread(dir_node, blocknr, NOCRED, 0, bp);
+		error = nilfs_bread(dir_node, blocknr, 0, bp);
 		if (error)
 			return EIO;
 

Index: src/sys/fs/nilfs/nilfs_subr.h
diff -u src/sys/fs/nilfs/nilfs_subr.h:1.3 src/sys/fs/nilfs/nilfs_subr.h:1.4
--- src/sys/fs/nilfs/nilfs_subr.h:1.3	Wed Oct 15 09:05:46 2014
+++ src/sys/fs/nilfs/nilfs_subr.h	Sun Mar 29 14:12:28 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.h,v 1.3 2014/10/15 09:05:46 hannken Exp $ */
+/* $NetBSD: nilfs_subr.h,v 1.4 2015/03/29 14:12:28 riastradh Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -46,7 +46,7 @@ int nilfs_get_segment_log(struct nilfs_d
 void nilfs_search_super_root(struct nilfs_device *nilfsdev);
 
 /* reading */
-int nilfs_bread(struct nilfs_node *node, uint64_t blocknr, struct kauth_cred *cred,
+int nilfs_bread(struct nilfs_node *node, uint64_t blocknr,
 	int flags, struct buf **bpp);
 
 /* btree operations */

Index: src/sys/fs/nilfs/nilfs_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.30 src/sys/fs/nilfs/nilfs_vnops.c:1.31
--- 

CVS commit: src/sys/fs/nilfs

2015-02-07 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sat Feb  7 10:40:57 UTC 2015

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
Revert previous, it was a false positive.

In nilfs_mount_device() there's one branch where the node is not released:
when the device is already mounted. Not releasing it was thus intentional,
but this is something code scanners can't understand.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.19 src/sys/fs/nilfs/nilfs_vfsops.c:1.20
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.19	Sat Feb  7 04:25:16 2015
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Sat Feb  7 10:40:57 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.19 2015/02/07 04:25:16 christos Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.20 2015/02/07 10:40:57 maxv Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.19 2015/02/07 04:25:16 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.20 2015/02/07 10:40:57 maxv Exp $);
 #endif /* not lint */
 
 
@@ -879,10 +879,8 @@ nilfs_mount(struct mount *mp, const char
 #endif
 
 	error = nilfs_mount_device(devvp, mp, args, nilfsdev);
-	if (error) {
-		vrele(devvp);
+	if (error)
 		return error;
-	}
 
 	/*
 	 * Create a nilfs_mount on the specified checkpoint. Note that only



CVS commit: src/sys/fs/nilfs

2015-02-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb  7 04:25:16 UTC 2015

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
fix devvp leak. Reported by:
http://www.m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html#Report-4


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.18 src/sys/fs/nilfs/nilfs_vfsops.c:1.19
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.18	Wed Oct 15 05:05:46 2014
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Fri Feb  6 23:25:16 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.18 2014/10/15 09:05:46 hannken Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.19 2015/02/07 04:25:16 christos Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.18 2014/10/15 09:05:46 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.19 2015/02/07 04:25:16 christos Exp $);
 #endif /* not lint */
 
 
@@ -879,8 +879,10 @@ nilfs_mount(struct mount *mp, const char
 #endif
 
 	error = nilfs_mount_device(devvp, mp, args, nilfsdev);
-	if (error)
+	if (error) {
+		vrele(devvp);
 		return error;
+	}
 
 	/*
 	 * Create a nilfs_mount on the specified checkpoint. Note that only



CVS commit: src/sys/fs/nilfs

2014-10-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Oct 15 09:03:53 UTC 2014

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c nilfs_subr.h nilfs_vfsops.c
nilfs_vnops.c

Log Message:
Prepare nilfs for vcache:
- Calling getnewvnode() with mp == NULL is wrong.  Stop attaching a
  vnode to system file nodes and change nilfs_bread() to translate
  the block address and then uyse the device for the read.
- Move the vnode initialisation to nilfs_get_node() and use
  nilfs_get_node_raw() to initialise the nilfs node only.
- Same for nilfs_reclaim() versus nilfs_dispose_node().
- Change nilfs_get_node() to return an unlocked vnode instead of
  a nilfs node with locked vnode.  Adapt nilfs_lookup() and nilfs_root().
- Don't treat unsupported node types (blk, chr ...) as regular,
  return ENXIO instead.
- Fix nilfs_getattr() to mask the mode with ALLPERMS.
- Destroy sync_cv before free.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_subr.h
cvs rdiff -u -r1.16 -r1.17 src/sys/fs/nilfs/nilfs_vfsops.c
cvs rdiff -u -r1.28 -r1.29 src/sys/fs/nilfs/nilfs_vnops.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.10 src/sys/fs/nilfs/nilfs_subr.c:1.11
--- src/sys/fs/nilfs/nilfs_subr.c:1.10	Fri Oct 18 19:57:28 2013
+++ src/sys/fs/nilfs/nilfs_subr.c	Wed Oct 15 09:03:53 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.10 2013/10/18 19:57:28 christos Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.11 2014/10/15 09:03:53 hannken 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.10 2013/10/18 19:57:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.11 2014/10/15 09:03:53 hannken Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -149,12 +149,22 @@ int
 nilfs_bread(struct nilfs_node *node, uint64_t blocknr,
 	struct kauth_cred *cred, int flags, struct buf **bpp)
 {
-	uint64_t vblocknr;
+	struct nilfs_device *nilfsdev = node-nilfsdev;
+	uint64_t vblocknr, pblockno;
 	int error;
 
 	error = nilfs_btree_lookup(node, blocknr, vblocknr);
 	if (error)
 		return error;
+
+	/* Read special files through devvp as they have no vnode attached. */
+	if (node-ino  NILFS_USER_INO  node-ino != NILFS_ROOT_INO) {
+		error = nilfs_nvtop(node, 1, vblocknr, pblockno);
+		if (error)
+			return error;
+		return nilfs_dev_bread(nilfsdev, pblockno, cred, flags, bpp);
+	}
+
 	return bread(node-vnode, vblocknr, node-nilfsdev-blocksize,
 		cred, flags, bpp);
 }
@@ -746,7 +756,7 @@ nilfs_register_node(struct nilfs_node *n
 }
 
 
-static void
+void
 nilfs_deregister_node(struct nilfs_node *node) 
 {
 	struct nilfs_mount *ump;
@@ -799,67 +809,25 @@ nilfs_get_node_raw(struct nilfs_device *
 	uint64_t ino, struct nilfs_inode *inode, struct nilfs_node **nodep)
 {
 	struct nilfs_node *node;
-	struct vnode *nvp;
-	struct mount *mp;
-	int (**vnodeops)(void *);
-	int error;
 
 	*nodep = NULL;
-	vnodeops = nilfs_vnodeop_p;
-
-	/* associate with mountpoint if present*/
-	mp = ump? ump-vfs_mountp : NULL;
-	error = getnewvnode(VT_NILFS, mp, vnodeops, NULL, nvp);
-	if (error)
-		return error;
-
-	/* lock node */
-	error = vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY);
-	if (error) {
-		nvp-v_data = NULL;
-		ungetnewvnode(nvp);
-		return error;
-	}
 
 	node = pool_get(nilfs_node_pool, PR_WAITOK);
 	memset(node, 0, sizeof(struct nilfs_node));
 
 	/* crosslink */
-	node-vnode= nvp;
 	node-ump  = ump;
 	node-nilfsdev = nilfsdev;
-	nvp-v_data= node;
 
 	/* initiase nilfs node */
 	node-ino   = ino;
 	node-inode = *inode;
 	node-lockf = NULL;
 
-	/* needed? */
+	/* initialise locks */
 	mutex_init(node-node_mutex, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(node-node_lock, nilfsnlk);
 
-	/* initialise genfs */
-	genfs_node_init(nvp, nilfs_genfsops);
-
-	/* check if we're fetching the root */
-	if (ino == NILFS_ROOT_INO)
-		nvp-v_vflag |= VV_ROOT;
-
-	/* update vnode's file type XXX is there a function for this? */
-	nvp-v_type = VREG;
-	if (S_ISDIR(inode-i_mode))
-		nvp-v_type = VDIR;
-	if (S_ISLNK(inode-i_mode))
-		nvp-v_type = VLNK;
-#if 0
-	if (S_ISCHR(inode-i_mode))
-		nvp-v_type = VCHR;
-	if (S_ISBLK(inode-i_mode))
-		nvp-v_type = VBLK;
-#endif
-	/* XXX what else? */
-
 	/* fixup inode size for system nodes */
 	if ((ino  NILFS_USER_INO)  (ino != NILFS_ROOT_INO)) {
 		DPRINTF(VOLUMES, (NEED TO GET my size for inode %PRIu64\n,
@@ -868,39 +836,41 @@ nilfs_get_node_raw(struct nilfs_device *
 		inode-i_size = nilfs_rw64(((uint64_t) -2));
 	}
 
-	uvm_vnp_setsize(nvp, nilfs_rw64(inode-i_size));
-
-	if (ump)
-		nilfs_register_node(node);
-
 	/* return node */
 	*nodep = node;
 	return 0;
 }
 
-
 int
-nilfs_get_node(struct nilfs_mount *ump, uint64_t ino, struct nilfs_node **nodep)

CVS commit: src/sys/fs/nilfs

2014-10-15 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Oct 15 09:05:46 UTC 2014

Modified Files:
src/sys/fs/nilfs: nilfs.h nilfs_subr.c nilfs_subr.h nilfs_vfsops.c
nilfs_vnops.c

Log Message:
Change nilfs to vcache.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/nilfs/nilfs.h
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/fs/nilfs/nilfs_subr.h
cvs rdiff -u -r1.17 -r1.18 src/sys/fs/nilfs/nilfs_vfsops.c
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/nilfs/nilfs_vnops.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.h
diff -u src/sys/fs/nilfs/nilfs.h:1.4 src/sys/fs/nilfs/nilfs.h:1.5
--- src/sys/fs/nilfs/nilfs.h:1.4	Fri Oct 18 19:57:28 2013
+++ src/sys/fs/nilfs/nilfs.h	Wed Oct 15 09:05:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs.h,v 1.4 2013/10/18 19:57:28 christos Exp $ */
+/* $NetBSD: nilfs.h,v 1.5 2014/10/15 09:05:46 hannken Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -172,11 +172,6 @@ struct nilfs_mount {
 	/* instance values */
 	struct nilfs_node	*ifile_node;
 
-	/* hash table to lookup ino - nilfs_node */
-	kmutex_t		 ihash_lock;
-	kmutex_t		 get_node_lock;
-	LIST_HEAD(, nilfs_node)  nilfs_nodes[NILFS_INODE_HASHSIZE];
-
 	/* lists */
 	STAILQ_ENTRY(nilfs_mount) next_mount;		/* in nilfs_device   */
 };

Index: src/sys/fs/nilfs/nilfs_subr.c
diff -u src/sys/fs/nilfs/nilfs_subr.c:1.11 src/sys/fs/nilfs/nilfs_subr.c:1.12
--- src/sys/fs/nilfs/nilfs_subr.c:1.11	Wed Oct 15 09:03:53 2014
+++ src/sys/fs/nilfs/nilfs_subr.c	Wed Oct 15 09:05:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.11 2014/10/15 09:03:53 hannken Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.12 2014/10/15 09:05:46 hannken 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.11 2014/10/15 09:03:53 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.12 2014/10/15 09:05:46 hannken Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -125,13 +125,6 @@ crc32_le(uint32_t crc, const uint8_t *bu
 }
 
 
-static int
-nilfs_calchash(uint64_t ino)
-{
-	return (int) ino;
-}
-
-
 /* dev reading */
 static int
 nilfs_dev_bread(struct nilfs_device *nilfsdev, uint64_t blocknr,
@@ -354,7 +347,7 @@ nilfs_btree_nlookup(struct nilfs_node *n
 /* vtop operations */
 
 /* translate index to a file block number and an entry */
-static void
+void
 nilfs_mdt_trans(struct nilfs_mdt *mdt, uint64_t index,
 	uint64_t *blocknr, uint32_t *entry_in_block)
 {
@@ -667,143 +660,6 @@ nilfs_search_super_root(struct nilfs_dev
 
 /* - */
 
-/*
- * Genfs interfacing
- *
- * static const struct genfs_ops nilfs_genfsops = {
- * 	.gop_size = genfs_size,
- * 		size of transfers
- * 	.gop_alloc = nilfs_gop_alloc,
- * 		allocate len bytes at offset
- * 	.gop_write = genfs_gop_write,
- * 		putpages interface code
- * 	.gop_markupdate = nilfs_gop_markupdate,
- * 		set update/modify flags etc.
- * }
- */
-
-/*
- * Callback from genfs to allocate len bytes at offset off; only called when
- * filling up gaps in the allocation.
- */
-static int
-nilfs_gop_alloc(struct vnode *vp, off_t off,
-off_t len, int flags, kauth_cred_t cred)
-{
-	DPRINTF(NOTIMPL, (nilfs_gop_alloc not implemented\n));
-	DPRINTF(ALLOC, (nilfs_gop_alloc called for %PRIu64 bytes\n, len));
-
-	return 0;
-}
-
-
-/*
- * callback from genfs to update our flags
- */
-static void
-nilfs_gop_markupdate(struct vnode *vp, int flags)
-{
-	struct nilfs_node *nilfs_node = VTOI(vp);
-	u_long mask = 0;
-
-	if ((flags  GOP_UPDATE_ACCESSED) != 0) {
-		mask = IN_ACCESS;
-	}
-	if ((flags  GOP_UPDATE_MODIFIED) != 0) {
-		if (vp-v_type == VREG) {
-			mask |= IN_CHANGE | IN_UPDATE;
-		} else {
-			mask |= IN_MODIFY;
-		}
-	}
-	if (mask) {
-		nilfs_node-i_flags |= mask;
-	}
-}
-
-
-static const struct genfs_ops nilfs_genfsops = {
-	.gop_size = genfs_size,
-	.gop_alloc = nilfs_gop_alloc,
-	.gop_write = genfs_gop_write_rwmap,
-	.gop_markupdate = nilfs_gop_markupdate,
-};
-
-/* - */
-
-static void
-nilfs_register_node(struct nilfs_node *node)
-{
-	struct nilfs_mount *ump;
-	uint32_t hashline;
-
-	ump = node-ump;
-	mutex_enter(ump-ihash_lock);
-
-	/* add to our hash table */
-	hashline = nilfs_calchash(node-ino)  NILFS_INODE_HASHMASK;
-#ifdef DEBUG
-	struct nilfs_node *chk;
-	LIST_FOREACH(chk, ump-nilfs_nodes[hashline], hashchain) {
-		assert(chk);
-		if (chk-ino == node-ino)
-			panic(Double node entered\n);
-	}
-#endif
-	LIST_INSERT_HEAD(ump-nilfs_nodes[hashline], node, hashchain);
-
-	mutex_exit(ump-ihash_lock);
-}
-
-
-void
-nilfs_deregister_node(struct nilfs_node *node) 
-{
-	struct nilfs_mount *ump;
-
-	ump = node-ump;
-	mutex_enter(ump-ihash_lock);
-
-	/* remove from hash 

CVS commit: src/sys/fs/nilfs

2013-11-01 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Fri Nov  1 06:41:56 UTC 2013

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
apply __diagused where appropriate.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.12 src/sys/fs/nilfs/nilfs_vfsops.c:1.13
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.12	Fri Oct 18 19:57:28 2013
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Fri Nov  1 06:41:56 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.12 2013/10/18 19:57:28 christos Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.13 2013/11/01 06:41:56 mrg Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.12 2013/10/18 19:57:28 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.13 2013/11/01 06:41:56 mrg Exp $);
 #endif /* not lint */
 
 
@@ -399,7 +399,7 @@ nilfs_read_superblock(struct nilfs_devic
 static void
 nilfs_unmount_base(struct nilfs_device *nilfsdev)
 {
-	int error;
+	int error __diagused;
 
 	if (!nilfsdev)
 		return;



CVS commit: src/sys/fs/nilfs

2013-10-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 18 19:57:28 UTC 2013

Modified Files:
src/sys/fs/nilfs: nilfs.h nilfs_subr.c nilfs_vfsops.c nilfs_vnops.c

Log Message:
remove unused variable warnings


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/nilfs/nilfs.h
cvs rdiff -u -r1.9 -r1.10 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/nilfs/nilfs_vfsops.c
cvs rdiff -u -r1.23 -r1.24 src/sys/fs/nilfs/nilfs_vnops.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.h
diff -u src/sys/fs/nilfs/nilfs.h:1.3 src/sys/fs/nilfs/nilfs.h:1.4
--- src/sys/fs/nilfs/nilfs.h:1.3	Fri Jul 27 20:43:23 2012
+++ src/sys/fs/nilfs/nilfs.h	Fri Oct 18 15:57:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs.h,v 1.3 2012/07/28 00:43:23 matt Exp $ */
+/* $NetBSD: nilfs.h,v 1.4 2013/10/18 19:57:28 christos Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -66,7 +66,7 @@ extern int nilfs_verbose;
 /* initial value of nilfs_verbose */
 #define NILFS_DEBUGGING		0
 
-#ifdef DEBUG
+#ifdef NILFS_DEBUG
 #define DPRINTF(name, arg) { \
 		if (nilfs_verbose  NILFS_DEBUG_##name) {\
 			printf arg;\

Index: src/sys/fs/nilfs/nilfs_subr.c
diff -u src/sys/fs/nilfs/nilfs_subr.c:1.9 src/sys/fs/nilfs/nilfs_subr.c:1.10
--- src/sys/fs/nilfs/nilfs_subr.c:1.9	Thu Dec 20 03:03:43 2012
+++ src/sys/fs/nilfs/nilfs_subr.c	Fri Oct 18 15:57:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.9 2012/12/20 08:03:43 hannken Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.10 2013/10/18 19:57:28 christos 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.9 2012/12/20 08:03:43 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.10 2013/10/18 19:57:28 christos Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -725,7 +725,6 @@ static void
 nilfs_register_node(struct nilfs_node *node)
 {
 	struct nilfs_mount *ump;
-	struct nilfs_node *chk;
 	uint32_t hashline;
 
 	ump = node-ump;
@@ -734,13 +733,12 @@ nilfs_register_node(struct nilfs_node *n
 	/* add to our hash table */
 	hashline = nilfs_calchash(node-ino)  NILFS_INODE_HASHMASK;
 #ifdef DEBUG
+	struct nilfs_node *chk;
 	LIST_FOREACH(chk, ump-nilfs_nodes[hashline], hashchain) {
 		assert(chk);
 		if (chk-ino == node-ino)
 			panic(Double node entered\n);
 	}
-#else
-	chk = NULL;
 #endif
 	LIST_INSERT_HEAD(ump-nilfs_nodes[hashline], node, hashchain);
 

Index: src/sys/fs/nilfs/nilfs_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.11 src/sys/fs/nilfs/nilfs_vfsops.c:1.12
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.11	Mon Sep 30 14:57:59 2013
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Fri Oct 18 15:57:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.11 2013/09/30 18:57:59 hannken Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.12 2013/10/18 19:57:28 christos Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.11 2013/09/30 18:57:59 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.12 2013/10/18 19:57:28 christos Exp $);
 #endif /* not lint */
 
 
@@ -693,6 +693,10 @@ nilfs_mount_checkpoint(struct nilfs_moun
 	DPRINTF(VOLUMES, (mount_nilfs: checkpoint header read in\n));
 	DPRINTF(VOLUMES, (\tNumber of checkpoints %PRIu64\n, ncp));
 	DPRINTF(VOLUMES, (\tNumber of snapshots   %PRIu64\n, nsn));
+#ifndef NILFS_DEBUG
+	__USE(ncp);
+	__USE(nsn);
+#endif
 
 	/* read in our specified checkpoint */
 	dlen = nilfs_rw16(ump-nilfsdev-super.s_checkpoint_size);

Index: src/sys/fs/nilfs/nilfs_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.23 src/sys/fs/nilfs/nilfs_vnops.c:1.24
--- src/sys/fs/nilfs/nilfs_vnops.c:1.23	Wed May  8 06:39:17 2013
+++ src/sys/fs/nilfs/nilfs_vnops.c	Fri Oct 18 15:57:28 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.23 2013/05/08 10:39:17 reinoud Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.24 2013/10/18 19:57:28 christos 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.23 2013/05/08 10:39:17 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.24 2013/10/18 19:57:28 christos Exp $);
 #endif /* not lint */
 
 
@@ -212,7 +212,7 @@ nilfs_write(void *v)
 	int   advice = IO_ADV_DECODE(ap-a_ioflag);
 	struct uvm_object*uobj;
 	struct nilfs_node  *nilfs_node = VTOI(vp);
-	uint64_t file_size, old_size;
+	uint64_t file_size;
 	vsize_t len;
 	int error, resid, extended;
 
@@ -235,12 +235,10 @@ nilfs_write(void *v)
 
 	assert(nilfs_node);
 	panic(nilfs_write() called\n);
-return EIO;
 
 	/* remember old file size */
 	assert(nilfs_node);
 	file_size = nilfs_rw64(nilfs_node-inode.i_size);
-	old_size = file_size;
 
 	/* if explicitly asked to append, uio_offset can be wrong? 

CVS commit: src/sys/fs/nilfs

2013-05-08 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed May  8 10:29:22 UTC 2013

Modified Files:
src/sys/fs/nilfs: nilfs_vnops.c

Log Message:
Fix serious file read problem due to not-so-clear VOP_BMAP description. Should
fix PR 45605.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/fs/nilfs/nilfs_vnops.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_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.21 src/sys/fs/nilfs/nilfs_vnops.c:1.22
--- src/sys/fs/nilfs/nilfs_vnops.c:1.21	Mon Mar 18 19:35:38 2013
+++ src/sys/fs/nilfs/nilfs_vnops.c	Wed May  8 10:29:22 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.21 2013/03/18 19:35:38 plunky Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.22 2013/05/08 10:29:22 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.21 2013/03/18 19:35:38 plunky Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.22 2013/05/08 10:29:22 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -315,6 +315,11 @@ return EIO;
 /*
  * bmap functionality that translates logical block numbers to the virtual
  * block numbers to be stored on the vnode itself.
+ *
+ * Important allert!
+ *
+ * If runp is not NULL, the number of contiguous blocks __starting from the
+ * next block after the queried block__ will be returned in runp.
  */
 
 int
@@ -364,7 +369,8 @@ nilfs_trivial_bmap(void *v)
 	run = 1;
 	while ((run  blks)  (l2vmap[run] == *bnp + run))
 		run++;
-	
+	run--;	/* see comment at start of function */
+
 	/* set runlength */
 	if (runp)
 		*runp = run;



CVS commit: src/sys/fs/nilfs

2013-05-08 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed May  8 10:39:17 UTC 2013

Modified Files:
src/sys/fs/nilfs: nilfs_vnops.c

Log Message:
Fix Typo


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/fs/nilfs/nilfs_vnops.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_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.22 src/sys/fs/nilfs/nilfs_vnops.c:1.23
--- src/sys/fs/nilfs/nilfs_vnops.c:1.22	Wed May  8 10:29:22 2013
+++ src/sys/fs/nilfs/nilfs_vnops.c	Wed May  8 10:39:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.22 2013/05/08 10:29:22 reinoud Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.23 2013/05/08 10:39:17 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.22 2013/05/08 10:29:22 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.23 2013/05/08 10:39:17 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -316,7 +316,7 @@ return EIO;
  * bmap functionality that translates logical block numbers to the virtual
  * block numbers to be stored on the vnode itself.
  *
- * Important allert!
+ * Important alert!
  *
  * If runp is not NULL, the number of contiguous blocks __starting from the
  * next block after the queried block__ will be returned in runp.



CVS commit: src/sys/fs/nilfs

2011-11-13 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Sun Nov 13 17:22:51 UTC 2011

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
Avoid panic on error path, from PR 45607. The error path is exercised
because this is using DIOCGPART to get the volume size, which doesn't
work on wedges. It should be calling getdisksize() instead.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.5 src/sys/fs/nilfs/nilfs_vfsops.c:1.6
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.5	Wed Aug 11 13:26:25 2010
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Sun Nov 13 17:22:51 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.5 2010/08/11 13:26:25 pgoyette Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.6 2011/11/13 17:22:51 dholland Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.5 2010/08/11 13:26:25 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.6 2011/11/13 17:22:51 dholland Exp $);
 #endif /* not lint */
 
 
@@ -635,6 +635,9 @@ nilfs_mount_device(struct vnode *devvp, 
 	cv_init(nilfsdev-sync_cv, nilfssyn);
 	STAILQ_INIT(nilfsdev-mounts);
 
+	/* register nilfs_device in list */
+	SLIST_INSERT_HEAD(nilfs_devices, nilfsdev, next_device);
+
 	/* get our device's size */
 	error = VOP_IOCTL(devvp, DIOCGPART, dpart, FREAD, NOCRED);
 	if (error) {
@@ -644,9 +647,6 @@ nilfs_mount_device(struct vnode *devvp, 
 	}
 	nilfsdev-devsize = dpart.part-p_size * dpart.disklab-d_secsize;
 
-	/* register nilfs_device in list */
-	SLIST_INSERT_HEAD(nilfs_devices, nilfsdev, next_device);
-
 	/* connect to the head for most recent files XXX really pass mp and args? */
 	error = nilfs_mount_base(nilfsdev, mp, args);
 	if (error) {



CVS commit: src/sys/fs/nilfs

2011-11-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 13 18:29:08 UTC 2011

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
use getdisksize, M_ZERO, and malloc M_WAITOK doesn't fai.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.6 src/sys/fs/nilfs/nilfs_vfsops.c:1.7
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.6	Sun Nov 13 12:22:51 2011
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Sun Nov 13 13:29:08 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.6 2011/11/13 17:22:51 dholland Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.7 2011/11/13 18:29:08 christos Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.6 2011/11/13 17:22:51 dholland Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.7 2011/11/13 18:29:08 christos Exp $);
 #endif /* not lint */
 
 
@@ -563,7 +563,8 @@ static int
 nilfs_mount_device(struct vnode *devvp, struct mount *mp, struct nilfs_args *args,
 	struct nilfs_device **nilfsdev_p)
 {
-	struct partinfo dpart;
+	uint64_t psize;
+	unsigned secsize;
 	struct nilfs_device *nilfsdev;
 	struct lwp *l = curlwp;
 	int openflags, accessmode, error;
@@ -624,11 +625,9 @@ nilfs_mount_device(struct vnode *devvp, 
 	}
 
 	/* opened ok, try mounting */
-	nilfsdev = malloc(sizeof(struct nilfs_device), M_NILFSMNT, M_WAITOK);
-	KASSERT(nilfsdev);
+	nilfsdev = malloc(sizeof(*nilfsdev), M_NILFSMNT, M_WAITOK | M_ZERO);
 
 	/* initialise */
-	memset(nilfsdev, 0, sizeof(struct nilfs_device));
 	nilfsdev-refcnt= 1;
 	nilfsdev-devvp = devvp;
 	nilfsdev-uncomitted_bl = 0;
@@ -639,13 +638,14 @@ nilfs_mount_device(struct vnode *devvp, 
 	SLIST_INSERT_HEAD(nilfs_devices, nilfsdev, next_device);
 
 	/* get our device's size */
-	error = VOP_IOCTL(devvp, DIOCGPART, dpart, FREAD, NOCRED);
+	error = getdisksize(devvp, psize, secsize);
 	if (error) {
 		/* remove all our information */
 		nilfs_unmount_device(nilfsdev);
 		return EINVAL;
 	}
-	nilfsdev-devsize = dpart.part-p_size * dpart.disklab-d_secsize;
+
+	nilfsdev-devsize = psize * secsize;
 
 	/* connect to the head for most recent files XXX really pass mp and args? */
 	error = nilfs_mount_base(nilfsdev, mp, args);



CVS commit: src/sys/fs/nilfs

2011-10-16 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Sun Oct 16 12:41:46 UTC 2011

Modified Files:
src/sys/fs/nilfs: nilfs_vnops.c

Log Message:
VOP_GETATTR() needs a shared lock at least.

While here fix a typo (fvp - tvp).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/fs/nilfs/nilfs_vnops.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_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.14 src/sys/fs/nilfs/nilfs_vnops.c:1.15
--- src/sys/fs/nilfs/nilfs_vnops.c:1.14	Tue Sep 27 01:34:41 2011
+++ src/sys/fs/nilfs/nilfs_vnops.c	Sun Oct 16 12:41:45 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.14 2011/09/27 01:34:41 christos Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken 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.14 2011/09/27 01:34:41 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.15 2011/10/16 12:41:45 hannken Exp $);
 #endif /* not lint */
 
 
@@ -1330,13 +1330,15 @@ nilfs_rename(void *v)
 	}
 
 	/* get info about the node to be moved */
+	vn_lock(fvp, LK_SHARED | LK_RETRY);
 	error = VOP_GETATTR(fvp, fvap, FSCRED);
+	VOP_UNLOCK(fvp);
 	KASSERT(error == 0);
 
 	/* check when to delete the old already existing entry */
 	if (tvp) {
 		/* get info about the node to be moved to */
-		error = VOP_GETATTR(fvp, tvap, FSCRED);
+		error = VOP_GETATTR(tvp, tvap, FSCRED);
 		KASSERT(error == 0);
 
 		/* if both dirs, make sure the destination is empty */



CVS commit: src/sys/fs/nilfs

2011-09-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Sep 27 01:34:41 UTC 2011

Modified Files:
src/sys/fs/nilfs: nilfs.h nilfs_vnops.c

Log Message:
define NILFS_MAXNAMLEN and use it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs.h
cvs rdiff -u -r1.13 -r1.14 src/sys/fs/nilfs/nilfs_vnops.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.h
diff -u src/sys/fs/nilfs/nilfs.h:1.1 src/sys/fs/nilfs/nilfs.h:1.2
--- src/sys/fs/nilfs/nilfs.h:1.1	Sat Jul 18 12:31:42 2009
+++ src/sys/fs/nilfs/nilfs.h	Mon Sep 26 21:34:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs.h,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs.h,v 1.2 2011/09/27 01:34:41 christos Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -106,6 +106,8 @@ struct nilfs_node;
 struct nilfs_mount;
 
 
+#define NILFS_MAXNAMLEN	255
+
 /* structure and derivatives */
 struct nilfs_mdt {
 	uint32_t  entries_per_block;

Index: src/sys/fs/nilfs/nilfs_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.13 src/sys/fs/nilfs/nilfs_vnops.c:1.14
--- src/sys/fs/nilfs/nilfs_vnops.c:1.13	Sat Jun 18 22:42:53 2011
+++ src/sys/fs/nilfs/nilfs_vnops.c	Mon Sep 26 21:34:41 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.13 2011/06/19 02:42:53 rmind Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.14 2011/09/27 01:34:41 christos 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.13 2011/06/19 02:42:53 rmind Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.14 2011/09/27 01:34:41 christos Exp $);
 #endif /* not lint */
 
 
@@ -902,7 +902,7 @@ nilfs_pathconf(void *v)
 		*ap-a_retval = (116)-1;	/* 16 bits */
 		return 0;
 	case _PC_NAME_MAX:
-		*ap-a_retval = NAME_MAX;
+		*ap-a_retval = NILFS_MAXNAMLEN;
 		return 0;
 	case _PC_PATH_MAX:
 		*ap-a_retval = PATH_MAX;



CVS commit: src/sys/fs/nilfs

2010-08-11 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Aug 11 11:43:13 UTC 2010

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c nilfs_vfsops.c

Log Message:
Keep condvar wmesg's within 8-char limit


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.3 -r1.4 src/sys/fs/nilfs/nilfs_vfsops.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.6 src/sys/fs/nilfs/nilfs_subr.c:1.7
--- src/sys/fs/nilfs/nilfs_subr.c:1.6	Wed Jul 21 17:52:10 2010
+++ src/sys/fs/nilfs/nilfs_subr.c	Wed Aug 11 11:43:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.6 2010/07/21 17:52:10 hannken Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.7 2010/08/11 11:43:13 pgoyette 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.6 2010/07/21 17:52:10 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.7 2010/08/11 11:43:13 pgoyette Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -841,7 +841,7 @@
 
 	/* needed? */
 	mutex_init(node-node_mutex, MUTEX_DEFAULT, IPL_NONE);
-	cv_init(node-node_lock, nilfs_nlk);
+	cv_init(node-node_lock, nilfsnlk);
 
 	/* initialise genfs */
 	genfs_node_init(nvp, nilfs_genfsops);

Index: src/sys/fs/nilfs/nilfs_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.3 src/sys/fs/nilfs/nilfs_vfsops.c:1.4
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.3	Thu Jun 24 13:03:10 2010
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Wed Aug 11 11:43:13 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.3 2010/06/24 13:03:10 hannken Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.4 2010/08/11 11:43:13 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.3 2010/06/24 13:03:10 hannken Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.4 2010/08/11 11:43:13 pgoyette Exp $);
 #endif /* not lint */
 
 
@@ -632,7 +632,7 @@
 	nilfsdev-refcnt= 1;
 	nilfsdev-devvp = devvp;
 	nilfsdev-uncomitted_bl = 0;
-	cv_init(nilfsdev-sync_cv, nilfssync);
+	cv_init(nilfsdev-sync_cv, nilfsisyn);
 	STAILQ_INIT(nilfsdev-mounts);
 
 	/* get our device's size */



CVS commit: src/sys/fs/nilfs

2010-08-11 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Wed Aug 11 13:26:25 UTC 2010

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
Remove extra char - not sure where that came from (duplicated vi command?)

I really need more caffeine.

Thanks pooka@ for noticing.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.4 src/sys/fs/nilfs/nilfs_vfsops.c:1.5
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.4	Wed Aug 11 11:43:13 2010
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Wed Aug 11 13:26:25 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.4 2010/08/11 11:43:13 pgoyette Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.5 2010/08/11 13:26:25 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.4 2010/08/11 11:43:13 pgoyette Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.5 2010/08/11 13:26:25 pgoyette Exp $);
 #endif /* not lint */
 
 
@@ -632,7 +632,7 @@
 	nilfsdev-refcnt= 1;
 	nilfsdev-devvp = devvp;
 	nilfsdev-uncomitted_bl = 0;
-	cv_init(nilfsdev-sync_cv, nilfsisyn);
+	cv_init(nilfsdev-sync_cv, nilfssyn);
 	STAILQ_INIT(nilfsdev-mounts);
 
 	/* get our device's size */



CVS commit: src/sys/fs/nilfs

2010-06-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 24 10:20:08 UTC 2010

Modified Files:
src/sys/fs/nilfs: nilfs_fs.h

Log Message:
Update NiLFS(2) on-disc structures from Linux version


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_fs.h

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_fs.h
diff -u src/sys/fs/nilfs/nilfs_fs.h:1.1 src/sys/fs/nilfs/nilfs_fs.h:1.2
--- src/sys/fs/nilfs/nilfs_fs.h:1.1	Sat Jul 18 16:31:42 2009
+++ src/sys/fs/nilfs/nilfs_fs.h	Thu Jun 24 10:20:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_fs.h,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs_fs.h,v 1.2 2010/06/24 10:20:08 reinoud Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -276,8 +276,7 @@
  uint16_t s_segment_usage_size;/* size of a segment usage*/
 
  uint8_t  s_uuid[16];  /* 128-bit uuid for volume*/
- char s_volume_name[16];   /* volume name*/
- char s_last_mounted[64];  /* directory where last mounted   */
+ char s_volume_name[80];   /* volume name*/
 
  uint32_t s_c_interval;/* commit interval of segment */
  uint32_t s_c_block_max;   /* threshold of data amount for
@@ -423,6 +422,7 @@
  uint32_t ss_nfinfo;		/* number of finfo structures follow */
  uint32_t ss_sumbytes;		/* total size of segment summary */
  uint32_t ss_pad;
+	 uint64_t ss_cno;		/* latest checkpoint number known*/
  /* stream of finfo structures */
 };
 



CVS commit: src/sys/fs/nilfs

2010-06-24 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Thu Jun 24 12:15:46 UTC 2010

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c nilfs_vnops.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/fs/nilfs/nilfs_subr.c
cvs rdiff -u -r1.5 -r1.6 src/sys/fs/nilfs/nilfs_vnops.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.4 src/sys/fs/nilfs/nilfs_subr.c:1.5
--- src/sys/fs/nilfs/nilfs_subr.c:1.4	Wed Jul 29 17:06:57 2009
+++ src/sys/fs/nilfs/nilfs_subr.c	Thu Jun 24 12:15:46 2010
@@ -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);

Index: src/sys/fs/nilfs/nilfs_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.5 src/sys/fs/nilfs/nilfs_vnops.c:1.6
--- src/sys/fs/nilfs/nilfs_vnops.c:1.5	Thu Jun 24 07:54:46 2010
+++ src/sys/fs/nilfs/nilfs_vnops.c	Thu Jun 24 12:15:46 2010
@@ -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 

CVS commit: src/sys/fs/nilfs

2010-05-01 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat May  1 21:21:28 UTC 2010

Modified Files:
src/sys/fs/nilfs: nilfs_vfsops.c

Log Message:
As per change in NiLFS2 spec, select the superblocks on highest checksum
number and not on their timestamp since one of the timestamps could be wrong 
when the
clock was set wrong for whatever reason.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_vfsops.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_vfsops.c
diff -u src/sys/fs/nilfs/nilfs_vfsops.c:1.1 src/sys/fs/nilfs/nilfs_vfsops.c:1.2
--- src/sys/fs/nilfs/nilfs_vfsops.c:1.1	Sat Jul 18 16:31:42 2009
+++ src/sys/fs/nilfs/nilfs_vfsops.c	Sat May  1 21:21:27 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vfsops.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs_vfsops.c,v 1.2 2010/05/01 21:21:27 reinoud Exp $ */
 
 /*
  * Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vfsops.c,v 1.2 2010/05/01 21:21:27 reinoud Exp $);
 #endif /* not lint */
 
 
@@ -333,7 +333,7 @@
 	struct nilfs_super_block *super, tmp_super;
 	struct buf *bp;
 	uint64_t sb1off, sb2off;
-	uint64_t time1, time2;
+	uint64_t last_cno1, last_cno2;
 	uint64_t dev_blk;
 	int dev_bsize, dev_blks;
 	int sb1ok, sb2ok, swp;
@@ -377,9 +377,9 @@
 	sb1ok = nilfs_check_superblock_crc(nilfsdev-super);
 	sb2ok = nilfs_check_superblock_crc(nilfsdev-super2);
 
-	time1 = nilfs_rw64(nilfsdev-super.s_wtime);
-	time2 = nilfs_rw64(nilfsdev-super2.s_wtime);
-	swp = sb2ok  (time2  time1);
+	last_cno1 = nilfs_rw64(nilfsdev-super.s_last_cno);
+	last_cno2 = nilfs_rw64(nilfsdev-super2.s_last_cno);
+	swp = sb2ok  (last_cno2  last_cno1);
 
 	if (swp) {
 		printf(nilfs warning: broken superblock, using spare\n);



CVS commit: src/sys/fs/nilfs

2009-08-25 Thread Elad Efrat
Module Name:src
Committed By:   elad
Date:   Wed Aug 26 03:40:48 UTC 2009

Modified Files:
src/sys/fs/nilfs: nilfs_vnops.c

Log Message:
Split nilfs_access() to nilfs_check_possible() and nilfs_check_permitted().


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/fs/nilfs/nilfs_vnops.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_vnops.c
diff -u src/sys/fs/nilfs/nilfs_vnops.c:1.1 src/sys/fs/nilfs/nilfs_vnops.c:1.2
--- src/sys/fs/nilfs/nilfs_vnops.c:1.1	Sat Jul 18 16:31:42 2009
+++ src/sys/fs/nilfs/nilfs_vnops.c	Wed Aug 26 03:40:48 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.1 2009/07/18 16:31:42 reinoud Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.2 2009/08/26 03:40:48 elad 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.1 2009/07/18 16:31:42 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_vnops.c,v 1.2 2009/08/26 03:40:48 elad Exp $);
 #endif /* not lint */
 
 
@@ -971,31 +971,13 @@
 
 /* - */
 
-int
-nilfs_access(void *v)
+static int
+nilfs_check_possible(struct vnode *vp, struct vattr *vap, mode_t mode)
 {
-	struct vop_access_args /* {
-		struct vnode *a_vp;
-		int a_mode;
-		kauth_cred_t a_cred;
-		struct proc *a_p;
-	} */ *ap = v;
-	struct vnode*vp   = ap-a_vp;
-	mode_t	 mode = ap-a_mode;
-	kauth_cred_t cred = ap-a_cred;
-	/* struct nilfs_node *nilfs_node = VTOI(vp); */
-	struct vattr vap;
 	int flags;
-	int error;
-
-	DPRINTF(VFSCALL, (nilfs_access called\n));
-
-	error = VOP_GETATTR(vp, vap, NULL);
-	if (error)
-		return error;
 
 	/* check if we are allowed to write */
-	switch (vap.va_type) {
+	switch (vap-va_type) {
 	case VDIR:
 	case VLNK:
 	case VREG:
@@ -1026,12 +1008,51 @@
 	if ((mode  VWRITE)  (flags  IMMUTABLE))
 		return EPERM;
 
+	return 0;
+}
+
+static int
+nilfs_check_permitted(struct vnode *vp, struct vattr *vap, mode_t mode,
+kauth_cred_t cred)
+{
+
 	/* ask the generic genfs_can_access to advice on security */
 	return genfs_can_access(vp-v_type,
-			vap.va_mode, vap.va_uid, vap.va_gid,
+			vap-va_mode, vap-va_uid, vap-va_gid,
 			mode, cred);
 }
 
+int
+nilfs_access(void *v)
+{
+	struct vop_access_args /* {
+		struct vnode *a_vp;
+		int a_mode;
+		kauth_cred_t a_cred;
+		struct proc *a_p;
+	} */ *ap = v;
+	struct vnode*vp   = ap-a_vp;
+	mode_t	 mode = ap-a_mode;
+	kauth_cred_t cred = ap-a_cred;
+	/* struct nilfs_node *nilfs_node = VTOI(vp); */
+	struct vattr vap;
+	int error;
+
+	DPRINTF(VFSCALL, (nilfs_access called\n));
+
+	error = VOP_GETATTR(vp, vap, NULL);
+	if (error)
+		return error;
+
+	error = nilfs_check_possible(vp, vap, mode);
+	if (error)
+		return error;
+
+	error = nilfs_check_permitted(vp, vap, mode, cred);
+
+	return error;
+}
+
 /* - */
 
 int



CVS commit: src/sys/fs/nilfs

2009-07-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul 29 13:23:23 UTC 2009

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c

Log Message:
Add debugging text to indicate a super root has been found while searching for
it.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/sys/fs/nilfs/nilfs_subr.c:1.3
--- src/sys/fs/nilfs/nilfs_subr.c:1.2	Tue Jul 28 15:31:21 2009
+++ src/sys/fs/nilfs/nilfs_subr.c	Wed Jul 29 13:23:23 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.2 2009/07/28 15:31:21 reinoud Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.3 2009/07/29 13:23:23 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.2 2009/07/28 15:31:21 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.3 2009/07/29 13:23:23 reinoud Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -535,6 +535,7 @@
 		error = EIO;
 	}
 	/* else got our super root! */
+	DPRINTF(VOLUMES, (got superroot\n));
 
 out:
 	if (bp)



CVS commit: src/sys/fs/nilfs

2009-07-29 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Wed Jul 29 17:06:57 UTC 2009

Modified Files:
src/sys/fs/nilfs: nilfs_subr.c

Log Message:
Re-do nilfs_load_super_root() and implement crc checking of read in super root
to check for consistency.

Since a new crc-seed is chosen on each new nilfs formatting, older structures
will fail the crc check.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/sys/fs/nilfs/nilfs_subr.c:1.4
--- src/sys/fs/nilfs/nilfs_subr.c:1.3	Wed Jul 29 13:23:23 2009
+++ src/sys/fs/nilfs/nilfs_subr.c	Wed Jul 29 17:06:57 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_subr.c,v 1.3 2009/07/29 13:23:23 reinoud Exp $ */
+/* $NetBSD: nilfs_subr.c,v 1.4 2009/07/29 17:06:57 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.3 2009/07/29 13:23:23 reinoud Exp $);
+__KERNEL_RCSID(0, $NetBSD: nilfs_subr.c,v 1.4 2009/07/29 17:06:57 reinoud Exp $);
 #endif /* not lint */
 
 #include sys/param.h
@@ -502,13 +502,13 @@
 	struct nilfs_recover_info *ri)
 {
 	struct nilfs_segment_summary *segsum = ri-segsum;
+	struct nilfs_super_root *super_root;
 	struct buf *bp;
 	uint64_t blocknr, offset;
 	uint32_t segsum_size, size;
 	uint32_t nsumblk, nfileblk;
-	int error;
-
-	bp = NULL;
+	uint32_t super_root_crc, comp_crc;
+	int off, error;
 
 	/* process segment summary */
 	segsum_size = nilfs_rw32(segsum-ss_sumbytes);
@@ -519,29 +519,39 @@
 	if ((nilfs_rw16(segsum-ss_flags)  NILFS_SS_SR) == 0) {
 		DPRINTF(VOLUMES, (nilfs: no super root in pseg %PRIu64\n,
 			ri-pseg));
-		error = ENOENT;
-		goto out;
+		return ENOENT;
 	}
 
 	/* get our super root, located at the end of the pseg */
 	blocknr = ri-pseg + nsumblk + nfileblk - 1;
 	offset = 0;
 	size = sizeof(struct nilfs_super_root);
+	bp = NULL;
 	error = nilfs_get_segment_log(nilfsdev,
 			blocknr, offset, bp,
 			size, (void *) nilfsdev-super_root);
+	if (bp)
+		brelse(bp, BC_AGE);
 	if (error) {
 		printf(read in of superroot failed\n);
-		error = EIO;
+		return EIO;
 	}
-	/* else got our super root! */
-	DPRINTF(VOLUMES, (got superroot\n));
 
-out:
-	if (bp)
-		brelse(bp, BC_AGE);
+	/* check super root crc */
+	super_root = nilfsdev-super_root;
+	super_root_crc = nilfs_rw32(super_root-sr_sum);
+	off = sizeof(super_root-sr_sum);
+	comp_crc = crc32_le(nilfs_rw32(nilfsdev-super.s_crc_seed),
+		(uint8_t *) super_root + off,
+		NILFS_SR_BYTES - off);
+	if (super_root_crc != comp_crc) {
+		DPRINTF(VOLUMES, (invalid superroot, likely from old format\n));
+		return EINVAL;
+	}
 
-	return error;
+	DPRINTF(VOLUMES, (got valid superroot\n));
+
+	return 0;
 }
 
 /* 



CVS commit: src/sys/fs/nilfs

2009-07-28 Thread Reinoud Zandijk
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;