diff options
Diffstat (limited to 'module')
-rw-r--r-- | module/spl/spl-atomic.c | 8 | ||||
-rw-r--r-- | module/spl/spl-condvar.c | 8 | ||||
-rw-r--r-- | module/spl/spl-cred.c | 38 | ||||
-rw-r--r-- | module/spl/spl-err.c | 5 | ||||
-rw-r--r-- | module/spl/spl-generic.c | 84 | ||||
-rw-r--r-- | module/spl/spl-kmem-cache.c | 22 | ||||
-rw-r--r-- | module/spl/spl-kmem.c | 2 | ||||
-rw-r--r-- | module/spl/spl-kobj.c | 12 | ||||
-rw-r--r-- | module/spl/spl-kstat.c | 521 | ||||
-rw-r--r-- | module/spl/spl-mutex.c | 8 | ||||
-rw-r--r-- | module/spl/spl-proc.c | 628 | ||||
-rw-r--r-- | module/spl/spl-rwlock.c | 10 | ||||
-rw-r--r-- | module/spl/spl-taskq.c | 22 | ||||
-rw-r--r-- | module/spl/spl-thread.c | 29 | ||||
-rw-r--r-- | module/spl/spl-vnode.c | 164 | ||||
-rw-r--r-- | module/spl/spl-xdr.c | 157 | ||||
-rw-r--r-- | module/spl/spl-zlib.c | 37 |
17 files changed, 873 insertions, 882 deletions
diff --git a/module/spl/spl-atomic.c b/module/spl/spl-atomic.c index 4c48684ba..47ed1886e 100644 --- a/module/spl/spl-atomic.c +++ b/module/spl/spl-atomic.c @@ -20,18 +20,12 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Atomic Implementation. */ #include <sys/atomic.h> -#ifdef DEBUG_SUBSYSTEM -#undef DEBUG_SUBSYSTEM -#endif - -#define DEBUG_SUBSYSTEM S_ATOMIC - #ifdef ATOMIC_SPINLOCK /* Global atomic lock declarations */ DEFINE_SPINLOCK(atomic32_lock); diff --git a/module/spl/spl-condvar.c b/module/spl/spl-condvar.c index 4778fb256..f0060bbdc 100644 --- a/module/spl/spl-condvar.c +++ b/module/spl/spl-condvar.c @@ -335,8 +335,8 @@ __cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t expire_time, * Compatibility wrapper for the cv_timedwait_hires() Illumos interface. */ static clock_t -cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res, - int flag, int state) +cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, + hrtime_t res, int flag, int state) { if (res > 1) { /* @@ -363,8 +363,8 @@ cv_timedwait_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res, EXPORT_SYMBOL(cv_timedwait_hires); clock_t -cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res, - int flag) +cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, + hrtime_t res, int flag) { return (cv_timedwait_hires_common(cvp, mp, tim, res, flag, TASK_INTERRUPTIBLE)); diff --git a/module/spl/spl-cred.c b/module/spl/spl-cred.c index f4431db7f..ea3e903f9 100644 --- a/module/spl/spl-cred.c +++ b/module/spl/spl-cred.c @@ -20,18 +20,12 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Credential Implementation. */ #include <sys/cred.h> -#ifdef DEBUG_SUBSYSTEM -#undef DEBUG_SUBSYSTEM -#endif - -#define DEBUG_SUBSYSTEM S_CRED - static int #ifdef HAVE_KUIDGID_T cr_groups_search(const struct group_info *group_info, kgid_t grp) @@ -43,7 +37,7 @@ cr_groups_search(const struct group_info *group_info, gid_t grp) int cmp; if (!group_info) - return 0; + return (0); left = 0; right = group_info->ngroups; @@ -57,16 +51,16 @@ cr_groups_search(const struct group_info *group_info, gid_t grp) else if (cmp < 0) right = mid; else - return 1; + return (1); } - return 0; + return (0); } /* Hold a reference on the credential */ void crhold(cred_t *cr) { - (void)get_cred((const cred_t *)cr); + (void) get_cred((const cred_t *)cr); } /* Free a reference on the credential */ @@ -96,7 +90,7 @@ crgetngroups(const cred_t *cr) rc = NGROUPS_PER_BLOCK; } #endif - return rc; + return (rc); } /* @@ -119,7 +113,7 @@ crgetgroups(const cred_t *cr) if (gi->nblocks > 0) gids = KGIDP_TO_SGIDP(gi->blocks[0]); #endif - return gids; + return (gids); } /* Check if the passed gid is available in supplied credential. */ @@ -132,63 +126,63 @@ groupmember(gid_t gid, const cred_t *cr) gi = cr->group_info; rc = cr_groups_search(gi, SGID_TO_KGID(gid)); - return rc; + return (rc); } /* Return the effective user id */ uid_t crgetuid(const cred_t *cr) { - return KUID_TO_SUID(cr->euid); + return (KUID_TO_SUID(cr->euid)); } /* Return the real user id */ uid_t crgetruid(const cred_t *cr) { - return KUID_TO_SUID(cr->uid); + return (KUID_TO_SUID(cr->uid)); } /* Return the saved user id */ uid_t crgetsuid(const cred_t *cr) { - return KUID_TO_SUID(cr->suid); + return (KUID_TO_SUID(cr->suid)); } /* Return the filesystem user id */ uid_t crgetfsuid(const cred_t *cr) { - return KUID_TO_SUID(cr->fsuid); + return (KUID_TO_SUID(cr->fsuid)); } /* Return the effective group id */ gid_t crgetgid(const cred_t *cr) { - return KGID_TO_SGID(cr->egid); + return (KGID_TO_SGID(cr->egid)); } /* Return the real group id */ gid_t crgetrgid(const cred_t *cr) { - return KGID_TO_SGID(cr->gid); + return (KGID_TO_SGID(cr->gid)); } /* Return the saved group id */ gid_t crgetsgid(const cred_t *cr) { - return KGID_TO_SGID(cr->sgid); + return (KGID_TO_SGID(cr->sgid)); } /* Return the filesystem group id */ gid_t crgetfsgid(const cred_t *cr) { - return KGID_TO_SGID(cr->fsgid); + return (KGID_TO_SGID(cr->fsgid)); } EXPORT_SYMBOL(crhold); diff --git a/module/spl/spl-err.c b/module/spl/spl-err.c index 28c5258ef..33a8df898 100644 --- a/module/spl/spl-err.c +++ b/module/spl/spl-err.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Error Implementation. */ @@ -36,8 +36,7 @@ */ unsigned int spl_panic_halt; module_param(spl_panic_halt, uint, 0644); -MODULE_PARM_DESC(spl_panic_halt, - "Cause kernel panic on assertion failures"); +MODULE_PARM_DESC(spl_panic_halt, "Cause kernel panic on assertion failures"); /* * Limit the number of stack traces dumped to not more than 5 every diff --git a/module/spl/spl-generic.c b/module/spl/spl-generic.c index b5c9a9aef..efd901094 100644 --- a/module/spl/spl-generic.c +++ b/module/spl/spl-generic.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Generic Implementation. */ @@ -109,13 +109,14 @@ spl_rand_next(uint64_t *s) { static inline void spl_rand_jump(uint64_t *s) { - static const uint64_t JUMP[] = { 0x8a5cd789635d2dff, 0x121fd2155c472f96 }; + static const uint64_t JUMP[] = + { 0x8a5cd789635d2dff, 0x121fd2155c472f96 }; uint64_t s0 = 0; uint64_t s1 = 0; int i, b; - for(i = 0; i < sizeof JUMP / sizeof *JUMP; i++) - for(b = 0; b < 64; b++) { + for (i = 0; i < sizeof (JUMP) / sizeof (*JUMP); i++) + for (b = 0; b < 64; b++) { if (JUMP[i] & 1ULL << b) { s0 ^= s[0]; s1 ^= s[1]; @@ -187,16 +188,16 @@ nlz64(uint64_t x) { register int n = 0; if (x == 0) - return 64; + return (64); - if (x <= 0x00000000FFFFFFFFULL) {n = n + 32; x = x << 32;} - if (x <= 0x0000FFFFFFFFFFFFULL) {n = n + 16; x = x << 16;} - if (x <= 0x00FFFFFFFFFFFFFFULL) {n = n + 8; x = x << 8;} - if (x <= 0x0FFFFFFFFFFFFFFFULL) {n = n + 4; x = x << 4;} - if (x <= 0x3FFFFFFFFFFFFFFFULL) {n = n + 2; x = x << 2;} - if (x <= 0x7FFFFFFFFFFFFFFFULL) {n = n + 1;} + if (x <= 0x00000000FFFFFFFFULL) { n = n + 32; x = x << 32; } + if (x <= 0x0000FFFFFFFFFFFFULL) { n = n + 16; x = x << 16; } + if (x <= 0x00FFFFFFFFFFFFFFULL) { n = n + 8; x = x << 8; } + if (x <= 0x0FFFFFFFFFFFFFFFULL) { n = n + 4; x = x << 4; } + if (x <= 0x3FFFFFFFFFFFFFFFULL) { n = n + 2; x = x << 2; } + if (x <= 0x7FFFFFFFFFFFFFFFULL) { n = n + 1; } - return n; + return (n); } /* @@ -207,7 +208,7 @@ static inline uint64_t __div_u64(uint64_t u, uint32_t v) { (void) do_div(u, v); - return u; + return (u); } /* @@ -227,7 +228,7 @@ __udivdi3(uint64_t u, uint64_t v) if (v >> 32 == 0) { // If v < 2**32: if (u >> 32 < v) { // If u/v cannot overflow, - return __div_u64(u, v); // just do one division. + return (__div_u64(u, v)); // just do one division. } else { // If u/v would overflow: u1 = u >> 32; // Break u into two halves. u0 = u & 0xFFFFFFFF; @@ -235,7 +236,7 @@ __udivdi3(uint64_t u, uint64_t v) k = u1 - q1 * v; // First remainder, < v. u0 += (k << 32); q0 = __div_u64(u0, v); // Seconds quotient digit. - return (q1 << 32) + q0; + return ((q1 << 32) + q0); } } else { // If v >= 2**32: n = nlz64(v); // 0 <= n <= 31. @@ -249,7 +250,7 @@ __udivdi3(uint64_t u, uint64_t v) if ((u - q0 * v) >= v) q0 = q0 + 1; // Now q0 is correct. - return q0; + return (q0); } } EXPORT_SYMBOL(__udivdi3); @@ -263,7 +264,7 @@ __divdi3(int64_t u, int64_t v) int64_t q, t; q = __udivdi3(abs64(u), abs64(v)); t = (u ^ v) >> 63; // If u, v have different - return (q ^ t) - t; // signs, negate q. + return ((q ^ t) - t); // signs, negate q. } EXPORT_SYMBOL(__divdi3); @@ -344,9 +345,11 @@ __aeabi_uldivmod(uint64_t u, uint64_t v) register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF); register uint32_t r3 asm("r3") = (mod >> 32); + /* BEGIN CSTYLED */ asm volatile("" : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */ : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */ + /* END CSTYLED */ return; /* r0; */ } @@ -367,9 +370,11 @@ __aeabi_ldivmod(int64_t u, int64_t v) register uint32_t r2 asm("r2") = (mod & 0xFFFFFFFF); register uint32_t r3 asm("r3") = (mod >> 32); + /* BEGIN CSTYLED */ asm volatile("" : "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */ : "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */ + /* END CSTYLED */ return; /* r0; */ } @@ -378,7 +383,8 @@ EXPORT_SYMBOL(__aeabi_ldivmod); #endif /* __arm || __arm__ */ #endif /* BITS_PER_LONG */ -/* NOTE: The strtoxx behavior is solely based on my reading of the Solaris +/* + * NOTE: The strtoxx behavior is solely based on my reading of the Solaris * ddi_strtol(9F) man page. I have not verified the behavior of these * functions against their Solaris counterparts. It is possible that I * may have misinterpreted the man page or the man page is incorrect. @@ -388,28 +394,28 @@ int ddi_strtol(const char *, char **, int, long *); int ddi_strtoull(const char *, char **, int, unsigned long long *); int ddi_strtoll(const char *, char **, int, long long *); -#define define_ddi_strtoux(type, valtype) \ +#define define_ddi_strtoux(type, valtype) \ int ddi_strtou##type(const char *str, char **endptr, \ - int base, valtype *result) \ + int base, valtype *result) \ { \ valtype last_value, value = 0; \ char *ptr = (char *)str; \ int flag = 1, digit; \ \ if (strlen(ptr) == 0) \ - return EINVAL; \ + return (EINVAL); \ \ /* Auto-detect base based on prefix */ \ if (!base) { \ if (str[0] == '0') { \ - if (tolower(str[1])=='x' && isxdigit(str[2])) { \ + if (tolower(str[1]) == 'x' && isxdigit(str[2])) { \ base = 16; /* hex */ \ ptr += 2; \ } else if (str[1] >= '0' && str[1] < 8) { \ base = 8; /* octal */ \ ptr += 1; \ } else { \ - return EINVAL; \ + return (EINVAL); \ } \ } else { \ base = 10; /* decimal */ \ @@ -430,7 +436,7 @@ int ddi_strtou##type(const char *str, char **endptr, \ last_value = value; \ value = value * base + digit; \ if (last_value > value) /* Overflow */ \ - return ERANGE; \ + return (ERANGE); \ \ flag = 1; \ ptr++; \ @@ -442,12 +448,12 @@ int ddi_strtou##type(const char *str, char **endptr, \ if (endptr) \ *endptr = (char *)(flag ? ptr : str); \ \ - return 0; \ + return (0); \ } \ -#define define_ddi_strtox(type, valtype) \ +#define define_ddi_strtox(type, valtype) \ int ddi_strto##type(const char *str, char **endptr, \ - int base, valtype *result) \ + int base, valtype *result) \ { \ int rc; \ \ @@ -463,7 +469,7 @@ int ddi_strto##type(const char *str, char **endptr, \ rc = ddi_strtou##type(str, endptr, base, result); \ } \ \ - return rc; \ + return (rc); \ } define_ddi_strtoux(l, unsigned long) @@ -482,10 +488,10 @@ ddi_copyin(const void *from, void *to, size_t len, int flags) /* Fake ioctl() issued by kernel, 'from' is a kernel address */ if (flags & FKIOCTL) { memcpy(to, from, len); - return 0; + return (0); } - return copyin(from, to, len); + return (copyin(from, to, len)); } EXPORT_SYMBOL(ddi_copyin); @@ -495,10 +501,10 @@ ddi_copyout(const void *from, void *to, size_t len, int flags) /* Fake ioctl() issued by kernel, 'from' is a kernel address */ if (flags & FKIOCTL) { memcpy(to, from, len); - return 0; + return (0); } - return copyout(from, to, len); + return (copyout(from, to, len)); } EXPORT_SYMBOL(ddi_copyout); @@ -559,7 +565,7 @@ hostid_read(uint32_t *hostid) return (error); } - if (size < sizeof(HW_HOSTID_MASK)) { + if (size < sizeof (HW_HOSTID_MASK)) { kobj_close_file(file); return (EINVAL); } @@ -568,7 +574,7 @@ hostid_read(uint32_t *hostid) * Read directly into the variable like eglibc does. * Short reads are okay; native behavior is preserved. */ - error = kobj_read_file(file, (char *)&value, sizeof(value), 0); + error = kobj_read_file(file, (char *)&value, sizeof (value), 0); if (error < 0) { kobj_close_file(file); return (EIO); @@ -578,7 +584,7 @@ hostid_read(uint32_t *hostid) *hostid = (value & HW_HOSTID_MASK); kobj_close_file(file); - return 0; + return (0); } /* @@ -704,7 +710,7 @@ spl_init(void) goto out10; printk(KERN_NOTICE "SPL: Loaded module v%s-%s%s\n", SPL_META_VERSION, - SPL_META_RELEASE, SPL_DEBUG_STR); + SPL_META_RELEASE, SPL_DEBUG_STR); return (rc); out10: @@ -727,8 +733,8 @@ out2: spl_kvmem_fini(); out1: printk(KERN_NOTICE "SPL: Failed to Load Solaris Porting Layer " - "v%s-%s%s, rc = %d\n", SPL_META_VERSION, SPL_META_RELEASE, - SPL_DEBUG_STR, rc); + "v%s-%s%s, rc = %d\n", SPL_META_VERSION, SPL_META_RELEASE, + SPL_DEBUG_STR, rc); return (rc); } @@ -737,7 +743,7 @@ static void __exit spl_fini(void) { printk(KERN_NOTICE "SPL: Unloaded module v%s-%s%s\n", - SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); + SPL_META_VERSION, SPL_META_RELEASE, SPL_DEBUG_STR); spl_zlib_fini(); spl_kstat_fini(); spl_proc_fini(); diff --git a/module/spl/spl-kmem-cache.c b/module/spl/spl-kmem-cache.c index 36686692b..e4bcdd825 100644 --- a/module/spl/spl-kmem-cache.c +++ b/module/spl/spl-kmem-cache.c @@ -134,8 +134,8 @@ MODULE_PARM_DESC(spl_kmem_cache_slab_limit, * have been deemed costly by the kernel. */ unsigned int spl_kmem_cache_kmem_limit = - ((1 << (PAGE_ALLOC_COSTLY_ORDER - 1)) * PAGE_SIZE) / - SPL_KMEM_CACHE_OBJ_PER_SLAB; + ((1 << (PAGE_ALLOC_COSTLY_ORDER - 1)) * PAGE_SIZE) / + SPL_KMEM_CACHE_OBJ_PER_SLAB; module_param(spl_kmem_cache_kmem_limit, uint, 0644); MODULE_PARM_DESC(spl_kmem_cache_kmem_limit, "Objects less than N bytes use the kmalloc"); @@ -1000,15 +1000,15 @@ spl_kmem_cache_create(char *name, size_t size, size_t align, #endif #if defined(HAVE_KMEM_CACHE_CREATE_USERCOPY) - /* - * Newer grsec patchset uses kmem_cache_create_usercopy() - * instead of SLAB_USERCOPY flag - */ - skc->skc_linux_cache = kmem_cache_create_usercopy( - skc->skc_name, size, align, slabflags, 0, size, NULL); + /* + * Newer grsec patchset uses kmem_cache_create_usercopy() + * instead of SLAB_USERCOPY flag + */ + skc->skc_linux_cache = kmem_cache_create_usercopy( + skc->skc_name, size, align, slabflags, 0, size, NULL); #else - skc->skc_linux_cache = kmem_cache_create( - skc->skc_name, size, align, slabflags, NULL); + skc->skc_linux_cache = kmem_cache_create( + skc->skc_name, size, align, slabflags, NULL); #endif if (skc->skc_linux_cache == NULL) { rc = ENOMEM; @@ -1186,7 +1186,7 @@ spl_cache_grow_work(void *data) spl_kmem_alloc_t *ska = (spl_kmem_alloc_t *)data; spl_kmem_cache_t *skc = ska->ska_cache; - (void)__spl_cache_grow(skc, ska->ska_flags); + (void) __spl_cache_grow(skc, ska->ska_flags); atomic_dec(&skc->skc_ref); smp_mb__before_atomic(); diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index 41bec75d2..bf9c6b179 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -383,7 +383,7 @@ spl_kmem_free_track(const void *ptr, size_t size) { kmem_debug_t *dptr; - /* Ignore NULL pointer since we haven't tracked it at all*/ + /* Ignore NULL pointer since we haven't tracked it at all */ if (ptr == NULL) return; diff --git a/module/spl/spl-kobj.c b/module/spl/spl-kobj.c index 6191163a8..7019369bd 100644 --- a/module/spl/spl-kobj.c +++ b/module/spl/spl-kobj.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Kobj Implementation. */ @@ -33,7 +33,7 @@ kobj_open_file(const char *name) vnode_t *vp; int rc; - file = kmalloc(sizeof(_buf_t), kmem_flags_convert(KM_SLEEP)); + file = kmalloc(sizeof (_buf_t), kmem_flags_convert(KM_SLEEP)); if (file == NULL) return ((_buf_t *)-1UL); @@ -52,7 +52,7 @@ void kobj_close_file(struct _buf *file) { VOP_CLOSE(file->vp, 0, 0, 0, 0, 0); - kfree(file); + kfree(file); } /* kobj_close_file() */ EXPORT_SYMBOL(kobj_close_file); @@ -72,15 +72,15 @@ EXPORT_SYMBOL(kobj_read_file); int kobj_get_filesize(struct _buf *file, uint64_t *size) { - vattr_t vap; + vattr_t vap; int rc; rc = VOP_GETATTR(file->vp, &vap, 0, 0, NULL); if (rc) return (rc); - *size = vap.va_size; + *size = vap.va_size; - return (rc); + return (rc); } /* kobj_get_filesize() */ EXPORT_SYMBOL(kobj_get_filesize); diff --git a/module/spl/spl-kstat.c b/module/spl/spl-kstat.c index 4517824e7..70c0c98f8 100644 --- a/module/spl/spl-kstat.c +++ b/module/spl/spl-kstat.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Kstat Implementation. */ @@ -30,7 +30,7 @@ #include <sys/cmn_err.h> #ifndef HAVE_PDE_DATA -#define PDE_DATA(x) (PDE(x)->data) +#define PDE_DATA(x) (PDE(x)->data) #endif static kmutex_t kstat_module_lock; @@ -41,13 +41,13 @@ static int kstat_resize_raw(kstat_t *ksp) { if (ksp->ks_raw_bufsize == KSTAT_RAW_MAX) - return ENOMEM; + return (ENOMEM); vmem_free(ksp->ks_raw_buf, ksp->ks_raw_bufsize); ksp->ks_raw_bufsize = MIN(ksp->ks_raw_bufsize * 2, KSTAT_RAW_MAX); ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP); - return 0; + return (0); } void @@ -119,210 +119,212 @@ EXPORT_SYMBOL(kstat_runq_exit); static int kstat_seq_show_headers(struct seq_file *f) { - kstat_t *ksp = (kstat_t *)f->private; + kstat_t *ksp = (kstat_t *)f->private; int rc = 0; - ASSERT(ksp->ks_magic == KS_MAGIC); + ASSERT(ksp->ks_magic == KS_MAGIC); - seq_printf(f, "%d %d 0x%02x %d %d %lld %lld\n", - ksp->ks_kid, ksp->ks_type, ksp->ks_flags, - ksp->ks_ndata, (int)ksp->ks_data_size, - ksp->ks_crtime, ksp->ks_snaptime); + seq_printf(f, "%d %d 0x%02x %d %d %lld %lld\n", + ksp->ks_kid, ksp->ks_type, ksp->ks_flags, + ksp->ks_ndata, (int)ksp->ks_data_size, + ksp->ks_crtime, ksp->ks_snaptime); switch (ksp->ks_type) { - case KSTAT_TYPE_RAW: + case KSTAT_TYPE_RAW: restart: - if (ksp->ks_raw_ops.headers) { - rc = ksp->ks_raw_ops.headers( - ksp->ks_raw_buf, ksp->ks_raw_bufsize); + if (ksp->ks_raw_ops.headers) { + rc = ksp->ks_raw_ops.headers( + ksp->ks_raw_buf, ksp->ks_raw_bufsize); if (rc == ENOMEM && !kstat_resize_raw(ksp)) goto restart; if (!rc) - seq_puts(f, ksp->ks_raw_buf); - } else { - seq_printf(f, "raw data\n"); - } - break; - case KSTAT_TYPE_NAMED: - seq_printf(f, "%-31s %-4s %s\n", - "name", "type", "data"); - break; - case KSTAT_TYPE_INTR: - seq_printf(f, "%-8s %-8s %-8s %-8s %-8s\n", - "hard", "soft", "watchdog", - "spurious", "multsvc"); - break; - case KSTAT_TYPE_IO: - seq_printf(f, - "%-8s %-8s %-8s %-8s %-8s %-8s " - "%-8s %-8s %-8s %-8s %-8s %-8s\n", - "nread", "nwritten", "reads", "writes", - "wtime", "wlentime", "wupdate", - "rtime", "rlentime", "rupdate", - "wcnt", "rcnt"); - break; - case KSTAT_TYPE_TIMER: - seq_printf(f, - "%-31s %-8s " - "%-8s %-8s %-8s %-8s %-8s\n", - "name", "events", "elapsed", - "min", "max", "start", "stop"); - break; - default: - PANIC("Undefined kstat type %d\n", ksp->ks_type); - } - - return -rc; + seq_puts(f, ksp->ks_raw_buf); + } else { + seq_printf(f, "raw data\n"); + } + break; + case KSTAT_TYPE_NAMED: + seq_printf(f, "%-31s %-4s %s\n", + "name", "type", "data"); + break; + case KSTAT_TYPE_INTR: + seq_printf(f, "%-8s %-8s %-8s %-8s %-8s\n", + "hard", "soft", "watchdog", + "spurious", "multsvc"); + break; + case KSTAT_TYPE_IO: + seq_printf(f, + "%-8s %-8s %-8s %-8s %-8s %-8s " + "%-8s %-8s %-8s %-8s %-8s %-8s\n", + "nread", "nwritten", "reads", "writes", + "wtime", "wlentime", "wupdate", + "rtime", "rlentime", "rupdate", + "wcnt", "rcnt"); + break; + case KSTAT_TYPE_TIMER: + seq_printf(f, + "%-31s %-8s " + "%-8s %-8s %-8s %-8s %-8s\n", + "name", "events", "elapsed", + "min", "max", "start", "stop"); + break; + default: + PANIC("Undefined kstat type %d\n", ksp->ks_type); + } + + return (-rc); } static int kstat_seq_show_raw(struct seq_file *f, unsigned char *p, int l) { - int i, j; + int i, j; - for (i = 0; ; i++) { - seq_printf(f, "%03x:", i); + for (i = 0; ; i++) { + seq_printf(f, "%03x:", i); - for (j = 0; j < 16; j++) { - if (i * 16 + j >= l) { - seq_printf(f, "\n"); - goto out; - } + for (j = 0; j < 16; j++) { + if (i * 16 + j >= l) { + seq_printf(f, "\n"); + goto out; + } - seq_printf(f, " %02x", (unsigned char)p[i * 16 + j]); - } - seq_printf(f, "\n"); - } + seq_printf(f, " %02x", (unsigned char)p[i * 16 + j]); + } + seq_printf(f, "\n"); + } out: - return 0; + return (0); } static int kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp) { - seq_printf(f, "%-31s %-4d ", knp->name, knp->data_type); - - switch (knp->data_type) { - case KSTAT_DATA_CHAR: - knp->value.c[15] = '\0'; /* NULL terminate */ - seq_printf(f, "%-16s", knp->value.c); - break; - /* XXX - We need to be more careful able what tokens are - * used for each arch, for now this is correct for x86_64. - */ - case KSTAT_DATA_INT32: - seq_printf(f, "%d", knp->value.i32); - break; - case KSTAT_DATA_UINT32: - seq_printf(f, "%u", knp->value.ui32); - break; - case KSTAT_DATA_INT64: - seq_printf(f, "%lld", (signed long long)knp->value.i64); - break; - case KSTAT_DATA_UINT64: - seq_printf(f, "%llu", (unsigned long long)knp->value.ui64); - break; - case KSTAT_DATA_LONG: - seq_printf(f, "%ld", knp->value.l); - break; - case KSTAT_DATA_ULONG: - seq_printf(f, "%lu", knp->value.ul); - break; - case KSTAT_DATA_STRING: - KSTAT_NAMED_STR_PTR(knp) - [KSTAT_NAMED_STR_BUFLEN(knp)-1] = '\0'; - seq_printf(f, "%s", KSTAT_NAMED_STR_PTR(knp)); - break; - default: - PANIC("Undefined kstat data type %d\n", knp->data_type); - } - - seq_printf(f, "\n"); - - return 0; + seq_printf(f, "%-31s %-4d ", knp->name, knp->data_type); + + switch (knp->data_type) { + case KSTAT_DATA_CHAR: + knp->value.c[15] = '\0'; /* NULL terminate */ + seq_printf(f, "%-16s", knp->value.c); + break; + /* + * NOTE - We need to be more careful able what tokens are + * used for each arch, for now this is correct for x86_64. + */ + case KSTAT_DATA_INT32: + seq_printf(f, "%d", knp->value.i32); + break; + case KSTAT_DATA_UINT32: + seq_printf(f, "%u", knp->value.ui32); + break; + case KSTAT_DATA_INT64: + seq_printf(f, "%lld", (signed long long)knp->value.i64); + break; + case KSTAT_DATA_UINT64: + seq_printf(f, "%llu", + (unsigned long long)knp->value.ui64); + break; + case KSTAT_DATA_LONG: + seq_printf(f, "%ld", knp->value.l); + break; + case KSTAT_DATA_ULONG: + seq_printf(f, "%lu", knp->value.ul); + break; + case KSTAT_DATA_STRING: + KSTAT_NAMED_STR_PTR(knp) + [KSTAT_NAMED_STR_BUFLEN(knp)-1] = '\0'; + seq_printf(f, "%s", KSTAT_NAMED_STR_PTR(knp)); + break; + default: + PANIC("Undefined kstat data type %d\n", knp->data_type); + } + + seq_printf(f, "\n"); + + return (0); } static int kstat_seq_show_intr(struct seq_file *f, kstat_intr_t *kip) { - seq_printf(f, "%-8u %-8u %-8u %-8u %-8u\n", - kip->intrs[KSTAT_INTR_HARD], - kip->intrs[KSTAT_INTR_SOFT], - kip->intrs[KSTAT_INTR_WATCHDOG], - kip->intrs[KSTAT_INTR_SPURIOUS], - kip->intrs[KSTAT_INTR_MULTSVC]); - - return 0; + seq_printf(f, "%-8u %-8u %-8u %-8u %-8u\n", + kip->intrs[KSTAT_INTR_HARD], + kip->intrs[KSTAT_INTR_SOFT], + kip->intrs[KSTAT_INTR_WATCHDOG], + kip->intrs[KSTAT_INTR_SPURIOUS], + kip->intrs[KSTAT_INTR_MULTSVC]); + + return (0); } static int kstat_seq_show_io(struct seq_file *f, kstat_io_t *kip) { - seq_printf(f, - "%-8llu %-8llu %-8u %-8u %-8lld %-8lld " - "%-8lld %-8lld %-8lld %-8lld %-8u %-8u\n", - kip->nread, kip->nwritten, - kip->reads, kip->writes, - kip->wtime, kip->wlentime, kip->wlastupdate, - kip->rtime, kip->rlentime, kip->rlastupdate, - kip->wcnt, kip->rcnt); - - return 0; + seq_printf(f, + "%-8llu %-8llu %-8u %-8u %-8lld %-8lld " + "%-8lld %-8lld %-8lld %-8lld %-8u %-8u\n", + kip->nread, kip->nwritten, + kip->reads, kip->writes, + kip->wtime, kip->wlentime, kip->wlastupdate, + kip->rtime, kip->rlentime, kip->rlastupdate, + kip->wcnt, kip->rcnt); + + return (0); } static int kstat_seq_show_timer(struct seq_file *f, kstat_timer_t *ktp) { - seq_printf(f, - "%-31s %-8llu %-8lld %-8lld %-8lld %-8lld %-8lld\n", - ktp->name, ktp->num_events, ktp->elapsed_time, - ktp->min_time, ktp->max_time, - ktp->start_time, ktp->stop_time); + seq_printf(f, + "%-31s %-8llu %-8lld %-8lld %-8lld %-8lld %-8lld\n", + ktp->name, ktp->num_events, ktp->elapsed_time, + ktp->min_time, ktp->max_time, + ktp->start_time, ktp->stop_time); - return 0; + return (0); } static int kstat_seq_show(struct seq_file *f, void *p) { - kstat_t *ksp = (kstat_t *)f->private; - int rc = 0; + kstat_t *ksp = (kstat_t *)f->private; + int rc = 0; - ASSERT(ksp->ks_magic == KS_MAGIC); + ASSERT(ksp->ks_magic == KS_MAGIC); switch (ksp->ks_type) { - case KSTAT_TYPE_RAW: + case KSTAT_TYPE_RAW: restart: - if (ksp->ks_raw_ops.data) { - rc = ksp->ks_raw_ops.data( + if (ksp->ks_raw_ops.data) { + rc = ksp->ks_raw_ops.data( ksp->ks_raw_buf, ksp->ks_raw_bufsize, p); if (rc == ENOMEM && !kstat_resize_raw(ksp)) goto restart; if (!rc) - seq_puts(f, ksp->ks_raw_buf); - } else { - ASSERT(ksp->ks_ndata == 1); - rc = kstat_seq_show_raw(f, ksp->ks_data, - ksp->ks_data_size); - } - break; - case KSTAT_TYPE_NAMED: - rc = kstat_seq_show_named(f, (kstat_named_t *)p); - break; - case KSTAT_TYPE_INTR: - rc = kstat_seq_show_intr(f, (kstat_intr_t *)p); - break; - case KSTAT_TYPE_IO: - rc = kstat_seq_show_io(f, (kstat_io_t *)p); - break; - case KSTAT_TYPE_TIMER: - rc = kstat_seq_show_timer(f, (kstat_timer_t *)p); - break; - default: - PANIC("Undefined kstat type %d\n", ksp->ks_type); - } - - return -rc; + seq_puts(f, ksp->ks_raw_buf); + } else { + ASSERT(ksp->ks_ndata == 1); + rc = kstat_seq_show_raw(f, ksp->ks_data, + ksp->ks_data_size); + } + break; + case KSTAT_TYPE_NAMED: + rc = kstat_seq_show_named(f, (kstat_named_t *)p); + break; + case KSTAT_TYPE_INTR: + rc = kstat_seq_show_intr(f, (kstat_intr_t *)p); + break; + case KSTAT_TYPE_IO: + rc = kstat_seq_show_io(f, (kstat_io_t *)p); + break; + case KSTAT_TYPE_TIMER: + rc = kstat_seq_show_timer(f, (kstat_timer_t *)p); + break; + default: + PANIC("Undefined kstat type %d\n", ksp->ks_type); + } + + return (-rc); } int @@ -333,79 +335,79 @@ kstat_default_update(kstat_t *ksp, int rw) if (rw == KSTAT_WRITE) return (EACCES); - return 0; + return (0); } static void * kstat_seq_data_addr(kstat_t *ksp, loff_t n) { - void *rc = NULL; + void *rc = NULL; switch (ksp->ks_type) { - case KSTAT_TYPE_RAW: - if (ksp->ks_raw_ops.addr) - rc = ksp->ks_raw_ops.addr(ksp, n); - else - rc = ksp->ks_data; - break; - case KSTAT_TYPE_NAMED: - rc = ksp->ks_data + n * sizeof(kstat_named_t); - break; - case KSTAT_TYPE_INTR: - rc = ksp->ks_data + n * sizeof(kstat_intr_t); - break; - case KSTAT_TYPE_IO: - rc = ksp->ks_data + n * sizeof(kstat_io_t); - break; - case KSTAT_TYPE_TIMER: - rc = ksp->ks_data + n * sizeof(kstat_timer_t); - break; - default: - PANIC("Undefined kstat type %d\n", ksp->ks_type); - } - - return (rc); + case KSTAT_TYPE_RAW: + if (ksp->ks_raw_ops.addr) + rc = ksp->ks_raw_ops.addr(ksp, n); + else + rc = ksp->ks_data; + break; + case KSTAT_TYPE_NAMED: + rc = ksp->ks_data + n * sizeof (kstat_named_t); + break; + case KSTAT_TYPE_INTR: + rc = ksp->ks_data + n * sizeof (kstat_intr_t); + break; + case KSTAT_TYPE_IO: + rc = ksp->ks_data + n * sizeof (kstat_io_t); + break; + case KSTAT_TYPE_TIMER: + rc = ksp->ks_data + n * sizeof (kstat_timer_t); + break; + default: + PANIC("Undefined kstat type %d\n", ksp->ks_type); + } + + return (rc); } static void * kstat_seq_start(struct seq_file *f, loff_t *pos) { - loff_t n = *pos; - kstat_t *ksp = (kstat_t *)f->private; - ASSERT(ksp->ks_magic == KS_MAGIC); + loff_t n = *pos; + kstat_t *ksp = (kstat_t *)f->private; + ASSERT(ksp->ks_magic == KS_MAGIC); mutex_enter(ksp->ks_lock); - if (ksp->ks_type == KSTAT_TYPE_RAW) { - ksp->ks_raw_bufsize = PAGE_SIZE; - ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP); - } + if (ksp->ks_type == KSTAT_TYPE_RAW) { + ksp->ks_raw_bufsize = PAGE_SIZE; + ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP); + } - /* Dynamically update kstat, on error existing kstats are used */ - (void) ksp->ks_update(ksp, KSTAT_READ); + /* Dynamically update kstat, on error existing kstats are used */ + (void) ksp->ks_update(ksp, KSTAT_READ); ksp->ks_snaptime = gethrtime(); - if (!n && kstat_seq_show_headers(f)) + if (!n && kstat_seq_show_headers(f)) return (NULL); - if (n >= ksp->ks_ndata) - return (NULL); + if (n >= ksp->ks_ndata) + return (NULL); - return (kstat_seq_data_addr(ksp, n)); + return (kstat_seq_data_addr(ksp, n)); } static void * kstat_seq_next(struct seq_file *f, void *p, loff_t *pos) { - kstat_t *ksp = (kstat_t *)f->private; - ASSERT(ksp->ks_magic == KS_MAGIC); + kstat_t *ksp = (kstat_t *)f->private; + ASSERT(ksp->ks_magic == KS_MAGIC); - ++*pos; - if (*pos >= ksp->ks_ndata) - return (NULL); + ++*pos; + if (*pos >= ksp->ks_ndata) + return (NULL); - return (kstat_seq_data_addr(ksp, *pos)); + return (kstat_seq_data_addr(ksp, *pos)); } static void @@ -421,10 +423,10 @@ kstat_seq_stop(struct seq_file *f, void *v) } static struct seq_operations kstat_seq_ops = { - .show = kstat_seq_show, - .start = kstat_seq_start, - .next = kstat_seq_next, - .stop = kstat_seq_stop, + .show = kstat_seq_show, + .start = kstat_seq_start, + .next = kstat_seq_next, + .stop = kstat_seq_stop, }; static kstat_module_t * @@ -465,28 +467,28 @@ kstat_delete_module(kstat_module_t *module) ASSERT(list_empty(&module->ksm_kstat_list)); remove_proc_entry(module->ksm_name, proc_spl_kstat); list_del(&module->ksm_module_list); - kmem_free(module, sizeof(kstat_module_t)); + kmem_free(module, sizeof (kstat_module_t)); } static int proc_kstat_open(struct inode *inode, struct file *filp) { - struct seq_file *f; - int rc; + struct seq_file *f; + int rc; - rc = seq_open(filp, &kstat_seq_ops); - if (rc) - return rc; + rc = seq_open(filp, &kstat_seq_ops); + if (rc) + return (rc); - f = filp->private_data; - f->private = PDE_DATA(inode); + f = filp->private_data; + f->private = PDE_DATA(inode); - return rc; + return (rc); } static ssize_t -proc_kstat_write(struct file *filp, const char __user *buf, - size_t len, loff_t *ppos) +proc_kstat_write(struct file *filp, const char __user *buf, size_t len, + loff_t *ppos) { struct seq_file *f = filp->private_data; kstat_t *ksp = f->private; @@ -527,8 +529,8 @@ EXPORT_SYMBOL(__kstat_set_raw_ops); kstat_t * __kstat_create(const char *ks_module, int ks_instance, const char *ks_name, - const char *ks_class, uchar_t ks_type, uint_t ks_ndata, - uchar_t ks_flags) + const char *ks_class, uchar_t ks_type, uint_t ks_ndata, + uchar_t ks_flags) { kstat_t *ksp; @@ -538,24 +540,24 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name, ASSERT(!(ks_flags & KSTAT_FLAG_UNSUPPORTED)); if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO)) - ASSERT(ks_ndata == 1); + ASSERT(ks_ndata == 1); - ksp = kmem_zalloc(sizeof(*ksp), KM_SLEEP); + ksp = kmem_zalloc(sizeof (*ksp), KM_SLEEP); if (ksp == NULL) - return ksp; + return (ksp); mutex_enter(&kstat_module_lock); ksp->ks_kid = kstat_id; - kstat_id++; + kstat_id++; mutex_exit(&kstat_module_lock); - ksp->ks_magic = KS_MAGIC; + ksp->ks_magic = KS_MAGIC; mutex_init(&ksp->ks_private_lock, NULL, MUTEX_DEFAULT, NULL); ksp->ks_lock = &ksp->ks_private_lock; INIT_LIST_HEAD(&ksp->ks_list); ksp->ks_crtime = gethrtime(); - ksp->ks_snaptime = ksp->ks_crtime; + ksp->ks_snaptime = ksp->ks_crtime; strncpy(ksp->ks_module, ks_module, KSTAT_STRLEN); ksp->ks_instance = ks_instance; strncpy(ksp->ks_name, ks_name, KSTAT_STRLEN); @@ -571,41 +573,41 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name, ksp->ks_raw_bufsize = 0; switch (ksp->ks_type) { - case KSTAT_TYPE_RAW: - ksp->ks_ndata = 1; - ksp->ks_data_size = ks_ndata; - break; - case KSTAT_TYPE_NAMED: - ksp->ks_ndata = ks_ndata; - ksp->ks_data_size = ks_ndata * sizeof(kstat_named_t); - break; - case KSTAT_TYPE_INTR: - ksp->ks_ndata = ks_ndata; - ksp->ks_data_size = ks_ndata * sizeof(kstat_intr_t); - break; - case KSTAT_TYPE_IO: - ksp->ks_ndata = ks_ndata; - ksp->ks_data_size = ks_ndata * sizeof(kstat_io_t); - break; - case KSTAT_TYPE_TIMER: - ksp->ks_ndata = ks_ndata; - ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t); - break; - default: - PANIC("Undefined kstat type %d\n", ksp->ks_type); - } + case KSTAT_TYPE_RAW: + ksp->ks_ndata = 1; + ksp->ks_data_size = ks_ndata; + break; + case KSTAT_TYPE_NAMED: + ksp->ks_ndata = ks_ndata; + ksp->ks_data_size = ks_ndata * sizeof (kstat_named_t); + break; + case KSTAT_TYPE_INTR: + ksp->ks_ndata = ks_ndata; + ksp->ks_data_size = ks_ndata * sizeof (kstat_intr_t); + break; + case KSTAT_TYPE_IO: + ksp->ks_ndata = ks_ndata; + ksp->ks_data_size = ks_ndata * sizeof (kstat_io_t); + break; + case KSTAT_TYPE_TIMER: + ksp->ks_ndata = ks_ndata; + ksp->ks_data_size = ks_ndata * sizeof (kstat_timer_t); + break; + default: + PANIC("Undefined kstat type %d\n", ksp->ks_type); + } if (ksp->ks_flags & KSTAT_FLAG_VIRTUAL) { - ksp->ks_data = NULL; - } else { - ksp->ks_data = kmem_zalloc(ksp->ks_data_size, KM_SLEEP); - if (ksp->ks_data == NULL) { - kmem_free(ksp, sizeof(*ksp)); - ksp = NULL; - } - } - - return ksp; + ksp->ks_data = NULL; + } else { + ksp->ks_data = kmem_zalloc(ksp->ks_data_size, KM_SLEEP); + if (ksp->ks_data == NULL) { + kmem_free(ksp, sizeof (*ksp)); + ksp = NULL; + } + } + + return (ksp); } EXPORT_SYMBOL(__kstat_create); @@ -706,9 +708,7 @@ __kstat_delete(kstat_t *ksp) ksp->ks_lock = NULL; mutex_destroy(&ksp->ks_private_lock); - kmem_free(ksp, sizeof(*ksp)); - - return; + kmem_free(ksp, sizeof (*ksp)); } EXPORT_SYMBOL(__kstat_delete); @@ -717,7 +717,7 @@ spl_kstat_init(void) { mutex_init(&kstat_module_lock, NULL, MUTEX_DEFAULT, NULL); INIT_LIST_HEAD(&kstat_module_list); - kstat_id = 0; + kstat_id = 0; return (0); } @@ -727,4 +727,3 @@ spl_kstat_fini(void) ASSERT(list_empty(&kstat_module_list)); mutex_destroy(&kstat_module_lock); } - diff --git a/module/spl/spl-mutex.c b/module/spl/spl-mutex.c index 9e1e103db..ba818862b 100644 --- a/module/spl/spl-mutex.c +++ b/module/spl/spl-mutex.c @@ -20,17 +20,11 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Mutex Implementation. */ #include <sys/mutex.h> -#ifdef DEBUG_SUBSYSTEM -#undef DEBUG_SUBSYSTEM -#endif - -#define DEBUG_SUBSYSTEM S_MUTEX - int spl_mutex_init(void) { return 0; } void spl_mutex_fini(void) { } diff --git a/module/spl/spl-proc.c b/module/spl/spl-proc.c index 848eebffe..f5998a06e 100644 --- a/module/spl/spl-proc.c +++ b/module/spl/spl-proc.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Proc Implementation. */ @@ -37,7 +37,7 @@ #include <linux/uaccess.h> #include <linux/version.h> -#if defined(CONSTIFY_PLUGIN) && LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0) +#if defined(CONSTIFY_PLUGIN) && LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0) typedef struct ctl_table __no_const spl_ctl_table; #else typedef struct ctl_table spl_ctl_table; @@ -55,56 +55,57 @@ static struct proc_dir_entry *proc_spl_taskq = NULL; struct proc_dir_entry *proc_spl_kstat = NULL; static int -proc_copyin_string(char *kbuffer, int kbuffer_size, - const char *ubuffer, int ubuffer_size) +proc_copyin_string(char *kbuffer, int kbuffer_size, const char *ubuffer, + int ubuffer_size) { - int size; + int size; - if (ubuffer_size > kbuffer_size) - return -EOVERFLOW; + if (ubuffer_size > kbuffer_size) + return (-EOVERFLOW); - if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size)) - return -EFAULT; + if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size)) + return (-EFAULT); - /* strip trailing whitespace */ - size = strnlen(kbuffer, ubuffer_size); - while (size-- >= 0) - if (!isspace(kbuffer[size])) - break; + /* strip trailing whitespace */ + size = strnlen(kbuffer, ubuffer_size); + while (size-- >= 0) + if (!isspace(kbuffer[size])) + break; - /* empty string */ - if (size < 0) - return -EINVAL; + /* empty string */ + if (size < 0) + return (-EINVAL); - /* no space to terminate */ - if (size == kbuffer_size) - return -EOVERFLOW; + /* no space to terminate */ + if (size == kbuffer_size) + return (-EOVERFLOW); - kbuffer[size + 1] = 0; - return 0; + kbuffer[size + 1] = 0; + return (0); } static int proc_copyout_string(char *ubuffer, int ubuffer_size, - const char *kbuffer, char *append) + const char *kbuffer, char *append) { - /* NB if 'append' != NULL, it's a single character to append to the - * copied out string - usually "\n", for /proc entries and - * (i.e. a terminating zero byte) for sysctl entries - */ - int size = MIN(strlen(kbuffer), ubuffer_size); + /* + * NB if 'append' != NULL, it's a single character to append to the + * copied out string - usually "\n", for /proc entries and + * (i.e. a terminating zero byte) for sysctl entries + */ + int size = MIN(strlen(kbuffer), ubuffer_size); - if (copy_to_user(ubuffer, kbuffer, size)) - return -EFAULT; + if (copy_to_user(ubuffer, kbuffer, size)) + return (-EFAULT); - if (append != NULL && size < ubuffer_size) { - if (copy_to_user(ubuffer + size, append, 1)) - return -EFAULT; + if (append != NULL && size < ubuffer_size) { + if (copy_to_user(ubuffer + size, append, 1)) + return (-EFAULT); - size++; - } + size++; + } - return size; + return (size); } #ifdef DEBUG_KMEM @@ -112,27 +113,27 @@ static int proc_domemused(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int rc = 0; - unsigned long min = 0, max = ~0, val; - spl_ctl_table dummy = *table; - - dummy.data = &val; - dummy.proc_handler = &proc_dointvec; - dummy.extra1 = &min; - dummy.extra2 = &max; - - if (write) { - *ppos += *lenp; - } else { -# ifdef HAVE_ATOMIC64_T - val = atomic64_read((atomic64_t *)table->data); -# else - val = atomic_read((atomic_t *)table->data); -# endif /* HAVE_ATOMIC64_T */ - rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos); - } - - return (rc); + int rc = 0; + unsigned long min = 0, max = ~0, val; + spl_ctl_table dummy = *table; + + dummy.data = &val; + dummy.proc_handler = &proc_dointvec; + dummy.extra1 = &min; + dummy.extra2 = &max; + + if (write) { + *ppos += *lenp; + } else { +#ifdef HAVE_ATOMIC64_T + val = atomic64_read((atomic64_t *)table->data); +#else + val = atomic_read((atomic_t *)table->data); +#endif /* HAVE_ATOMIC64_T */ + rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos); + } + + return (rc); } #endif /* DEBUG_KMEM */ @@ -140,23 +141,23 @@ static int proc_doslab(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int rc = 0; - unsigned long min = 0, max = ~0, val = 0, mask; - spl_ctl_table dummy = *table; - spl_kmem_cache_t *skc; + int rc = 0; + unsigned long min = 0, max = ~0, val = 0, mask; + spl_ctl_table dummy = *table; + spl_kmem_cache_t *skc; - dummy.data = &val; - dummy.proc_handler = &proc_dointvec; - dummy.extra1 = &min; - dummy.extra2 = &max; + dummy.data = &val; + dummy.proc_handler = &proc_dointvec; + dummy.extra1 = &min; + dummy.extra2 = &max; - if (write) { - *ppos += *lenp; - } else { - down_read(&spl_kmem_cache_sem); - mask = (unsigned long)table->data; + if (write) { + *ppos += *lenp; + } else { + down_read(&spl_kmem_cache_sem); + mask = (unsigned long)table->data; - list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) { + list_for_each_entry(skc, &spl_kmem_cache_list, skc_list) { /* Only use slabs of the correct kmem/vmem type */ if (!(skc->skc_flags & mask)) @@ -165,58 +166,61 @@ proc_doslab(struct ctl_table *table, int write, /* Sum the specified field for selected slabs */ switch (mask & (KMC_TOTAL | KMC_ALLOC | KMC_MAX)) { case KMC_TOTAL: - val += skc->skc_slab_size * skc->skc_slab_total; + val += skc->skc_slab_size * skc->skc_slab_total; break; case KMC_ALLOC: - val += skc->skc_obj_size * skc->skc_obj_alloc; + val += skc->skc_obj_size * skc->skc_obj_alloc; break; case KMC_MAX: - val += skc->skc_obj_size * skc->skc_obj_max; + val += skc->skc_obj_size * skc->skc_obj_max; break; } - } + } - up_read(&spl_kmem_cache_sem); - rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos); - } + up_read(&spl_kmem_cache_sem); + rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos); + } - return (rc); + return (rc); } static int proc_dohostid(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int len, rc = 0; - char *end, str[32]; - - if (write) { - /* We can't use proc_doulongvec_minmax() in the write - * case here because hostid while a hex value has no - * leading 0x which confuses the helper function. */ - rc = proc_copyin_string(str, sizeof(str), buffer, *lenp); - if (rc < 0) - return (rc); - - spl_hostid = simple_strtoul(str, &end, 16); - if (str == end) - return (-EINVAL); - - } else { - len = snprintf(str, sizeof(str), "%lx", + int len, rc = 0; + char *end, str[32]; + + if (write) { + /* + * We can't use proc_doulongvec_minmax() in the write + * case here because hostid while a hex value has no + * leading 0x which confuses the helper function. + */ + rc = proc_copyin_string(str, sizeof (str), buffer, *lenp); + if (rc < 0) + return (rc); + + spl_hostid = simple_strtoul(str, &end, 16); + if (str == end) + return (-EINVAL); + + } else { + len = snprintf(str, sizeof (str), "%lx", (unsigned long) zone_get_hostid(NULL)); - if (*ppos >= len) - rc = 0; - else - rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n"); - - if (rc >= 0) { - *lenp = rc; - *ppos += rc; - } - } - - return (rc); + if (*ppos >= len) + rc = 0; + else + rc = proc_copyout_string(buffer, + *lenp, str + *ppos, "\n"); + + if (rc >= 0) { + *lenp = rc; + *ppos += rc; + } + } + + return (rc); } static void @@ -229,11 +233,11 @@ taskq_seq_show_headers(struct seq_file *f) /* indices into the lheads array below */ #define LHEAD_PEND 0 -#define LHEAD_PRIO 1 -#define LHEAD_DELAY 2 -#define LHEAD_WAIT 3 -#define LHEAD_ACTIVE 4 -#define LHEAD_SIZE 5 +#define LHEAD_PRIO 1 +#define LHEAD_DELAY 2 +#define LHEAD_WAIT 3 +#define LHEAD_ACTIVE 4 +#define LHEAD_SIZE 5 static unsigned int spl_max_show_tasks = 512; module_param(spl_max_show_tasks, uint, 0644); @@ -287,7 +291,7 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag) spin_unlock_irqrestore(&tq->tq_wait_waitq.lock, wflags); /* show the base taskq contents */ - snprintf(name, sizeof(name), "%s/%d", tq->tq_name, tq->tq_instance); + snprintf(name, sizeof (name), "%s/%d", tq->tq_name, tq->tq_instance); seq_printf(f, "%-25s ", name); seq_printf(f, "%5d %5d %5d %5d %5d %5d %12d %5d %10x\n", tq->tq_nactive, tq->tq_nthreads, tq->tq_nspawn, @@ -299,7 +303,8 @@ taskq_seq_show_impl(struct seq_file *f, void *p, boolean_t allflag) j = 0; list_for_each_entry(tqt, &tq->tq_active_list, tqt_active_list) { if (j == 0) - seq_printf(f, "\t%s:", list_names[LHEAD_ACTIVE]); + seq_printf(f, "\t%s:", + list_names[LHEAD_ACTIVE]); else if (j == 2) { seq_printf(f, "\n\t "); j = 0; @@ -403,32 +408,32 @@ taskq_seq_next(struct seq_file *f, void *p, loff_t *pos) ++*pos; return ((tq->tq_taskqs.next == &tq_list) ? - NULL : list_entry(tq->tq_taskqs.next, taskq_t, tq_taskqs)); + NULL : list_entry(tq->tq_taskqs.next, taskq_t, tq_taskqs)); } static void slab_seq_show_headers(struct seq_file *f) { - seq_printf(f, - "--------------------- cache ----------" - "--------------------------------------------- " - "----- slab ------ " - "---- object ----- " - "--- emergency ---\n"); - seq_printf(f, - "name " - " flags size alloc slabsize objsize " - "total alloc max " - "total alloc max " - "dlock alloc max\n"); + seq_printf(f, + "--------------------- cache ----------" + "--------------------------------------------- " + "----- slab ------ " + "---- object ----- " + "--- emergency ---\n"); + seq_printf(f, + "name " + " flags size alloc slabsize objsize " + "total alloc max " + "total alloc max " + "dlock alloc max\n"); } static int slab_seq_show(struct seq_file *f, void *p) { - spl_kmem_cache_t *skc = p; + spl_kmem_cache_t *skc = p; - ASSERT(skc->skc_magic == SKC_MAGIC); + ASSERT(skc->skc_magic == SKC_MAGIC); /* * Backed by Linux slab see /proc/slabinfo. @@ -436,48 +441,48 @@ slab_seq_show(struct seq_file *f, void *p) if (skc->skc_flags & KMC_SLAB) return (0); - spin_lock(&skc->skc_lock); - seq_printf(f, "%-36s ", skc->skc_name); - seq_printf(f, "0x%05lx %9lu %9lu %8u %8u " - "%5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n", - (long unsigned)skc->skc_flags, - (long unsigned)(skc->skc_slab_size * skc->skc_slab_total), - (long unsigned)(skc->skc_obj_size * skc->skc_obj_alloc), - (unsigned)skc->skc_slab_size, - (unsigned)skc->skc_obj_size, - (long unsigned)skc->skc_slab_total, - (long unsigned)skc->skc_slab_alloc, - (long unsigned)skc->skc_slab_max, - (long unsigned)skc->skc_obj_total, - (long unsigned)skc->skc_obj_alloc, - (long unsigned)skc->skc_obj_max, - (long unsigned)skc->skc_obj_deadlock, - (long unsigned)skc->skc_obj_emergency, - (long unsigned)skc->skc_obj_emergency_max); - - spin_unlock(&skc->skc_lock); - - return 0; + spin_lock(&skc->skc_lock); + seq_printf(f, "%-36s ", skc->skc_name); + seq_printf(f, "0x%05lx %9lu %9lu %8u %8u " + "%5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu %5lu\n", + (long unsigned)skc->skc_flags, + (long unsigned)(skc->skc_slab_size * skc->skc_slab_total), + (long unsigned)(skc->skc_obj_size * skc->skc_obj_alloc), + (unsigned)skc->skc_slab_size, + (unsigned)skc->skc_obj_size, + (long unsigned)skc->skc_slab_total, + (long unsigned)skc->skc_slab_alloc, + (long unsigned)skc->skc_slab_max, + (long unsigned)skc->skc_obj_total, + (long unsigned)skc->skc_obj_alloc, + (long unsigned)skc->skc_obj_max, + (long unsigned)skc->skc_obj_deadlock, + (long unsigned)skc->skc_obj_emergency, + (long unsigned)skc->skc_obj_emergency_max); + + spin_unlock(&skc->skc_lock); + + return (0); } static void * slab_seq_start(struct seq_file *f, loff_t *pos) { - struct list_head *p; - loff_t n = *pos; + struct list_head *p; + loff_t n = *pos; down_read(&spl_kmem_cache_sem); - if (!n) - slab_seq_show_headers(f); + if (!n) + slab_seq_show_headers(f); - p = spl_kmem_cache_list.next; - while (n--) { - p = p->next; - if (p == &spl_kmem_cache_list) - return (NULL); - } + p = spl_kmem_cache_list.next; + while (n--) { + p = p->next; + if (p == &spl_kmem_cache_list) + return (NULL); + } - return (list_entry(p, spl_kmem_cache_t, skc_list)); + return (list_entry(p, spl_kmem_cache_t, skc_list)); } static void * @@ -485,9 +490,9 @@ slab_seq_next(struct seq_file *f, void *p, loff_t *pos) { spl_kmem_cache_t *skc = p; - ++*pos; - return ((skc->skc_list.next == &spl_kmem_cache_list) ? - NULL : list_entry(skc->skc_list.next,spl_kmem_cache_t,skc_list)); + ++*pos; + return ((skc->skc_list.next == &spl_kmem_cache_list) ? + NULL : list_entry(skc->skc_list.next, spl_kmem_cache_t, skc_list)); } static void @@ -497,23 +502,23 @@ slab_seq_stop(struct seq_file *f, void *v) } static struct seq_operations slab_seq_ops = { - .show = slab_seq_show, - .start = slab_seq_start, - .next = slab_seq_next, - .stop = slab_seq_stop, + .show = slab_seq_show, + .start = slab_seq_start, + .next = slab_seq_next, + .stop = slab_seq_stop, }; static int proc_slab_open(struct inode *inode, struct file *filp) { - return seq_open(filp, &slab_seq_ops); + return (seq_open(filp, &slab_seq_ops)); } static struct file_operations proc_slab_operations = { - .open = proc_slab_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, + .open = proc_slab_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static void @@ -523,122 +528,122 @@ taskq_seq_stop(struct seq_file *f, void *v) } static struct seq_operations taskq_all_seq_ops = { - .show = taskq_all_seq_show, - .start = taskq_seq_start, - .next = taskq_seq_next, - .stop = taskq_seq_stop, + .show = taskq_all_seq_show, + .start = taskq_seq_start, + .next = taskq_seq_next, + .stop = taskq_seq_stop, }; static struct seq_operations taskq_seq_ops = { - .show = taskq_seq_show, - .start = taskq_seq_start, - .next = taskq_seq_next, - .stop = taskq_seq_stop, + .show = taskq_seq_show, + .start = taskq_seq_start, + .next = taskq_seq_next, + .stop = taskq_seq_stop, }; static int proc_taskq_all_open(struct inode *inode, struct file *filp) { - return seq_open(filp, &taskq_all_seq_ops); + return (seq_open(filp, &taskq_all_seq_ops)); } static int proc_taskq_open(struct inode *inode, struct file *filp) { - return seq_open(filp, &taskq_seq_ops); + return (seq_open(filp, &taskq_seq_ops)); } static struct file_operations proc_taskq_all_operations = { - .open = proc_taskq_all_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, + .open = proc_taskq_all_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static struct file_operations proc_taskq_operations = { - .open = proc_taskq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = seq_release, + .open = proc_taskq_open, + .read = seq_read, + .llseek = seq_lseek, + .release = seq_release, }; static struct ctl_table spl_kmem_table[] = { #ifdef DEBUG_KMEM - { - .procname = "kmem_used", - .data = &kmem_alloc_used, -# ifdef HAVE_ATOMIC64_T - .maxlen = sizeof(atomic64_t), -# else - .maxlen = sizeof(atomic_t), -# endif /* HAVE_ATOMIC64_T */ - .mode = 0444, - .proc_handler = &proc_domemused, - }, - { - .procname = "kmem_max", - .data = &kmem_alloc_max, - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doulongvec_minmax, - }, + { + .procname = "kmem_used", + .data = &kmem_alloc_used, +#ifdef HAVE_ATOMIC64_T + .maxlen = sizeof (atomic64_t), +#else + .maxlen = sizeof (atomic_t), +#endif /* HAVE_ATOMIC64_T */ + .mode = 0444, + .proc_handler = &proc_domemused, + }, + { + .procname = "kmem_max", + .data = &kmem_alloc_max, + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doulongvec_minmax, + }, #endif /* DEBUG_KMEM */ - { - .procname = "slab_kmem_total", - .data = (void *)(KMC_KMEM | KMC_TOTAL), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, - { - .procname = "slab_kmem_alloc", - .data = (void *)(KMC_KMEM | KMC_ALLOC), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, - { - .procname = "slab_kmem_max", - .data = (void *)(KMC_KMEM | KMC_MAX), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, - { - .procname = "slab_vmem_total", - .data = (void *)(KMC_VMEM | KMC_TOTAL), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, - { - .procname = "slab_vmem_alloc", - .data = (void *)(KMC_VMEM | KMC_ALLOC), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, - { - .procname = "slab_vmem_max", - .data = (void *)(KMC_VMEM | KMC_MAX), - .maxlen = sizeof(unsigned long), - .extra1 = &table_min, - .extra2 = &table_max, - .mode = 0444, - .proc_handler = &proc_doslab, - }, + { + .procname = "slab_kmem_total", + .data = (void *)(KMC_KMEM | KMC_TOTAL), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, + { + .procname = "slab_kmem_alloc", + .data = (void *)(KMC_KMEM | KMC_ALLOC), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, + { + .procname = "slab_kmem_max", + .data = (void *)(KMC_KMEM | KMC_MAX), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, + { + .procname = "slab_vmem_total", + .data = (void *)(KMC_VMEM | KMC_TOTAL), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, + { + .procname = "slab_vmem_alloc", + .data = (void *)(KMC_VMEM | KMC_ALLOC), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, + { + .procname = "slab_vmem_max", + .data = (void *)(KMC_VMEM | KMC_MAX), + .maxlen = sizeof (unsigned long), + .extra1 = &table_min, + .extra2 = &table_max, + .mode = 0444, + .proc_handler = &proc_doslab, + }, {}, }; @@ -647,43 +652,44 @@ static struct ctl_table spl_kstat_table[] = { }; static struct ctl_table spl_table[] = { - /* NB No .strategy entries have been provided since - * sysctl(8) prefers to go via /proc for portability. - */ - { - .procname = "version", - .data = spl_version, - .maxlen = sizeof(spl_version), - .mode = 0444, - .proc_handler = &proc_dostring, - }, - { - .procname = "hostid", - .data = &spl_hostid, - .maxlen = sizeof(unsigned long), - .mode = 0644, - .proc_handler = &proc_dohostid, - }, + /* + * NB No .strategy entries have been provided since + * sysctl(8) prefers to go via /proc for portability. + */ + { + .procname = "version", + .data = spl_version, + .maxlen = sizeof (spl_version), + .mode = 0444, + .proc_handler = &proc_dostring, + }, + { + .procname = "hostid", + .data = &spl_hostid, + .maxlen = sizeof (unsigned long), + .mode = 0644, + .proc_handler = &proc_dohostid, + }, { - .procname = "kmem", - .mode = 0555, - .child = spl_kmem_table, + .procname = "kmem", + .mode = 0555, + .child = spl_kmem_table, }, { - .procname = "kstat", - .mode = 0555, - .child = spl_kstat_table, + .procname = "kstat", + .mode = 0555, + .child = spl_kstat_table, }, - {}, + {}, }; static struct ctl_table spl_dir[] = { - { - .procname = "spl", - .mode = 0555, - .child = spl_table, - }, - {} + { + .procname = "spl", + .mode = 0555, + .child = spl_table, + }, + {} }; static struct ctl_table spl_root[] = { @@ -703,7 +709,7 @@ spl_proc_init(void) { int rc = 0; - spl_header = register_sysctl_table(spl_root); + spl_header = register_sysctl_table(spl_root); if (spl_header == NULL) return (-EUNATCH); @@ -727,48 +733,48 @@ spl_proc_init(void) goto out; } - proc_spl_kmem = proc_mkdir("kmem", proc_spl); - if (proc_spl_kmem == NULL) { - rc = -EUNATCH; + proc_spl_kmem = proc_mkdir("kmem", proc_spl); + if (proc_spl_kmem == NULL) { + rc = -EUNATCH; goto out; } proc_spl_kmem_slab = proc_create_data("slab", 0444, proc_spl_kmem, &proc_slab_operations, NULL); - if (proc_spl_kmem_slab == NULL) { + if (proc_spl_kmem_slab == NULL) { rc = -EUNATCH; goto out; } - proc_spl_kstat = proc_mkdir("kstat", proc_spl); - if (proc_spl_kstat == NULL) { - rc = -EUNATCH; + proc_spl_kstat = proc_mkdir("kstat", proc_spl); + if (proc_spl_kstat == NULL) { + rc = -EUNATCH; goto out; } out: if (rc) { remove_proc_entry("kstat", proc_spl); - remove_proc_entry("slab", proc_spl_kmem); + remove_proc_entry("slab", proc_spl_kmem); remove_proc_entry("kmem", proc_spl); remove_proc_entry("taskq-all", proc_spl); remove_proc_entry("taskq", proc_spl); remove_proc_entry("spl", NULL); - unregister_sysctl_table(spl_header); + unregister_sysctl_table(spl_header); } - return (rc); + return (rc); } void spl_proc_fini(void) { remove_proc_entry("kstat", proc_spl); - remove_proc_entry("slab", proc_spl_kmem); + remove_proc_entry("slab", proc_spl_kmem); remove_proc_entry("kmem", proc_spl); remove_proc_entry("taskq-all", proc_spl); remove_proc_entry("taskq", proc_spl); remove_proc_entry("spl", NULL); - ASSERT(spl_header != NULL); - unregister_sysctl_table(spl_header); + ASSERT(spl_header != NULL); + unregister_sysctl_table(spl_header); } diff --git a/module/spl/spl-rwlock.c b/module/spl/spl-rwlock.c index e497775e6..9a992cc3a 100644 --- a/module/spl/spl-rwlock.c +++ b/module/spl/spl-rwlock.c @@ -20,18 +20,12 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Reader/Writer Lock Implementation. */ #include <sys/rwlock.h> -#ifdef DEBUG_SUBSYSTEM -#undef DEBUG_SUBSYSTEM -#endif - -#define DEBUG_SUBSYSTEM S_RWLOCK - #if defined(CONFIG_PREEMPT_RT_FULL) #include <linux/rtmutex.h> @@ -94,7 +88,7 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem) static int __rwsem_tryupgrade(struct rw_semaphore *rwsem) { - typeof (rwsem->count) val; + typeof(rwsem->count) val; val = cmpxchg(&rwsem->count, SPL_RWSEM_SINGLE_READER_VALUE, SPL_RWSEM_SINGLE_WRITER_VALUE); return (val == SPL_RWSEM_SINGLE_READER_VALUE); diff --git a/module/spl/spl-taskq.c b/module/spl/spl-taskq.c index ae26bdb2e..2919a942a 100644 --- a/module/spl/spl-taskq.c +++ b/module/spl/spl-taskq.c @@ -87,7 +87,7 @@ taskq_find_by_name(const char *name) list_for_each_prev(tql, &tq_list) { tq = list_entry(tql, taskq_t, tq_taskqs); if (strcmp(name, tq->tq_name) == 0) - return tq->tq_instance; + return (tq->tq_instance); } return (-1); } @@ -573,7 +573,8 @@ taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags) ASSERT(tq->tq_nactive <= tq->tq_nthreads); if ((flags & TQ_NOQUEUE) && (tq->tq_nactive == tq->tq_nthreads)) { /* Dynamic taskq may be able to spawn another thread */ - if (!(tq->tq_flags & TASKQ_DYNAMIC) || taskq_thread_spawn(tq) == 0) + if (!(tq->tq_flags & TASKQ_DYNAMIC) || + taskq_thread_spawn(tq) == 0) goto out; } @@ -686,7 +687,8 @@ taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint_t flags, if ((flags & TQ_NOQUEUE) && (tq->tq_nactive == tq->tq_nthreads)) { /* Dynamic taskq may be able to spawn another thread */ - if (!(tq->tq_flags & TASKQ_DYNAMIC) || taskq_thread_spawn(tq) == 0) + if (!(tq->tq_flags & TASKQ_DYNAMIC) || + taskq_thread_spawn(tq) == 0) goto out2; flags |= TQ_FRONT; } @@ -786,7 +788,8 @@ taskq_thread_spawn_task(void *arg) if (taskq_thread_create(tq) == NULL) { /* restore spawning count if failed */ - spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class); + spin_lock_irqsave_nested(&tq->tq_lock, flags, + tq->tq_lock_class); tq->tq_nspawn--; spin_unlock_irqrestore(&tq->tq_lock, flags); } @@ -1146,7 +1149,8 @@ taskq_destroy(taskq_t *tq) while (tq->tq_nspawn) { spin_unlock_irqrestore(&tq->tq_lock, flags); schedule_timeout_interruptible(1); - spin_lock_irqsave_nested(&tq->tq_lock, flags, tq->tq_lock_class); + spin_lock_irqsave_nested(&tq->tq_lock, flags, + tq->tq_lock_class); } /* @@ -1239,16 +1243,16 @@ param_set_taskq_kick(const char *val, struct kernel_param *kp) #ifdef module_param_cb static const struct kernel_param_ops param_ops_taskq_kick = { - .set = param_set_taskq_kick, - .get = param_get_uint, + .set = param_set_taskq_kick, + .get = param_get_uint, }; module_param_cb(spl_taskq_kick, ¶m_ops_taskq_kick, &spl_taskq_kick, 0644); #else module_param_call(spl_taskq_kick, param_set_taskq_kick, param_get_uint, - &spl_taskq_kick, 0644); + &spl_taskq_kick, 0644); #endif MODULE_PARM_DESC(spl_taskq_kick, - "Write nonzero to kick stuck taskqs to spawn more threads"); + "Write nonzero to kick stuck taskqs to spawn more threads"); int spl_taskq_init(void) diff --git a/module/spl/spl-thread.c b/module/spl/spl-thread.c index 92eba42ba..9ad044161 100644 --- a/module/spl/spl-thread.c +++ b/module/spl/spl-thread.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Thread Implementation. */ @@ -33,8 +33,8 @@ */ typedef struct thread_priv_s { unsigned long tp_magic; /* Magic */ - int tp_name_size; /* Name size */ - char *tp_name; /* Name (without _thread suffix) */ + int tp_name_size; /* Name size */ + char *tp_name; /* Name (without _thread suffix) */ void (*tp_func)(void *); /* Registered function */ void *tp_args; /* Args to be passed to function */ size_t tp_len; /* Len to be passed to function */ @@ -55,12 +55,12 @@ thread_generic_wrapper(void *arg) set_current_state(tp->tp_state); set_user_nice((kthread_t *)current, PRIO_TO_NICE(tp->tp_pri)); kmem_free(tp->tp_name, tp->tp_name_size); - kmem_free(tp, sizeof(thread_priv_t)); + kmem_free(tp, sizeof (thread_priv_t)); if (func) func(args); - return 0; + return (0); } void @@ -72,9 +72,11 @@ __thread_exit(void) } EXPORT_SYMBOL(__thread_exit); -/* thread_create() may block forever if it cannot create a thread or +/* + * thread_create() may block forever if it cannot create a thread or * allocate memory. This is preferable to returning a NULL which Solaris - * style callers likely never check for... since it can't fail. */ + * style callers likely never check for... since it can't fail. + */ kthread_t * __thread_create(caddr_t stk, size_t stksize, thread_func_t func, const char *name, void *args, size_t len, proc_t *pp, @@ -88,7 +90,7 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func, /* Variable stack size unsupported */ ASSERT(stk == NULL); - tp = kmem_alloc(sizeof(thread_priv_t), KM_PUSHPAGE); + tp = kmem_alloc(sizeof (thread_priv_t), KM_PUSHPAGE); if (tp == NULL) return (NULL); @@ -96,14 +98,15 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func, tp->tp_name_size = strlen(name) + 1; tp->tp_name = kmem_alloc(tp->tp_name_size, KM_PUSHPAGE); - if (tp->tp_name == NULL) { - kmem_free(tp, sizeof(thread_priv_t)); + if (tp->tp_name == NULL) { + kmem_free(tp, sizeof (thread_priv_t)); return (NULL); } strncpy(tp->tp_name, name, tp->tp_name_size); - /* Strip trailing "_thread" from passed name which will be the func + /* + * Strip trailing "_thread" from passed name which will be the func * name since the exposed API has no parameter for passing a name. */ p = strstr(tp->tp_name, "_thread"); @@ -117,7 +120,7 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func, tp->tp_pri = pri; tsk = spl_kthread_create(thread_generic_wrapper, (void *)tp, - "%s", tp->tp_name); + "%s", tp->tp_name); if (IS_ERR(tsk)) return (NULL); @@ -139,7 +142,7 @@ spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...) char name[TASK_COMM_LEN]; va_start(args, namefmt); - vsnprintf(name, sizeof(name), namefmt, args); + vsnprintf(name, sizeof (name), namefmt, args); va_end(args); do { tsk = kthread_create(func, data, "%s", name); diff --git a/module/spl/spl-vnode.c b/module/spl/spl-vnode.c index 19b3b76cd..f019a0877 100644 --- a/module/spl/spl-vnode.c +++ b/module/spl/spl-vnode.c @@ -20,7 +20,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) Vnode Implementation. */ @@ -43,27 +43,27 @@ vtype_t vn_mode_to_vtype(mode_t mode) { if (S_ISREG(mode)) - return VREG; + return (VREG); if (S_ISDIR(mode)) - return VDIR; + return (VDIR); if (S_ISCHR(mode)) - return VCHR; + return (VCHR); if (S_ISBLK(mode)) - return VBLK; + return (VBLK); if (S_ISFIFO(mode)) - return VFIFO; + return (VFIFO); if (S_ISLNK(mode)) - return VLNK; + return (VLNK); if (S_ISSOCK(mode)) - return VSOCK; + return (VSOCK); - return VNON; + return (VNON); } /* vn_mode_to_vtype() */ EXPORT_SYMBOL(vn_mode_to_vtype); @@ -71,27 +71,27 @@ mode_t vn_vtype_to_mode(vtype_t vtype) { if (vtype == VREG) - return S_IFREG; + return (S_IFREG); if (vtype == VDIR) - return S_IFDIR; + return (S_IFDIR); if (vtype == VCHR) - return S_IFCHR; + return (S_IFCHR); if (vtype == VBLK) - return S_IFBLK; + return (S_IFBLK); if (vtype == VFIFO) - return S_IFIFO; + return (S_IFIFO); if (vtype == VLNK) - return S_IFLNK; + return (S_IFLNK); if (vtype == VSOCK) - return S_IFSOCK; + return (S_IFSOCK); - return VNON; + return (VNON); } /* vn_vtype_to_mode() */ EXPORT_SYMBOL(vn_vtype_to_mode); @@ -135,7 +135,8 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode, if (!(flags & FCREAT) && (flags & FWRITE)) flags |= FEXCL; - /* Note for filp_open() the two low bits must be remapped to mean: + /* + * Note for filp_open() the two low bits must be remapped to mean: * 01 - read-only -> 00 read-only * 10 - write-only -> 01 write-only * 11 - read-write -> 10 read-write @@ -148,7 +149,7 @@ vn_open(const char *path, uio_seg_t seg, int flags, int mode, fp = filp_open(path, flags, mode); if (flags & FCREAT) - (void)xchg(¤t->fs->umask, saved_umask); + (void) xchg(¤t->fs->umask, saved_umask); if (IS_ERR(fp)) return (-PTR_ERR(fp)); @@ -187,7 +188,7 @@ EXPORT_SYMBOL(vn_open); int vn_openat(const char *path, uio_seg_t seg, int flags, int mode, - vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd) + vnode_t **vpp, int x1, void *x2, vnode_t *vp, int fd) { char *realpath; int len, rc; @@ -199,7 +200,7 @@ vn_openat(const char *path, uio_seg_t seg, int flags, int mode, if (!realpath) return (ENOMEM); - (void)snprintf(realpath, len, "/%s", path); + (void) snprintf(realpath, len, "/%s", path); rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2); kfree(realpath); @@ -259,9 +260,11 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4) } /* vn_close() */ EXPORT_SYMBOL(vn_close); -/* vn_seek() does not actually seek it only performs bounds checking on the +/* + * vn_seek() does not actually seek it only performs bounds checking on the * proposed seek. We perform minimal checking and allow vn_rdwr() to catch - * anything more serious. */ + * anything more serious. + */ int vn_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, void *ct) { @@ -293,26 +296,27 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4) if (rc) return (-rc); - vap->va_type = vn_mode_to_vtype(stat.mode); - vap->va_mode = stat.mode; - vap->va_uid = KUID_TO_SUID(stat.uid); - vap->va_gid = KGID_TO_SGID(stat.gid); - vap->va_fsid = 0; - vap->va_nodeid = stat.ino; - vap->va_nlink = stat.nlink; - vap->va_size = stat.size; - vap->va_blksize = stat.blksize; - vap->va_atime = stat.atime; - vap->va_mtime = stat.mtime; - vap->va_ctime = stat.ctime; - vap->va_rdev = stat.rdev; - vap->va_nblocks = stat.blocks; + vap->va_type = vn_mode_to_vtype(stat.mode); + vap->va_mode = stat.mode; + vap->va_uid = KUID_TO_SUID(stat.uid); + vap->va_gid = KGID_TO_SGID(stat.gid); + vap->va_fsid = 0; + vap->va_nodeid = stat.ino; + vap->va_nlink = stat.nlink; + vap->va_size = stat.size; + vap->va_blksize = stat.blksize; + vap->va_atime = stat.atime; + vap->va_mtime = stat.mtime; + vap->va_ctime = stat.ctime; + vap->va_rdev = stat.rdev; + vap->va_nblocks = stat.blocks; return (0); } EXPORT_SYMBOL(vn_getattr); -int vn_fsync(vnode_t *vp, int flags, void *x3, void *x4) +int +vn_fsync(vnode_t *vp, int flags, void *x3, void *x4) { int datasync = 0; int error; @@ -412,22 +416,22 @@ EXPORT_SYMBOL(vn_space); static file_t * file_find(int fd, struct task_struct *task) { - file_t *fp; + file_t *fp; - list_for_each_entry(fp, &vn_file_list, f_list) { + list_for_each_entry(fp, &vn_file_list, f_list) { if (fd == fp->f_fd && fp->f_task == task) { ASSERT(atomic_read(&fp->f_ref) != 0); - return fp; + return (fp); } } - return NULL; + return (NULL); } /* file_find() */ file_t * vn_getf(int fd) { - struct kstat stat; + struct kstat stat; struct file *lfp; file_t *fp; vnode_t *vp; @@ -482,13 +486,14 @@ vn_getf(int fd) goto out_fget; #if defined(HAVE_4ARGS_VFS_GETATTR) - rc = vfs_getattr(&lfp->f_path, &stat, STATX_TYPE, AT_STATX_SYNC_AS_STAT); + rc = vfs_getattr(&lfp->f_path, &stat, STATX_TYPE, + AT_STATX_SYNC_AS_STAT); #elif defined(HAVE_2ARGS_VFS_GETATTR) rc = vfs_getattr(&lfp->f_path, &stat); #else rc = vfs_getattr(lfp->f_path.mnt, lfp->f_dentry, &stat); #endif - if (rc) + if (rc) goto out_vnode; mutex_enter(&vp->v_lock); @@ -515,7 +520,7 @@ out_mutex: mutex_exit(&fp->f_lock); kmem_cache_free(vn_file_cache, fp); out: - return (NULL); + return (NULL); } /* getf() */ EXPORT_SYMBOL(getf); @@ -556,12 +561,10 @@ vn_areleasef(int fd, uf_info_t *fip) return; } - list_del(&fp->f_list); + list_del(&fp->f_list); releasef_locked(fp); } spin_unlock(&vn_file_lock); - - return; } /* releasef() */ EXPORT_SYMBOL(areleasef); @@ -596,34 +599,34 @@ vn_set_fs_pwd(struct fs_struct *fs, struct path *path) int vn_set_pwd(const char *filename) { - struct path path; - mm_segment_t saved_fs; - int rc; - - /* - * user_path_dir() and __user_walk() both expect 'filename' to be - * a user space address so we must briefly increase the data segment - * size to ensure strncpy_from_user() does not fail with -EFAULT. - */ - saved_fs = get_fs(); - set_fs(get_ds()); - - rc = user_path_dir(filename, &path); - if (rc) + struct path path; + mm_segment_t saved_fs; + int rc; + + /* + * user_path_dir() and __user_walk() both expect 'filename' to be + * a user space address so we must briefly increase the data segment + * size to ensure strncpy_from_user() does not fail with -EFAULT. + */ + saved_fs = get_fs(); + set_fs(get_ds()); + + rc = user_path_dir(filename, &path); + if (rc) goto out; - rc = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS); - if (rc) + rc = inode_permission(path.dentry->d_inode, MAY_EXEC | MAY_ACCESS); + if (rc) goto dput_and_out; - vn_set_fs_pwd(current->fs, &path); + vn_set_fs_pwd(current->fs, &path); dput_and_out: - path_put(&path); + path_put(&path); out: set_fs(saved_fs); - return (-rc); + return (-rc); } /* vn_set_pwd() */ EXPORT_SYMBOL(vn_set_pwd); @@ -651,10 +654,10 @@ vn_file_cache_constructor(void *buf, void *cdrarg, int kmflags) file_t *fp = buf; atomic_set(&fp->f_ref, 0); - mutex_init(&fp->f_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&fp->f_lock, NULL, MUTEX_DEFAULT, NULL); INIT_LIST_HEAD(&fp->f_list); - return (0); + return (0); } /* file_cache_constructor() */ static void @@ -669,29 +672,26 @@ int spl_vn_init(void) { vn_cache = kmem_cache_create("spl_vn_cache", - sizeof(struct vnode), 64, - vn_cache_constructor, - vn_cache_destructor, - NULL, NULL, NULL, 0); + sizeof (struct vnode), 64, vn_cache_constructor, + vn_cache_destructor, NULL, NULL, NULL, 0); vn_file_cache = kmem_cache_create("spl_vn_file_cache", - sizeof(file_t), 64, - vn_file_cache_constructor, - vn_file_cache_destructor, - NULL, NULL, NULL, 0); + sizeof (file_t), 64, vn_file_cache_constructor, + vn_file_cache_destructor, NULL, NULL, NULL, 0); + return (0); } /* vn_init() */ void spl_vn_fini(void) { - file_t *fp, *next_fp; + file_t *fp, *next_fp; int leaked = 0; spin_lock(&vn_file_lock); - list_for_each_entry_safe(fp, next_fp, &vn_file_list, f_list) { - list_del(&fp->f_list); + list_for_each_entry_safe(fp, next_fp, &vn_file_list, f_list) { + list_del(&fp->f_list); releasef_locked(fp); leaked++; } @@ -703,6 +703,4 @@ spl_vn_fini(void) kmem_cache_destroy(vn_file_cache); kmem_cache_destroy(vn_cache); - - return; } /* vn_fini() */ diff --git a/module/spl/spl-xdr.c b/module/spl/spl-xdr.c index 04a337c2b..c582913f1 100644 --- a/module/spl/spl-xdr.c +++ b/module/spl/spl-xdr.c @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * * Solaris Porting Layer (SPL) XDR Implementation. */ @@ -163,12 +163,12 @@ xdrmem_control(XDR *xdrs, int req, void *info) struct xdr_bytesrec *rec = (struct xdr_bytesrec *) info; if (req != XDR_GET_BYTES_AVAIL) - return FALSE; + return (FALSE); rec->xc_is_last_record = TRUE; /* always TRUE in xdrmem streams */ rec->xc_num_avail = xdrs->x_addr_end - xdrs->x_addr; - return TRUE; + return (TRUE); } static bool_t @@ -178,13 +178,13 @@ xdrmem_enc_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt) uint_t pad; if (size < cnt) - return FALSE; /* Integer overflow */ + return (FALSE); /* Integer overflow */ if (xdrs->x_addr > xdrs->x_addr_end) - return FALSE; + return (FALSE); if (xdrs->x_addr_end - xdrs->x_addr < size) - return FALSE; + return (FALSE); memcpy(xdrs->x_addr, cp, cnt); @@ -196,7 +196,7 @@ xdrmem_enc_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt) xdrs->x_addr += pad; } - return TRUE; + return (TRUE); } static bool_t @@ -207,13 +207,13 @@ xdrmem_dec_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt) uint_t pad; if (size < cnt) - return FALSE; /* Integer overflow */ + return (FALSE); /* Integer overflow */ if (xdrs->x_addr > xdrs->x_addr_end) - return FALSE; + return (FALSE); if (xdrs->x_addr_end - xdrs->x_addr < size) - return FALSE; + return (FALSE); memcpy(cp, xdrs->x_addr, cnt); xdrs->x_addr += cnt; @@ -222,38 +222,38 @@ xdrmem_dec_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt) if (pad > 0) { /* An inverted memchr() would be useful here... */ if (memcmp(&zero, xdrs->x_addr, pad) != 0) - return FALSE; + return (FALSE); xdrs->x_addr += pad; } - return TRUE; + return (TRUE); } static bool_t xdrmem_enc_uint32(XDR *xdrs, uint32_t val) { - if (xdrs->x_addr + sizeof(uint32_t) > xdrs->x_addr_end) - return FALSE; + if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end) + return (FALSE); *((uint32_t *) xdrs->x_addr) = cpu_to_be32(val); - xdrs->x_addr += sizeof(uint32_t); + xdrs->x_addr += sizeof (uint32_t); - return TRUE; + return (TRUE); } static bool_t xdrmem_dec_uint32(XDR *xdrs, uint32_t *val) { - if (xdrs->x_addr + sizeof(uint32_t) > xdrs->x_addr_end) - return FALSE; + if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end) + return (FALSE); *val = be32_to_cpu(*((uint32_t *) xdrs->x_addr)); - xdrs->x_addr += sizeof(uint32_t); + xdrs->x_addr += sizeof (uint32_t); - return TRUE; + return (TRUE); } static bool_t @@ -261,10 +261,10 @@ xdrmem_enc_char(XDR *xdrs, char *cp) { uint32_t val; - BUILD_BUG_ON(sizeof(char) != 1); + BUILD_BUG_ON(sizeof (char) != 1); val = *((unsigned char *) cp); - return xdrmem_enc_uint32(xdrs, val); + return (xdrmem_enc_uint32(xdrs, val)); } static bool_t @@ -272,10 +272,10 @@ xdrmem_dec_char(XDR *xdrs, char *cp) { uint32_t val; - BUILD_BUG_ON(sizeof(char) != 1); + BUILD_BUG_ON(sizeof (char) != 1); if (!xdrmem_dec_uint32(xdrs, &val)) - return FALSE; + return (FALSE); /* * If any of the 3 other bytes are non-zero then val will be greater @@ -283,19 +283,19 @@ xdrmem_dec_char(XDR *xdrs, char *cp) * not have a char encoded in it. */ if (val > 0xff) - return FALSE; + return (FALSE); *((unsigned char *) cp) = val; - return TRUE; + return (TRUE); } static bool_t xdrmem_enc_ushort(XDR *xdrs, unsigned short *usp) { - BUILD_BUG_ON(sizeof(unsigned short) != 2); + BUILD_BUG_ON(sizeof (unsigned short) != 2); - return xdrmem_enc_uint32(xdrs, *usp); + return (xdrmem_enc_uint32(xdrs, *usp)); } static bool_t @@ -303,48 +303,48 @@ xdrmem_dec_ushort(XDR *xdrs, unsigned short *usp) { uint32_t val; - BUILD_BUG_ON(sizeof(unsigned short) != 2); + BUILD_BUG_ON(sizeof (unsigned short) != 2); if (!xdrmem_dec_uint32(xdrs, &val)) - return FALSE; + return (FALSE); /* * Short ints are not in the RFC, but we assume similar logic as in * xdrmem_dec_char(). */ if (val > 0xffff) - return FALSE; + return (FALSE); *usp = val; - return TRUE; + return (TRUE); } static bool_t xdrmem_enc_uint(XDR *xdrs, unsigned *up) { - BUILD_BUG_ON(sizeof(unsigned) != 4); + BUILD_BUG_ON(sizeof (unsigned) != 4); - return xdrmem_enc_uint32(xdrs, *up); + return (xdrmem_enc_uint32(xdrs, *up)); } static bool_t xdrmem_dec_uint(XDR *xdrs, unsigned *up) { - BUILD_BUG_ON(sizeof(unsigned) != 4); + BUILD_BUG_ON(sizeof (unsigned) != 4); - return xdrmem_dec_uint32(xdrs, (uint32_t *) up); + return (xdrmem_dec_uint32(xdrs, (uint32_t *) up)); } static bool_t xdrmem_enc_ulonglong(XDR *xdrs, u_longlong_t *ullp) { - BUILD_BUG_ON(sizeof(u_longlong_t) != 8); + BUILD_BUG_ON(sizeof (u_longlong_t) != 8); if (!xdrmem_enc_uint32(xdrs, *ullp >> 32)) - return FALSE; + return (FALSE); - return xdrmem_enc_uint32(xdrs, *ullp & 0xffffffff); + return (xdrmem_enc_uint32(xdrs, *ullp & 0xffffffff)); } static bool_t @@ -352,16 +352,16 @@ xdrmem_dec_ulonglong(XDR *xdrs, u_longlong_t *ullp) { uint32_t low, high; - BUILD_BUG_ON(sizeof(u_longlong_t) != 8); + BUILD_BUG_ON(sizeof (u_longlong_t) != 8); if (!xdrmem_dec_uint32(xdrs, &high)) - return FALSE; + return (FALSE); if (!xdrmem_dec_uint32(xdrs, &low)) - return FALSE; + return (FALSE); *ullp = ((u_longlong_t) high << 32) | low; - return TRUE; + return (TRUE); } static bool_t @@ -372,18 +372,18 @@ xdr_enc_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize, caddr_t addr = *arrp; if (*sizep > maxsize || *sizep > UINT_MAX / elsize) - return FALSE; + return (FALSE); if (!xdrmem_enc_uint(xdrs, sizep)) - return FALSE; + return (FALSE); for (i = 0; i < *sizep; i++) { if (!elproc(xdrs, addr)) - return FALSE; + return (FALSE); addr += elsize; } - return TRUE; + return (TRUE); } static bool_t @@ -395,23 +395,23 @@ xdr_dec_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize, caddr_t addr; if (!xdrmem_dec_uint(xdrs, sizep)) - return FALSE; + return (FALSE); size = *sizep; if (size > maxsize || size > UINT_MAX / elsize) - return FALSE; + return (FALSE); /* * The Solaris man page says: "If *arrp is NULL when decoding, * xdr_array() allocates memory and *arrp points to it". */ if (*arrp == NULL) { - BUILD_BUG_ON(sizeof(uint_t) > sizeof(size_t)); + BUILD_BUG_ON(sizeof (uint_t) > sizeof (size_t)); *arrp = kmem_alloc(size * elsize, KM_NOSLEEP); if (*arrp == NULL) - return FALSE; + return (FALSE); alloc = TRUE; } @@ -422,12 +422,12 @@ xdr_dec_array(XDR *xdrs, caddr_t *arrp, uint_t *sizep, const uint_t maxsize, if (!elproc(xdrs, addr)) { if (alloc) kmem_free(*arrp, size * elsize); - return FALSE; + return (FALSE); } addr += elsize; } - return TRUE; + return (TRUE); } static bool_t @@ -437,14 +437,14 @@ xdr_enc_string(XDR *xdrs, char **sp, const uint_t maxsize) uint_t len; if (slen > maxsize) - return FALSE; + return (FALSE); len = slen; if (!xdrmem_enc_uint(xdrs, &len)) - return FALSE; + return (FALSE); - return xdrmem_enc_bytes(xdrs, *sp, len); + return (xdrmem_enc_bytes(xdrs, *sp, len)); } static bool_t @@ -454,21 +454,21 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize) bool_t alloc = FALSE; if (!xdrmem_dec_uint(xdrs, &size)) - return FALSE; + return (FALSE); if (size > maxsize || size > UINT_MAX - 1) - return FALSE; + return (FALSE); /* * Solaris man page: "If *sp is NULL when decoding, xdr_string() * allocates memory and *sp points to it". */ if (*sp == NULL) { - BUILD_BUG_ON(sizeof(uint_t) > sizeof(size_t)); + BUILD_BUG_ON(sizeof (uint_t) > sizeof (size_t)); *sp = kmem_alloc(size + 1, KM_NOSLEEP); if (*sp == NULL) - return FALSE; + return (FALSE); alloc = TRUE; } @@ -481,34 +481,33 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize) (*sp)[size] = '\0'; - return TRUE; + return (TRUE); fail: if (alloc) kmem_free(*sp, size + 1); - return FALSE; + return (FALSE); } static struct xdr_ops xdrmem_encode_ops = { - .xdr_control = xdrmem_control, - .xdr_char = xdrmem_enc_char, - .xdr_u_short = xdrmem_enc_ushort, - .xdr_u_int = xdrmem_enc_uint, - .xdr_u_longlong_t = xdrmem_enc_ulonglong, - .xdr_opaque = xdrmem_enc_bytes, - .xdr_string = xdr_enc_string, - .xdr_array = xdr_enc_array + .xdr_control = xdrmem_control, + .xdr_char = xdrmem_enc_char, + .xdr_u_short = xdrmem_enc_ushort, + .xdr_u_int = xdrmem_enc_uint, + .xdr_u_longlong_t = xdrmem_enc_ulonglong, + .xdr_opaque = xdrmem_enc_bytes, + .xdr_string = xdr_enc_string, + .xdr_array = xdr_enc_array }; static struct xdr_ops xdrmem_decode_ops = { - .xdr_control = xdrmem_control, - .xdr_char = xdrmem_dec_char, - .xdr_u_short = xdrmem_dec_ushort, - .xdr_u_int = xdrmem_dec_uint, - .xdr_u_longlong_t = xdrmem_dec_ulonglong, - .xdr_opaque = xdrmem_dec_bytes, - .xdr_string = xdr_dec_string, - .xdr_array = xdr_dec_array + .xdr_control = xdrmem_control, + .xdr_char = xdrmem_dec_char, + .xdr_u_short = xdrmem_dec_ushort, + .xdr_u_int = xdrmem_dec_uint, + .xdr_u_longlong_t = xdrmem_dec_ulonglong, + .xdr_opaque = xdrmem_dec_bytes, + .xdr_string = xdr_dec_string, + .xdr_array = xdr_dec_array }; - diff --git a/module/spl/spl-zlib.c b/module/spl/spl-zlib.c index 609bf5048..177a626df 100644 --- a/module/spl/spl-zlib.c +++ b/module/spl/spl-zlib.c @@ -20,7 +20,8 @@ * * You should have received a copy of the GNU General Public License along * with the SPL. If not, see <http://www.gnu.org/licenses/>. - ***************************************************************************** + * + * * z_compress_level/z_uncompress are nearly identical copies of the * compress2/uncompress functions provided by the official zlib package * available at http://zlib.net/. The only changes made we to slightly @@ -72,7 +73,7 @@ static spl_kmem_cache_t *zlib_workspace_cache; static void * zlib_workspace_alloc(int flags) { - return kmem_cache_alloc(zlib_workspace_cache, flags & ~(__GFP_FS)); + return (kmem_cache_alloc(zlib_workspace_cache, flags & ~(__GFP_FS))); } static void @@ -94,7 +95,7 @@ zlib_workspace_free(void *workspace) */ int z_compress_level(void *dest, size_t *destLen, const void *source, - size_t sourceLen, int level) + size_t sourceLen, int level) { z_stream stream; int err; @@ -105,30 +106,30 @@ z_compress_level(void *dest, size_t *destLen, const void *source, stream.avail_out = (uInt)*destLen; if ((size_t)stream.avail_out != *destLen) - return Z_BUF_ERROR; + return (Z_BUF_ERROR); stream.workspace = zlib_workspace_alloc(KM_SLEEP); if (!stream.workspace) - return Z_MEM_ERROR; + return (Z_MEM_ERROR); err = zlib_deflateInit(&stream, level); if (err != Z_OK) { zlib_workspace_free(stream.workspace); - return err; + return (err); } err = zlib_deflate(&stream, Z_FINISH); if (err != Z_STREAM_END) { zlib_deflateEnd(&stream); zlib_workspace_free(stream.workspace); - return err == Z_OK ? Z_BUF_ERROR : err; + return (err == Z_OK ? Z_BUF_ERROR : err); } *destLen = stream.total_out; err = zlib_deflateEnd(&stream); zlib_workspace_free(stream.workspace); - return err; + return (err); } EXPORT_SYMBOL(z_compress_level); @@ -159,16 +160,16 @@ z_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen) stream.avail_out = (uInt)*destLen; if ((size_t)stream.avail_out != *destLen) - return Z_BUF_ERROR; + return (Z_BUF_ERROR); stream.workspace = zlib_workspace_alloc(KM_SLEEP); if (!stream.workspace) - return Z_MEM_ERROR; + return (Z_MEM_ERROR); err = zlib_inflateInit(&stream); if (err != Z_OK) { zlib_workspace_free(stream.workspace); - return err; + return (err); } err = zlib_inflate(&stream, Z_FINISH); @@ -177,17 +178,17 @@ z_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen) zlib_workspace_free(stream.workspace); if (err == Z_NEED_DICT || - (err == Z_BUF_ERROR && stream.avail_in == 0)) - return Z_DATA_ERROR; + (err == Z_BUF_ERROR && stream.avail_in == 0)) + return (Z_DATA_ERROR); - return err; + return (err); } *destLen = stream.total_out; err = zlib_inflateEnd(&stream); zlib_workspace_free(stream.workspace); - return err; + return (err); } EXPORT_SYMBOL(z_uncompress); @@ -203,15 +204,15 @@ spl_zlib_init(void) "spl_zlib_workspace_cache", size, 0, NULL, NULL, NULL, NULL, NULL, KMC_VMEM | KMC_NOEMERGENCY); - if (!zlib_workspace_cache) + if (!zlib_workspace_cache) return (1); - return (0); + return (0); } void spl_zlib_fini(void) { kmem_cache_destroy(zlib_workspace_cache); - zlib_workspace_cache = NULL; + zlib_workspace_cache = NULL; } |