mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Apply fix from bug239 for rwlock deadlock.
Update check.sh script to take V=1 env var so you can run it verbosely as follows if your chasing something: sudo make check V=1 Add new kobj api and needed regression tests to allow reading of files from within the kernel. Normally thats not something I support but the spa layer needs the support for its config file. Add some more missing stub headers git-svn-id: https://outreach.scidac.gov/svn/spl/trunk@38 7e1ea52c-4ff2-0310-8f11-9dd32ca42a1c
This commit is contained in:
+1
-1
@@ -6,7 +6,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/types.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/* XXX - Portions commented out because we really just want to have the type
|
||||
* defined and the contents aren't nearly so important at the moment. */
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef _SPL_KIDMAP_H
|
||||
#define _SPL_KIDMAP_H
|
||||
|
||||
#endif /* SPL_KIDMAP_H */
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef _SPL_KOBJ_H
|
||||
#define _SPL_KOBJ_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/kmem.h>
|
||||
|
||||
typedef struct _buf {
|
||||
struct file *fp;
|
||||
} _buf_t;
|
||||
|
||||
extern void *rootdir;
|
||||
|
||||
extern struct _buf *kobj_open_file(const char *name);
|
||||
extern void kobj_close_file(struct _buf *file);
|
||||
extern int kobj_read_file(struct _buf *file, char *buf,
|
||||
unsigned size, unsigned off);
|
||||
extern int kobj_get_filesize(struct _buf *file, uint64_t *size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* SPL_KOBJ_H */
|
||||
+70
-1
@@ -36,6 +36,65 @@ typedef struct {
|
||||
struct task_struct *rw_owner; /* holder of the write lock */
|
||||
} krwlock_t;
|
||||
|
||||
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
||||
struct rwsem_waiter {
|
||||
struct list_head list;
|
||||
struct task_struct *task;
|
||||
unsigned int flags;
|
||||
#define RWSEM_WAITING_FOR_READ 0x00000001
|
||||
#define RWSEM_WAITING_FOR_WRITE 0x00000002
|
||||
};
|
||||
|
||||
/*
|
||||
* wake a single writer
|
||||
*/
|
||||
static inline struct rw_semaphore *
|
||||
__rwsem_wake_one_writer_locked(struct rw_semaphore *sem)
|
||||
{
|
||||
struct rwsem_waiter *waiter;
|
||||
struct task_struct *tsk;
|
||||
|
||||
sem->activity = -1;
|
||||
|
||||
waiter = list_entry(sem->wait_list.next, struct rwsem_waiter, list);
|
||||
list_del(&waiter->list);
|
||||
|
||||
tsk = waiter->task;
|
||||
smp_mb();
|
||||
waiter->task = NULL;
|
||||
wake_up_process(tsk);
|
||||
put_task_struct(tsk);
|
||||
return sem;
|
||||
}
|
||||
|
||||
/*
|
||||
* release a read lock on the semaphore
|
||||
*/
|
||||
static void fastcall
|
||||
__up_read_locked(struct rw_semaphore *sem)
|
||||
{
|
||||
if (--sem->activity == 0 && !list_empty(&sem->wait_list))
|
||||
sem = __rwsem_wake_one_writer_locked(sem);
|
||||
}
|
||||
|
||||
/*
|
||||
* trylock for writing -- returns 1 if successful, 0 if contention
|
||||
*/
|
||||
static int fastcall
|
||||
__down_write_trylock_locked(struct rw_semaphore *sem)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (sem->activity == 0 && list_empty(&sem->wait_list)) {
|
||||
/* granted */
|
||||
sem->activity = -1;
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int __rw_read_held(krwlock_t *rwlp);
|
||||
extern int __rw_write_held(krwlock_t *rwlp);
|
||||
extern int __rw_lock_held(krwlock_t *rwlp);
|
||||
@@ -168,7 +227,7 @@ rw_downgrade(krwlock_t *rwlp)
|
||||
static __inline__ int
|
||||
rw_tryupgrade(krwlock_t *rwlp)
|
||||
{
|
||||
int result;
|
||||
int result = 0;
|
||||
BUG_ON(rwlp->rw_magic != RW_MAGIC);
|
||||
|
||||
spin_lock(&rwlp->rw_sem.wait_lock);
|
||||
@@ -197,6 +256,15 @@ rw_tryupgrade(krwlock_t *rwlp)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_RWSEM_GENERIC_SPINLOCK
|
||||
/* Here it should be safe to drop the
|
||||
* read lock and reacquire it for writing since
|
||||
* we know there are no waiters */
|
||||
__up_read_locked(&rwlp->rw_sem);
|
||||
|
||||
/* returns 1 if success, 0 if contention */
|
||||
result = __down_write_trylock_locked(&rwlp->rw_sem);
|
||||
#else
|
||||
/* Here it should be safe to drop the
|
||||
* read lock and reacquire it for writing since
|
||||
* we know there are no waiters */
|
||||
@@ -204,6 +272,7 @@ rw_tryupgrade(krwlock_t *rwlp)
|
||||
|
||||
/* returns 1 if success, 0 if contention */
|
||||
result = down_write_trylock(&rwlp->rw_sem);
|
||||
#endif
|
||||
|
||||
/* Check if upgrade failed. Should not ever happen
|
||||
* if we got to this point */
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
#ifndef _SPL_SID_H
|
||||
#define _SPL_SID_H
|
||||
|
||||
#endif /* SPL_SID_H */
|
||||
@@ -135,7 +135,6 @@ extern int highbit(unsigned long i);
|
||||
#define makedevice(maj,min) makedev(maj,min)
|
||||
#define zone_dataset_visible(x, y) (1)
|
||||
#define INGLOBALZONE(z) (1)
|
||||
#define utsname system_utsname
|
||||
|
||||
/* XXX - Borrowed from zfs project libsolcompat/include/sys/sysmacros.h */
|
||||
/* common macros */
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef _SPL_UTSNAME_H
|
||||
#define _SPL_UTSNAME_H
|
||||
|
||||
#include <linux/utsname.h>
|
||||
|
||||
#define utsname system_utsname
|
||||
|
||||
#endif /* SPL_UTSNAME_H */
|
||||
@@ -1,4 +1,8 @@
|
||||
#ifndef _SPL_ZFS_H
|
||||
#define _SPL_ZFS_H
|
||||
|
||||
typedef struct vfs_s {
|
||||
int foo;
|
||||
} vfs_t;
|
||||
|
||||
#endif /* SPL_ZFS_H */
|
||||
|
||||
Reference in New Issue
Block a user