X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=libcfs%2Flibcfs%2Flinux%2Flinux-prim.c;h=0940c80f29c94c8f6e2ada7991fb52ec43348455;hp=d9fd96b4da567f08ccd09bb57f4cac419016b42d;hb=d7249d9d70ac0fcfa665ece78634b495bc9a22cd;hpb=b9a32054600a8d63948cced361191aa6ae7ea8f2 diff --git a/libcfs/libcfs/linux/linux-prim.c b/libcfs/libcfs/linux/linux-prim.c index d9fd96b..0940c80 100644 --- a/libcfs/libcfs/linux/linux-prim.c +++ b/libcfs/libcfs/linux/linux-prim.c @@ -31,22 +31,24 @@ */ #define DEBUG_SUBSYSTEM S_LNET + +#include #include #include #include -#include #include #ifdef HAVE_SCHED_HEADERS -#include #include #endif #include -#include #if defined(CONFIG_KGDB) #include #endif +#include +#include + #ifndef HAVE_KTIME_GET_TS64 void ktime_get_ts64(struct timespec64 *ts) { @@ -101,6 +103,35 @@ time64_t ktime_get_seconds(void) EXPORT_SYMBOL(ktime_get_seconds); #endif /* HAVE_KTIME_GET_SECONDS */ +static int (*cfs_apply_workqueue_attrs_t)(struct workqueue_struct *wq, + const struct workqueue_attrs *attrs); + +int cfs_apply_workqueue_attrs(struct workqueue_struct *wq, + const struct workqueue_attrs *attrs) +{ + if (cfs_apply_workqueue_attrs_t) + return cfs_apply_workqueue_attrs_t(wq, attrs); + return 0; +} +EXPORT_SYMBOL_GPL(cfs_apply_workqueue_attrs); + +#ifndef HAVE_XARRAY_SUPPORT +struct kmem_cache (*radix_tree_node_cachep); +#endif + +void __init cfs_arch_init(void) +{ +#ifndef HAVE_WAIT_VAR_EVENT + wait_bit_init(); +#endif + cfs_apply_workqueue_attrs_t = + (void *)kallsyms_lookup_name("apply_workqueue_attrs"); +#ifndef HAVE_XARRAY_SUPPORT + radix_tree_node_cachep = + (void *)kallsyms_lookup_name("radix_tree_node_cachep"); +#endif +} + int cfs_kernel_write(struct file *filp, const void *buf, size_t count, loff_t *pos) { @@ -110,7 +141,7 @@ int cfs_kernel_write(struct file *filp, const void *buf, size_t count, mm_segment_t __old_fs = get_fs(); int rc; - set_fs(get_ds()); + set_fs(KERNEL_DS); rc = vfs_write(filp, (__force const char __user *)buf, count, pos); set_fs(__old_fs); @@ -119,6 +150,20 @@ int cfs_kernel_write(struct file *filp, const void *buf, size_t count, } EXPORT_SYMBOL(cfs_kernel_write); +ssize_t cfs_kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) +{ +#ifdef HAVE_KERNEL_READ_LAST_POSP + return kernel_read(file, buf, count, pos); +#else + ssize_t size = kernel_read(file, *pos, buf, count); + + if (size > 0) + *pos += size; + return size; +#endif +} +EXPORT_SYMBOL(cfs_kernel_read); + #ifndef HAVE_KSET_FIND_OBJ struct kobject *kset_find_obj(struct kset *kset, const char *name) { @@ -155,70 +200,3 @@ int kstrtobool_from_user(const char __user *s, size_t count, bool *res) } EXPORT_SYMBOL(kstrtobool_from_user); #endif /* !HAVE_KSTRTOBOOL_FROM_USER */ - -sigset_t -cfs_block_allsigs(void) -{ - unsigned long flags; - sigset_t old; - - spin_lock_irqsave(¤t->sighand->siglock, flags); - old = current->blocked; - sigfillset(¤t->blocked); - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); - return old; -} -EXPORT_SYMBOL(cfs_block_allsigs); - -sigset_t cfs_block_sigs(unsigned long sigs) -{ - unsigned long flags; - sigset_t old; - - spin_lock_irqsave(¤t->sighand->siglock, flags); - old = current->blocked; - sigaddsetmask(¤t->blocked, sigs); - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); - return old; -} -EXPORT_SYMBOL(cfs_block_sigs); - -/* Block all signals except for the @sigs */ -sigset_t cfs_block_sigsinv(unsigned long sigs) -{ - unsigned long flags; - sigset_t old; - - spin_lock_irqsave(¤t->sighand->siglock, flags); - old = current->blocked; - sigaddsetmask(¤t->blocked, ~sigs); - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); - return old; -} -EXPORT_SYMBOL(cfs_block_sigsinv); - -void -cfs_restore_sigs(sigset_t old) -{ - unsigned long flags; - - spin_lock_irqsave(¤t->sighand->siglock, flags); - current->blocked = old; - recalc_sigpending(); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); -} -EXPORT_SYMBOL(cfs_restore_sigs); - -void -cfs_clear_sigpending(void) -{ - unsigned long flags; - - spin_lock_irqsave(¤t->sighand->siglock, flags); - clear_tsk_thread_flag(current, TIF_SIGPENDING); - spin_unlock_irqrestore(¤t->sighand->siglock, flags); -} -EXPORT_SYMBOL(cfs_clear_sigpending);