Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/v7fs Defer deallocating unlinked inodes to v7fs_recla...
details: https://anonhg.NetBSD.org/src/rev/01e6bc46b07f
branches: trunk
changeset: 805325:01e6bc46b07f
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Dec 29 15:28:58 2014 +0000
description:
Defer deallocating unlinked inodes to v7fs_reclaim().
Remove v7fs_vnode_reload() and always use v7fs_inode_load(). No need
to search for a vnode we already hold a reference on.
diffstat:
sys/fs/v7fs/v7fs_file.c | 16 +++++---------
sys/fs/v7fs/v7fs_vfsops.c | 36 +-------------------------------
sys/fs/v7fs/v7fs_vnops.c | 50 ++++++++++++++++++++++++++++------------------
3 files changed, 38 insertions(+), 64 deletions(-)
diffs (237 lines):
diff -r 7fb29c2213b4 -r 01e6bc46b07f sys/fs/v7fs/v7fs_file.c
--- a/sys/fs/v7fs/v7fs_file.c Mon Dec 29 15:28:08 2014 +0000
+++ b/sys/fs/v7fs/v7fs_file.c Mon Dec 29 15:28:58 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_file.c,v 1.5 2012/12/07 06:50:15 msaitoh Exp $ */
+/* $NetBSD: v7fs_file.c,v 1.6 2014/12/29 15:28:58 hannken Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_file.c,v 1.5 2012/12/07 06:50:15 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_file.c,v 1.6 2014/12/29 15:28:58 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -259,6 +259,9 @@
DPRINTF("directory not empty.\n");
return ENOTEMPTY;/* t_vnops dir_noempty, rename_dir(6)*/
}
+ error = v7fs_datablock_size_change(fs, 0, &inode);
+ if (error)
+ return error;
inode.nlink = 0; /* remove this. */
} else {
/* Decrement reference count. */
@@ -271,14 +274,7 @@
return error;
DPRINTF("remove dirent\n");
- if (inode.nlink == 0) {
- v7fs_datablock_contract(fs, &inode, inode.filesize);
- DPRINTF("remove datablock\n");
- v7fs_inode_deallocate(fs, ino);
- DPRINTF("remove inode\n");
- } else {
- v7fs_inode_writeback(fs, &inode);
- }
+ v7fs_inode_writeback(fs, &inode);
return 0;
}
diff -r 7fb29c2213b4 -r 01e6bc46b07f sys/fs/v7fs/v7fs_vfsops.c
--- a/sys/fs/v7fs/v7fs_vfsops.c Mon Dec 29 15:28:08 2014 +0000
+++ b/sys/fs/v7fs/v7fs_vfsops.c Mon Dec 29 15:28:58 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vfsops.c,v 1.10 2014/04/16 18:55:19 maxv Exp $ */
+/* $NetBSD: v7fs_vfsops.c,v 1.11 2014/12/29 15:28:58 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.10 2014/04/16 18:55:19 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.11 2014/12/29 15:28:58 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -74,7 +74,6 @@
static void v7fs_closefs(struct vnode *, struct mount *);
static int is_v7fs_partition(struct vnode *);
static enum vtype v7fs_mode_to_vtype(v7fs_mode_t mode);
-int v7fs_vnode_reload(struct mount *, struct vnode *);
int
v7fs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
@@ -586,34 +585,3 @@
return 0;
}
-
-/* Reload disk inode information */
-int
-v7fs_vnode_reload(struct mount *mp, struct vnode *vp)
-{
- struct v7fs_mount *v7fsmount = mp->mnt_data;
- struct v7fs_self *fs = v7fsmount->core;
- struct v7fs_node *v7fs_node;
- struct v7fs_inode *inode = &((struct v7fs_node *)vp->v_data)->inode;
- int target_ino = inode->inode_number;
- int error = 0;
-
- DPRINTF("#%d\n", target_ino);
- mutex_enter(&mntvnode_lock);
- for (v7fs_node = LIST_FIRST(&v7fsmount->v7fs_node_head);
- v7fs_node != NULL; v7fs_node = LIST_NEXT(v7fs_node, link)) {
- inode = &v7fs_node->inode;
- if (!v7fs_inode_allocated(inode)) {
- continue;
- }
- if (inode->inode_number == target_ino) {
- error = v7fs_inode_load(fs, &v7fs_node->inode,
- target_ino);
- DPRINTF("sync #%d error=%d\n", target_ino, error);
- break;
- }
- }
- mutex_exit(&mntvnode_lock);
-
- return error;
-}
diff -r 7fb29c2213b4 -r 01e6bc46b07f sys/fs/v7fs/v7fs_vnops.c
--- a/sys/fs/v7fs/v7fs_vnops.c Mon Dec 29 15:28:08 2014 +0000
+++ b/sys/fs/v7fs/v7fs_vnops.c Mon Dec 29 15:28:58 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: v7fs_vnops.c,v 1.18 2014/12/29 15:28:08 hannken Exp $ */
+/* $NetBSD: v7fs_vnops.c,v 1.19 2014/12/29 15:28:58 hannken Exp $ */
/*-
* Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.18 2014/12/29 15:28:08 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.19 2014/12/29 15:28:58 hannken Exp $");
#if defined _KERNEL_OPT
#include "opt_v7fs.h"
#endif
@@ -64,8 +64,6 @@
#define DPRINTF(arg...) ((void)0)
#endif
-int v7fs_vnode_reload(struct mount *, struct vnode *);
-
static v7fs_mode_t vtype_to_v7fs_mode(enum vtype);
static uint8_t v7fs_mode_to_d_type(v7fs_mode_t);
@@ -131,6 +129,10 @@
return EROFS;
}
+ /* No lookup on removed directory */
+ if (v7fs_inode_nlink(parent) == 0)
+ return ENOENT;
+
/* "." */
if (namelen == 1 && name[0] == '.') {
if ((nameiop == RENAME) && islastcn) {
@@ -684,10 +686,9 @@
struct v7fs_node *parent_node = a->a_dvp->v_data;
struct v7fs_mount *v7fsmount = parent_node->v7fsmount;
struct vnode *vp = a->a_vp;
+ struct vnode *dvp = a->a_dvp;
struct v7fs_inode *inode = &((struct v7fs_node *)vp->v_data)->inode;
- struct vnode *dvp = a->a_dvp;
struct v7fs_self *fs = v7fsmount->core;
- bool remove;
int error = 0;
DPRINTF("delete %s\n", a->a_cnp->cn_nameptr);
@@ -697,20 +698,16 @@
goto out;
}
- remove = v7fs_inode_nlink(inode) == 1;
- if (remove)
- uvm_vnp_setsize(vp, 0);
-
if ((error = v7fs_file_deallocate(fs, &parent_node->inode,
a->a_cnp->cn_nameptr))) {
DPRINTF("v7fs_file_delete failed.\n");
goto out;
}
+ error = v7fs_inode_load(fs, inode, inode->inode_number);
+ if (error)
+ goto out;
/* Sync dirent size change. */
uvm_vnp_setsize(dvp, v7fs_inode_filesize(&parent_node->inode));
- /* This inode is no longer used. -> v7fs_inactive */
- if (remove)
- memset(inode, 0, sizeof(*inode));
out:
if (dvp == vp)
@@ -794,8 +791,12 @@
&parent_to->inode, to_name);
/* 'to file' inode may be changed. (hard-linked and it is cached.)
t_vnops rename_reg_nodir */
- if (tvp) {
- v7fs_vnode_reload(parent_from->v7fsmount->mountp, tvp);
+ if (error == 0 && tvp) {
+ struct v7fs_inode *inode =
+ &((struct v7fs_node *)tvp->v_data)->inode;
+
+ error = v7fs_inode_load(fs, inode, inode->inode_number);
+ uvm_vnp_setsize(tvp, v7fs_inode_filesize(inode));
}
/* Sync dirent size change. */
uvm_vnp_setsize(tdvp, v7fs_inode_filesize(&parent_to->inode));
@@ -885,11 +886,12 @@
DPRINTF("v7fs_directory_deallocate failed.\n");
goto out;
}
- uvm_vnp_setsize(vp, 0);
+ error = v7fs_inode_load(fs, inode, inode->inode_number);
+ if (error)
+ goto out;
+ uvm_vnp_setsize(vp, v7fs_inode_filesize(inode));
/* Sync dirent size change. */
uvm_vnp_setsize(dvp, v7fs_inode_filesize(&parent_node->inode));
- /* This inode is no longer used. -> v7fs_inactive */
- memset(inode, 0, sizeof(*inode));
out:
vput(vp);
vput(dvp);
@@ -1016,7 +1018,7 @@
struct v7fs_inode *inode = &v7node->inode;
DPRINTF("%p #%d\n", vp, inode->inode_number);
- if (v7fs_inode_allocated(inode)) {
+ if (v7fs_inode_nlink(inode) > 0) {
v7fs_update(vp, 0, 0, UPDATE_WAIT);
*a->a_recycle = false;
} else {
@@ -1038,8 +1040,16 @@
} */ *a = v;
struct vnode *vp = a->a_vp;
struct v7fs_node *v7node = vp->v_data;
+ struct v7fs_self *fs = v7node->v7fsmount->core;
+ struct v7fs_inode *inode = &v7node->inode;
- DPRINTF("%p #%d\n", vp, v7node->inode.inode_number);
+ DPRINTF("%p #%d\n", vp, inode->inode_number);
+ if (v7fs_inode_nlink(inode) == 0) {
+ v7fs_datablock_size_change(fs, 0, inode);
+ DPRINTF("remove datablock\n");
+ v7fs_inode_deallocate(fs, inode->inode_number);
+ DPRINTF("remove inode\n");
+ }
mutex_enter(&mntvnode_lock);
LIST_REMOVE(v7node, link);
mutex_exit(&mntvnode_lock);
Home |
Main Index |
Thread Index |
Old Index