#endif /* __KERNEL__ */
#include <libcfs/libcfs_debug.h>
-#include <libcfs/libcfs_private.h>
#ifdef __KERNEL__
+# include <libcfs/libcfs_private.h>
# include <libcfs/bitmap.h>
# include <libcfs/libcfs_cpu.h>
# include <libcfs/libcfs_ioctl.h>
# define DEBUG_SUBSYSTEM S_UNDEFINED
#endif
-#ifdef __KERNEL__
-
#ifdef LIBCFS_DEBUG
/*
lbug_with_loc(&msgdata); \
} while(0)
-extern atomic_t libcfs_kmemory;
/*
* Memory
*/
#ifdef LIBCFS_DEBUG
+extern atomic_t libcfs_kmemory;
+
# define libcfs_kmem_inc(ptr, size) \
do { \
atomic_add(size, &libcfs_kmemory); \
/******************************************************************************/
-/* htonl hack - either this, or compile with -O2. Stupid byteorder/generic.h */
-#if defined(__GNUC__) && (__GNUC__ >= 2) && !defined(__OPTIMIZE__)
-#define ___htonl(x) __cpu_to_be32(x)
-#define ___htons(x) __cpu_to_be16(x)
-#define ___ntohl(x) __be32_to_cpu(x)
-#define ___ntohs(x) __be16_to_cpu(x)
-#define htonl(x) ___htonl(x)
-#define ntohl(x) ___ntohl(x)
-#define htons(x) ___htons(x)
-#define ntohs(x) ___ntohs(x)
-#endif
+struct task_struct;
void libcfs_debug_dumpstack(struct task_struct *tsk);
void libcfs_debug_dumplog(void);
int libcfs_debug_clear_buffer(void);
int libcfs_debug_mark_buffer(const char *text);
-#else /* !__KERNEL__ */
-# ifdef LIBCFS_DEBUG
-# undef NDEBUG
-# include <assert.h>
-# define LASSERT(e) assert(e)
-# define LASSERTF(cond, ...) \
-do { \
- if (!(cond)) \
- CERROR(__VA_ARGS__); \
- assert(cond); \
-} while (0)
-# define LBUG() assert(0)
-# ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
-# define LINVRNT(exp) LASSERT(exp)
-# else
-# define LINVRNT(exp) ((void)sizeof!!(exp))
-# endif
-# else
-# define LASSERT(e) ((void)sizeof!!(e))
-# define LASSERTF(cond, ...) ((void)sizeof!!(cond))
-# define LBUG() ((void)(0))
-# define LINVRNT(exp) ((void)sizeof!!(exp))
-# endif /* LIBCFS_DEBUG */
-# define KLASSERT(e) ((void)0)
-# define printk printf
-#define LIBCFS_ALLOC_GFP(ptr, size, mask) \
-do { \
- (ptr) = calloc(1, size); \
-} while (0)
-# define LIBCFS_FREE(ptr, size) do { free(ptr); } while((size) - (size))
-# define LIBCFS_ALLOC(ptr, size) \
- LIBCFS_ALLOC_GFP(ptr, size, 0)
-# define LIBCFS_CPT_ALLOC_GFP(ptr, cptab, cpt, size, mask) \
- LIBCFS_ALLOC(ptr, size)
-# define LIBCFS_CPT_ALLOC(ptr, cptab, cpt, size) \
- LIBCFS_ALLOC(ptr, size)
-
-void libcfs_debug_dumplog(void);
-int libcfs_debug_init(unsigned long bufsize);
-int libcfs_debug_cleanup(void);
-
-#define libcfs_debug_dumpstack(tsk) ((void)0)
-
-/*
- * Generic compiler-dependent macros required for kernel
- * build go below this comment. Actual compiler/compiler version
- * specific implementations come from the above header files
- */
-#define likely(x) __builtin_expect(!!(x), 1)
-#define unlikely(x) __builtin_expect(!!(x), 0)
-/* !__KERNEL__ */
-#endif
-
/*
* allocate a variable array, returned value is an array of pointers.
* Caller can specify length of array by count.
return cfs_size_round(strlen(fset) + 1);
}
-#define LOGL(var,len,ptr) \
-do { \
- if (var) \
- memcpy((char *)ptr, (const char *)var, len); \
- ptr += cfs_size_round(len); \
-} while (0)
-
-#define LOGU(var,len,ptr) \
-do { \
- if (var) \
- memcpy((char *)var, (const char *)ptr, len); \
- ptr += cfs_size_round(len); \
-} while (0)
-
extern struct cfs_psdev_ops libcfs_psdev_ops;
extern struct miscdevice libcfs_dev;
extern struct cfs_wi_sched *cfs_sched_rehash;
#include <linux/spinlock.h>
#include <linux/seq_file.h>
+#include <libcfs/libcfs.h>
#include <lustre/lustre_idl.h>
struct lprocfs_vars {
#include <asm/byteorder.h>
#include <linux/types.h>
-#include <libcfs/libcfs.h>
#include <lnet/types.h>
#include <lustre/lustre_user.h> /* Defn's shared with user-space. */
#include <lustre_ver.h>
if (fid_seq_is_mdt0(ostid->oi.oi_seq))
return FID_SEQ_OST_MDT0;
- if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
+ if (fid_seq_is_default(ostid->oi.oi_seq))
return FID_SEQ_LOV_DEFAULT;
if (fid_is_idif(&ostid->oi_fid))
if (fid_seq_is_mdt0(ostid->oi.oi_seq))
return ostid->oi.oi_id & IDIF_OID_MASK;
- if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
+ if (fid_seq_is_default(ostid->oi.oi_seq))
return ostid->oi.oi_id;
if (fid_is_idif(&ostid->oi_fid))
/* pack any OST FID into an ostid (id/seq) for the wire/disk */
static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid)
{
- if (unlikely(fid_seq_is_igif(fid->f_seq))) {
+ if (fid_seq_is_igif(fid->f_seq)) {
CERROR("bad IGIF, "DFID"\n", PFID(fid));
return -EBADF;
}
#include <linux/types.h>
#ifdef __KERNEL__
+# include <linux/fs.h>
# include <linux/quota.h>
# include <linux/string.h> /* snprintf() */
# include <linux/version.h>
__u32 i;
size_t offset;
__u32 bufcount;
- LASSERT (lcfg != NULL);
+
+ if (!lcfg)
+ return NULL;
bufcount = lcfg->lcfg_bufcount;
if (index >= bufcount)
ptr = (char *)lcfg + LCFG_HDR_SIZE(lcfg->lcfg_bufcount);
for (i = 0; i < lcfg->lcfg_bufcount; i++) {
lcfg->lcfg_buflens[i] = bufs->lcfg_buflen[i];
- LOGL((char *)bufs->lcfg_buf[i], bufs->lcfg_buflen[i], ptr);
+ if (bufs->lcfg_buf[i]) {
+ memcpy(ptr, bufs->lcfg_buf[i], bufs->lcfg_buflen[i]);
+ ptr += cfs_size_round(bufs->lcfg_buflen[i]);
+ }
}
}
memcpy(*pbuf, data, sizeof(*data));
ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1 != NULL)
- LOGL(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
+ if (data->ioc_inlbuf1) {
+ memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
+ ptr += cfs_size_round(data->ioc_inllen1);
+ }
- if (data->ioc_inlbuf2 != NULL)
- LOGL(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf2) {
+ memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
+ ptr += cfs_size_round(data->ioc_inllen2);
+ }
- if (data->ioc_inlbuf3 != NULL)
- LOGL(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
+ if (data->ioc_inlbuf3) {
+ memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
+ ptr += cfs_size_round(data->ioc_inllen3);
+ }
- if (data->ioc_inlbuf4 != NULL)
- LOGL(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
+ if (data->ioc_inlbuf4) {
+ memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
+ ptr += cfs_size_round(data->ioc_inllen4);
+ }
if (obd_ioctl_is_invalid(overlay)) {
fprintf(stderr, "invalid ioctl data: ioc_len = %u, "
memcpy(data, pbuf, sizeof(*data));
ptr = overlay->ioc_bulk;
- if (data->ioc_inlbuf1 != NULL)
- LOGU(data->ioc_inlbuf1, data->ioc_inllen1, ptr);
+ if (data->ioc_inlbuf1) {
+ memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
+ ptr += cfs_size_round(data->ioc_inllen1);
+ }
- if (data->ioc_inlbuf2 != NULL)
- LOGU(data->ioc_inlbuf2, data->ioc_inllen2, ptr);
+ if (data->ioc_inlbuf2) {
+ memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
+ ptr += cfs_size_round(data->ioc_inllen2);
+ }
- if (data->ioc_inlbuf3 != NULL)
- LOGU(data->ioc_inlbuf3, data->ioc_inllen3, ptr);
+ if (data->ioc_inlbuf3) {
+ memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
+ ptr += cfs_size_round(data->ioc_inllen3);
+ }
- if (data->ioc_inlbuf4 != NULL)
- LOGU(data->ioc_inlbuf4, data->ioc_inllen4, ptr);
+ if (data->ioc_inlbuf4) {
+ memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
+ ptr += cfs_size_round(data->ioc_inllen4);
+ }
return 0;
}
if (bufs == NULL)
return;
- ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
- for (i = 0; i < count; i++) {
- char *tmp = bufs[i];
- LOGL(tmp, lens[i], ptr);
- }
+ ptr = (char *)msg + lustre_msg_hdr_size_v2(count);
+ for (i = 0; i < count; i++) {
+ char *tmp = bufs[i];
+
+ if (tmp)
+ memcpy(ptr, tmp, lens[i]);
+ ptr += cfs_size_round(lens[i]);
+ }
}
EXPORT_SYMBOL(lustre_init_msg_v2);
*
* Author: jay <jxiong@clusterfs.com>
*/
+#include <assert.h>
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <linux/types.h>
+/*
+ * it_test.c is built against one of the lustre kernel
+ * files (interval_tree.c). This pulls in kernel specific
+ * definitions which are not of interest for user land.
+ */
#define EXPORT_SYMBOL(s)
+#define LASSERT assert
#include <../ldlm/interval_tree.c>
return rc;
}
- LASSERT(sk_hmac_types[hmac_alg].sht_bytes ==
- tmp_hash.length);
+ if (sk_hmac_types[hmac_alg].sht_bytes != tmp_hash.length) {
+ free(tmp_hash.value);
+ return -EINVAL;
+ }
bytes = (remain < tmp_hash.length) ? remain : tmp_hash.length;
memcpy(keydata, tmp_hash.value, bytes);
#include <string.h>
#include <endian.h>
#include <errno.h>
-#include <assert.h>
#include <sys/ioctl.h>
#include <sys/types.h>
{
struct obd_statfs stat_buf;
struct obd_uuid uuid_buf;
- int ret;
+ int ret;
- LASSERT(type == LL_STATFS_LOV || type == LL_STATFS_LMV);
+ if (type != LL_STATFS_LOV && type != LL_STATFS_LMV)
+ return -EINVAL;
memset(&stat_buf, 0, sizeof(struct obd_statfs));
memset(&uuid_buf, 0, sizeof(struct obd_uuid));
int checked_type = 0;
int ret = 0;
- LASSERT(parent != NULL || dir != NULL);
+ if (parent == NULL && dir == NULL)
+ return -EINVAL;
param->fp_lmd->lmd_lmm.lmm_stripe_count = 0;
char *filename;
bool retry = false;
- LASSERT(parent != NULL || dirp != NULL);
+ if (parent == NULL && dirp == NULL)
+ return -EINVAL;
+
if (dirp != NULL)
closedir(*dirp);
int ret;
int mdtidx;
- LASSERT(parent != NULL || d != NULL);
+ if (parent == NULL && d == NULL)
+ return -EINVAL;
if (d != NULL) {
ret = llapi_file_fget_mdtidx(dirfd(d), &mdtidx);
DIR *d = dirp == NULL ? NULL : *dirp;
int ret = 0;
- LASSERT(parent != NULL || d != NULL);
+ if (parent == NULL && d == NULL)
+ return -EINVAL;
if (param->fp_obd_uuid) {
param->fp_quiet = 1;
}
ptr = strrchr(param.gl_pathv[0], '-');
- LASSERT(ptr != NULL);
+ if (ptr == NULL) {
+ rc = -EINVAL;
+ goto out;
+ }
for (i = 1; i < param.gl_pathc; i++) {
char *ptr2 = strrchr(param.gl_pathv[i], '-');
- LASSERT(ptr2 != NULL);
+ if (ptr2 == NULL) {
+ rc = -EINVAL;
+ goto out;
+ }
if ((ptr - param.gl_pathv[0]) != (ptr2 - param.gl_pathv[i]) ||
strncmp(param.gl_pathv[0], param.gl_pathv[i],
* [pfid,tfid,name] tracked from (1) is used for this.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utime.h>
#include <time.h>
#include <sys/xattr.h>
+#include <linux/types.h>
+#include <libcfs/libcfs_debug.h>
#include <libcfs/util/string.h>
#include <libcfs/util/parser.h>
#include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
#include "lustre_rsync.h"
#define REPLICATE_STATUS_VER 1
int special_dest = 0;
char srcpath[PATH_MAX + 1] = "";
- LASSERT(info->is_extended);
+ assert(info->is_extended);
rc_src = lr_get_path(info, info->spfid);
if (rc_src < 0 && rc_src != -ENOENT)
#include <errno.h>
#include <string.h>
#include <sys/mount.h>
+#include <sys/param.h>
#include <lustre_ver.h>
#include <ctype.h>
#include <limits.h>
/* Return true if backfs_ops has operations for the given mount_type. */
int backfs_mount_type_okay(enum ldd_mount_type mount_type)
{
- if (unlikely(mount_type >= LDD_MT_LAST || mount_type < 0)) {
+ if (mount_type >= LDD_MT_LAST || mount_type < 0) {
fatal();
fprintf(stderr, "fs type out of range %d\n", mount_type);
return 0;
switch (cmd) {
case LCFG_POOL_NEW: {
- LASSERT(ostname == NULL);
+ if (ostname != NULL)
+ return -EINVAL;
+
if (rc >= 0) {
fprintf(stderr, "Pool %s.%s already exists\n",
fsname, poolname);
return 0;
}
case LCFG_POOL_DEL: {
- LASSERT(ostname == NULL);
+ if (ostname != NULL)
+ return -EINVAL;
+
if (rc == 1) {
fprintf(stderr, "Pool %s.%s not empty, "
"please remove all members\n",
#include <lustre/lustre_lfsck_user.h>
#include <lustre_disk.h>
-#undef LASSERT
-#undef LASSERTF
#define LASSERT(cond) if (!(cond)) { printf("failed " #cond "\n"); ret = 1; }
#define LASSERTF(cond, fmt, ...) if (!(cond)) { printf("failed '" #cond "'" fmt, ## __VA_ARGS__);ret = 1;}
+/*
+ * Compile-time LASSERT, which verifies correctness at compile-time rather
+ * than runtime. If "cond" is true, then there are two different cases
+ * ("(non-zero)" and "0"). If "cond" is false, then there are two identical cases
+ * ("0" and "0"), which is an error that causes the compiler to complain.
+ */
+#define CLASSERT(cond) do {switch (1) {case (cond): case 0: break; } } while (0)
int ret;