Fix cstyle warnings
This patch contains no functional changes. It is solely intended to resolve cstyle warnings in order to facilitate moving the spl source code in to the zfs repository. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #681
This commit is contained in:
parent
23602fdb39
commit
5461eefe50
|
@ -26,6 +26,7 @@
|
||||||
#define _SPL_MATH64_COMPAT_H
|
#define _SPL_MATH64_COMPAT_H
|
||||||
|
|
||||||
#ifndef abs64
|
#ifndef abs64
|
||||||
|
/* CSTYLED */
|
||||||
#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; })
|
#define abs64(x) ({ uint64_t t = (x) >> 63; ((x) ^ t) - t; })
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -36,8 +36,7 @@ enum xdr_op {
|
||||||
struct xdr_ops;
|
struct xdr_ops;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
struct xdr_ops *x_ops; /* Also used to let caller know if
|
struct xdr_ops *x_ops; /* Let caller know xdrmem_create() succeeds */
|
||||||
xdrmem_create() succeeds (sigh..) */
|
|
||||||
caddr_t x_addr; /* Current buffer addr */
|
caddr_t x_addr; /* Current buffer addr */
|
||||||
caddr_t x_addr_end; /* End of the buffer */
|
caddr_t x_addr_end; /* End of the buffer */
|
||||||
enum xdr_op x_op; /* Stream direction */
|
enum xdr_op x_op; /* Stream direction */
|
||||||
|
@ -74,11 +73,12 @@ struct xdr_bytesrec {
|
||||||
*/
|
*/
|
||||||
void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size,
|
void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size,
|
||||||
const enum xdr_op op);
|
const enum xdr_op op);
|
||||||
#define xdr_destroy(xdrs) ((void) 0) /* Currently not needed. If needed later,
|
|
||||||
we'll add it to struct xdr_ops */
|
|
||||||
|
|
||||||
#define xdr_control(xdrs, req, info) (xdrs)->x_ops->xdr_control((xdrs), \
|
/* Currently not needed. If needed later, we'll add it to struct xdr_ops */
|
||||||
(req), (info))
|
#define xdr_destroy(xdrs) ((void) 0)
|
||||||
|
|
||||||
|
#define xdr_control(xdrs, req, info) \
|
||||||
|
(xdrs)->x_ops->xdr_control((xdrs), (req), (info))
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For precaution, the following are defined as static inlines instead of macros
|
* For precaution, the following are defined as static inlines instead of macros
|
||||||
|
@ -89,40 +89,40 @@ void xdrmem_create(XDR *xdrs, const caddr_t addr, const uint_t size,
|
||||||
*/
|
*/
|
||||||
static inline bool_t xdr_char(XDR *xdrs, char *cp)
|
static inline bool_t xdr_char(XDR *xdrs, char *cp)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_char(xdrs, cp);
|
return (xdrs->x_ops->xdr_char(xdrs, cp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_u_short(XDR *xdrs, unsigned short *usp)
|
static inline bool_t xdr_u_short(XDR *xdrs, unsigned short *usp)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_u_short(xdrs, usp);
|
return (xdrs->x_ops->xdr_u_short(xdrs, usp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_short(XDR *xdrs, short *sp)
|
static inline bool_t xdr_short(XDR *xdrs, short *sp)
|
||||||
{
|
{
|
||||||
BUILD_BUG_ON(sizeof(short) != 2);
|
BUILD_BUG_ON(sizeof (short) != 2);
|
||||||
return xdrs->x_ops->xdr_u_short(xdrs, (unsigned short *) sp);
|
return (xdrs->x_ops->xdr_u_short(xdrs, (unsigned short *) sp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_u_int(XDR *xdrs, unsigned *up)
|
static inline bool_t xdr_u_int(XDR *xdrs, unsigned *up)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_u_int(xdrs, up);
|
return (xdrs->x_ops->xdr_u_int(xdrs, up));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_int(XDR *xdrs, int *ip)
|
static inline bool_t xdr_int(XDR *xdrs, int *ip)
|
||||||
{
|
{
|
||||||
BUILD_BUG_ON(sizeof(int) != 4);
|
BUILD_BUG_ON(sizeof (int) != 4);
|
||||||
return xdrs->x_ops->xdr_u_int(xdrs, (unsigned *) ip);
|
return (xdrs->x_ops->xdr_u_int(xdrs, (unsigned *)ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
|
static inline bool_t xdr_u_longlong_t(XDR *xdrs, u_longlong_t *ullp)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_u_longlong_t(xdrs, ullp);
|
return (xdrs->x_ops->xdr_u_longlong_t(xdrs, ullp));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool_t xdr_longlong_t(XDR *xdrs, longlong_t *llp)
|
static inline bool_t xdr_longlong_t(XDR *xdrs, longlong_t *llp)
|
||||||
{
|
{
|
||||||
BUILD_BUG_ON(sizeof(longlong_t) != 8);
|
BUILD_BUG_ON(sizeof (longlong_t) != 8);
|
||||||
return xdrs->x_ops->xdr_u_longlong_t(xdrs, (u_longlong_t *) llp);
|
return (xdrs->x_ops->xdr_u_longlong_t(xdrs, (u_longlong_t *)llp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -130,7 +130,7 @@ static inline bool_t xdr_longlong_t(XDR *xdrs, longlong_t *llp)
|
||||||
*/
|
*/
|
||||||
static inline bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt)
|
static inline bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_opaque(xdrs, cp, cnt);
|
return (xdrs->x_ops->xdr_opaque(xdrs, cp, cnt));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -139,7 +139,7 @@ static inline bool_t xdr_opaque(XDR *xdrs, caddr_t cp, const uint_t cnt)
|
||||||
*/
|
*/
|
||||||
static inline bool_t xdr_string(XDR *xdrs, char **sp, const uint_t maxsize)
|
static inline bool_t xdr_string(XDR *xdrs, char **sp, const uint_t maxsize)
|
||||||
{
|
{
|
||||||
return xdrs->x_ops->xdr_string(xdrs, sp, maxsize);
|
return (xdrs->x_ops->xdr_string(xdrs, sp, maxsize));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -103,11 +103,13 @@ typedef struct ace_object {
|
||||||
|
|
||||||
#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE|ACE_IDENTIFIER_GROUP)
|
#define ACE_TYPE_FLAGS (ACE_OWNER|ACE_GROUP|ACE_EVERYONE|ACE_IDENTIFIER_GROUP)
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
|
#define ACE_ALL_PERMS (ACE_READ_DATA|ACE_LIST_DIRECTORY|ACE_WRITE_DATA| \
|
||||||
ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
|
ACE_ADD_FILE|ACE_APPEND_DATA|ACE_ADD_SUBDIRECTORY|ACE_READ_NAMED_ATTRS| \
|
||||||
ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
|
ACE_WRITE_NAMED_ATTRS|ACE_EXECUTE|ACE_DELETE_CHILD|ACE_READ_ATTRIBUTES| \
|
||||||
ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
|
ACE_WRITE_ATTRIBUTES|ACE_DELETE|ACE_READ_ACL|ACE_WRITE_ACL| \
|
||||||
ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
|
ACE_WRITE_OWNER|ACE_SYNCHRONIZE)
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
#define VSA_ACE 0x0010
|
#define VSA_ACE 0x0010
|
||||||
#define VSA_ACECNT 0x0020
|
#define VSA_ACECNT 0x0020
|
||||||
|
|
|
@ -91,7 +91,7 @@ atomic_inc_32_nv(volatile uint32_t *target)
|
||||||
nv = ++(*target);
|
nv = ++(*target);
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint32_t
|
static __inline__ uint32_t
|
||||||
|
@ -103,7 +103,7 @@ atomic_dec_32_nv(volatile uint32_t *target)
|
||||||
nv = --(*target);
|
nv = --(*target);
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint32_t
|
static __inline__ uint32_t
|
||||||
|
@ -116,7 +116,7 @@ atomic_add_32_nv(volatile uint32_t *target, uint32_t delta)
|
||||||
nv = *target;
|
nv = *target;
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint32_t
|
static __inline__ uint32_t
|
||||||
|
@ -129,12 +129,11 @@ atomic_sub_32_nv(volatile uint32_t *target, uint32_t delta)
|
||||||
nv = *target;
|
nv = *target;
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint32_t
|
static __inline__ uint32_t
|
||||||
atomic_cas_32(volatile uint32_t *target, uint32_t cmp,
|
atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t newval)
|
||||||
uint32_t newval)
|
|
||||||
{
|
{
|
||||||
uint32_t rc;
|
uint32_t rc;
|
||||||
|
|
||||||
|
@ -145,7 +144,7 @@ atomic_cas_32(volatile uint32_t *target, uint32_t cmp,
|
||||||
|
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint32_t
|
static __inline__ uint32_t
|
||||||
|
@ -158,7 +157,7 @@ atomic_swap_32(volatile uint32_t *target, uint32_t newval)
|
||||||
*target = newval;
|
*target = newval;
|
||||||
spin_unlock(&atomic32_lock);
|
spin_unlock(&atomic32_lock);
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ void
|
static __inline__ void
|
||||||
|
@ -202,7 +201,7 @@ atomic_inc_64_nv(volatile uint64_t *target)
|
||||||
nv = ++(*target);
|
nv = ++(*target);
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
|
@ -214,7 +213,7 @@ atomic_dec_64_nv(volatile uint64_t *target)
|
||||||
nv = --(*target);
|
nv = --(*target);
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
|
@ -227,7 +226,7 @@ atomic_add_64_nv(volatile uint64_t *target, uint64_t delta)
|
||||||
nv = *target;
|
nv = *target;
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
|
@ -240,12 +239,11 @@ atomic_sub_64_nv(volatile uint64_t *target, uint64_t delta)
|
||||||
nv = *target;
|
nv = *target;
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return nv;
|
return (nv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
|
atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t newval)
|
||||||
uint64_t newval)
|
|
||||||
{
|
{
|
||||||
uint64_t rc;
|
uint64_t rc;
|
||||||
|
|
||||||
|
@ -255,7 +253,7 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp,
|
||||||
*target = newval;
|
*target = newval;
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
|
@ -268,7 +266,7 @@ atomic_swap_64(volatile uint64_t *target, uint64_t newval)
|
||||||
*target = newval;
|
*target = newval;
|
||||||
spin_unlock(&atomic64_lock);
|
spin_unlock(&atomic64_lock);
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else /* ATOMIC_SPINLOCK */
|
#else /* ATOMIC_SPINLOCK */
|
||||||
|
@ -300,15 +298,15 @@ atomic_swap_64(volatile uint64_t *target, uint64_t newval)
|
||||||
static __inline__ void *
|
static __inline__ void *
|
||||||
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
|
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
|
||||||
{
|
{
|
||||||
return (void *)atomic_cas_64((volatile uint64_t *)target,
|
return ((void *)atomic_cas_64((volatile uint64_t *)target,
|
||||||
(uint64_t)cmp, (uint64_t)newval);
|
(uint64_t)cmp, (uint64_t)newval));
|
||||||
}
|
}
|
||||||
#else /* _LP64 */
|
#else /* _LP64 */
|
||||||
static __inline__ void *
|
static __inline__ void *
|
||||||
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
|
atomic_cas_ptr(volatile void *target, void *cmp, void *newval)
|
||||||
{
|
{
|
||||||
return (void *)atomic_cas_32((volatile uint32_t *)target,
|
return ((void *)atomic_cas_32((volatile uint32_t *)target,
|
||||||
(uint32_t)cmp, (uint32_t)newval);
|
(uint32_t)cmp, (uint32_t)newval));
|
||||||
}
|
}
|
||||||
#endif /* _LP64 */
|
#endif /* _LP64 */
|
||||||
|
|
||||||
|
|
|
@ -46,22 +46,26 @@
|
||||||
|
|
||||||
#ifdef _BIG_ENDIAN
|
#ifdef _BIG_ENDIAN
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
htonll(uint64_t n) {
|
htonll(uint64_t n)
|
||||||
|
{
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
ntohll(uint64_t n) {
|
ntohll(uint64_t n)
|
||||||
|
{
|
||||||
return (n);
|
return (n);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
htonll(uint64_t n) {
|
htonll(uint64_t n)
|
||||||
|
{
|
||||||
return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32));
|
return ((((uint64_t)htonl(n)) << 32) + htonl(n >> 32));
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ uint64_t
|
static __inline__ uint64_t
|
||||||
ntohll(uint64_t n) {
|
ntohll(uint64_t n)
|
||||||
|
{
|
||||||
return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32));
|
return ((((uint64_t)ntohl(n)) << 32) + ntohl(n >> 32));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -52,4 +52,3 @@ typedef struct callb_cpr {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SPL_CALLB_H */
|
#endif /* _SPL_CALLB_H */
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ extern gid_t crgetrgid(const cred_t *cr);
|
||||||
extern gid_t crgetsgid(const cred_t *cr);
|
extern gid_t crgetsgid(const cred_t *cr);
|
||||||
extern gid_t crgetfsgid(const cred_t *cr);
|
extern gid_t crgetfsgid(const cred_t *cr);
|
||||||
extern int crgetngroups(const cred_t *cr);
|
extern int crgetngroups(const cred_t *cr);
|
||||||
extern gid_t * crgetgroups(const cred_t *cr);
|
extern gid_t *crgetgroups(const cred_t *cr);
|
||||||
extern int groupmember(gid_t gid, const cred_t *cr);
|
extern int groupmember(gid_t gid, const cred_t *cr);
|
||||||
|
|
||||||
#endif /* _SPL_CRED_H */
|
#endif /* _SPL_CRED_H */
|
||||||
|
|
|
@ -54,16 +54,17 @@ int spl_panic(const char *file, const char *func, int line,
|
||||||
const char *fmt, ...);
|
const char *fmt, ...);
|
||||||
void spl_dumpstack(void);
|
void spl_dumpstack(void);
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
#define PANIC(fmt, a...) \
|
#define PANIC(fmt, a...) \
|
||||||
spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a)
|
spl_panic(__FILE__, __FUNCTION__, __LINE__, fmt, ## a)
|
||||||
|
|
||||||
#define VERIFY(cond) \
|
#define VERIFY(cond) \
|
||||||
(void)(unlikely(!(cond)) && \
|
(void) (unlikely(!(cond)) && \
|
||||||
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
||||||
"%s", "VERIFY(" #cond ") failed\n"))
|
"%s", "VERIFY(" #cond ") failed\n"))
|
||||||
|
|
||||||
#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) \
|
#define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE, FMT, CAST) \
|
||||||
(void)((!((TYPE)(LEFT) OP (TYPE)(RIGHT))) && \
|
(void) ((!((TYPE)(LEFT) OP (TYPE)(RIGHT))) && \
|
||||||
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
||||||
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
|
"VERIFY3(" #LEFT " " #OP " " #RIGHT ") " \
|
||||||
"failed (" FMT " " #OP " " FMT ")\n", \
|
"failed (" FMT " " #OP " " FMT ")\n", \
|
||||||
|
@ -120,6 +121,7 @@ void spl_dumpstack(void);
|
||||||
((void)((!!(A) == !!(B)) || \
|
((void)((!!(A) == !!(B)) || \
|
||||||
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
spl_panic(__FILE__, __FUNCTION__, __LINE__, \
|
||||||
"(" #A ") is equivalent to (" #B ")")))
|
"(" #A ") is equivalent to (" #B ")")))
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
#endif /* NDEBUG */
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ static inline void dfl_free(dkioc_free_list_t *dfl) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline dkioc_free_list_t *dfl_alloc(uint64_t dfl_num_exts, int flags) {
|
static inline dkioc_free_list_t *dfl_alloc(uint64_t dfl_num_exts, int flags) {
|
||||||
return vmem_zalloc(DFL_SZ(dfl_num_exts), flags);
|
return (vmem_zalloc(DFL_SZ(dfl_num_exts), flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SPL_DKIOC_UTIL_H */
|
#endif /* _SPL_DKIOC_UTIL_H */
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
#define KSTAT_STRLEN 255
|
#define KSTAT_STRLEN 255
|
||||||
#define KSTAT_RAW_MAX (128*1024)
|
#define KSTAT_RAW_MAX (128*1024)
|
||||||
|
|
||||||
/* For reference valid classes are:
|
/*
|
||||||
|
* For reference valid classes are:
|
||||||
* disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc
|
* disk, tape, net, controller, vm, kvm, hat, streams, kstat, misc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@
|
||||||
#define KSTAT_FLAG_WRITABLE 0x04
|
#define KSTAT_FLAG_WRITABLE 0x04
|
||||||
#define KSTAT_FLAG_PERSISTENT 0x08
|
#define KSTAT_FLAG_PERSISTENT 0x08
|
||||||
#define KSTAT_FLAG_DORMANT 0x10
|
#define KSTAT_FLAG_DORMANT 0x10
|
||||||
#define KSTAT_FLAG_UNSUPPORTED (KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
|
#define KSTAT_FLAG_UNSUPPORTED \
|
||||||
|
(KSTAT_FLAG_VAR_SIZE | KSTAT_FLAG_WRITABLE | \
|
||||||
KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
|
KSTAT_FLAG_PERSISTENT | KSTAT_FLAG_DORMANT)
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +111,7 @@ struct kstat_s {
|
||||||
uchar_t ks_type; /* kstat data type */
|
uchar_t ks_type; /* kstat data type */
|
||||||
uchar_t ks_flags; /* kstat flags */
|
uchar_t ks_flags; /* kstat flags */
|
||||||
void *ks_data; /* kstat type-specific data */
|
void *ks_data; /* kstat type-specific data */
|
||||||
uint_t ks_ndata; /* # of type-specific data records */
|
uint_t ks_ndata; /* # of data records */
|
||||||
size_t ks_data_size; /* size of kstat data section */
|
size_t ks_data_size; /* size of kstat data section */
|
||||||
struct proc_dir_entry *ks_proc; /* proc linkage */
|
struct proc_dir_entry *ks_proc; /* proc linkage */
|
||||||
kstat_update_t *ks_update; /* dynamic updates */
|
kstat_update_t *ks_update; /* dynamic updates */
|
||||||
|
@ -157,7 +159,7 @@ typedef struct kstat_io {
|
||||||
uint_t reads; /* number of read operations */
|
uint_t reads; /* number of read operations */
|
||||||
uint_t writes; /* number of write operations */
|
uint_t writes; /* number of write operations */
|
||||||
hrtime_t wtime; /* cumulative wait (pre-service) time */
|
hrtime_t wtime; /* cumulative wait (pre-service) time */
|
||||||
hrtime_t wlentime; /* cumulative wait length*time product*/
|
hrtime_t wlentime; /* cumulative wait len*time product */
|
||||||
hrtime_t wlastupdate; /* last time wait queue changed */
|
hrtime_t wlastupdate; /* last time wait queue changed */
|
||||||
hrtime_t rtime; /* cumulative run (service) time */
|
hrtime_t rtime; /* cumulative run (service) time */
|
||||||
hrtime_t rlentime; /* cumulative run length*time product */
|
hrtime_t rlentime; /* cumulative run length*time product */
|
||||||
|
@ -183,10 +185,11 @@ extern void __kstat_set_raw_ops(kstat_t *ksp,
|
||||||
int (*headers)(char *buf, size_t size),
|
int (*headers)(char *buf, size_t size),
|
||||||
int (*data)(char *buf, size_t size, void *data),
|
int (*data)(char *buf, size_t size, void *data),
|
||||||
void* (*addr)(kstat_t *ksp, loff_t index));
|
void* (*addr)(kstat_t *ksp, loff_t index));
|
||||||
|
|
||||||
extern kstat_t *__kstat_create(const char *ks_module, int ks_instance,
|
extern kstat_t *__kstat_create(const char *ks_module, int ks_instance,
|
||||||
const char *ks_name, const char *ks_class,
|
const char *ks_name, const char *ks_class, uchar_t ks_type,
|
||||||
uchar_t ks_type, uint_t ks_ndata,
|
uint_t ks_ndata, uchar_t ks_flags);
|
||||||
uchar_t ks_flags);
|
|
||||||
extern void __kstat_install(kstat_t *ksp);
|
extern void __kstat_install(kstat_t *ksp);
|
||||||
extern void __kstat_delete(kstat_t *ksp);
|
extern void __kstat_delete(kstat_t *ksp);
|
||||||
extern void kstat_waitq_enter(kstat_io_t *);
|
extern void kstat_waitq_enter(kstat_io_t *);
|
||||||
|
@ -194,8 +197,11 @@ extern void kstat_waitq_exit(kstat_io_t *);
|
||||||
extern void kstat_runq_enter(kstat_io_t *);
|
extern void kstat_runq_enter(kstat_io_t *);
|
||||||
extern void kstat_runq_exit(kstat_io_t *);
|
extern void kstat_runq_exit(kstat_io_t *);
|
||||||
|
|
||||||
#define kstat_set_raw_ops(k,h,d,a) __kstat_set_raw_ops(k,h,d,a)
|
#define kstat_set_raw_ops(k, h, d, a) \
|
||||||
#define kstat_create(m,i,n,c,t,s,f) __kstat_create(m,i,n,c,t,s,f)
|
__kstat_set_raw_ops(k, h, d, a)
|
||||||
|
#define kstat_create(m, i, n, c, t, s, f) \
|
||||||
|
__kstat_create(m, i, n, c, t, s, f)
|
||||||
|
|
||||||
#define kstat_install(k) __kstat_install(k)
|
#define kstat_install(k) __kstat_install(k)
|
||||||
#define kstat_delete(k) __kstat_delete(k)
|
#define kstat_delete(k) __kstat_delete(k)
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct list {
|
||||||
static inline int
|
static inline int
|
||||||
list_is_empty(list_t *list)
|
list_is_empty(list_t *list)
|
||||||
{
|
{
|
||||||
return list_empty(&list->list_head);
|
return (list_empty(&list->list_head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -74,7 +74,7 @@ list_create(list_t *list, size_t size, size_t offset)
|
||||||
{
|
{
|
||||||
ASSERT(list);
|
ASSERT(list);
|
||||||
ASSERT(size > 0);
|
ASSERT(size > 0);
|
||||||
ASSERT(size >= offset + sizeof(list_node_t));
|
ASSERT(size >= offset + sizeof (list_node_t));
|
||||||
|
|
||||||
list->list_size = size;
|
list->list_size = size;
|
||||||
list->list_offset = offset;
|
list->list_offset = offset;
|
||||||
|
@ -132,10 +132,10 @@ list_remove_head(list_t *list)
|
||||||
{
|
{
|
||||||
list_node_t *head = list->list_head.next;
|
list_node_t *head = list->list_head.next;
|
||||||
if (head == &list->list_head)
|
if (head == &list->list_head)
|
||||||
return NULL;
|
return (NULL);
|
||||||
|
|
||||||
list_del(head);
|
list_del(head);
|
||||||
return list_object(list, head);
|
return (list_object(list, head));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
|
@ -143,28 +143,28 @@ list_remove_tail(list_t *list)
|
||||||
{
|
{
|
||||||
list_node_t *tail = list->list_head.prev;
|
list_node_t *tail = list->list_head.prev;
|
||||||
if (tail == &list->list_head)
|
if (tail == &list->list_head)
|
||||||
return NULL;
|
return (NULL);
|
||||||
|
|
||||||
list_del(tail);
|
list_del(tail);
|
||||||
return list_object(list, tail);
|
return (list_object(list, tail));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
list_head(list_t *list)
|
list_head(list_t *list)
|
||||||
{
|
{
|
||||||
if (list_is_empty(list))
|
if (list_is_empty(list))
|
||||||
return NULL;
|
return (NULL);
|
||||||
|
|
||||||
return list_object(list, list->list_head.next);
|
return (list_object(list, list->list_head.next));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
list_tail(list_t *list)
|
list_tail(list_t *list)
|
||||||
{
|
{
|
||||||
if (list_is_empty(list))
|
if (list_is_empty(list))
|
||||||
return NULL;
|
return (NULL);
|
||||||
|
|
||||||
return list_object(list, list->list_head.prev);
|
return (list_object(list, list->list_head.prev));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
|
@ -173,9 +173,9 @@ list_next(list_t *list, void *object)
|
||||||
list_node_t *node = list_d2l(list, object);
|
list_node_t *node = list_d2l(list, object);
|
||||||
|
|
||||||
if (node->next != &list->list_head)
|
if (node->next != &list->list_head)
|
||||||
return list_object(list, node->next);
|
return (list_object(list, node->next));
|
||||||
|
|
||||||
return NULL;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
|
@ -184,9 +184,9 @@ list_prev(list_t *list, void *object)
|
||||||
list_node_t *node = list_d2l(list, object);
|
list_node_t *node = list_d2l(list, object);
|
||||||
|
|
||||||
if (node->prev != &list->list_head)
|
if (node->prev != &list->list_head)
|
||||||
return list_object(list, node->prev);
|
return (list_object(list, node->prev));
|
||||||
|
|
||||||
return NULL;
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
|
|
|
@ -113,6 +113,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
|
||||||
VERIFY3P(mutex_owner(mp), ==, NULL); \
|
VERIFY3P(mutex_owner(mp), ==, NULL); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
#define mutex_tryenter(mp) \
|
#define mutex_tryenter(mp) \
|
||||||
({ \
|
({ \
|
||||||
int _rc_; \
|
int _rc_; \
|
||||||
|
@ -124,6 +125,7 @@ spl_mutex_lockdep_on_maybe(kmutex_t *mp) \
|
||||||
\
|
\
|
||||||
_rc_; \
|
_rc_; \
|
||||||
})
|
})
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||||
#define mutex_enter_nested(mp, subclass) \
|
#define mutex_enter_nested(mp, subclass) \
|
||||||
|
|
|
@ -25,23 +25,23 @@
|
||||||
#ifndef _SPL_POLICY_H
|
#ifndef _SPL_POLICY_H
|
||||||
#define _SPL_POLICY_H
|
#define _SPL_POLICY_H
|
||||||
|
|
||||||
#define secpolicy_fs_unmount(c,vfs) (0)
|
#define secpolicy_fs_unmount(c, vfs) (0)
|
||||||
#define secpolicy_nfs(c) (0)
|
#define secpolicy_nfs(c) (0)
|
||||||
#define secpolicy_sys_config(c,co) (0)
|
#define secpolicy_sys_config(c, co) (0)
|
||||||
#define secpolicy_zfs(c) (0)
|
#define secpolicy_zfs(c) (0)
|
||||||
#define secpolicy_zinject(c) (0)
|
#define secpolicy_zinject(c) (0)
|
||||||
#define secpolicy_vnode_setids_setgids(c,id) (0)
|
#define secpolicy_vnode_setids_setgids(c, id) (0)
|
||||||
#define secpolicy_vnode_setid_retain(c, sr) (0)
|
#define secpolicy_vnode_setid_retain(c, sr) (0)
|
||||||
#define secpolicy_setid_clear(v, c) (0)
|
#define secpolicy_setid_clear(v, c) (0)
|
||||||
#define secpolicy_vnode_any_access(c,vp,o) (0)
|
#define secpolicy_vnode_any_access(c, vp, o) (0)
|
||||||
#define secpolicy_vnode_access2(c,cp,o,m1,m2) (0)
|
#define secpolicy_vnode_access2(c, cp, o, m1, m2) (0)
|
||||||
#define secpolicy_vnode_chown(c,o) (0)
|
#define secpolicy_vnode_chown(c, o) (0)
|
||||||
#define secpolicy_vnode_setdac(c,o) (0)
|
#define secpolicy_vnode_setdac(c, o) (0)
|
||||||
#define secpolicy_vnode_remove(c) (0)
|
#define secpolicy_vnode_remove(c) (0)
|
||||||
#define secpolicy_vnode_setattr(c,v,a,o,f,func,n) (0)
|
#define secpolicy_vnode_setattr(c, v, a, o, f, func, n) (0)
|
||||||
#define secpolicy_xvattr(x, o, c, t) (0)
|
#define secpolicy_xvattr(x, o, c, t) (0)
|
||||||
#define secpolicy_vnode_stky_modify(c) (0)
|
#define secpolicy_vnode_stky_modify(c) (0)
|
||||||
#define secpolicy_setid_setsticky_clear(v,a,o,c) (0)
|
#define secpolicy_setid_setsticky_clear(v, a, o, c) (0)
|
||||||
#define secpolicy_basic_link(c) (0)
|
#define secpolicy_basic_link(c) (0)
|
||||||
|
|
||||||
#endif /* SPL_POLICY_H */
|
#endif /* SPL_POLICY_H */
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
static __inline__ int
|
static __inline__ int
|
||||||
random_get_bytes(uint8_t *ptr, size_t len)
|
random_get_bytes(uint8_t *ptr, size_t len)
|
||||||
{
|
{
|
||||||
get_random_bytes((void *)ptr,(int)len);
|
get_random_bytes((void *)ptr, (int)len);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
|
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
|
||||||
|
|
|
@ -81,9 +81,9 @@ static inline kthread_t *
|
||||||
rw_owner(krwlock_t *rwp)
|
rw_owner(krwlock_t *rwp)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
#ifdef CONFIG_RWSEM_SPIN_ON_OWNER
|
||||||
return SEM(rwp)->owner;
|
return (SEM(rwp)->owner);
|
||||||
#else
|
#else
|
||||||
return rwp->rw_owner;
|
return (rwp->rw_owner);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ RW_WRITE_HELD(krwlock_t *rwp)
|
||||||
static inline int
|
static inline int
|
||||||
RW_LOCK_HELD(krwlock_t *rwp)
|
RW_LOCK_HELD(krwlock_t *rwp)
|
||||||
{
|
{
|
||||||
return spl_rwsem_is_locked(SEM(rwp));
|
return (spl_rwsem_is_locked(SEM(rwp)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -140,6 +140,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
|
||||||
* will be correctly located in the users code which is important
|
* will be correctly located in the users code which is important
|
||||||
* for the built in kernel lock analysis tools
|
* for the built in kernel lock analysis tools
|
||||||
*/
|
*/
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
#define rw_init(rwp, name, type, arg) \
|
#define rw_init(rwp, name, type, arg) \
|
||||||
({ \
|
({ \
|
||||||
static struct lock_class_key __key; \
|
static struct lock_class_key __key; \
|
||||||
|
@ -227,6 +228,7 @@ RW_LOCK_HELD(krwlock_t *rwp)
|
||||||
} \
|
} \
|
||||||
_rc_; \
|
_rc_; \
|
||||||
})
|
})
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
int spl_rw_init(void);
|
int spl_rw_init(void);
|
||||||
void spl_rw_fini(void);
|
void spl_rw_fini(void);
|
||||||
|
|
|
@ -44,7 +44,7 @@ ksid_lookupdomain(const char *dom)
|
||||||
ksiddomain_t *kd;
|
ksiddomain_t *kd;
|
||||||
int len = strlen(dom);
|
int len = strlen(dom);
|
||||||
|
|
||||||
kd = kmem_zalloc(sizeof(ksiddomain_t), KM_SLEEP);
|
kd = kmem_zalloc(sizeof (ksiddomain_t), KM_SLEEP);
|
||||||
kd->kd_name = kmem_zalloc(len + 1, KM_SLEEP);
|
kd->kd_name = kmem_zalloc(len + 1, KM_SLEEP);
|
||||||
memcpy(kd->kd_name, dom, len);
|
memcpy(kd->kd_name, dom, len);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ static inline void
|
||||||
ksiddomain_rele(ksiddomain_t *ksid)
|
ksiddomain_rele(ksiddomain_t *ksid)
|
||||||
{
|
{
|
||||||
kmem_free(ksid->kd_name, strlen(ksid->kd_name) + 1);
|
kmem_free(ksid->kd_name, strlen(ksid->kd_name) + 1);
|
||||||
kmem_free(ksid, sizeof(ksiddomain_t));
|
kmem_free(ksid, sizeof (ksiddomain_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _SPL_SID_H */
|
#endif /* _SPL_SID_H */
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
#define FORREAL 0 /* Usual side-effects */
|
#define FORREAL 0 /* Usual side-effects */
|
||||||
#define JUSTLOOKING 1 /* Don't stop the process */
|
#define JUSTLOOKING 1 /* Don't stop the process */
|
||||||
|
|
||||||
/* The "why" argument indicates the allowable side-effects of the call:
|
/*
|
||||||
|
* The "why" argument indicates the allowable side-effects of the call:
|
||||||
*
|
*
|
||||||
* FORREAL: Extract the next pending signal from p_sig into p_cursig;
|
* FORREAL: Extract the next pending signal from p_sig into p_cursig;
|
||||||
* stop the process if a stop has been requested or if a traced signal
|
* stop the process if a stop has been requested or if a traced signal
|
||||||
|
@ -48,7 +49,7 @@ issig(int why)
|
||||||
{
|
{
|
||||||
ASSERT(why == FORREAL || why == JUSTLOOKING);
|
ASSERT(why == FORREAL || why == JUSTLOOKING);
|
||||||
|
|
||||||
return signal_pending(current);
|
return (signal_pending(current));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SPL_SIGNAL_H */
|
#endif /* SPL_SIGNAL_H */
|
||||||
|
|
|
@ -44,7 +44,7 @@ typedef int ddi_devid_t;
|
||||||
#define DDI_SUCCESS 0
|
#define DDI_SUCCESS 0
|
||||||
#define DDI_FAILURE -1
|
#define DDI_FAILURE -1
|
||||||
|
|
||||||
#define ddi_prop_lookup_string(x1,x2,x3,x4,x5) (*x5 = NULL)
|
#define ddi_prop_lookup_string(x1, x2, x3, x4, x5) (*x5 = NULL)
|
||||||
#define ddi_prop_free(x) (void)0
|
#define ddi_prop_free(x) (void)0
|
||||||
#define ddi_root_node() (void)0
|
#define ddi_root_node() (void)0
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@
|
||||||
#define RLIM64_INFINITY (~0ULL)
|
#define RLIM64_INFINITY (~0ULL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* 0..MAX_PRIO-1: Process priority
|
/*
|
||||||
|
* 0..MAX_PRIO-1: Process priority
|
||||||
* 0..MAX_RT_PRIO-1: RT priority tasks
|
* 0..MAX_RT_PRIO-1: RT priority tasks
|
||||||
* MAX_RT_PRIO..MAX_PRIO-1: SCHED_NORMAL tasks
|
* MAX_RT_PRIO..MAX_PRIO-1: SCHED_NORMAL tasks
|
||||||
*
|
*
|
||||||
|
@ -122,11 +123,12 @@
|
||||||
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
|
#define BSWAP_32(x) ((BSWAP_16(x) << 16) | BSWAP_16((x) >> 16))
|
||||||
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
|
#define BSWAP_64(x) ((BSWAP_32(x) << 32) | BSWAP_32((x) >> 32))
|
||||||
|
|
||||||
/* Map some simple functions.
|
/*
|
||||||
|
* Map some simple functions.
|
||||||
*/
|
*/
|
||||||
#define bzero(ptr,size) memset(ptr,0,size)
|
#define bzero(ptr, size) memset(ptr, 0, size)
|
||||||
#define bcopy(src,dest,size) memmove(dest,src,size)
|
#define bcopy(src, dest, size) memmove(dest, src, size)
|
||||||
#define bcmp(src,dest,size) memcmp((src), (dest), (size_t)(size))
|
#define bcmp(src, dest, size) memcmp((src), (dest), (size_t)(size))
|
||||||
|
|
||||||
/* Dtrace probes do not exist in the linux kernel */
|
/* Dtrace probes do not exist in the linux kernel */
|
||||||
#ifdef DTRACE_PROBE
|
#ifdef DTRACE_PROBE
|
||||||
|
@ -167,7 +169,7 @@ extern void spl_cleanup(void);
|
||||||
#define lowbit(x) __ffs(x)
|
#define lowbit(x) __ffs(x)
|
||||||
|
|
||||||
#define highbit64(x) fls64(x)
|
#define highbit64(x) fls64(x)
|
||||||
#define makedevice(maj,min) makedev(maj,min)
|
#define makedevice(maj, min) makedev(maj, min)
|
||||||
|
|
||||||
/* common macros */
|
/* common macros */
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
|
@ -180,7 +182,7 @@ extern void spl_cleanup(void);
|
||||||
#define ABS(a) ((a) < 0 ? -(a) : (a))
|
#define ABS(a) ((a) < 0 ? -(a) : (a))
|
||||||
#endif
|
#endif
|
||||||
#ifndef DIV_ROUND_UP
|
#ifndef DIV_ROUND_UP
|
||||||
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
|
#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d))
|
||||||
#endif
|
#endif
|
||||||
#ifndef roundup
|
#ifndef roundup
|
||||||
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
|
||||||
|
@ -198,7 +200,7 @@ extern void spl_cleanup(void);
|
||||||
#define P2PHASE(x, align) ((x) & ((align) - 1))
|
#define P2PHASE(x, align) ((x) & ((align) - 1))
|
||||||
#define P2NPHASE(x, align) (-(x) & ((align) - 1))
|
#define P2NPHASE(x, align) (-(x) & ((align) - 1))
|
||||||
#define ISP2(x) (((x) & ((x) - 1)) == 0)
|
#define ISP2(x) (((x) & ((x) - 1)) == 0)
|
||||||
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1))==0)
|
#define IS_P2ALIGNED(v, a) ((((uintptr_t)(v)) & ((uintptr_t)(a) - 1)) == 0)
|
||||||
#define P2BOUNDARY(off, len, align) \
|
#define P2BOUNDARY(off, len, align) \
|
||||||
(((off) ^ ((off) + (len) - 1)) > (align) - 1)
|
(((off) ^ ((off) + (len) - 1)) > (align) - 1)
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ typedef struct taskq {
|
||||||
taskqid_t tq_lowest_id; /* lowest pend/work id */
|
taskqid_t tq_lowest_id; /* lowest pend/work id */
|
||||||
struct list_head tq_free_list; /* free taskq_ent_t's */
|
struct list_head tq_free_list; /* free taskq_ent_t's */
|
||||||
struct list_head tq_pend_list; /* pending taskq_ent_t's */
|
struct list_head tq_pend_list; /* pending taskq_ent_t's */
|
||||||
struct list_head tq_prio_list; /* priority pending taskq_ent_t's */
|
struct list_head tq_prio_list; /* priority taskq_ent_t's */
|
||||||
struct list_head tq_delay_list; /* delayed taskq_ent_t's */
|
struct list_head tq_delay_list; /* delayed taskq_ent_t's */
|
||||||
struct list_head tq_taskqs; /* all taskq_t's */
|
struct list_head tq_taskqs; /* all taskq_t's */
|
||||||
spl_wait_queue_head_t tq_work_waitq; /* new work waitq */
|
spl_wait_queue_head_t tq_work_waitq; /* new work waitq */
|
||||||
|
|
|
@ -45,9 +45,12 @@
|
||||||
|
|
||||||
typedef void (*thread_func_t)(void *);
|
typedef void (*thread_func_t)(void *);
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
|
#define thread_create(stk, stksize, func, arg, len, pp, state, pri) \
|
||||||
__thread_create(stk, stksize, (thread_func_t)func, \
|
__thread_create(stk, stksize, (thread_func_t)func, \
|
||||||
#func, arg, len, pp, state, pri)
|
#func, arg, len, pp, state, pri)
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
#define thread_exit() __thread_exit()
|
#define thread_exit() __thread_exit()
|
||||||
#define thread_join(t) VERIFY(0)
|
#define thread_join(t) VERIFY(0)
|
||||||
#define curthread current
|
#define curthread current
|
||||||
|
@ -55,8 +58,7 @@ typedef void (*thread_func_t)(void *);
|
||||||
#define getpid() current->pid
|
#define getpid() current->pid
|
||||||
|
|
||||||
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
|
extern kthread_t *__thread_create(caddr_t stk, size_t stksize,
|
||||||
thread_func_t func, const char *name,
|
thread_func_t func, const char *name, void *args, size_t len, proc_t *pp,
|
||||||
void *args, size_t len, proc_t *pp,
|
|
||||||
int state, pri_t pri);
|
int state, pri_t pri);
|
||||||
extern void __thread_exit(void);
|
extern void __thread_exit(void);
|
||||||
extern struct task_struct *spl_kthread_create(int (*func)(void *),
|
extern struct task_struct *spl_kthread_create(int (*func)(void *),
|
||||||
|
|
|
@ -57,4 +57,3 @@
|
||||||
#define NSEC_TO_TICK(ns) usecs_to_jiffies(ns / NSEC_PER_USEC)
|
#define NSEC_TO_TICK(ns) usecs_to_jiffies(ns / NSEC_PER_USEC)
|
||||||
|
|
||||||
#endif /* _SPL_TIMER_H */
|
#endif /* _SPL_TIMER_H */
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
#define LLONG_MAX ((long long)(~0ULL>>1))
|
#define LLONG_MAX ((long long)(~0ULL>>1))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum { B_FALSE=0, B_TRUE=1 } boolean_t;
|
typedef enum { B_FALSE = 0, B_TRUE = 1 } boolean_t;
|
||||||
typedef unsigned long intptr_t;
|
typedef unsigned long intptr_t;
|
||||||
typedef unsigned long ulong_t;
|
typedef unsigned long ulong_t;
|
||||||
typedef unsigned int uint_t;
|
typedef unsigned int uint_t;
|
||||||
|
|
|
@ -41,7 +41,7 @@ typedef enum uio_rw {
|
||||||
typedef enum uio_seg {
|
typedef enum uio_seg {
|
||||||
UIO_USERSPACE = 0,
|
UIO_USERSPACE = 0,
|
||||||
UIO_SYSSPACE = 1,
|
UIO_SYSSPACE = 1,
|
||||||
UIO_USERISPACE= 2,
|
UIO_USERISPACE = 2,
|
||||||
UIO_BVEC = 3,
|
UIO_BVEC = 3,
|
||||||
} uio_seg_t;
|
} uio_seg_t;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ typedef struct spl_fid {
|
||||||
long fid_pad;
|
long fid_pad;
|
||||||
struct {
|
struct {
|
||||||
ushort_t len; /* length of data in bytes */
|
ushort_t len; /* length of data in bytes */
|
||||||
char data[MAXFIDSZ];/* data (variable len) */
|
char data[MAXFIDSZ]; /* data (variable len) */
|
||||||
} _fid;
|
} _fid;
|
||||||
} un;
|
} un;
|
||||||
} fid_t;
|
} fid_t;
|
||||||
|
|
|
@ -48,9 +48,9 @@ copyin(const void *from, void *to, size_t len)
|
||||||
{
|
{
|
||||||
/* On error copyin routine returns -1 */
|
/* On error copyin routine returns -1 */
|
||||||
if (xcopyin(from, to, len))
|
if (xcopyin(from, to, len))
|
||||||
return -1;
|
return (-1);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int
|
static __inline__ int
|
||||||
|
@ -58,9 +58,9 @@ copyout(const void *from, void *to, size_t len)
|
||||||
{
|
{
|
||||||
/* On error copyout routine returns -1 */
|
/* On error copyout routine returns -1 */
|
||||||
if (xcopyout(from, to, len))
|
if (xcopyout(from, to, len))
|
||||||
return -1;
|
return (-1);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static __inline__ int
|
static __inline__ int
|
||||||
|
@ -69,7 +69,7 @@ copyinstr(const void *from, void *to, size_t len, size_t *done)
|
||||||
size_t rc;
|
size_t rc;
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return -ENAMETOOLONG;
|
return (-ENAMETOOLONG);
|
||||||
|
|
||||||
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
/* XXX: Should return ENAMETOOLONG if 'strlen(from) > len' */
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ copyinstr(const void *from, void *to, size_t len, size_t *done)
|
||||||
if (done != NULL)
|
if (done != NULL)
|
||||||
*done = rc;
|
*done = rc;
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* SPL_VMSYSTM_H */
|
#endif /* SPL_VMSYSTM_H */
|
||||||
|
|
|
@ -121,8 +121,8 @@ typedef enum vtype {
|
||||||
|
|
||||||
typedef struct vattr {
|
typedef struct vattr {
|
||||||
enum vtype va_type; /* vnode type */
|
enum vtype va_type; /* vnode type */
|
||||||
u_int va_mask; /* attribute bit-mask */
|
uint_t va_mask; /* attribute bit-mask */
|
||||||
u_short va_mode; /* acc mode */
|
ushort_t va_mode; /* acc mode */
|
||||||
uid_t va_uid; /* owner uid */
|
uid_t va_uid; /* owner uid */
|
||||||
gid_t va_gid; /* owner gid */
|
gid_t va_gid; /* owner gid */
|
||||||
long va_fsid; /* fs id */
|
long va_fsid; /* fs id */
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
|
*
|
||||||
* z_compress_level/z_uncompress are nearly identical copies of the
|
* z_compress_level/z_uncompress are nearly identical copies of the
|
||||||
* compress2/uncompress functions provided by the official zlib package
|
* compress2/uncompress functions provided by the official zlib package
|
||||||
* available at http://zlib.net/. The only changes made we to slightly
|
* available at http://zlib.net/. The only changes made we to slightly
|
||||||
|
|
|
@ -20,18 +20,12 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Atomic Implementation.
|
* Solaris Porting Layer (SPL) Atomic Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/atomic.h>
|
#include <sys/atomic.h>
|
||||||
|
|
||||||
#ifdef DEBUG_SUBSYSTEM
|
|
||||||
#undef DEBUG_SUBSYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_SUBSYSTEM S_ATOMIC
|
|
||||||
|
|
||||||
#ifdef ATOMIC_SPINLOCK
|
#ifdef ATOMIC_SPINLOCK
|
||||||
/* Global atomic lock declarations */
|
/* Global atomic lock declarations */
|
||||||
DEFINE_SPINLOCK(atomic32_lock);
|
DEFINE_SPINLOCK(atomic32_lock);
|
||||||
|
|
|
@ -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.
|
* Compatibility wrapper for the cv_timedwait_hires() Illumos interface.
|
||||||
*/
|
*/
|
||||||
static clock_t
|
static clock_t
|
||||||
cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,
|
cv_timedwait_hires_common(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim,
|
||||||
int flag, int state)
|
hrtime_t res, int flag, int state)
|
||||||
{
|
{
|
||||||
if (res > 1) {
|
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);
|
EXPORT_SYMBOL(cv_timedwait_hires);
|
||||||
|
|
||||||
clock_t
|
clock_t
|
||||||
cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim, hrtime_t res,
|
cv_timedwait_sig_hires(kcondvar_t *cvp, kmutex_t *mp, hrtime_t tim,
|
||||||
int flag)
|
hrtime_t res, int flag)
|
||||||
{
|
{
|
||||||
return (cv_timedwait_hires_common(cvp, mp, tim, res, flag,
|
return (cv_timedwait_hires_common(cvp, mp, tim, res, flag,
|
||||||
TASK_INTERRUPTIBLE));
|
TASK_INTERRUPTIBLE));
|
||||||
|
|
|
@ -20,18 +20,12 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Credential Implementation.
|
* Solaris Porting Layer (SPL) Credential Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cred.h>
|
#include <sys/cred.h>
|
||||||
|
|
||||||
#ifdef DEBUG_SUBSYSTEM
|
|
||||||
#undef DEBUG_SUBSYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_SUBSYSTEM S_CRED
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
#ifdef HAVE_KUIDGID_T
|
#ifdef HAVE_KUIDGID_T
|
||||||
cr_groups_search(const struct group_info *group_info, kgid_t grp)
|
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;
|
int cmp;
|
||||||
|
|
||||||
if (!group_info)
|
if (!group_info)
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
left = 0;
|
left = 0;
|
||||||
right = group_info->ngroups;
|
right = group_info->ngroups;
|
||||||
|
@ -57,16 +51,16 @@ cr_groups_search(const struct group_info *group_info, gid_t grp)
|
||||||
else if (cmp < 0)
|
else if (cmp < 0)
|
||||||
right = mid;
|
right = mid;
|
||||||
else
|
else
|
||||||
return 1;
|
return (1);
|
||||||
}
|
}
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hold a reference on the credential */
|
/* Hold a reference on the credential */
|
||||||
void
|
void
|
||||||
crhold(cred_t *cr)
|
crhold(cred_t *cr)
|
||||||
{
|
{
|
||||||
(void)get_cred((const cred_t *)cr);
|
(void) get_cred((const cred_t *)cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free a reference on the credential */
|
/* Free a reference on the credential */
|
||||||
|
@ -96,7 +90,7 @@ crgetngroups(const cred_t *cr)
|
||||||
rc = NGROUPS_PER_BLOCK;
|
rc = NGROUPS_PER_BLOCK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -119,7 +113,7 @@ crgetgroups(const cred_t *cr)
|
||||||
if (gi->nblocks > 0)
|
if (gi->nblocks > 0)
|
||||||
gids = KGIDP_TO_SGIDP(gi->blocks[0]);
|
gids = KGIDP_TO_SGIDP(gi->blocks[0]);
|
||||||
#endif
|
#endif
|
||||||
return gids;
|
return (gids);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the passed gid is available in supplied credential. */
|
/* 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;
|
gi = cr->group_info;
|
||||||
rc = cr_groups_search(gi, SGID_TO_KGID(gid));
|
rc = cr_groups_search(gi, SGID_TO_KGID(gid));
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the effective user id */
|
/* Return the effective user id */
|
||||||
uid_t
|
uid_t
|
||||||
crgetuid(const cred_t *cr)
|
crgetuid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KUID_TO_SUID(cr->euid);
|
return (KUID_TO_SUID(cr->euid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the real user id */
|
/* Return the real user id */
|
||||||
uid_t
|
uid_t
|
||||||
crgetruid(const cred_t *cr)
|
crgetruid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KUID_TO_SUID(cr->uid);
|
return (KUID_TO_SUID(cr->uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the saved user id */
|
/* Return the saved user id */
|
||||||
uid_t
|
uid_t
|
||||||
crgetsuid(const cred_t *cr)
|
crgetsuid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KUID_TO_SUID(cr->suid);
|
return (KUID_TO_SUID(cr->suid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the filesystem user id */
|
/* Return the filesystem user id */
|
||||||
uid_t
|
uid_t
|
||||||
crgetfsuid(const cred_t *cr)
|
crgetfsuid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KUID_TO_SUID(cr->fsuid);
|
return (KUID_TO_SUID(cr->fsuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the effective group id */
|
/* Return the effective group id */
|
||||||
gid_t
|
gid_t
|
||||||
crgetgid(const cred_t *cr)
|
crgetgid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KGID_TO_SGID(cr->egid);
|
return (KGID_TO_SGID(cr->egid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the real group id */
|
/* Return the real group id */
|
||||||
gid_t
|
gid_t
|
||||||
crgetrgid(const cred_t *cr)
|
crgetrgid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KGID_TO_SGID(cr->gid);
|
return (KGID_TO_SGID(cr->gid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the saved group id */
|
/* Return the saved group id */
|
||||||
gid_t
|
gid_t
|
||||||
crgetsgid(const cred_t *cr)
|
crgetsgid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KGID_TO_SGID(cr->sgid);
|
return (KGID_TO_SGID(cr->sgid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the filesystem group id */
|
/* Return the filesystem group id */
|
||||||
gid_t
|
gid_t
|
||||||
crgetfsgid(const cred_t *cr)
|
crgetfsgid(const cred_t *cr)
|
||||||
{
|
{
|
||||||
return KGID_TO_SGID(cr->fsgid);
|
return (KGID_TO_SGID(cr->fsgid));
|
||||||
}
|
}
|
||||||
|
|
||||||
EXPORT_SYMBOL(crhold);
|
EXPORT_SYMBOL(crhold);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Error Implementation.
|
* Solaris Porting Layer (SPL) Error Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@
|
||||||
*/
|
*/
|
||||||
unsigned int spl_panic_halt;
|
unsigned int spl_panic_halt;
|
||||||
module_param(spl_panic_halt, uint, 0644);
|
module_param(spl_panic_halt, uint, 0644);
|
||||||
MODULE_PARM_DESC(spl_panic_halt,
|
MODULE_PARM_DESC(spl_panic_halt, "Cause kernel panic on assertion failures");
|
||||||
"Cause kernel panic on assertion failures");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Limit the number of stack traces dumped to not more than 5 every
|
* Limit the number of stack traces dumped to not more than 5 every
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Generic Implementation.
|
* Solaris Porting Layer (SPL) Generic Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -109,13 +109,14 @@ spl_rand_next(uint64_t *s) {
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
spl_rand_jump(uint64_t *s) {
|
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 s0 = 0;
|
||||||
uint64_t s1 = 0;
|
uint64_t s1 = 0;
|
||||||
int i, b;
|
int i, b;
|
||||||
for(i = 0; i < sizeof JUMP / sizeof *JUMP; i++)
|
for (i = 0; i < sizeof (JUMP) / sizeof (*JUMP); i++)
|
||||||
for(b = 0; b < 64; b++) {
|
for (b = 0; b < 64; b++) {
|
||||||
if (JUMP[i] & 1ULL << b) {
|
if (JUMP[i] & 1ULL << b) {
|
||||||
s0 ^= s[0];
|
s0 ^= s[0];
|
||||||
s1 ^= s[1];
|
s1 ^= s[1];
|
||||||
|
@ -187,16 +188,16 @@ nlz64(uint64_t x) {
|
||||||
register int n = 0;
|
register int n = 0;
|
||||||
|
|
||||||
if (x == 0)
|
if (x == 0)
|
||||||
return 64;
|
return (64);
|
||||||
|
|
||||||
if (x <= 0x00000000FFFFFFFFULL) {n = n + 32; x = x << 32;}
|
if (x <= 0x00000000FFFFFFFFULL) { n = n + 32; x = x << 32; }
|
||||||
if (x <= 0x0000FFFFFFFFFFFFULL) {n = n + 16; x = x << 16;}
|
if (x <= 0x0000FFFFFFFFFFFFULL) { n = n + 16; x = x << 16; }
|
||||||
if (x <= 0x00FFFFFFFFFFFFFFULL) {n = n + 8; x = x << 8;}
|
if (x <= 0x00FFFFFFFFFFFFFFULL) { n = n + 8; x = x << 8; }
|
||||||
if (x <= 0x0FFFFFFFFFFFFFFFULL) {n = n + 4; x = x << 4;}
|
if (x <= 0x0FFFFFFFFFFFFFFFULL) { n = n + 4; x = x << 4; }
|
||||||
if (x <= 0x3FFFFFFFFFFFFFFFULL) {n = n + 2; x = x << 2;}
|
if (x <= 0x3FFFFFFFFFFFFFFFULL) { n = n + 2; x = x << 2; }
|
||||||
if (x <= 0x7FFFFFFFFFFFFFFFULL) {n = n + 1;}
|
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)
|
__div_u64(uint64_t u, uint32_t v)
|
||||||
{
|
{
|
||||||
(void) do_div(u, 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 (v >> 32 == 0) { // If v < 2**32:
|
||||||
if (u >> 32 < v) { // If u/v cannot overflow,
|
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:
|
} else { // If u/v would overflow:
|
||||||
u1 = u >> 32; // Break u into two halves.
|
u1 = u >> 32; // Break u into two halves.
|
||||||
u0 = u & 0xFFFFFFFF;
|
u0 = u & 0xFFFFFFFF;
|
||||||
|
@ -235,7 +236,7 @@ __udivdi3(uint64_t u, uint64_t v)
|
||||||
k = u1 - q1 * v; // First remainder, < v.
|
k = u1 - q1 * v; // First remainder, < v.
|
||||||
u0 += (k << 32);
|
u0 += (k << 32);
|
||||||
q0 = __div_u64(u0, v); // Seconds quotient digit.
|
q0 = __div_u64(u0, v); // Seconds quotient digit.
|
||||||
return (q1 << 32) + q0;
|
return ((q1 << 32) + q0);
|
||||||
}
|
}
|
||||||
} else { // If v >= 2**32:
|
} else { // If v >= 2**32:
|
||||||
n = nlz64(v); // 0 <= n <= 31.
|
n = nlz64(v); // 0 <= n <= 31.
|
||||||
|
@ -249,7 +250,7 @@ __udivdi3(uint64_t u, uint64_t v)
|
||||||
if ((u - q0 * v) >= v)
|
if ((u - q0 * v) >= v)
|
||||||
q0 = q0 + 1; // Now q0 is correct.
|
q0 = q0 + 1; // Now q0 is correct.
|
||||||
|
|
||||||
return q0;
|
return (q0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__udivdi3);
|
EXPORT_SYMBOL(__udivdi3);
|
||||||
|
@ -263,7 +264,7 @@ __divdi3(int64_t u, int64_t v)
|
||||||
int64_t q, t;
|
int64_t q, t;
|
||||||
q = __udivdi3(abs64(u), abs64(v));
|
q = __udivdi3(abs64(u), abs64(v));
|
||||||
t = (u ^ v) >> 63; // If u, v have different
|
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);
|
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 r2 asm("r2") = (mod & 0xFFFFFFFF);
|
||||||
register uint32_t r3 asm("r3") = (mod >> 32);
|
register uint32_t r3 asm("r3") = (mod >> 32);
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
asm volatile(""
|
asm volatile(""
|
||||||
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
|
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
|
||||||
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
|
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
return; /* r0; */
|
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 r2 asm("r2") = (mod & 0xFFFFFFFF);
|
||||||
register uint32_t r3 asm("r3") = (mod >> 32);
|
register uint32_t r3 asm("r3") = (mod >> 32);
|
||||||
|
|
||||||
|
/* BEGIN CSTYLED */
|
||||||
asm volatile(""
|
asm volatile(""
|
||||||
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
|
: "+r"(r0), "+r"(r1), "+r"(r2),"+r"(r3) /* output */
|
||||||
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
|
: "r"(r0), "r"(r1), "r"(r2), "r"(r3)); /* input */
|
||||||
|
/* END CSTYLED */
|
||||||
|
|
||||||
return; /* r0; */
|
return; /* r0; */
|
||||||
}
|
}
|
||||||
|
@ -378,7 +383,8 @@ EXPORT_SYMBOL(__aeabi_ldivmod);
|
||||||
#endif /* __arm || __arm__ */
|
#endif /* __arm || __arm__ */
|
||||||
#endif /* BITS_PER_LONG */
|
#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
|
* ddi_strtol(9F) man page. I have not verified the behavior of these
|
||||||
* functions against their Solaris counterparts. It is possible that I
|
* functions against their Solaris counterparts. It is possible that I
|
||||||
* may have misinterpreted the man page or the man page is incorrect.
|
* may have misinterpreted the man page or the man page is incorrect.
|
||||||
|
@ -397,19 +403,19 @@ int ddi_strtou##type(const char *str, char **endptr, \
|
||||||
int flag = 1, digit; \
|
int flag = 1, digit; \
|
||||||
\
|
\
|
||||||
if (strlen(ptr) == 0) \
|
if (strlen(ptr) == 0) \
|
||||||
return EINVAL; \
|
return (EINVAL); \
|
||||||
\
|
\
|
||||||
/* Auto-detect base based on prefix */ \
|
/* Auto-detect base based on prefix */ \
|
||||||
if (!base) { \
|
if (!base) { \
|
||||||
if (str[0] == '0') { \
|
if (str[0] == '0') { \
|
||||||
if (tolower(str[1])=='x' && isxdigit(str[2])) { \
|
if (tolower(str[1]) == 'x' && isxdigit(str[2])) { \
|
||||||
base = 16; /* hex */ \
|
base = 16; /* hex */ \
|
||||||
ptr += 2; \
|
ptr += 2; \
|
||||||
} else if (str[1] >= '0' && str[1] < 8) { \
|
} else if (str[1] >= '0' && str[1] < 8) { \
|
||||||
base = 8; /* octal */ \
|
base = 8; /* octal */ \
|
||||||
ptr += 1; \
|
ptr += 1; \
|
||||||
} else { \
|
} else { \
|
||||||
return EINVAL; \
|
return (EINVAL); \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
base = 10; /* decimal */ \
|
base = 10; /* decimal */ \
|
||||||
|
@ -430,7 +436,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
|
||||||
last_value = value; \
|
last_value = value; \
|
||||||
value = value * base + digit; \
|
value = value * base + digit; \
|
||||||
if (last_value > value) /* Overflow */ \
|
if (last_value > value) /* Overflow */ \
|
||||||
return ERANGE; \
|
return (ERANGE); \
|
||||||
\
|
\
|
||||||
flag = 1; \
|
flag = 1; \
|
||||||
ptr++; \
|
ptr++; \
|
||||||
|
@ -442,7 +448,7 @@ int ddi_strtou##type(const char *str, char **endptr, \
|
||||||
if (endptr) \
|
if (endptr) \
|
||||||
*endptr = (char *)(flag ? ptr : str); \
|
*endptr = (char *)(flag ? ptr : str); \
|
||||||
\
|
\
|
||||||
return 0; \
|
return (0); \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#define define_ddi_strtox(type, valtype) \
|
#define define_ddi_strtox(type, valtype) \
|
||||||
|
@ -463,7 +469,7 @@ int ddi_strto##type(const char *str, char **endptr, \
|
||||||
rc = ddi_strtou##type(str, endptr, base, result); \
|
rc = ddi_strtou##type(str, endptr, base, result); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return rc; \
|
return (rc); \
|
||||||
}
|
}
|
||||||
|
|
||||||
define_ddi_strtoux(l, unsigned long)
|
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 */
|
/* Fake ioctl() issued by kernel, 'from' is a kernel address */
|
||||||
if (flags & FKIOCTL) {
|
if (flags & FKIOCTL) {
|
||||||
memcpy(to, from, len);
|
memcpy(to, from, len);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copyin(from, to, len);
|
return (copyin(from, to, len));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ddi_copyin);
|
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 */
|
/* Fake ioctl() issued by kernel, 'from' is a kernel address */
|
||||||
if (flags & FKIOCTL) {
|
if (flags & FKIOCTL) {
|
||||||
memcpy(to, from, len);
|
memcpy(to, from, len);
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return copyout(from, to, len);
|
return (copyout(from, to, len));
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(ddi_copyout);
|
EXPORT_SYMBOL(ddi_copyout);
|
||||||
|
|
||||||
|
@ -559,7 +565,7 @@ hostid_read(uint32_t *hostid)
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size < sizeof(HW_HOSTID_MASK)) {
|
if (size < sizeof (HW_HOSTID_MASK)) {
|
||||||
kobj_close_file(file);
|
kobj_close_file(file);
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
@ -568,7 +574,7 @@ hostid_read(uint32_t *hostid)
|
||||||
* Read directly into the variable like eglibc does.
|
* Read directly into the variable like eglibc does.
|
||||||
* Short reads are okay; native behavior is preserved.
|
* 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) {
|
if (error < 0) {
|
||||||
kobj_close_file(file);
|
kobj_close_file(file);
|
||||||
return (EIO);
|
return (EIO);
|
||||||
|
@ -578,7 +584,7 @@ hostid_read(uint32_t *hostid)
|
||||||
*hostid = (value & HW_HOSTID_MASK);
|
*hostid = (value & HW_HOSTID_MASK);
|
||||||
kobj_close_file(file);
|
kobj_close_file(file);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1186,7 +1186,7 @@ spl_cache_grow_work(void *data)
|
||||||
spl_kmem_alloc_t *ska = (spl_kmem_alloc_t *)data;
|
spl_kmem_alloc_t *ska = (spl_kmem_alloc_t *)data;
|
||||||
spl_kmem_cache_t *skc = ska->ska_cache;
|
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);
|
atomic_dec(&skc->skc_ref);
|
||||||
smp_mb__before_atomic();
|
smp_mb__before_atomic();
|
||||||
|
|
|
@ -383,7 +383,7 @@ spl_kmem_free_track(const void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
kmem_debug_t *dptr;
|
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)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Kobj Implementation.
|
* Solaris Porting Layer (SPL) Kobj Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ kobj_open_file(const char *name)
|
||||||
vnode_t *vp;
|
vnode_t *vp;
|
||||||
int rc;
|
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)
|
if (file == NULL)
|
||||||
return ((_buf_t *)-1UL);
|
return ((_buf_t *)-1UL);
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Kstat Implementation.
|
* Solaris Porting Layer (SPL) Kstat Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@ static int
|
||||||
kstat_resize_raw(kstat_t *ksp)
|
kstat_resize_raw(kstat_t *ksp)
|
||||||
{
|
{
|
||||||
if (ksp->ks_raw_bufsize == KSTAT_RAW_MAX)
|
if (ksp->ks_raw_bufsize == KSTAT_RAW_MAX)
|
||||||
return ENOMEM;
|
return (ENOMEM);
|
||||||
|
|
||||||
vmem_free(ksp->ks_raw_buf, ksp->ks_raw_bufsize);
|
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_bufsize = MIN(ksp->ks_raw_bufsize * 2, KSTAT_RAW_MAX);
|
||||||
ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP);
|
ksp->ks_raw_buf = vmem_alloc(ksp->ks_raw_bufsize, KM_SLEEP);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -172,7 +172,7 @@ restart:
|
||||||
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -rc;
|
return (-rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -194,7 +194,7 @@ kstat_seq_show_raw(struct seq_file *f, unsigned char *p, int l)
|
||||||
seq_printf(f, "\n");
|
seq_printf(f, "\n");
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -207,7 +207,8 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
|
||||||
knp->value.c[15] = '\0'; /* NULL terminate */
|
knp->value.c[15] = '\0'; /* NULL terminate */
|
||||||
seq_printf(f, "%-16s", knp->value.c);
|
seq_printf(f, "%-16s", knp->value.c);
|
||||||
break;
|
break;
|
||||||
/* XXX - We need to be more careful able what tokens are
|
/*
|
||||||
|
* NOTE - We need to be more careful able what tokens are
|
||||||
* used for each arch, for now this is correct for x86_64.
|
* used for each arch, for now this is correct for x86_64.
|
||||||
*/
|
*/
|
||||||
case KSTAT_DATA_INT32:
|
case KSTAT_DATA_INT32:
|
||||||
|
@ -220,7 +221,8 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
|
||||||
seq_printf(f, "%lld", (signed long long)knp->value.i64);
|
seq_printf(f, "%lld", (signed long long)knp->value.i64);
|
||||||
break;
|
break;
|
||||||
case KSTAT_DATA_UINT64:
|
case KSTAT_DATA_UINT64:
|
||||||
seq_printf(f, "%llu", (unsigned long long)knp->value.ui64);
|
seq_printf(f, "%llu",
|
||||||
|
(unsigned long long)knp->value.ui64);
|
||||||
break;
|
break;
|
||||||
case KSTAT_DATA_LONG:
|
case KSTAT_DATA_LONG:
|
||||||
seq_printf(f, "%ld", knp->value.l);
|
seq_printf(f, "%ld", knp->value.l);
|
||||||
|
@ -239,7 +241,7 @@ kstat_seq_show_named(struct seq_file *f, kstat_named_t *knp)
|
||||||
|
|
||||||
seq_printf(f, "\n");
|
seq_printf(f, "\n");
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -252,7 +254,7 @@ kstat_seq_show_intr(struct seq_file *f, kstat_intr_t *kip)
|
||||||
kip->intrs[KSTAT_INTR_SPURIOUS],
|
kip->intrs[KSTAT_INTR_SPURIOUS],
|
||||||
kip->intrs[KSTAT_INTR_MULTSVC]);
|
kip->intrs[KSTAT_INTR_MULTSVC]);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -267,7 +269,7 @@ kstat_seq_show_io(struct seq_file *f, kstat_io_t *kip)
|
||||||
kip->rtime, kip->rlentime, kip->rlastupdate,
|
kip->rtime, kip->rlentime, kip->rlastupdate,
|
||||||
kip->wcnt, kip->rcnt);
|
kip->wcnt, kip->rcnt);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -279,7 +281,7 @@ kstat_seq_show_timer(struct seq_file *f, kstat_timer_t *ktp)
|
||||||
ktp->min_time, ktp->max_time,
|
ktp->min_time, ktp->max_time,
|
||||||
ktp->start_time, ktp->stop_time);
|
ktp->start_time, ktp->stop_time);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -322,7 +324,7 @@ restart:
|
||||||
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -rc;
|
return (-rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -333,7 +335,7 @@ kstat_default_update(kstat_t *ksp, int rw)
|
||||||
if (rw == KSTAT_WRITE)
|
if (rw == KSTAT_WRITE)
|
||||||
return (EACCES);
|
return (EACCES);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -349,16 +351,16 @@ kstat_seq_data_addr(kstat_t *ksp, loff_t n)
|
||||||
rc = ksp->ks_data;
|
rc = ksp->ks_data;
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_NAMED:
|
case KSTAT_TYPE_NAMED:
|
||||||
rc = ksp->ks_data + n * sizeof(kstat_named_t);
|
rc = ksp->ks_data + n * sizeof (kstat_named_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_INTR:
|
case KSTAT_TYPE_INTR:
|
||||||
rc = ksp->ks_data + n * sizeof(kstat_intr_t);
|
rc = ksp->ks_data + n * sizeof (kstat_intr_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_IO:
|
case KSTAT_TYPE_IO:
|
||||||
rc = ksp->ks_data + n * sizeof(kstat_io_t);
|
rc = ksp->ks_data + n * sizeof (kstat_io_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_TIMER:
|
case KSTAT_TYPE_TIMER:
|
||||||
rc = ksp->ks_data + n * sizeof(kstat_timer_t);
|
rc = ksp->ks_data + n * sizeof (kstat_timer_t);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
||||||
|
@ -465,7 +467,7 @@ kstat_delete_module(kstat_module_t *module)
|
||||||
ASSERT(list_empty(&module->ksm_kstat_list));
|
ASSERT(list_empty(&module->ksm_kstat_list));
|
||||||
remove_proc_entry(module->ksm_name, proc_spl_kstat);
|
remove_proc_entry(module->ksm_name, proc_spl_kstat);
|
||||||
list_del(&module->ksm_module_list);
|
list_del(&module->ksm_module_list);
|
||||||
kmem_free(module, sizeof(kstat_module_t));
|
kmem_free(module, sizeof (kstat_module_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -476,17 +478,17 @@ proc_kstat_open(struct inode *inode, struct file *filp)
|
||||||
|
|
||||||
rc = seq_open(filp, &kstat_seq_ops);
|
rc = seq_open(filp, &kstat_seq_ops);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return (rc);
|
||||||
|
|
||||||
f = filp->private_data;
|
f = filp->private_data;
|
||||||
f->private = PDE_DATA(inode);
|
f->private = PDE_DATA(inode);
|
||||||
|
|
||||||
return rc;
|
return (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
proc_kstat_write(struct file *filp, const char __user *buf,
|
proc_kstat_write(struct file *filp, const char __user *buf, size_t len,
|
||||||
size_t len, loff_t *ppos)
|
loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct seq_file *f = filp->private_data;
|
struct seq_file *f = filp->private_data;
|
||||||
kstat_t *ksp = f->private;
|
kstat_t *ksp = f->private;
|
||||||
|
@ -540,9 +542,9 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
|
||||||
if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO))
|
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)
|
if (ksp == NULL)
|
||||||
return ksp;
|
return (ksp);
|
||||||
|
|
||||||
mutex_enter(&kstat_module_lock);
|
mutex_enter(&kstat_module_lock);
|
||||||
ksp->ks_kid = kstat_id;
|
ksp->ks_kid = kstat_id;
|
||||||
|
@ -577,19 +579,19 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_NAMED:
|
case KSTAT_TYPE_NAMED:
|
||||||
ksp->ks_ndata = ks_ndata;
|
ksp->ks_ndata = ks_ndata;
|
||||||
ksp->ks_data_size = ks_ndata * sizeof(kstat_named_t);
|
ksp->ks_data_size = ks_ndata * sizeof (kstat_named_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_INTR:
|
case KSTAT_TYPE_INTR:
|
||||||
ksp->ks_ndata = ks_ndata;
|
ksp->ks_ndata = ks_ndata;
|
||||||
ksp->ks_data_size = ks_ndata * sizeof(kstat_intr_t);
|
ksp->ks_data_size = ks_ndata * sizeof (kstat_intr_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_IO:
|
case KSTAT_TYPE_IO:
|
||||||
ksp->ks_ndata = ks_ndata;
|
ksp->ks_ndata = ks_ndata;
|
||||||
ksp->ks_data_size = ks_ndata * sizeof(kstat_io_t);
|
ksp->ks_data_size = ks_ndata * sizeof (kstat_io_t);
|
||||||
break;
|
break;
|
||||||
case KSTAT_TYPE_TIMER:
|
case KSTAT_TYPE_TIMER:
|
||||||
ksp->ks_ndata = ks_ndata;
|
ksp->ks_ndata = ks_ndata;
|
||||||
ksp->ks_data_size = ks_ndata * sizeof(kstat_timer_t);
|
ksp->ks_data_size = ks_ndata * sizeof (kstat_timer_t);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
PANIC("Undefined kstat type %d\n", ksp->ks_type);
|
||||||
|
@ -600,12 +602,12 @@ __kstat_create(const char *ks_module, int ks_instance, const char *ks_name,
|
||||||
} else {
|
} else {
|
||||||
ksp->ks_data = kmem_zalloc(ksp->ks_data_size, KM_SLEEP);
|
ksp->ks_data = kmem_zalloc(ksp->ks_data_size, KM_SLEEP);
|
||||||
if (ksp->ks_data == NULL) {
|
if (ksp->ks_data == NULL) {
|
||||||
kmem_free(ksp, sizeof(*ksp));
|
kmem_free(ksp, sizeof (*ksp));
|
||||||
ksp = NULL;
|
ksp = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ksp;
|
return (ksp);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__kstat_create);
|
EXPORT_SYMBOL(__kstat_create);
|
||||||
|
|
||||||
|
@ -706,9 +708,7 @@ __kstat_delete(kstat_t *ksp)
|
||||||
|
|
||||||
ksp->ks_lock = NULL;
|
ksp->ks_lock = NULL;
|
||||||
mutex_destroy(&ksp->ks_private_lock);
|
mutex_destroy(&ksp->ks_private_lock);
|
||||||
kmem_free(ksp, sizeof(*ksp));
|
kmem_free(ksp, sizeof (*ksp));
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__kstat_delete);
|
EXPORT_SYMBOL(__kstat_delete);
|
||||||
|
|
||||||
|
@ -727,4 +727,3 @@ spl_kstat_fini(void)
|
||||||
ASSERT(list_empty(&kstat_module_list));
|
ASSERT(list_empty(&kstat_module_list));
|
||||||
mutex_destroy(&kstat_module_lock);
|
mutex_destroy(&kstat_module_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,11 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Mutex Implementation.
|
* Solaris Porting Layer (SPL) Mutex Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/mutex.h>
|
#include <sys/mutex.h>
|
||||||
|
|
||||||
#ifdef DEBUG_SUBSYSTEM
|
|
||||||
#undef DEBUG_SUBSYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_SUBSYSTEM S_MUTEX
|
|
||||||
|
|
||||||
int spl_mutex_init(void) { return 0; }
|
int spl_mutex_init(void) { return 0; }
|
||||||
void spl_mutex_fini(void) { }
|
void spl_mutex_fini(void) { }
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Proc Implementation.
|
* Solaris Porting Layer (SPL) Proc Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/version.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;
|
typedef struct ctl_table __no_const spl_ctl_table;
|
||||||
#else
|
#else
|
||||||
typedef struct ctl_table spl_ctl_table;
|
typedef struct ctl_table spl_ctl_table;
|
||||||
|
@ -55,16 +55,16 @@ static struct proc_dir_entry *proc_spl_taskq = NULL;
|
||||||
struct proc_dir_entry *proc_spl_kstat = NULL;
|
struct proc_dir_entry *proc_spl_kstat = NULL;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
proc_copyin_string(char *kbuffer, int kbuffer_size,
|
proc_copyin_string(char *kbuffer, int kbuffer_size, const char *ubuffer,
|
||||||
const char *ubuffer, int ubuffer_size)
|
int ubuffer_size)
|
||||||
{
|
{
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (ubuffer_size > kbuffer_size)
|
if (ubuffer_size > kbuffer_size)
|
||||||
return -EOVERFLOW;
|
return (-EOVERFLOW);
|
||||||
|
|
||||||
if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size))
|
if (copy_from_user((void *)kbuffer, (void *)ubuffer, ubuffer_size))
|
||||||
return -EFAULT;
|
return (-EFAULT);
|
||||||
|
|
||||||
/* strip trailing whitespace */
|
/* strip trailing whitespace */
|
||||||
size = strnlen(kbuffer, ubuffer_size);
|
size = strnlen(kbuffer, ubuffer_size);
|
||||||
|
@ -74,37 +74,38 @@ proc_copyin_string(char *kbuffer, int kbuffer_size,
|
||||||
|
|
||||||
/* empty string */
|
/* empty string */
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return -EINVAL;
|
return (-EINVAL);
|
||||||
|
|
||||||
/* no space to terminate */
|
/* no space to terminate */
|
||||||
if (size == kbuffer_size)
|
if (size == kbuffer_size)
|
||||||
return -EOVERFLOW;
|
return (-EOVERFLOW);
|
||||||
|
|
||||||
kbuffer[size + 1] = 0;
|
kbuffer[size + 1] = 0;
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
proc_copyout_string(char *ubuffer, int ubuffer_size,
|
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
|
/*
|
||||||
|
* NB if 'append' != NULL, it's a single character to append to the
|
||||||
* copied out string - usually "\n", for /proc entries and
|
* copied out string - usually "\n", for /proc entries and
|
||||||
* (i.e. a terminating zero byte) for sysctl entries
|
* (i.e. a terminating zero byte) for sysctl entries
|
||||||
*/
|
*/
|
||||||
int size = MIN(strlen(kbuffer), ubuffer_size);
|
int size = MIN(strlen(kbuffer), ubuffer_size);
|
||||||
|
|
||||||
if (copy_to_user(ubuffer, kbuffer, size))
|
if (copy_to_user(ubuffer, kbuffer, size))
|
||||||
return -EFAULT;
|
return (-EFAULT);
|
||||||
|
|
||||||
if (append != NULL && size < ubuffer_size) {
|
if (append != NULL && size < ubuffer_size) {
|
||||||
if (copy_to_user(ubuffer + size, append, 1))
|
if (copy_to_user(ubuffer + size, append, 1))
|
||||||
return -EFAULT;
|
return (-EFAULT);
|
||||||
|
|
||||||
size++;
|
size++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return (size);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_KMEM
|
#ifdef DEBUG_KMEM
|
||||||
|
@ -124,11 +125,11 @@ proc_domemused(struct ctl_table *table, int write,
|
||||||
if (write) {
|
if (write) {
|
||||||
*ppos += *lenp;
|
*ppos += *lenp;
|
||||||
} else {
|
} else {
|
||||||
# ifdef HAVE_ATOMIC64_T
|
#ifdef HAVE_ATOMIC64_T
|
||||||
val = atomic64_read((atomic64_t *)table->data);
|
val = atomic64_read((atomic64_t *)table->data);
|
||||||
# else
|
#else
|
||||||
val = atomic_read((atomic_t *)table->data);
|
val = atomic_read((atomic_t *)table->data);
|
||||||
# endif /* HAVE_ATOMIC64_T */
|
#endif /* HAVE_ATOMIC64_T */
|
||||||
rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos);
|
rc = proc_doulongvec_minmax(&dummy, write, buffer, lenp, ppos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,10 +192,12 @@ proc_dohostid(struct ctl_table *table, int write,
|
||||||
char *end, str[32];
|
char *end, str[32];
|
||||||
|
|
||||||
if (write) {
|
if (write) {
|
||||||
/* We can't use proc_doulongvec_minmax() in the write
|
/*
|
||||||
|
* We can't use proc_doulongvec_minmax() in the write
|
||||||
* case here because hostid while a hex value has no
|
* case here because hostid while a hex value has no
|
||||||
* leading 0x which confuses the helper function. */
|
* leading 0x which confuses the helper function.
|
||||||
rc = proc_copyin_string(str, sizeof(str), buffer, *lenp);
|
*/
|
||||||
|
rc = proc_copyin_string(str, sizeof (str), buffer, *lenp);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return (rc);
|
return (rc);
|
||||||
|
|
||||||
|
@ -203,12 +206,13 @@ proc_dohostid(struct ctl_table *table, int write,
|
||||||
return (-EINVAL);
|
return (-EINVAL);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
len = snprintf(str, sizeof(str), "%lx",
|
len = snprintf(str, sizeof (str), "%lx",
|
||||||
(unsigned long) zone_get_hostid(NULL));
|
(unsigned long) zone_get_hostid(NULL));
|
||||||
if (*ppos >= len)
|
if (*ppos >= len)
|
||||||
rc = 0;
|
rc = 0;
|
||||||
else
|
else
|
||||||
rc = proc_copyout_string(buffer,*lenp,str+*ppos,"\n");
|
rc = proc_copyout_string(buffer,
|
||||||
|
*lenp, str + *ppos, "\n");
|
||||||
|
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
*lenp = rc;
|
*lenp = rc;
|
||||||
|
@ -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);
|
spin_unlock_irqrestore(&tq->tq_wait_waitq.lock, wflags);
|
||||||
|
|
||||||
/* show the base taskq contents */
|
/* 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, "%-25s ", name);
|
||||||
seq_printf(f, "%5d %5d %5d %5d %5d %5d %12d %5d %10x\n",
|
seq_printf(f, "%5d %5d %5d %5d %5d %5d %12d %5d %10x\n",
|
||||||
tq->tq_nactive, tq->tq_nthreads, tq->tq_nspawn,
|
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;
|
j = 0;
|
||||||
list_for_each_entry(tqt, &tq->tq_active_list, tqt_active_list) {
|
list_for_each_entry(tqt, &tq->tq_active_list, tqt_active_list) {
|
||||||
if (j == 0)
|
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) {
|
else if (j == 2) {
|
||||||
seq_printf(f, "\n\t ");
|
seq_printf(f, "\n\t ");
|
||||||
j = 0;
|
j = 0;
|
||||||
|
@ -457,7 +462,7 @@ slab_seq_show(struct seq_file *f, void *p)
|
||||||
|
|
||||||
spin_unlock(&skc->skc_lock);
|
spin_unlock(&skc->skc_lock);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -487,7 +492,7 @@ slab_seq_next(struct seq_file *f, void *p, loff_t *pos)
|
||||||
|
|
||||||
++*pos;
|
++*pos;
|
||||||
return ((skc->skc_list.next == &spl_kmem_cache_list) ?
|
return ((skc->skc_list.next == &spl_kmem_cache_list) ?
|
||||||
NULL : list_entry(skc->skc_list.next,spl_kmem_cache_t,skc_list));
|
NULL : list_entry(skc->skc_list.next, spl_kmem_cache_t, skc_list));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -506,7 +511,7 @@ static struct seq_operations slab_seq_ops = {
|
||||||
static int
|
static int
|
||||||
proc_slab_open(struct inode *inode, struct file *filp)
|
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 = {
|
static struct file_operations proc_slab_operations = {
|
||||||
|
@ -539,13 +544,13 @@ static struct seq_operations taskq_seq_ops = {
|
||||||
static int
|
static int
|
||||||
proc_taskq_all_open(struct inode *inode, struct file *filp)
|
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
|
static int
|
||||||
proc_taskq_open(struct inode *inode, struct file *filp)
|
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 = {
|
static struct file_operations proc_taskq_all_operations = {
|
||||||
|
@ -567,18 +572,18 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "kmem_used",
|
.procname = "kmem_used",
|
||||||
.data = &kmem_alloc_used,
|
.data = &kmem_alloc_used,
|
||||||
# ifdef HAVE_ATOMIC64_T
|
#ifdef HAVE_ATOMIC64_T
|
||||||
.maxlen = sizeof(atomic64_t),
|
.maxlen = sizeof (atomic64_t),
|
||||||
# else
|
#else
|
||||||
.maxlen = sizeof(atomic_t),
|
.maxlen = sizeof (atomic_t),
|
||||||
# endif /* HAVE_ATOMIC64_T */
|
#endif /* HAVE_ATOMIC64_T */
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
.proc_handler = &proc_domemused,
|
.proc_handler = &proc_domemused,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.procname = "kmem_max",
|
.procname = "kmem_max",
|
||||||
.data = &kmem_alloc_max,
|
.data = &kmem_alloc_max,
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -588,7 +593,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_kmem_total",
|
.procname = "slab_kmem_total",
|
||||||
.data = (void *)(KMC_KMEM | KMC_TOTAL),
|
.data = (void *)(KMC_KMEM | KMC_TOTAL),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -597,7 +602,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_kmem_alloc",
|
.procname = "slab_kmem_alloc",
|
||||||
.data = (void *)(KMC_KMEM | KMC_ALLOC),
|
.data = (void *)(KMC_KMEM | KMC_ALLOC),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -606,7 +611,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_kmem_max",
|
.procname = "slab_kmem_max",
|
||||||
.data = (void *)(KMC_KMEM | KMC_MAX),
|
.data = (void *)(KMC_KMEM | KMC_MAX),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -615,7 +620,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_vmem_total",
|
.procname = "slab_vmem_total",
|
||||||
.data = (void *)(KMC_VMEM | KMC_TOTAL),
|
.data = (void *)(KMC_VMEM | KMC_TOTAL),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -624,7 +629,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_vmem_alloc",
|
.procname = "slab_vmem_alloc",
|
||||||
.data = (void *)(KMC_VMEM | KMC_ALLOC),
|
.data = (void *)(KMC_VMEM | KMC_ALLOC),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -633,7 +638,7 @@ static struct ctl_table spl_kmem_table[] = {
|
||||||
{
|
{
|
||||||
.procname = "slab_vmem_max",
|
.procname = "slab_vmem_max",
|
||||||
.data = (void *)(KMC_VMEM | KMC_MAX),
|
.data = (void *)(KMC_VMEM | KMC_MAX),
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.extra1 = &table_min,
|
.extra1 = &table_min,
|
||||||
.extra2 = &table_max,
|
.extra2 = &table_max,
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
|
@ -647,20 +652,21 @@ static struct ctl_table spl_kstat_table[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ctl_table spl_table[] = {
|
static struct ctl_table spl_table[] = {
|
||||||
/* NB No .strategy entries have been provided since
|
/*
|
||||||
|
* NB No .strategy entries have been provided since
|
||||||
* sysctl(8) prefers to go via /proc for portability.
|
* sysctl(8) prefers to go via /proc for portability.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
.procname = "version",
|
.procname = "version",
|
||||||
.data = spl_version,
|
.data = spl_version,
|
||||||
.maxlen = sizeof(spl_version),
|
.maxlen = sizeof (spl_version),
|
||||||
.mode = 0444,
|
.mode = 0444,
|
||||||
.proc_handler = &proc_dostring,
|
.proc_handler = &proc_dostring,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.procname = "hostid",
|
.procname = "hostid",
|
||||||
.data = &spl_hostid,
|
.data = &spl_hostid,
|
||||||
.maxlen = sizeof(unsigned long),
|
.maxlen = sizeof (unsigned long),
|
||||||
.mode = 0644,
|
.mode = 0644,
|
||||||
.proc_handler = &proc_dohostid,
|
.proc_handler = &proc_dohostid,
|
||||||
},
|
},
|
||||||
|
|
|
@ -20,18 +20,12 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Reader/Writer Lock Implementation.
|
* Solaris Porting Layer (SPL) Reader/Writer Lock Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/rwlock.h>
|
#include <sys/rwlock.h>
|
||||||
|
|
||||||
#ifdef DEBUG_SUBSYSTEM
|
|
||||||
#undef DEBUG_SUBSYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define DEBUG_SUBSYSTEM S_RWLOCK
|
|
||||||
|
|
||||||
#if defined(CONFIG_PREEMPT_RT_FULL)
|
#if defined(CONFIG_PREEMPT_RT_FULL)
|
||||||
|
|
||||||
#include <linux/rtmutex.h>
|
#include <linux/rtmutex.h>
|
||||||
|
@ -94,7 +88,7 @@ __rwsem_tryupgrade(struct rw_semaphore *rwsem)
|
||||||
static int
|
static int
|
||||||
__rwsem_tryupgrade(struct rw_semaphore *rwsem)
|
__rwsem_tryupgrade(struct rw_semaphore *rwsem)
|
||||||
{
|
{
|
||||||
typeof (rwsem->count) val;
|
typeof(rwsem->count) val;
|
||||||
val = cmpxchg(&rwsem->count, SPL_RWSEM_SINGLE_READER_VALUE,
|
val = cmpxchg(&rwsem->count, SPL_RWSEM_SINGLE_READER_VALUE,
|
||||||
SPL_RWSEM_SINGLE_WRITER_VALUE);
|
SPL_RWSEM_SINGLE_WRITER_VALUE);
|
||||||
return (val == SPL_RWSEM_SINGLE_READER_VALUE);
|
return (val == SPL_RWSEM_SINGLE_READER_VALUE);
|
||||||
|
|
|
@ -87,7 +87,7 @@ taskq_find_by_name(const char *name)
|
||||||
list_for_each_prev(tql, &tq_list) {
|
list_for_each_prev(tql, &tq_list) {
|
||||||
tq = list_entry(tql, taskq_t, tq_taskqs);
|
tq = list_entry(tql, taskq_t, tq_taskqs);
|
||||||
if (strcmp(name, tq->tq_name) == 0)
|
if (strcmp(name, tq->tq_name) == 0)
|
||||||
return tq->tq_instance;
|
return (tq->tq_instance);
|
||||||
}
|
}
|
||||||
return (-1);
|
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);
|
ASSERT(tq->tq_nactive <= tq->tq_nthreads);
|
||||||
if ((flags & TQ_NOQUEUE) && (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 */
|
/* 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;
|
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)) {
|
if ((flags & TQ_NOQUEUE) && (tq->tq_nactive == tq->tq_nthreads)) {
|
||||||
/* Dynamic taskq may be able to spawn another thread */
|
/* 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;
|
goto out2;
|
||||||
flags |= TQ_FRONT;
|
flags |= TQ_FRONT;
|
||||||
}
|
}
|
||||||
|
@ -786,7 +788,8 @@ taskq_thread_spawn_task(void *arg)
|
||||||
|
|
||||||
if (taskq_thread_create(tq) == NULL) {
|
if (taskq_thread_create(tq) == NULL) {
|
||||||
/* restore spawning count if failed */
|
/* 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--;
|
tq->tq_nspawn--;
|
||||||
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
||||||
}
|
}
|
||||||
|
@ -1146,7 +1149,8 @@ taskq_destroy(taskq_t *tq)
|
||||||
while (tq->tq_nspawn) {
|
while (tq->tq_nspawn) {
|
||||||
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
spin_unlock_irqrestore(&tq->tq_lock, flags);
|
||||||
schedule_timeout_interruptible(1);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Thread Implementation.
|
* Solaris Porting Layer (SPL) Thread Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -55,12 +55,12 @@ thread_generic_wrapper(void *arg)
|
||||||
set_current_state(tp->tp_state);
|
set_current_state(tp->tp_state);
|
||||||
set_user_nice((kthread_t *)current, PRIO_TO_NICE(tp->tp_pri));
|
set_user_nice((kthread_t *)current, PRIO_TO_NICE(tp->tp_pri));
|
||||||
kmem_free(tp->tp_name, tp->tp_name_size);
|
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)
|
if (func)
|
||||||
func(args);
|
func(args);
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -72,9 +72,11 @@ __thread_exit(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(__thread_exit);
|
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
|
* 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 *
|
kthread_t *
|
||||||
__thread_create(caddr_t stk, size_t stksize, thread_func_t func,
|
__thread_create(caddr_t stk, size_t stksize, thread_func_t func,
|
||||||
const char *name, void *args, size_t len, proc_t *pp,
|
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 */
|
/* Variable stack size unsupported */
|
||||||
ASSERT(stk == NULL);
|
ASSERT(stk == NULL);
|
||||||
|
|
||||||
tp = kmem_alloc(sizeof(thread_priv_t), KM_PUSHPAGE);
|
tp = kmem_alloc(sizeof (thread_priv_t), KM_PUSHPAGE);
|
||||||
if (tp == NULL)
|
if (tp == NULL)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
|
@ -97,13 +99,14 @@ __thread_create(caddr_t stk, size_t stksize, thread_func_t func,
|
||||||
|
|
||||||
tp->tp_name = kmem_alloc(tp->tp_name_size, KM_PUSHPAGE);
|
tp->tp_name = kmem_alloc(tp->tp_name_size, KM_PUSHPAGE);
|
||||||
if (tp->tp_name == NULL) {
|
if (tp->tp_name == NULL) {
|
||||||
kmem_free(tp, sizeof(thread_priv_t));
|
kmem_free(tp, sizeof (thread_priv_t));
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(tp->tp_name, name, tp->tp_name_size);
|
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.
|
* name since the exposed API has no parameter for passing a name.
|
||||||
*/
|
*/
|
||||||
p = strstr(tp->tp_name, "_thread");
|
p = strstr(tp->tp_name, "_thread");
|
||||||
|
@ -139,7 +142,7 @@ spl_kthread_create(int (*func)(void *), void *data, const char namefmt[], ...)
|
||||||
char name[TASK_COMM_LEN];
|
char name[TASK_COMM_LEN];
|
||||||
|
|
||||||
va_start(args, namefmt);
|
va_start(args, namefmt);
|
||||||
vsnprintf(name, sizeof(name), namefmt, args);
|
vsnprintf(name, sizeof (name), namefmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
do {
|
do {
|
||||||
tsk = kthread_create(func, data, "%s", name);
|
tsk = kthread_create(func, data, "%s", name);
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) Vnode Implementation.
|
* Solaris Porting Layer (SPL) Vnode Implementation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -43,27 +43,27 @@ vtype_t
|
||||||
vn_mode_to_vtype(mode_t mode)
|
vn_mode_to_vtype(mode_t mode)
|
||||||
{
|
{
|
||||||
if (S_ISREG(mode))
|
if (S_ISREG(mode))
|
||||||
return VREG;
|
return (VREG);
|
||||||
|
|
||||||
if (S_ISDIR(mode))
|
if (S_ISDIR(mode))
|
||||||
return VDIR;
|
return (VDIR);
|
||||||
|
|
||||||
if (S_ISCHR(mode))
|
if (S_ISCHR(mode))
|
||||||
return VCHR;
|
return (VCHR);
|
||||||
|
|
||||||
if (S_ISBLK(mode))
|
if (S_ISBLK(mode))
|
||||||
return VBLK;
|
return (VBLK);
|
||||||
|
|
||||||
if (S_ISFIFO(mode))
|
if (S_ISFIFO(mode))
|
||||||
return VFIFO;
|
return (VFIFO);
|
||||||
|
|
||||||
if (S_ISLNK(mode))
|
if (S_ISLNK(mode))
|
||||||
return VLNK;
|
return (VLNK);
|
||||||
|
|
||||||
if (S_ISSOCK(mode))
|
if (S_ISSOCK(mode))
|
||||||
return VSOCK;
|
return (VSOCK);
|
||||||
|
|
||||||
return VNON;
|
return (VNON);
|
||||||
} /* vn_mode_to_vtype() */
|
} /* vn_mode_to_vtype() */
|
||||||
EXPORT_SYMBOL(vn_mode_to_vtype);
|
EXPORT_SYMBOL(vn_mode_to_vtype);
|
||||||
|
|
||||||
|
@ -71,27 +71,27 @@ mode_t
|
||||||
vn_vtype_to_mode(vtype_t vtype)
|
vn_vtype_to_mode(vtype_t vtype)
|
||||||
{
|
{
|
||||||
if (vtype == VREG)
|
if (vtype == VREG)
|
||||||
return S_IFREG;
|
return (S_IFREG);
|
||||||
|
|
||||||
if (vtype == VDIR)
|
if (vtype == VDIR)
|
||||||
return S_IFDIR;
|
return (S_IFDIR);
|
||||||
|
|
||||||
if (vtype == VCHR)
|
if (vtype == VCHR)
|
||||||
return S_IFCHR;
|
return (S_IFCHR);
|
||||||
|
|
||||||
if (vtype == VBLK)
|
if (vtype == VBLK)
|
||||||
return S_IFBLK;
|
return (S_IFBLK);
|
||||||
|
|
||||||
if (vtype == VFIFO)
|
if (vtype == VFIFO)
|
||||||
return S_IFIFO;
|
return (S_IFIFO);
|
||||||
|
|
||||||
if (vtype == VLNK)
|
if (vtype == VLNK)
|
||||||
return S_IFLNK;
|
return (S_IFLNK);
|
||||||
|
|
||||||
if (vtype == VSOCK)
|
if (vtype == VSOCK)
|
||||||
return S_IFSOCK;
|
return (S_IFSOCK);
|
||||||
|
|
||||||
return VNON;
|
return (VNON);
|
||||||
} /* vn_vtype_to_mode() */
|
} /* vn_vtype_to_mode() */
|
||||||
EXPORT_SYMBOL(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))
|
if (!(flags & FCREAT) && (flags & FWRITE))
|
||||||
flags |= FEXCL;
|
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
|
* 01 - read-only -> 00 read-only
|
||||||
* 10 - write-only -> 01 write-only
|
* 10 - write-only -> 01 write-only
|
||||||
* 11 - read-write -> 10 read-write
|
* 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);
|
fp = filp_open(path, flags, mode);
|
||||||
|
|
||||||
if (flags & FCREAT)
|
if (flags & FCREAT)
|
||||||
(void)xchg(¤t->fs->umask, saved_umask);
|
(void) xchg(¤t->fs->umask, saved_umask);
|
||||||
|
|
||||||
if (IS_ERR(fp))
|
if (IS_ERR(fp))
|
||||||
return (-PTR_ERR(fp));
|
return (-PTR_ERR(fp));
|
||||||
|
@ -199,7 +200,7 @@ vn_openat(const char *path, uio_seg_t seg, int flags, int mode,
|
||||||
if (!realpath)
|
if (!realpath)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
|
||||||
(void)snprintf(realpath, len, "/%s", path);
|
(void) snprintf(realpath, len, "/%s", path);
|
||||||
rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2);
|
rc = vn_open(realpath, seg, flags, mode, vpp, x1, x2);
|
||||||
kfree(realpath);
|
kfree(realpath);
|
||||||
|
|
||||||
|
@ -259,9 +260,11 @@ vn_close(vnode_t *vp, int flags, int x1, int x2, void *x3, void *x4)
|
||||||
} /* vn_close() */
|
} /* vn_close() */
|
||||||
EXPORT_SYMBOL(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
|
* proposed seek. We perform minimal checking and allow vn_rdwr() to catch
|
||||||
* anything more serious. */
|
* anything more serious.
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
vn_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, void *ct)
|
vn_seek(vnode_t *vp, offset_t ooff, offset_t *noffp, void *ct)
|
||||||
{
|
{
|
||||||
|
@ -312,7 +315,8 @@ vn_getattr(vnode_t *vp, vattr_t *vap, int flags, void *x3, void *x4)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(vn_getattr);
|
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 datasync = 0;
|
||||||
int error;
|
int error;
|
||||||
|
@ -417,11 +421,11 @@ file_find(int fd, struct task_struct *task)
|
||||||
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) {
|
if (fd == fp->f_fd && fp->f_task == task) {
|
||||||
ASSERT(atomic_read(&fp->f_ref) != 0);
|
ASSERT(atomic_read(&fp->f_ref) != 0);
|
||||||
return fp;
|
return (fp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return (NULL);
|
||||||
} /* file_find() */
|
} /* file_find() */
|
||||||
|
|
||||||
file_t *
|
file_t *
|
||||||
|
@ -482,7 +486,8 @@ vn_getf(int fd)
|
||||||
goto out_fget;
|
goto out_fget;
|
||||||
|
|
||||||
#if defined(HAVE_4ARGS_VFS_GETATTR)
|
#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)
|
#elif defined(HAVE_2ARGS_VFS_GETATTR)
|
||||||
rc = vfs_getattr(&lfp->f_path, &stat);
|
rc = vfs_getattr(&lfp->f_path, &stat);
|
||||||
#else
|
#else
|
||||||
|
@ -560,8 +565,6 @@ vn_areleasef(int fd, uf_info_t *fip)
|
||||||
releasef_locked(fp);
|
releasef_locked(fp);
|
||||||
}
|
}
|
||||||
spin_unlock(&vn_file_lock);
|
spin_unlock(&vn_file_lock);
|
||||||
|
|
||||||
return;
|
|
||||||
} /* releasef() */
|
} /* releasef() */
|
||||||
EXPORT_SYMBOL(areleasef);
|
EXPORT_SYMBOL(areleasef);
|
||||||
|
|
||||||
|
@ -669,16 +672,13 @@ int
|
||||||
spl_vn_init(void)
|
spl_vn_init(void)
|
||||||
{
|
{
|
||||||
vn_cache = kmem_cache_create("spl_vn_cache",
|
vn_cache = kmem_cache_create("spl_vn_cache",
|
||||||
sizeof(struct vnode), 64,
|
sizeof (struct vnode), 64, vn_cache_constructor,
|
||||||
vn_cache_constructor,
|
vn_cache_destructor, NULL, NULL, NULL, 0);
|
||||||
vn_cache_destructor,
|
|
||||||
NULL, NULL, NULL, 0);
|
|
||||||
|
|
||||||
vn_file_cache = kmem_cache_create("spl_vn_file_cache",
|
vn_file_cache = kmem_cache_create("spl_vn_file_cache",
|
||||||
sizeof(file_t), 64,
|
sizeof (file_t), 64, vn_file_cache_constructor,
|
||||||
vn_file_cache_constructor,
|
vn_file_cache_destructor, NULL, NULL, NULL, 0);
|
||||||
vn_file_cache_destructor,
|
|
||||||
NULL, NULL, NULL, 0);
|
|
||||||
return (0);
|
return (0);
|
||||||
} /* vn_init() */
|
} /* vn_init() */
|
||||||
|
|
||||||
|
@ -703,6 +703,4 @@ spl_vn_fini(void)
|
||||||
|
|
||||||
kmem_cache_destroy(vn_file_cache);
|
kmem_cache_destroy(vn_file_cache);
|
||||||
kmem_cache_destroy(vn_cache);
|
kmem_cache_destroy(vn_cache);
|
||||||
|
|
||||||
return;
|
|
||||||
} /* vn_fini() */
|
} /* vn_fini() */
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
* Solaris Porting Layer (SPL) XDR Implementation.
|
* 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;
|
struct xdr_bytesrec *rec = (struct xdr_bytesrec *) info;
|
||||||
|
|
||||||
if (req != XDR_GET_BYTES_AVAIL)
|
if (req != XDR_GET_BYTES_AVAIL)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
rec->xc_is_last_record = TRUE; /* always TRUE in xdrmem streams */
|
rec->xc_is_last_record = TRUE; /* always TRUE in xdrmem streams */
|
||||||
rec->xc_num_avail = xdrs->x_addr_end - xdrs->x_addr;
|
rec->xc_num_avail = xdrs->x_addr_end - xdrs->x_addr;
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
|
@ -178,13 +178,13 @@ xdrmem_enc_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
|
||||||
uint_t pad;
|
uint_t pad;
|
||||||
|
|
||||||
if (size < cnt)
|
if (size < cnt)
|
||||||
return FALSE; /* Integer overflow */
|
return (FALSE); /* Integer overflow */
|
||||||
|
|
||||||
if (xdrs->x_addr > xdrs->x_addr_end)
|
if (xdrs->x_addr > xdrs->x_addr_end)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
if (xdrs->x_addr_end - xdrs->x_addr < size)
|
if (xdrs->x_addr_end - xdrs->x_addr < size)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
memcpy(xdrs->x_addr, cp, cnt);
|
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;
|
xdrs->x_addr += pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
|
@ -207,13 +207,13 @@ xdrmem_dec_bytes(XDR *xdrs, caddr_t cp, const uint_t cnt)
|
||||||
uint_t pad;
|
uint_t pad;
|
||||||
|
|
||||||
if (size < cnt)
|
if (size < cnt)
|
||||||
return FALSE; /* Integer overflow */
|
return (FALSE); /* Integer overflow */
|
||||||
|
|
||||||
if (xdrs->x_addr > xdrs->x_addr_end)
|
if (xdrs->x_addr > xdrs->x_addr_end)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
if (xdrs->x_addr_end - xdrs->x_addr < size)
|
if (xdrs->x_addr_end - xdrs->x_addr < size)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
memcpy(cp, xdrs->x_addr, cnt);
|
memcpy(cp, xdrs->x_addr, cnt);
|
||||||
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) {
|
if (pad > 0) {
|
||||||
/* An inverted memchr() would be useful here... */
|
/* An inverted memchr() would be useful here... */
|
||||||
if (memcmp(&zero, xdrs->x_addr, pad) != 0)
|
if (memcmp(&zero, xdrs->x_addr, pad) != 0)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
xdrs->x_addr += pad;
|
xdrs->x_addr += pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
xdrmem_enc_uint32(XDR *xdrs, uint32_t val)
|
xdrmem_enc_uint32(XDR *xdrs, uint32_t val)
|
||||||
{
|
{
|
||||||
if (xdrs->x_addr + sizeof(uint32_t) > xdrs->x_addr_end)
|
if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
*((uint32_t *) xdrs->x_addr) = cpu_to_be32(val);
|
*((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
|
static bool_t
|
||||||
xdrmem_dec_uint32(XDR *xdrs, uint32_t *val)
|
xdrmem_dec_uint32(XDR *xdrs, uint32_t *val)
|
||||||
{
|
{
|
||||||
if (xdrs->x_addr + sizeof(uint32_t) > xdrs->x_addr_end)
|
if (xdrs->x_addr + sizeof (uint32_t) > xdrs->x_addr_end)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
*val = be32_to_cpu(*((uint32_t *) xdrs->x_addr));
|
*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
|
static bool_t
|
||||||
|
@ -261,10 +261,10 @@ xdrmem_enc_char(XDR *xdrs, char *cp)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
BUILD_BUG_ON(sizeof(char) != 1);
|
BUILD_BUG_ON(sizeof (char) != 1);
|
||||||
val = *((unsigned char *) cp);
|
val = *((unsigned char *) cp);
|
||||||
|
|
||||||
return xdrmem_enc_uint32(xdrs, val);
|
return (xdrmem_enc_uint32(xdrs, val));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
|
@ -272,10 +272,10 @@ xdrmem_dec_char(XDR *xdrs, char *cp)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
BUILD_BUG_ON(sizeof(char) != 1);
|
BUILD_BUG_ON(sizeof (char) != 1);
|
||||||
|
|
||||||
if (!xdrmem_dec_uint32(xdrs, &val))
|
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
|
* 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.
|
* not have a char encoded in it.
|
||||||
*/
|
*/
|
||||||
if (val > 0xff)
|
if (val > 0xff)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
*((unsigned char *) cp) = val;
|
*((unsigned char *) cp) = val;
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
xdrmem_enc_ushort(XDR *xdrs, unsigned short *usp)
|
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
|
static bool_t
|
||||||
|
@ -303,48 +303,48 @@ xdrmem_dec_ushort(XDR *xdrs, unsigned short *usp)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
BUILD_BUG_ON(sizeof(unsigned short) != 2);
|
BUILD_BUG_ON(sizeof (unsigned short) != 2);
|
||||||
|
|
||||||
if (!xdrmem_dec_uint32(xdrs, &val))
|
if (!xdrmem_dec_uint32(xdrs, &val))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Short ints are not in the RFC, but we assume similar logic as in
|
* Short ints are not in the RFC, but we assume similar logic as in
|
||||||
* xdrmem_dec_char().
|
* xdrmem_dec_char().
|
||||||
*/
|
*/
|
||||||
if (val > 0xffff)
|
if (val > 0xffff)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
*usp = val;
|
*usp = val;
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
xdrmem_enc_uint(XDR *xdrs, unsigned *up)
|
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
|
static bool_t
|
||||||
xdrmem_dec_uint(XDR *xdrs, unsigned *up)
|
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
|
static bool_t
|
||||||
xdrmem_enc_ulonglong(XDR *xdrs, u_longlong_t *ullp)
|
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))
|
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
|
static bool_t
|
||||||
|
@ -352,16 +352,16 @@ xdrmem_dec_ulonglong(XDR *xdrs, u_longlong_t *ullp)
|
||||||
{
|
{
|
||||||
uint32_t low, high;
|
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))
|
if (!xdrmem_dec_uint32(xdrs, &high))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
if (!xdrmem_dec_uint32(xdrs, &low))
|
if (!xdrmem_dec_uint32(xdrs, &low))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
*ullp = ((u_longlong_t) high << 32) | low;
|
*ullp = ((u_longlong_t) high << 32) | low;
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
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;
|
caddr_t addr = *arrp;
|
||||||
|
|
||||||
if (*sizep > maxsize || *sizep > UINT_MAX / elsize)
|
if (*sizep > maxsize || *sizep > UINT_MAX / elsize)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
if (!xdrmem_enc_uint(xdrs, sizep))
|
if (!xdrmem_enc_uint(xdrs, sizep))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
for (i = 0; i < *sizep; i++) {
|
for (i = 0; i < *sizep; i++) {
|
||||||
if (!elproc(xdrs, addr))
|
if (!elproc(xdrs, addr))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
addr += elsize;
|
addr += elsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
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;
|
caddr_t addr;
|
||||||
|
|
||||||
if (!xdrmem_dec_uint(xdrs, sizep))
|
if (!xdrmem_dec_uint(xdrs, sizep))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
size = *sizep;
|
size = *sizep;
|
||||||
|
|
||||||
if (size > maxsize || size > UINT_MAX / elsize)
|
if (size > maxsize || size > UINT_MAX / elsize)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Solaris man page says: "If *arrp is NULL when decoding,
|
* The Solaris man page says: "If *arrp is NULL when decoding,
|
||||||
* xdr_array() allocates memory and *arrp points to it".
|
* xdr_array() allocates memory and *arrp points to it".
|
||||||
*/
|
*/
|
||||||
if (*arrp == NULL) {
|
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);
|
*arrp = kmem_alloc(size * elsize, KM_NOSLEEP);
|
||||||
if (*arrp == NULL)
|
if (*arrp == NULL)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
alloc = TRUE;
|
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 (!elproc(xdrs, addr)) {
|
||||||
if (alloc)
|
if (alloc)
|
||||||
kmem_free(*arrp, size * elsize);
|
kmem_free(*arrp, size * elsize);
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
}
|
}
|
||||||
addr += elsize;
|
addr += elsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t
|
||||||
|
@ -437,14 +437,14 @@ xdr_enc_string(XDR *xdrs, char **sp, const uint_t maxsize)
|
||||||
uint_t len;
|
uint_t len;
|
||||||
|
|
||||||
if (slen > maxsize)
|
if (slen > maxsize)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
len = slen;
|
len = slen;
|
||||||
|
|
||||||
if (!xdrmem_enc_uint(xdrs, &len))
|
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
|
static bool_t
|
||||||
|
@ -454,21 +454,21 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize)
|
||||||
bool_t alloc = FALSE;
|
bool_t alloc = FALSE;
|
||||||
|
|
||||||
if (!xdrmem_dec_uint(xdrs, &size))
|
if (!xdrmem_dec_uint(xdrs, &size))
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
if (size > maxsize || size > UINT_MAX - 1)
|
if (size > maxsize || size > UINT_MAX - 1)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Solaris man page: "If *sp is NULL when decoding, xdr_string()
|
* Solaris man page: "If *sp is NULL when decoding, xdr_string()
|
||||||
* allocates memory and *sp points to it".
|
* allocates memory and *sp points to it".
|
||||||
*/
|
*/
|
||||||
if (*sp == NULL) {
|
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);
|
*sp = kmem_alloc(size + 1, KM_NOSLEEP);
|
||||||
if (*sp == NULL)
|
if (*sp == NULL)
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
|
|
||||||
alloc = TRUE;
|
alloc = TRUE;
|
||||||
}
|
}
|
||||||
|
@ -481,13 +481,13 @@ xdr_dec_string(XDR *xdrs, char **sp, const uint_t maxsize)
|
||||||
|
|
||||||
(*sp)[size] = '\0';
|
(*sp)[size] = '\0';
|
||||||
|
|
||||||
return TRUE;
|
return (TRUE);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
if (alloc)
|
if (alloc)
|
||||||
kmem_free(*sp, size + 1);
|
kmem_free(*sp, size + 1);
|
||||||
|
|
||||||
return FALSE;
|
return (FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct xdr_ops xdrmem_encode_ops = {
|
static struct xdr_ops xdrmem_encode_ops = {
|
||||||
|
@ -511,4 +511,3 @@ static struct xdr_ops xdrmem_decode_ops = {
|
||||||
.xdr_string = xdr_dec_string,
|
.xdr_string = xdr_dec_string,
|
||||||
.xdr_array = xdr_dec_array
|
.xdr_array = xdr_dec_array
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along
|
* You should have received a copy of the GNU General Public License along
|
||||||
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
* with the SPL. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*****************************************************************************
|
*
|
||||||
|
*
|
||||||
* z_compress_level/z_uncompress are nearly identical copies of the
|
* z_compress_level/z_uncompress are nearly identical copies of the
|
||||||
* compress2/uncompress functions provided by the official zlib package
|
* compress2/uncompress functions provided by the official zlib package
|
||||||
* available at http://zlib.net/. The only changes made we to slightly
|
* 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 *
|
static void *
|
||||||
zlib_workspace_alloc(int flags)
|
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
|
static void
|
||||||
|
@ -105,30 +106,30 @@ z_compress_level(void *dest, size_t *destLen, const void *source,
|
||||||
stream.avail_out = (uInt)*destLen;
|
stream.avail_out = (uInt)*destLen;
|
||||||
|
|
||||||
if ((size_t)stream.avail_out != *destLen)
|
if ((size_t)stream.avail_out != *destLen)
|
||||||
return Z_BUF_ERROR;
|
return (Z_BUF_ERROR);
|
||||||
|
|
||||||
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
|
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
|
||||||
if (!stream.workspace)
|
if (!stream.workspace)
|
||||||
return Z_MEM_ERROR;
|
return (Z_MEM_ERROR);
|
||||||
|
|
||||||
err = zlib_deflateInit(&stream, level);
|
err = zlib_deflateInit(&stream, level);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
zlib_workspace_free(stream.workspace);
|
zlib_workspace_free(stream.workspace);
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = zlib_deflate(&stream, Z_FINISH);
|
err = zlib_deflate(&stream, Z_FINISH);
|
||||||
if (err != Z_STREAM_END) {
|
if (err != Z_STREAM_END) {
|
||||||
zlib_deflateEnd(&stream);
|
zlib_deflateEnd(&stream);
|
||||||
zlib_workspace_free(stream.workspace);
|
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;
|
*destLen = stream.total_out;
|
||||||
|
|
||||||
err = zlib_deflateEnd(&stream);
|
err = zlib_deflateEnd(&stream);
|
||||||
zlib_workspace_free(stream.workspace);
|
zlib_workspace_free(stream.workspace);
|
||||||
|
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(z_compress_level);
|
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;
|
stream.avail_out = (uInt)*destLen;
|
||||||
|
|
||||||
if ((size_t)stream.avail_out != *destLen)
|
if ((size_t)stream.avail_out != *destLen)
|
||||||
return Z_BUF_ERROR;
|
return (Z_BUF_ERROR);
|
||||||
|
|
||||||
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
|
stream.workspace = zlib_workspace_alloc(KM_SLEEP);
|
||||||
if (!stream.workspace)
|
if (!stream.workspace)
|
||||||
return Z_MEM_ERROR;
|
return (Z_MEM_ERROR);
|
||||||
|
|
||||||
err = zlib_inflateInit(&stream);
|
err = zlib_inflateInit(&stream);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
zlib_workspace_free(stream.workspace);
|
zlib_workspace_free(stream.workspace);
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
err = zlib_inflate(&stream, Z_FINISH);
|
err = zlib_inflate(&stream, Z_FINISH);
|
||||||
|
@ -178,16 +179,16 @@ z_uncompress(void *dest, size_t *destLen, const void *source, size_t sourceLen)
|
||||||
|
|
||||||
if (err == Z_NEED_DICT ||
|
if (err == Z_NEED_DICT ||
|
||||||
(err == Z_BUF_ERROR && stream.avail_in == 0))
|
(err == Z_BUF_ERROR && stream.avail_in == 0))
|
||||||
return Z_DATA_ERROR;
|
return (Z_DATA_ERROR);
|
||||||
|
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
*destLen = stream.total_out;
|
*destLen = stream.total_out;
|
||||||
|
|
||||||
err = zlib_inflateEnd(&stream);
|
err = zlib_inflateEnd(&stream);
|
||||||
zlib_workspace_free(stream.workspace);
|
zlib_workspace_free(stream.workspace);
|
||||||
|
|
||||||
return err;
|
return (err);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(z_uncompress);
|
EXPORT_SYMBOL(z_uncompress);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue