mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
Commit bulk of remaining 2.6.9 and 2.6.26 compat changes.
git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@155 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/hardirq.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/notifier.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/debug.h>
|
||||
@@ -375,7 +376,7 @@ spl_debug_dumplog_thread(void *arg)
|
||||
spl_debug_dumplog_internal(dp);
|
||||
atomic_set(&dp->dp_done, 1);
|
||||
wake_up(&dp->dp_waitq);
|
||||
do_exit(0);
|
||||
complete_and_exit(NULL, 0);
|
||||
|
||||
return 0; /* Unreachable */
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ int
|
||||
highbit(unsigned long i)
|
||||
{
|
||||
register int h = 1;
|
||||
ENTRY;
|
||||
ENTRY;
|
||||
|
||||
if (i == 0)
|
||||
RETURN(0);
|
||||
@@ -97,7 +97,11 @@ EXPORT_SYMBOL(ddi_strtoul);
|
||||
|
||||
struct new_utsname *__utsname(void)
|
||||
{
|
||||
#ifdef HAVE_INIT_UTSNAME
|
||||
return init_utsname();
|
||||
#else
|
||||
return &system_utsname;
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__utsname);
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ spl_magazine_alloc(spl_kmem_cache_t *skc, int node)
|
||||
sizeof(void *) * skc->skc_mag_size;
|
||||
ENTRY;
|
||||
|
||||
skm = kmalloc_node(size, GFP_KERNEL, node);
|
||||
skm = kmem_alloc_node(size, GFP_KERNEL, node);
|
||||
if (skm) {
|
||||
skm->skm_magic = SKM_MAGIC;
|
||||
skm->skm_avail = 0;
|
||||
|
||||
+31
-22
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/taskq.h>
|
||||
#include <sys/kmem.h>
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
@@ -32,39 +33,47 @@
|
||||
|
||||
#define DEBUG_SUBSYSTEM S_TASKQ
|
||||
|
||||
typedef struct spl_task {
|
||||
spinlock_t t_lock;
|
||||
struct list_head t_list;
|
||||
taskqid_t t_id;
|
||||
task_func_t *t_func;
|
||||
void *t_arg;
|
||||
} spl_task_t;
|
||||
|
||||
/* NOTE: Must be called with tq->tq_lock held, returns a list_t which
|
||||
* is not attached to the free, work, or pending taskq lists.
|
||||
*/
|
||||
static task_t *
|
||||
static spl_task_t *
|
||||
task_alloc(taskq_t *tq, uint_t flags)
|
||||
{
|
||||
task_t *t;
|
||||
spl_task_t *t;
|
||||
int count = 0;
|
||||
ENTRY;
|
||||
|
||||
ASSERT(tq);
|
||||
ASSERT(flags & (TQ_SLEEP | TQ_NOSLEEP)); /* One set */
|
||||
ASSERT(!((flags & TQ_SLEEP) && (flags & TQ_NOSLEEP))); /* Not both */
|
||||
ASSERT(spin_is_locked(&tq->tq_lock));
|
||||
ASSERT(spin_is_locked(&tq->tq_lock));
|
||||
retry:
|
||||
/* Aquire task_t's from free list if available */
|
||||
/* Aquire spl_task_t's from free list if available */
|
||||
if (!list_empty(&tq->tq_free_list) && !(flags & TQ_NEW)) {
|
||||
t = list_entry(tq->tq_free_list.next, task_t, t_list);
|
||||
list_del_init(&t->t_list);
|
||||
RETURN(t);
|
||||
t = list_entry(tq->tq_free_list.next, spl_task_t, t_list);
|
||||
list_del_init(&t->t_list);
|
||||
RETURN(t);
|
||||
}
|
||||
|
||||
/* Free list is empty and memory allocs are prohibited */
|
||||
if (flags & TQ_NOALLOC)
|
||||
RETURN(NULL);
|
||||
|
||||
/* Hit maximum task_t pool size */
|
||||
/* Hit maximum spl_task_t pool size */
|
||||
if (tq->tq_nalloc >= tq->tq_maxalloc) {
|
||||
if (flags & TQ_NOSLEEP)
|
||||
RETURN(NULL);
|
||||
|
||||
/* Sleep periodically polling the free list for an available
|
||||
* task_t. If a full second passes and we have not found
|
||||
* spl_task_t. If a full second passes and we have not found
|
||||
* one gives up and return a NULL to the caller. */
|
||||
if (flags & TQ_SLEEP) {
|
||||
spin_unlock_irq(&tq->tq_lock);
|
||||
@@ -81,7 +90,7 @@ retry:
|
||||
}
|
||||
|
||||
spin_unlock_irq(&tq->tq_lock);
|
||||
t = kmem_alloc(sizeof(task_t), flags & (TQ_SLEEP | TQ_NOSLEEP));
|
||||
t = kmem_alloc(sizeof(spl_task_t), flags & (TQ_SLEEP | TQ_NOSLEEP));
|
||||
spin_lock_irq(&tq->tq_lock);
|
||||
|
||||
if (t) {
|
||||
@@ -96,11 +105,11 @@ retry:
|
||||
RETURN(t);
|
||||
}
|
||||
|
||||
/* NOTE: Must be called with tq->tq_lock held, expectes the task_t
|
||||
/* NOTE: Must be called with tq->tq_lock held, expectes the spl_task_t
|
||||
* to already be removed from the free, work, or pending taskq lists.
|
||||
*/
|
||||
static void
|
||||
task_free(taskq_t *tq, task_t *t)
|
||||
task_free(taskq_t *tq, spl_task_t *t)
|
||||
{
|
||||
ENTRY;
|
||||
|
||||
@@ -109,17 +118,17 @@ task_free(taskq_t *tq, task_t *t)
|
||||
ASSERT(spin_is_locked(&tq->tq_lock));
|
||||
ASSERT(list_empty(&t->t_list));
|
||||
|
||||
kmem_free(t, sizeof(task_t));
|
||||
kmem_free(t, sizeof(spl_task_t));
|
||||
tq->tq_nalloc--;
|
||||
|
||||
EXIT;
|
||||
}
|
||||
|
||||
/* NOTE: Must be called with tq->tq_lock held, either destroyes the
|
||||
* task_t if too many exist or moves it to the free list for later use.
|
||||
* spl_task_t if too many exist or moves it to the free list for later use.
|
||||
*/
|
||||
static void
|
||||
task_done(taskq_t *tq, task_t *t)
|
||||
task_done(taskq_t *tq, spl_task_t *t)
|
||||
{
|
||||
ENTRY;
|
||||
ASSERT(tq);
|
||||
@@ -207,7 +216,7 @@ EXPORT_SYMBOL(__taskq_member);
|
||||
taskqid_t
|
||||
__taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags)
|
||||
{
|
||||
task_t *t;
|
||||
spl_task_t *t;
|
||||
taskqid_t rc = 0;
|
||||
ENTRY;
|
||||
|
||||
@@ -254,7 +263,7 @@ static taskqid_t
|
||||
taskq_lowest_id(taskq_t *tq)
|
||||
{
|
||||
taskqid_t lowest_id = ~0;
|
||||
task_t *t;
|
||||
spl_task_t *t;
|
||||
ENTRY;
|
||||
|
||||
ASSERT(tq);
|
||||
@@ -278,7 +287,7 @@ taskq_thread(void *args)
|
||||
sigset_t blocked;
|
||||
taskqid_t id;
|
||||
taskq_t *tq = args;
|
||||
task_t *t;
|
||||
spl_task_t *t;
|
||||
ENTRY;
|
||||
|
||||
ASSERT(tq);
|
||||
@@ -306,7 +315,7 @@ taskq_thread(void *args)
|
||||
|
||||
remove_wait_queue(&tq->tq_work_waitq, &wait);
|
||||
if (!list_empty(&tq->tq_pend_list)) {
|
||||
t = list_entry(tq->tq_pend_list.next, task_t, t_list);
|
||||
t = list_entry(tq->tq_pend_list.next, spl_task_t, t_list);
|
||||
list_del_init(&t->t_list);
|
||||
list_add_tail(&t->t_list, &tq->tq_work_list);
|
||||
tq->tq_nactive++;
|
||||
@@ -418,7 +427,7 @@ EXPORT_SYMBOL(__taskq_create);
|
||||
void
|
||||
__taskq_destroy(taskq_t *tq)
|
||||
{
|
||||
task_t *t;
|
||||
spl_task_t *t;
|
||||
int i, nthreads;
|
||||
ENTRY;
|
||||
|
||||
@@ -438,7 +447,7 @@ __taskq_destroy(taskq_t *tq)
|
||||
spin_lock_irq(&tq->tq_lock);
|
||||
|
||||
while (!list_empty(&tq->tq_free_list)) {
|
||||
t = list_entry(tq->tq_free_list.next, task_t, t_list);
|
||||
t = list_entry(tq->tq_free_list.next, spl_task_t, t_list);
|
||||
list_del_init(&t->t_list);
|
||||
task_free(tq, t);
|
||||
}
|
||||
@@ -450,7 +459,7 @@ __taskq_destroy(taskq_t *tq)
|
||||
ASSERT(list_empty(&tq->tq_pend_list));
|
||||
|
||||
spin_unlock_irq(&tq->tq_lock);
|
||||
kmem_free(tq->tq_threads, nthreads * sizeof(task_t *));
|
||||
kmem_free(tq->tq_threads, nthreads * sizeof(spl_task_t *));
|
||||
kmem_free(tq, sizeof(taskq_t));
|
||||
|
||||
EXIT;
|
||||
|
||||
@@ -73,7 +73,7 @@ __thread_exit(void)
|
||||
{
|
||||
ENTRY;
|
||||
EXIT;
|
||||
do_exit(0);
|
||||
complete_and_exit(NULL, 0);
|
||||
/* Unreachable */
|
||||
}
|
||||
EXPORT_SYMBOL(__thread_exit);
|
||||
|
||||
+20
-16
@@ -27,6 +27,10 @@
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef HAVE_MONOTONIC_CLOCK
|
||||
extern unsigned long long monotonic_clock(void);
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SUBSYSTEM
|
||||
#undef DEBUG_SUBSYSTEM
|
||||
#endif
|
||||
@@ -36,27 +40,26 @@
|
||||
void
|
||||
__gethrestime(timestruc_t *ts)
|
||||
{
|
||||
getnstimeofday((struct timespec *)ts);
|
||||
struct timeval tv;
|
||||
|
||||
do_gettimeofday(&tv);
|
||||
ts->tv_sec = tv.tv_sec;
|
||||
ts->tv_nsec = tv.tv_usec * NSEC_PER_USEC;
|
||||
}
|
||||
EXPORT_SYMBOL(__gethrestime);
|
||||
|
||||
int
|
||||
__clock_gettime(clock_type_t type, timespec_t *tp)
|
||||
{
|
||||
/* Only support CLOCK_REALTIME+__CLOCK_REALTIME0 for now */
|
||||
ASSERT((type == CLOCK_REALTIME) || (type == __CLOCK_REALTIME0));
|
||||
|
||||
getnstimeofday(tp);
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(__clock_gettime);
|
||||
|
||||
/* This function may not be as fast as using monotonic_clock() but it
|
||||
* should be much more portable, if performance becomes as issue we can
|
||||
* look at using monotonic_clock() for x86_64 and x86 arches.
|
||||
/* Use monotonic_clock() by default. It's faster and is available on older
|
||||
* kernels, but few architectures have them, so we must fallback to
|
||||
* do_posix_clock_monotonic_gettime().
|
||||
*/
|
||||
hrtime_t
|
||||
__gethrtime(void) {
|
||||
#ifdef HAVE_MONOTONIC_CLOCK
|
||||
unsigned long long res = monotonic_clock();
|
||||
|
||||
/* Deal with signed/unsigned mismatch */
|
||||
return (hrtime_t)(res & ~(1ULL << (BITS_PER_LONG - 1)));
|
||||
#else
|
||||
timespec_t tv;
|
||||
hrtime_t rc;
|
||||
|
||||
@@ -64,12 +67,13 @@ __gethrtime(void) {
|
||||
rc = (NSEC_PER_SEC * (hrtime_t)tv.tv_sec) + (hrtime_t)tv.tv_nsec;
|
||||
|
||||
return rc;
|
||||
#endif
|
||||
}
|
||||
EXPORT_SYMBOL(__gethrtime);
|
||||
|
||||
/* set_normalized_timespec() API changes
|
||||
* 2.6.0 - 2.6.15: Inline function provided by linux/time.h
|
||||
* 2.6.16 - 2.6.25: Function prototypedefined but not exported
|
||||
* 2.6.16 - 2.6.25: Function prototype defined but not exported
|
||||
* 2.6.26 - 2.6.x: Function defined and exported
|
||||
*/
|
||||
#if !defined(HAVE_SET_NORMALIZED_TIMESPEC_INLINE) && \
|
||||
|
||||
+11
-3
@@ -261,10 +261,10 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
struct nameidata nd;
|
||||
struct inode *inode = NULL;
|
||||
int rc = 0;
|
||||
ENTRY;
|
||||
ENTRY;
|
||||
|
||||
ASSERT(seg == UIO_SYSSPACE);
|
||||
ASSERT(flags == RMFILE);
|
||||
ASSERT(seg == UIO_SYSSPACE);
|
||||
ASSERT(flags == RMFILE);
|
||||
|
||||
rc = path_lookup(path, LOOKUP_PARENT, &nd);
|
||||
if (rc)
|
||||
@@ -274,7 +274,11 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
if (nd.last_type != LAST_NORM)
|
||||
GOTO(exit1, rc);
|
||||
|
||||
#ifdef HAVE_INODE_I_MUTEX
|
||||
mutex_lock_nested(&nd.nd_dentry->d_inode->i_mutex, I_MUTEX_PARENT);
|
||||
#else
|
||||
down(&nd.nd_dentry->d_inode->i_sem);
|
||||
#endif
|
||||
dentry = vn_lookup_hash(&nd);
|
||||
rc = PTR_ERR(dentry);
|
||||
if (!IS_ERR(dentry)) {
|
||||
@@ -289,7 +293,11 @@ vn_remove(const char *path, uio_seg_t seg, int flags)
|
||||
exit2:
|
||||
dput(dentry);
|
||||
}
|
||||
#ifdef HAVE_INODE_I_MUTEX
|
||||
mutex_unlock(&nd.nd_dentry->d_inode->i_mutex);
|
||||
#else
|
||||
up(&nd.nd_dentry->d_inode->i_sem);
|
||||
#endif
|
||||
if (inode)
|
||||
iput(inode); /* truncate the inode here */
|
||||
exit1:
|
||||
|
||||
Reference in New Issue
Block a user