Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/udf Change udf to vcache, keyed on udf_node->loc.loc.
details: https://anonhg.NetBSD.org/src/rev/2a18a670fdbd
branches: trunk
changeset: 337197:2a18a670fdbd
user: hannken <hannken%NetBSD.org@localhost>
date: Mon Apr 06 08:39:23 2015 +0000
description:
Change udf to vcache, keyed on udf_node->loc.loc.
diffstat:
sys/fs/udf/udf.h | 4 +-
sys/fs/udf/udf_subr.c | 345 ++++++++++++++++++++---------------------------
sys/fs/udf/udf_vfsops.c | 11 +-
sys/fs/udf/udf_vnops.c | 9 +-
4 files changed, 160 insertions(+), 209 deletions(-)
diffs (truncated from 647 to 300 lines):
diff -r e8d1603d4bfe -r 2a18a670fdbd sys/fs/udf/udf.h
--- a/sys/fs/udf/udf.h Mon Apr 06 08:39:06 2015 +0000
+++ b/sys/fs/udf/udf.h Mon Apr 06 08:39:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.h,v 1.47 2014/09/17 19:47:05 reinoud Exp $ */
+/* $NetBSD: udf.h,v 1.48 2015/04/06 08:39:23 hannken Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -94,6 +94,7 @@
#define DPRINTFIF(name, cond, arg) {}
#endif
+VFS_PROTOS(udf);
/* constants to identify what kind of identifier we are dealing with */
#define UDF_REGID_DOMAIN 1
@@ -339,7 +340,6 @@
/* rb tree for lookup icb to udf_node and sorted list for sync */
kmutex_t ihash_lock;
- kmutex_t get_node_lock;
struct rb_tree udf_node_tree;
/* syncing */
diff -r e8d1603d4bfe -r 2a18a670fdbd sys/fs/udf/udf_subr.c
--- a/sys/fs/udf/udf_subr.c Mon Apr 06 08:39:06 2015 +0000
+++ b/sys/fs/udf/udf_subr.c Mon Apr 06 08:39:23 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $ */
+/* $NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.128 2015/02/07 04:18:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_subr.c,v 1.129 2015/04/06 08:39:23 hannken Exp $");
#endif /* not lint */
@@ -3444,31 +3444,6 @@
}
-static struct udf_node *
-udf_node_lookup(struct udf_mount *ump, struct long_ad *icbptr)
-{
- struct udf_node *udf_node;
- struct vnode *vp;
-
-loop:
- mutex_enter(&ump->ihash_lock);
-
- udf_node = rb_tree_find_node(&ump->udf_node_tree, icbptr);
- if (udf_node) {
- vp = udf_node->vnode;
- assert(vp);
- mutex_enter(vp->v_interlock);
- mutex_exit(&ump->ihash_lock);
- if (vget(vp, LK_EXCLUSIVE))
- goto loop;
- return udf_node;
- }
- mutex_exit(&ump->ihash_lock);
-
- return NULL;
-}
-
-
static void
udf_register_node(struct udf_node *udf_node)
{
@@ -5279,44 +5254,33 @@
*/
int
-udf_get_node(struct udf_mount *ump, struct long_ad *node_icb_loc,
- struct udf_node **udf_noderes)
+udf_loadvnode(struct mount *mp, struct vnode *vp,
+ const void *key, size_t key_len, const void **new_key)
{
union dscrptr *dscr;
+ struct udf_mount *ump;
struct udf_node *udf_node;
- struct vnode *nvp;
- struct long_ad icb_loc, next_icb_loc, last_fe_icb_loc;
+ struct long_ad node_icb_loc, icb_loc, next_icb_loc, last_fe_icb_loc;
uint64_t file_size;
uint32_t lb_size, sector, dummy;
int udf_file_type, dscr_type, strat, strat4096, needs_indirect;
int slot, eof, error;
int num_indir_followed = 0;
- DPRINTF(NODE, ("udf_get_node called\n"));
- *udf_noderes = udf_node = NULL;
-
- /* lock to disallow simultanious creation of same udf_node */
- mutex_enter(&ump->get_node_lock);
-
- DPRINTF(NODE, ("\tlookup in hash table\n"));
- /* lookup in hash table */
- assert(ump);
- assert(node_icb_loc);
- udf_node = udf_node_lookup(ump, node_icb_loc);
- if (udf_node) {
- DPRINTF(NODE, ("\tgot it from the hash!\n"));
- /* vnode is returned locked */
- *udf_noderes = udf_node;
- mutex_exit(&ump->get_node_lock);
- return 0;
- }
+ DPRINTF(NODE, ("udf_loadvnode called\n"));
+ udf_node = NULL;
+ ump = VFSTOUDF(mp);
+
+ KASSERT(key_len == sizeof(node_icb_loc.loc));
+ memset(&node_icb_loc, 0, sizeof(node_icb_loc));
+ node_icb_loc.len = ump->logical_vol->lb_size;
+ memcpy(&node_icb_loc.loc, key, key_len);
/* garbage check: translate udf_node_icb_loc to sectornr */
- error = udf_translate_vtop(ump, node_icb_loc, §or, &dummy);
+ error = udf_translate_vtop(ump, &node_icb_loc, §or, &dummy);
if (error) {
DPRINTF(NODE, ("\tcan't translate icb address!\n"));
/* no use, this will fail anyway */
- mutex_exit(&ump->get_node_lock);
return EINVAL;
}
@@ -5324,33 +5288,18 @@
udf_node = pool_get(&udf_node_pool, PR_WAITOK);
memset(udf_node, 0, sizeof(struct udf_node));
- DPRINTF(NODE, ("\tget new vnode\n"));
- /* give it a vnode */
- error = getnewvnode(VT_UDF, ump->vfs_mountp, udf_vnodeop_p, NULL, &nvp);
- if (error) {
- pool_put(&udf_node_pool, udf_node);
- mutex_exit(&ump->get_node_lock);
- return error;
- }
-
- /* always return locked vnode */
- if ((error = vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY))) {
- /* recycle vnode and unlock; simultaneous will fail too */
- ungetnewvnode(nvp);
- pool_put(&udf_node_pool, udf_node);
- mutex_exit(&ump->get_node_lock);
- return error;
- }
+ vp->v_tag = VT_UDF;
+ vp->v_op = udf_vnodeop_p;
+ vp->v_data = udf_node;
/* initialise crosslinks, note location of fe/efe for hashing */
udf_node->ump = ump;
- udf_node->vnode = nvp;
- nvp->v_data = udf_node;
- udf_node->loc = *node_icb_loc;
+ udf_node->vnode = vp;
+ udf_node->loc = node_icb_loc;
udf_node->lockf = 0;
mutex_init(&udf_node->node_mutex, MUTEX_DEFAULT, IPL_NONE);
cv_init(&udf_node->node_lock, "udf_nlk");
- genfs_node_init(nvp, &udf_genfsops); /* inititise genfs */
+ genfs_node_init(vp, &udf_genfsops); /* inititise genfs */
udf_node->outstanding_bufs = 0;
udf_node->outstanding_nodedscr = 0;
udf_node->uncommitted_lbs = 0;
@@ -5359,15 +5308,12 @@
if (ump->fileset_desc)
if (memcmp(&udf_node->loc, &ump->fileset_desc->rootdir_icb,
sizeof(struct long_ad)) == 0)
- nvp->v_vflag |= VV_ROOT;
+ vp->v_vflag |= VV_ROOT;
/* insert into the hash lookup */
udf_register_node(udf_node);
- /* safe to unlock, the entry is in the hash table, vnode is locked */
- mutex_exit(&ump->get_node_lock);
-
- icb_loc = *node_icb_loc;
+ icb_loc = node_icb_loc;
needs_indirect = 0;
strat4096 = 0;
udf_file_type = UDF_ICB_FILETYPE_UNKNOWN;
@@ -5471,10 +5417,6 @@
/* recycle udf_node */
udf_dispose_node(udf_node);
- VOP_UNLOCK(nvp);
- nvp->v_data = NULL;
- ungetnewvnode(nvp);
-
return EINVAL; /* error code ok? */
}
DPRINTF(NODE, ("\tnode fe/efe read in fine\n"));
@@ -5567,10 +5509,6 @@
/* recycle udf_node */
udf_dispose_node(udf_node);
- VOP_UNLOCK(nvp);
- nvp->v_data = NULL;
- ungetnewvnode(nvp);
-
return EINVAL; /* error code ok? */
}
@@ -5587,46 +5525,66 @@
switch (udf_file_type) {
case UDF_ICB_FILETYPE_DIRECTORY :
case UDF_ICB_FILETYPE_STREAMDIR :
- nvp->v_type = VDIR;
+ vp->v_type = VDIR;
break;
case UDF_ICB_FILETYPE_BLOCKDEVICE :
- nvp->v_type = VBLK;
+ vp->v_type = VBLK;
break;
case UDF_ICB_FILETYPE_CHARDEVICE :
- nvp->v_type = VCHR;
+ vp->v_type = VCHR;
break;
case UDF_ICB_FILETYPE_SOCKET :
- nvp->v_type = VSOCK;
+ vp->v_type = VSOCK;
break;
case UDF_ICB_FILETYPE_FIFO :
- nvp->v_type = VFIFO;
+ vp->v_type = VFIFO;
break;
case UDF_ICB_FILETYPE_SYMLINK :
- nvp->v_type = VLNK;
+ vp->v_type = VLNK;
break;
case UDF_ICB_FILETYPE_VAT :
case UDF_ICB_FILETYPE_META_MAIN :
case UDF_ICB_FILETYPE_META_MIRROR :
- nvp->v_type = VNON;
+ vp->v_type = VNON;
break;
case UDF_ICB_FILETYPE_RANDOMACCESS :
case UDF_ICB_FILETYPE_REALTIME :
- nvp->v_type = VREG;
+ vp->v_type = VREG;
break;
default:
/* YIKES, something else */
- nvp->v_type = VNON;
+ vp->v_type = VNON;
}
/* TODO specfs, fifofs etc etc. vnops setting */
/* don't forget to set vnode's v_size */
- uvm_vnp_setsize(nvp, file_size);
+ uvm_vnp_setsize(vp, file_size);
/* TODO ext attr and streamdir udf_nodes */
- *udf_noderes = udf_node;
-
+ *new_key = &udf_node->loc.loc;
+
+ return 0;
+}
+
+int
+udf_get_node(struct udf_mount *ump, struct long_ad *node_icb_loc,
+ struct udf_node **udf_noderes)
+{
+ int error;
+ struct vnode *vp;
+
+ error = vcache_get(ump->vfs_mountp, &node_icb_loc->loc,
+ sizeof(node_icb_loc->loc), &vp);
+ if (error)
+ return error;
+ error = vn_lock(vp, LK_EXCLUSIVE);
+ if (error) {
+ vrele(vp);
+ return error;
+ }
+ *udf_noderes = VTOI(vp);
return 0;
}
@@ -5759,19 +5717,19 @@
/*
- * create a new node using the specified vnodeops, vap and cnp but with the
- * udf_file_type. This allows special files to be created. Use with care.
+ * create a new node using the specified dvp, vap and cnp.
+ * This allows special files to be created. Use with care.
Home |
Main Index |
Thread Index |
Old Index