mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Breaking the world for a little bit. If anyone is going to continue
working on this branch for the next few days I suggested you work off of the 0.3.1 tag. The following changes are fairly extensive and are designed to make the SPL compatible with all kernels in the range of 2.6.18-2.6.25. There were 13 relevant API changes between these releases and I have added the needed autoconf tests to check for them. However, this has not all been tested extensively. I'll sort of the breakage on Fedora Core 9 and RHEL5 this week. SPL_AC_TYPE_UINTPTR_T SPL_AC_TYPE_KMEM_CACHE_T SPL_AC_KMEM_CACHE_DESTROY_INT SPL_AC_ATOMIC_PANIC_NOTIFIER SPL_AC_3ARGS_INIT_WORK SPL_AC_2ARGS_REGISTER_SYSCTL SPL_AC_KMEM_CACHE_T SPL_AC_KMEM_CACHE_CREATE_DTOR SPL_AC_3ARG_KMEM_CACHE_CREATE_CTOR SPL_AC_SET_SHRINKER SPL_AC_PATH_IN_NAMEIDATA SPL_AC_TASK_CURR SPL_AC_CTL_UNNUMBERED git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@119 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
@@ -4,7 +4,7 @@ MODULES := spl
|
||||
DISTFILES = Makefile.in \
|
||||
spl-kmem.c spl-rwlock.c spl-taskq.c \
|
||||
spl-thread.c spl-generic.c
|
||||
CPPFLAGS += @KERNELCPPFLAGS@
|
||||
EXTRA_CFLAGS = @KERNELCPPFLAGS@
|
||||
|
||||
# Solaris porting layer module
|
||||
obj-m := spl.o
|
||||
|
||||
+12
-2
@@ -44,7 +44,6 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/debug.h>
|
||||
#include <spl-ctl.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
@@ -1118,7 +1117,7 @@ void spl_debug_dumpstack(struct task_struct *tsk)
|
||||
tsk = current;
|
||||
|
||||
printk(KERN_ERR "SPL: Showing stack for process %d\n", tsk->pid);
|
||||
show_task(tsk);
|
||||
dump_stack();
|
||||
}
|
||||
EXPORT_SYMBOL(spl_debug_dumpstack);
|
||||
|
||||
@@ -1255,8 +1254,13 @@ debug_init(void)
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
#ifdef HAVE_ATOMIC_PANIC_NOTIFIER
|
||||
atomic_notifier_chain_register(&panic_notifier_list,
|
||||
&spl_panic_notifier);
|
||||
#else
|
||||
notifier_chain_register(&panic_notifier_list,
|
||||
&spl_panic_notifier);
|
||||
#endif
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -1306,8 +1310,14 @@ trace_fini(void)
|
||||
void
|
||||
debug_fini(void)
|
||||
{
|
||||
#ifdef HAVE_ATOMIC_PANIC_NOTIFIER
|
||||
atomic_notifier_chain_unregister(&panic_notifier_list,
|
||||
&spl_panic_notifier);
|
||||
#else
|
||||
notifier_chain_unregister(&panic_notifier_list,
|
||||
&spl_panic_notifier);
|
||||
#endif
|
||||
|
||||
trace_fini();
|
||||
|
||||
return;
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/cmn_err.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include <sys/proc.h>
|
||||
#include <sys/kstat.h>
|
||||
#include <linux/kmod.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
@@ -101,7 +100,7 @@ set_hostid(void)
|
||||
char sh_path[] = "/bin/sh";
|
||||
char *argv[] = { sh_path,
|
||||
"-c",
|
||||
"/usr/bin/hostid >/proc/sys/spl/hostid",
|
||||
"/usr/bin/hostid >/proc/sys/kernel/spl/hostid",
|
||||
NULL };
|
||||
char *envp[] = { "HOME=/",
|
||||
"TERM=linux",
|
||||
|
||||
+79
-14
@@ -104,7 +104,15 @@ typedef struct kmem_cache_cb {
|
||||
|
||||
static struct rw_semaphore kmem_cache_cb_sem;
|
||||
static struct list_head kmem_cache_cb_list;
|
||||
#ifdef HAVE_SET_SHRINKER
|
||||
static struct shrinker *kmem_cache_shrinker;
|
||||
#else
|
||||
static int kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask);
|
||||
static struct shrinker kmem_cache_shrinker = {
|
||||
.shrink = kmem_cache_generic_shrinker,
|
||||
.seeks = KMC_DEFAULT_SEEKS,
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Function must be called while holding the kmem_cache_cb_sem
|
||||
* Because kmem_cache_t is an opaque datatype we're forced to
|
||||
@@ -166,19 +174,21 @@ kmem_cache_remove_cache_cb(kmem_cache_cb_t *kcc)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_3ARG_KMEM_CACHE_CREATE_CTOR
|
||||
static void
|
||||
kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache, unsigned long flags)
|
||||
kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache,
|
||||
unsigned long flags)
|
||||
{
|
||||
kmem_cache_cb_t *kcc;
|
||||
kmem_constructor_t constructor;
|
||||
void *private;
|
||||
|
||||
ASSERT(flags & SLAB_CTOR_CONSTRUCTOR);
|
||||
|
||||
/* Ensure constructor verifies are not passed to the registered
|
||||
* constructors. This may not be safe due to the Solaris constructor
|
||||
* not being aware of how to handle the SLAB_CTOR_VERIFY flag
|
||||
*/
|
||||
ASSERT(flags & SLAB_CTOR_CONSTRUCTOR);
|
||||
|
||||
if (flags & SLAB_CTOR_VERIFY)
|
||||
return;
|
||||
|
||||
@@ -186,7 +196,15 @@ kmem_cache_generic_constructor(void *ptr, kmem_cache_t *cache, unsigned long fla
|
||||
flags = KM_NOSLEEP;
|
||||
else
|
||||
flags = KM_SLEEP;
|
||||
|
||||
#else
|
||||
static void
|
||||
kmem_cache_generic_constructor(kmem_cache_t *cache, void *ptr)
|
||||
{
|
||||
kmem_cache_cb_t *kcc;
|
||||
kmem_constructor_t constructor;
|
||||
void *private;
|
||||
int flags = KM_NOSLEEP;
|
||||
#endif
|
||||
/* We can be called with interrupts disabled so it is critical that
|
||||
* this function and the registered constructor never sleep.
|
||||
*/
|
||||
@@ -244,7 +262,7 @@ kmem_cache_generic_destructor(void *ptr, kmem_cache_t *cache, unsigned long flag
|
||||
atomic_dec(&kcc->kcc_ref);
|
||||
}
|
||||
|
||||
/* XXX - Arguments are ignored */
|
||||
/* Arguments are ignored */
|
||||
static int
|
||||
kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask)
|
||||
{
|
||||
@@ -306,6 +324,7 @@ kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask)
|
||||
#undef kmem_cache_create
|
||||
#undef kmem_cache_destroy
|
||||
#undef kmem_cache_alloc
|
||||
#undef kmem_cache_free
|
||||
|
||||
kmem_cache_t *
|
||||
__kmem_cache_create(char *name, size_t size, size_t align,
|
||||
@@ -329,23 +348,32 @@ __kmem_cache_create(char *name, size_t size, size_t align,
|
||||
RETURN(NULL);
|
||||
|
||||
strcpy(cache_name, name);
|
||||
|
||||
#ifdef HAVE_KMEM_CACHE_CREATE_DTOR
|
||||
cache = kmem_cache_create(cache_name, size, align, flags,
|
||||
kmem_cache_generic_constructor,
|
||||
kmem_cache_generic_destructor);
|
||||
#else
|
||||
cache = kmem_cache_create(cache_name, size, align, flags, NULL);
|
||||
#endif
|
||||
if (cache == NULL)
|
||||
RETURN(NULL);
|
||||
|
||||
/* Register shared shrinker function on initial cache create */
|
||||
down_read(&kmem_cache_cb_sem);
|
||||
if (list_empty(&kmem_cache_cb_list)) {
|
||||
kmem_cache_shrinker = set_shrinker(KMC_DEFAULT_SEEKS,
|
||||
kmem_cache_generic_shrinker);
|
||||
#ifdef HAVE_SET_SHRINKER
|
||||
kmem_cache_shrinker =
|
||||
set_shrinker(KMC_DEFAULT_SEEKS,
|
||||
kmem_cache_generic_shrinker);
|
||||
if (kmem_cache_shrinker == NULL) {
|
||||
kmem_cache_destroy(cache);
|
||||
up_read(&kmem_cache_cb_sem);
|
||||
RETURN(NULL);
|
||||
}
|
||||
|
||||
#else
|
||||
register_shrinker(&kmem_cache_shrinker);
|
||||
#endif
|
||||
}
|
||||
up_read(&kmem_cache_cb_sem);
|
||||
|
||||
@@ -353,7 +381,11 @@ __kmem_cache_create(char *name, size_t size, size_t align,
|
||||
reclaim, priv, vmp);
|
||||
if (kcc == NULL) {
|
||||
if (shrinker_flag) /* New shrinker registered must be removed */
|
||||
#ifdef HAVE_SET_SHRINKER
|
||||
remove_shrinker(kmem_cache_shrinker);
|
||||
#else
|
||||
unregister_shrinker(&kmem_cache_shrinker);
|
||||
#endif
|
||||
|
||||
kmem_cache_destroy(cache);
|
||||
RETURN(NULL);
|
||||
@@ -383,7 +415,13 @@ __kmem_cache_destroy(kmem_cache_t *cache)
|
||||
up_read(&kmem_cache_cb_sem);
|
||||
|
||||
name = (char *)kmem_cache_name(cache);
|
||||
|
||||
#ifdef HAVE_KMEM_CACHE_DESTROY_INT
|
||||
rc = kmem_cache_destroy(cache);
|
||||
#else
|
||||
kmem_cache_destroy(cache);
|
||||
rc = 0;
|
||||
#endif
|
||||
|
||||
atomic_dec(&kcc->kcc_ref);
|
||||
kmem_cache_remove_cache_cb(kcc);
|
||||
@@ -392,7 +430,11 @@ __kmem_cache_destroy(kmem_cache_t *cache)
|
||||
/* Unregister generic shrinker on removal of all caches */
|
||||
down_read(&kmem_cache_cb_sem);
|
||||
if (list_empty(&kmem_cache_cb_list))
|
||||
remove_shrinker(kmem_cache_shrinker);
|
||||
#ifdef HAVE_SET_SHRINKER
|
||||
remove_shrinker(kmem_cache_shrinker);
|
||||
#else
|
||||
unregister_shrinker(&kmem_cache_shrinker);
|
||||
#endif
|
||||
|
||||
up_read(&kmem_cache_cb_sem);
|
||||
RETURN(rc);
|
||||
@@ -409,22 +451,45 @@ EXPORT_SYMBOL(__kmem_cache_destroy);
|
||||
void *
|
||||
__kmem_cache_alloc(kmem_cache_t *cache, gfp_t flags)
|
||||
{
|
||||
void *rc;
|
||||
void *obj;
|
||||
ENTRY;
|
||||
|
||||
restart:
|
||||
rc = kmem_cache_alloc(cache, flags);
|
||||
if ((rc == NULL) && (flags & KM_SLEEP)) {
|
||||
obj = kmem_cache_alloc(cache, flags);
|
||||
if ((obj == NULL) && (flags & KM_SLEEP)) {
|
||||
#ifdef DEBUG_KMEM
|
||||
atomic64_inc(&kmem_cache_alloc_failed);
|
||||
#endif /* DEBUG_KMEM */
|
||||
GOTO(restart, rc);
|
||||
GOTO(restart, obj);
|
||||
}
|
||||
|
||||
RETURN(rc);
|
||||
/* When destructor support is removed we must be careful not to
|
||||
* use the provided constructor which will end up being called
|
||||
* more often than the destructor which we only call on free. Thus
|
||||
* we many call the proper constructor when there is no destructor.
|
||||
*/
|
||||
#ifndef HAVE_KMEM_CACHE_CREATE_DTOR
|
||||
#ifdef HAVE_3ARG_KMEM_CACHE_CREATE_CTOR
|
||||
kmem_cache_generic_constructor(obj, cache, flags);
|
||||
#else
|
||||
kmem_cache_generic_constructor(cache, obj);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
RETURN(obj);
|
||||
}
|
||||
EXPORT_SYMBOL(__kmem_cache_alloc);
|
||||
|
||||
void
|
||||
__kmem_cache_free(kmem_cache_t *cache, void *obj)
|
||||
{
|
||||
#ifndef HAVE_KMEM_CACHE_CREATE_DTOR
|
||||
kmem_cache_generic_destructor(obj, cache, 0);
|
||||
#endif
|
||||
kmem_cache_free(cache, obj);
|
||||
}
|
||||
EXPORT_SYMBOL(__kmem_cache_free);
|
||||
|
||||
void
|
||||
__kmem_reap(void)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
#include <sys/kobj.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/sunddi.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
@@ -171,6 +171,11 @@ __mutex_tryenter(kmutex_t *mp)
|
||||
}
|
||||
EXPORT_SYMBOL(__mutex_tryenter);
|
||||
|
||||
#ifndef HAVE_TASK_CURR
|
||||
#define task_curr(owner) 0
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
mutex_enter_adaptive(kmutex_t *mp)
|
||||
{
|
||||
|
||||
+66
-6
@@ -39,8 +39,10 @@ static unsigned long table_max = ~0;
|
||||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
static struct ctl_table_header *spl_header = NULL;
|
||||
#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
|
||||
static struct proc_dir_entry *proc_sys = NULL;
|
||||
static struct proc_dir_entry *proc_sys_spl = NULL;
|
||||
#endif
|
||||
#ifdef DEBUG_MUTEX
|
||||
static struct proc_dir_entry *proc_sys_spl_mutex = NULL;
|
||||
static struct proc_dir_entry *proc_sys_spl_mutex_stats = NULL;
|
||||
@@ -53,6 +55,49 @@ struct proc_dir_entry *proc_sys_spl_kstat = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CTL_UNNUMBERED
|
||||
|
||||
#define CTL_SPL CTL_UNNUMBERED
|
||||
#define CTL_SPL_DEBUG CTL_UNNUMBERED
|
||||
#define CTL_SPL_MUTEX CTL_UNNUMBERED
|
||||
#define CTL_SPL_KMEM CTL_UNNUMBERED
|
||||
#define CTL_SPL_KSTAT CTL_UNNUMBERED
|
||||
|
||||
#define CTL_VERSION CTL_UNNUMBERED /* Version */
|
||||
#define CTL_HOSTID CTL_UNNUMBERED /* Host id by /usr/bin/hostid */
|
||||
#define CTL_HW_SERIAL CTL_UNNUMBERED /* HW serial number by hostid */
|
||||
|
||||
#define CTL_DEBUG_SUBSYS CTL_UNNUMBERED /* Debug subsystem */
|
||||
#define CTL_DEBUG_MASK CTL_UNNUMBERED /* Debug mask */
|
||||
#define CTL_DEBUG_PRINTK CTL_UNNUMBERED /* All messages to console */
|
||||
#define CTL_DEBUG_MB CTL_UNNUMBERED /* Debug buffer size */
|
||||
#define CTL_DEBUG_BINARY CTL_UNNUMBERED /* Binary data in buffer */
|
||||
#define CTL_DEBUG_CATASTROPHE CTL_UNNUMBERED /* Set if BUG'd or panic'd */
|
||||
#define CTL_DEBUG_PANIC_ON_BUG CTL_UNNUMBERED /* Should panic on BUG */
|
||||
#define CTL_DEBUG_PATH CTL_UNNUMBERED /* Dump log location */
|
||||
#define CTL_DEBUG_DUMP CTL_UNNUMBERED /* Dump debug buffer to file */
|
||||
#define CTL_DEBUG_FORCE_BUG CTL_UNNUMBERED /* Hook to force a BUG */
|
||||
#define CTL_DEBUG_STACK_SIZE CTL_UNNUMBERED /* Max observed stack size */
|
||||
|
||||
#define CTL_CONSOLE_RATELIMIT CTL_UNNUMBERED /* Ratelimit console messages */
|
||||
#define CTL_CONSOLE_MAX_DELAY_CS CTL_UNNUMBERED /* Max delay skip messages */
|
||||
#define CTL_CONSOLE_MIN_DELAY_CS CTL_UNNUMBERED /* Init delay skip messages */
|
||||
#define CTL_CONSOLE_BACKOFF CTL_UNNUMBERED /* Delay increase factor */
|
||||
|
||||
#ifdef DEBUG_KMEM
|
||||
#define CTL_KMEM_KMEMUSED CTL_UNNUMBERED /* Alloc'd kmem bytes */
|
||||
#define CTL_KMEM_KMEMMAX CTL_UNNUMBERED /* Max alloc'd by kmem bytes */
|
||||
#define CTL_KMEM_VMEMUSED CTL_UNNUMBERED /* Alloc'd vmem bytes */
|
||||
#define CTL_KMEM_VMEMMAX CTL_UNNUMBERED /* Max alloc'd by vmem bytes */
|
||||
#define CTL_KMEM_ALLOC_FAILED CTL_UNNUMBERED /* Cache allocations failed */
|
||||
#endif
|
||||
|
||||
#define CTL_MUTEX_STATS CTL_UNNUMBERED /* Global mutex statistics */
|
||||
#define CTL_MUTEX_STATS_PER CTL_UNNUMBERED /* Per mutex statistics */
|
||||
#define CTL_MUTEX_SPIN_MAX CTL_UNNUMBERED /* Max mutex spin iterations */
|
||||
|
||||
#else /* HAVE_CTL_UNNUMBERED */
|
||||
|
||||
#define CTL_SPL 0x87
|
||||
#define CTL_SPL_DEBUG 0x88
|
||||
#define CTL_SPL_MUTEX 0x89
|
||||
@@ -82,9 +127,9 @@ enum {
|
||||
CTL_CONSOLE_BACKOFF, /* Delay increase factor */
|
||||
|
||||
#ifdef DEBUG_KMEM
|
||||
CTL_KMEM_KMEMUSED, /* Crrently alloc'd kmem bytes */
|
||||
CTL_KMEM_KMEMUSED, /* Alloc'd kmem bytes */
|
||||
CTL_KMEM_KMEMMAX, /* Max alloc'd by kmem bytes */
|
||||
CTL_KMEM_VMEMUSED, /* Currently alloc'd vmem bytes */
|
||||
CTL_KMEM_VMEMUSED, /* Alloc'd vmem bytes */
|
||||
CTL_KMEM_VMEMMAX, /* Max alloc'd by vmem bytes */
|
||||
CTL_KMEM_ALLOC_FAILED, /* Cache allocation failed */
|
||||
#endif
|
||||
@@ -93,6 +138,7 @@ enum {
|
||||
CTL_MUTEX_STATS_PER, /* Per mutex statistics */
|
||||
CTL_MUTEX_SPIN_MAX, /* Maximum mutex spin iterations */
|
||||
};
|
||||
#endif /* HAVE_CTL_UNNUMBERED */
|
||||
|
||||
static int
|
||||
proc_copyin_string(char *kbuffer, int kbuffer_size,
|
||||
@@ -775,7 +821,17 @@ static struct ctl_table spl_dir[] = {
|
||||
.mode = 0555,
|
||||
.child = spl_table,
|
||||
},
|
||||
{0}
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static struct ctl_table spl_root[] = {
|
||||
{
|
||||
.ctl_name = CTL_KERN,
|
||||
.procname = "kernel",
|
||||
.mode = 0555,
|
||||
.child = spl_dir,
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
static int
|
||||
@@ -818,10 +874,11 @@ proc_init(void)
|
||||
ENTRY;
|
||||
|
||||
#ifdef CONFIG_SYSCTL
|
||||
spl_header = register_sysctl_table(spl_dir, 0);
|
||||
spl_header = spl_register_sysctl_table(spl_root, 0);
|
||||
if (spl_header == NULL)
|
||||
RETURN(-EUNATCH);
|
||||
|
||||
#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
|
||||
proc_sys = proc_dir_entry_find(&proc_root, "sys");
|
||||
if (proc_sys == NULL)
|
||||
GOTO(out, rc = -EUNATCH);
|
||||
@@ -829,6 +886,7 @@ proc_init(void)
|
||||
proc_sys_spl = proc_dir_entry_find(proc_sys, "spl");
|
||||
if (proc_sys_spl == NULL)
|
||||
GOTO(out, rc = -EUNATCH);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_MUTEX
|
||||
proc_sys_spl_mutex = proc_dir_entry_find(proc_sys_spl, "mutex");
|
||||
@@ -862,8 +920,10 @@ out2:
|
||||
#ifdef DEBUG_MUTEX
|
||||
remove_proc_entry("stats_per", proc_sys_spl_mutex);
|
||||
#endif /* DEBUG_MUTEX */
|
||||
#if defined(DEBUG_MUTEX) || defined(DEBUG_KMEM) || defined(DEBUG_KSTAT)
|
||||
out:
|
||||
unregister_sysctl_table(spl_header);
|
||||
#endif
|
||||
spl_unregister_sysctl_table(spl_header);
|
||||
#endif /* CONFIG_SYSCTL */
|
||||
RETURN(rc);
|
||||
}
|
||||
@@ -878,7 +938,7 @@ proc_fini(void)
|
||||
#ifdef DEBUG_MUTEX
|
||||
remove_proc_entry("stats_per", proc_sys_spl_mutex);
|
||||
#endif /* DEBUG_MUTEX */
|
||||
unregister_sysctl_table(spl_header);
|
||||
spl_unregister_sysctl_table(spl_header);
|
||||
#endif
|
||||
EXIT;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/time.h>
|
||||
#include "config.h"
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
|
||||
+23
-17
@@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/vnode.h>
|
||||
#include "config.h"
|
||||
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
@@ -105,7 +104,7 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode,
|
||||
{
|
||||
struct file *fp;
|
||||
struct kstat stat;
|
||||
int rc, saved_umask;
|
||||
int rc, saved_umask = 0;
|
||||
vnode_t *vp;
|
||||
ENTRY;
|
||||
|
||||
@@ -243,11 +242,17 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
|
||||
} /* vn_close() */
|
||||
EXPORT_SYMBOL(vn_close);
|
||||
|
||||
static struct dentry *lookup_hash(struct nameidata *nd)
|
||||
static struct dentry *vn_lookup_hash(struct nameidata *nd)
|
||||
{
|
||||
return __lookup_hash(&nd->last, nd->dentry, nd);
|
||||
return lookup_one_len(nd->last.name, nd->nd_dentry, nd->last.len);
|
||||
} /* lookup_hash() */
|
||||
|
||||
static void vn_path_release(struct nameidata *nd)
|
||||
{
|
||||
dput(nd->nd_dentry);
|
||||
mntput(nd->nd_mnt);
|
||||
}
|
||||
|
||||
/* Modified do_unlinkat() from linux/fs/namei.c, only uses exported symbols */
|
||||
int
|
||||
vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
@@ -269,8 +274,8 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
if (nd.last_type != LAST_NORM)
|
||||
GOTO(exit1, rc);
|
||||
|
||||
mutex_lock_nested(&nd.dentry->d_inode->i_mutex, I_MUTEX_PARENT);
|
||||
dentry = lookup_hash(&nd);
|
||||
mutex_lock_nested(&nd.nd_dentry->d_inode->i_mutex, I_MUTEX_PARENT);
|
||||
dentry = vn_lookup_hash(&nd);
|
||||
rc = PTR_ERR(dentry);
|
||||
if (!IS_ERR(dentry)) {
|
||||
/* Why not before? Because we want correct rc value */
|
||||
@@ -280,15 +285,15 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
inode = dentry->d_inode;
|
||||
if (inode)
|
||||
atomic_inc(&inode->i_count);
|
||||
rc = vfs_unlink(nd.dentry->d_inode, dentry);
|
||||
rc = vfs_unlink(nd.nd_dentry->d_inode, dentry);
|
||||
exit2:
|
||||
dput(dentry);
|
||||
}
|
||||
mutex_unlock(&nd.dentry->d_inode->i_mutex);
|
||||
mutex_unlock(&nd.nd_dentry->d_inode->i_mutex);
|
||||
if (inode)
|
||||
iput(inode); /* truncate the inode here */
|
||||
exit1:
|
||||
path_release(&nd);
|
||||
vn_path_release(&nd);
|
||||
exit:
|
||||
RETURN(-rc);
|
||||
|
||||
@@ -319,21 +324,21 @@ vn_rename(const char *oldname, const char *newname, int x1)
|
||||
GOTO(exit1, rc);
|
||||
|
||||
rc = -EXDEV;
|
||||
if (oldnd.mnt != newnd.mnt)
|
||||
if (oldnd.nd_mnt != newnd.nd_mnt)
|
||||
GOTO(exit2, rc);
|
||||
|
||||
old_dir = oldnd.dentry;
|
||||
old_dir = oldnd.nd_dentry;
|
||||
rc = -EBUSY;
|
||||
if (oldnd.last_type != LAST_NORM)
|
||||
GOTO(exit2, rc);
|
||||
|
||||
new_dir = newnd.dentry;
|
||||
new_dir = newnd.nd_dentry;
|
||||
if (newnd.last_type != LAST_NORM)
|
||||
GOTO(exit2, rc);
|
||||
|
||||
trap = lock_rename(new_dir, old_dir);
|
||||
|
||||
old_dentry = lookup_hash(&oldnd);
|
||||
old_dentry = vn_lookup_hash(&oldnd);
|
||||
|
||||
rc = PTR_ERR(old_dentry);
|
||||
if (IS_ERR(old_dentry))
|
||||
@@ -358,7 +363,7 @@ vn_rename(const char *oldname, const char *newname, int x1)
|
||||
if (old_dentry == trap)
|
||||
GOTO(exit4, rc);
|
||||
|
||||
new_dentry = lookup_hash(&newnd);
|
||||
new_dentry = vn_lookup_hash(&newnd);
|
||||
rc = PTR_ERR(new_dentry);
|
||||
if (IS_ERR(new_dentry))
|
||||
GOTO(exit4, rc);
|
||||
@@ -377,9 +382,9 @@ exit4:
|
||||
exit3:
|
||||
unlock_rename(new_dir, old_dir);
|
||||
exit2:
|
||||
path_release(&newnd);
|
||||
vn_path_release(&newnd);
|
||||
exit1:
|
||||
path_release(&oldnd);
|
||||
vn_path_release(&oldnd);
|
||||
exit:
|
||||
RETURN(-rc);
|
||||
}
|
||||
@@ -610,7 +615,8 @@ int
|
||||
vn_init(void)
|
||||
{
|
||||
ENTRY;
|
||||
vn_cache = kmem_cache_create("spl_vn_cache", sizeof(struct vnode), 64,
|
||||
vn_cache = kmem_cache_create("spl_vn_cache",
|
||||
sizeof(struct vnode), 64,
|
||||
vn_cache_constructor,
|
||||
vn_cache_destructor,
|
||||
NULL, NULL, NULL, 0);
|
||||
|
||||
Reference in New Issue
Block a user