diff --git a/lustre/ChangeLog b/lustre/ChangeLog index d9a55e5d956ec608cbbdebb11899ea67faa82d0a..45d39ab86b779724e61af89f0b31653f64080fad 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1,4 +1,11 @@ -2002-01-02 Andreas Dilger <adilger@clusterfs.com> +TBA + * bug fixes + - LRU counters were broken, causing constant lock purge (433, 432) + - garbage on read from stripes with failed OSTs (441) + - mark OSCs as active before reconnecting during recovery (438) + - lov_enqueue and lov_cancel need to handle inactive OSTs (403) + +2002-12-02 Andreas Dilger <adilger@clusterfs.com> * version v0_5_18 * bug fixes - fix many simultaneous client startup (392) @@ -12,10 +19,10 @@ - fix echo client over LOV (409) - fix dbench 2, extN refcount problem (170, 258, 356, 418) - fix double-O_EXCL intent crash (424) - - fix LOV-with-dead-OST bugs (307, 325, 326, 400, 403, 410) - * Features + - avoid sending multiple lock CANCELs (352) + * Features - MDS can do multi-client recovery (modulo bugs in new code) - * Documentation + * Documentation - many updates, edits, cleanups 2002-11-18 Phil Schwan <phil@clusterfs.com> diff --git a/lustre/include/linux/lustre_dlm.h b/lustre/include/linux/lustre_dlm.h index 29a800e7d1d97e9cd6e83bf16c5936f6b970930c..916db86a0f3c4eab6e79f5d3e68152b000de7571 100644 --- a/lustre/include/linux/lustre_dlm.h +++ b/lustre/include/linux/lustre_dlm.h @@ -42,19 +42,18 @@ typedef enum { #define LDLM_FL_CBPENDING (1 << 4) // this lock is being destroyed #define LDLM_FL_AST_SENT (1 << 5) // blocking or cancel packet was sent -#define LDLM_FL_DESTROYED (1 << 6) // this lock is destroyed -#define LDLM_FL_WAIT_NOREPROC (1 << 7)// not a real lock flag,not saved in lock -#define LDLM_FL_CANCEL (1 << 8) // cancellation callback already run +#define LDLM_FL_WAIT_NOREPROC (1 << 6)// not a real lock flag,not saved in lock +#define LDLM_FL_CANCEL (1 << 7) // cancellation callback already run /* Lock is being replayed. This could probably be implied by the fact that one * of BLOCK_{GRANTED,CONV,WAIT} is set, but that is pretty dangerous. */ -#define LDLM_FL_REPLAY (1 << 9) +#define LDLM_FL_REPLAY (1 << 8) -#define LDLM_FL_INTENT_ONLY (1 << 10) /* don't grant lock, just do intent */ -#define LDLM_FL_LOCAL_ONLY (1 << 11) /* see ldlm_cli_cancel_unused */ -#define LDLM_FL_NO_CALLBACK (1 << 12) /* see ldlm_cli_cancel_unused */ -#define LDLM_FL_HAS_INTENT (1 << 13) /* lock request has intent */ -#define LDLM_FL_CANCELING (1 << 14) /* lock cancel has already been sent */ +#define LDLM_FL_INTENT_ONLY (1 << 9) /* don't grant lock, just do intent */ +#define LDLM_FL_LOCAL_ONLY (1 << 10) /* see ldlm_cli_cancel_unused */ +#define LDLM_FL_NO_CALLBACK (1 << 11) /* see ldlm_cli_cancel_unused */ +#define LDLM_FL_HAS_INTENT (1 << 12) /* lock request has intent */ +#define LDLM_FL_CANCELING (1 << 13) /* lock cancel has already been sent */ /* The blocking callback is overloaded to perform two functions. These flags * indicate which operation should be performed. */ @@ -146,7 +145,7 @@ typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags); struct ldlm_lock { __u64 l_random; - int l_refc; + atomic_t l_refc; struct ldlm_resource *l_resource; struct ldlm_lock *l_parent; struct list_head l_children; @@ -174,6 +173,7 @@ struct ldlm_lock { __u32 l_readers; __u32 l_writers; + __u8 l_destroyed; /* If the lock is granted, a process sleeps on this waitq to learn when * it's no longer in use. If the lock is not granted, a process sleeps @@ -326,6 +326,7 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *, int strict, int flags); void ldlm_cancel_callback(struct ldlm_lock *); int ldlm_lock_set_data(struct lustre_handle *, void *data, int datalen); +void ldlm_lock_remove_from_lru(struct ldlm_lock *); static inline struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *h) { @@ -395,7 +396,7 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent, __u64 *name, __u32 type, int create); struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res); -int ldlm_resource_put(struct ldlm_resource *res); +int ldlm_resource_putref(struct ldlm_resource *res); void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, struct ldlm_lock *lock); void ldlm_resource_unlink_lock(struct ldlm_lock *lock); diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index b5c7e3038b3073a543503a113a62b934e407acce..da5cc81c7a657d1e87f34159b241fd47db683827 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -29,21 +29,11 @@ # include <string.h> #else # include <asm/semaphore.h> -#include <linux/kp30.h> /* XXX just for LASSERT! */ #endif +#include <linux/kp30.h> /* XXX just for LASSERT! */ #include <linux/portals_lib.h> #include <linux/lustre_idl.h> -#if BITS_PER_LONG > 32 -#define LPU64 "%lu" -#define LPD64 "%ld" -#define LPX64 "%#lx" -#else -#define LPU64 "%Lu" -#define LPD64 "%Ld" -#define LPX64 "%#Lx" -#endif - #ifdef __KERNEL__ /* l_net.c */ struct ptlrpc_request; diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index c028a0eee50b00b1e842e819382c2c05670f9a74..cb72b5bdb583b10f61f59e7a0d1bc947828433d3 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -273,7 +273,7 @@ struct obd_device { }; struct obd_ops { - int (*o_iocontrol)(long cmd, struct lustre_handle *, int len, + int (*o_iocontrol)(unsigned int cmd, struct lustre_handle *, int len, void *karg, void *uarg); int (*o_get_info)(struct lustre_handle *, obd_count keylen, void *key, obd_count *vallen, void **val); diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index 7efd82dc5698895c0a7a0c8da90a802630509d92..197de8453b1bd8aef83fccb04e54b185201ba937 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -469,7 +469,7 @@ static inline int obd_commitrw(int cmd, struct lustre_handle *conn, RETURN(rc); } -static inline int obd_iocontrol(int cmd, struct lustre_handle *conn, +static inline int obd_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg) { struct obd_export *exp; diff --git a/lustre/include/linux/obd_snap_support.h b/lustre/include/linux/obd_snap_support.h index 75ec08a0b349ff0b889216416a1661e5f4a03c7b..fd8baa4b4cd3ef7eff74e7c70335a73a83b7587c 100644 --- a/lustre/include/linux/obd_snap_support.h +++ b/lustre/include/linux/obd_snap_support.h @@ -73,7 +73,7 @@ inline struct lustre_handle *child_conn(struct lustre_handle *conn); int snap_deleteobj(obd_id id, obd_gr group, void *data); int snap_restoreobj(obd_id id, obd_gr group, void *data); int snap_printobj(obd_id id, obd_gr group, void *data); -int snap_iocontrol(int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg); +int snap_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg); /* In the future, this function may have to deal with offsets into the obdmd. * Currently, we assume we have the whole obdmd struct. diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 59818f89da892ac92ff74cc05ab4567439187ed9..83a6661f50987f775ec332e839373609d5e8588f 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -91,6 +91,7 @@ char *ldlm_it2str(int it) } extern kmem_cache_t *ldlm_lock_slab; +struct lustre_lock ldlm_handle_lock; static int ldlm_plain_compat(struct ldlm_lock *a, struct ldlm_lock *b); @@ -141,7 +142,7 @@ void ldlm_unregister_intent(void) struct ldlm_lock *ldlm_lock_get(struct ldlm_lock *lock) { l_lock(&lock->l_resource->lr_namespace->ns_lock); - lock->l_refc++; + atomic_inc(&lock->l_refc); ldlm_resource_getref(lock->l_resource); l_unlock(&lock->l_resource->lr_namespace->ns_lock); return lock; @@ -153,23 +154,21 @@ void ldlm_lock_put(struct ldlm_lock *lock) ENTRY; l_lock(&ns->ns_lock); - lock->l_refc--; - //LDLM_DEBUG(lock, "after refc--"); - if (lock->l_refc < 0) - LBUG(); + atomic_dec(&lock->l_refc); + LASSERT(atomic_read(&lock->l_refc) >= 0); - if (ldlm_resource_put(lock->l_resource)) { - LASSERT(lock->l_refc == 0); + if (ldlm_resource_putref(lock->l_resource)) { + LASSERT(atomic_read(&lock->l_refc) == 0); lock->l_resource = NULL; } if (lock->l_parent) LDLM_LOCK_PUT(lock->l_parent); - if (lock->l_refc == 0 && (lock->l_flags & LDLM_FL_DESTROYED)) { + if (atomic_read(&lock->l_refc) == 0) { + LASSERT(lock->l_destroyed); l_unlock(&ns->ns_lock); LDLM_DEBUG(lock, "final lock_put on destroyed lock, freeing"); - //spin_lock(&ldlm_handle_lock); spin_lock(&ns->ns_counter_lock); ns->ns_locks--; spin_unlock(&ns->ns_counter_lock); @@ -180,7 +179,6 @@ void ldlm_lock_put(struct ldlm_lock *lock) ptlrpc_put_connection(lock->l_export->exp_connection); memset(lock, 0x5a, sizeof(*lock)); kmem_cache_free(ldlm_lock_slab, lock); - //spin_unlock(&ldlm_handle_lock); CDEBUG(D_MALLOC, "kfreed 'lock': %d at %p (tot 0).\n", sizeof(*lock), lock); } else @@ -189,6 +187,19 @@ void ldlm_lock_put(struct ldlm_lock *lock) EXIT; } +void ldlm_lock_remove_from_lru(struct ldlm_lock *lock) +{ + ENTRY; + l_lock(&lock->l_resource->lr_namespace->ns_lock); + if (!list_empty(&lock->l_lru)) { + list_del_init(&lock->l_lru); + lock->l_resource->lr_namespace->ns_nr_unused--; + LASSERT(lock->l_resource->lr_namespace->ns_nr_unused >= 0); + } + l_unlock(&lock->l_resource->lr_namespace->ns_lock); + EXIT; +} + void ldlm_lock_destroy(struct ldlm_lock *lock) { ENTRY; @@ -210,17 +221,17 @@ void ldlm_lock_destroy(struct ldlm_lock *lock) LBUG(); } - if (lock->l_flags & LDLM_FL_DESTROYED) { + if (lock->l_destroyed) { LASSERT(list_empty(&lock->l_lru)); l_unlock(&lock->l_resource->lr_namespace->ns_lock); EXIT; return; } + lock->l_destroyed = 1; - list_del_init(&lock->l_lru); list_del(&lock->l_export_chain); lock->l_export = NULL; - lock->l_flags |= LDLM_FL_DESTROYED; + ldlm_lock_remove_from_lru(lock); /* Wake anyone waiting for this lock */ /* FIXME: I should probably add yet another flag, instead of using @@ -258,7 +269,7 @@ static struct ldlm_lock *ldlm_lock_new(struct ldlm_lock *parent, lock->l_resource = resource; /* this refcount matches the one of the resource passed in which is not being put away */ - lock->l_refc = 1; + atomic_set(&lock->l_refc, 1); INIT_LIST_HEAD(&lock->l_children); INIT_LIST_HEAD(&lock->l_res_link); INIT_LIST_HEAD(&lock->l_lru); @@ -288,7 +299,7 @@ int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3]) { struct ldlm_namespace *ns = lock->l_resource->lr_namespace; struct ldlm_resource *oldres = lock->l_resource; - int i; + int i, refc; ENTRY; l_lock(&ns->ns_lock); @@ -312,15 +323,16 @@ int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3]) } /* move references over */ - for (i = 0; i < lock->l_refc; i++) { + refc = atomic_read(&lock->l_refc); + for (i = 0; i < refc; i++) { int rc; ldlm_resource_getref(lock->l_resource); - rc = ldlm_resource_put(oldres); - if (rc == 1 && i != lock->l_refc - 1) + rc = ldlm_resource_putref(oldres); + if (rc == 1 && i != refc - 1) LBUG(); } /* compensate for the initial get above.. */ - ldlm_resource_put(lock->l_resource); + ldlm_resource_putref(lock->l_resource); l_unlock(&ns->ns_lock); RETURN(0); @@ -341,8 +353,8 @@ void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh) * Return NULL if flag already set */ -struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, - int strict, int flags) +struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, int strict, + int flags) { struct ldlm_lock *lock = NULL, *retval = NULL; ENTRY; @@ -352,7 +364,6 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, if (!handle->addr) RETURN(NULL); - //spin_lock(&ldlm_handle_lock); lock = (struct ldlm_lock *)(unsigned long)(handle->addr); if (!kmem_cache_validate(ldlm_lock_slab, (void *)lock)) { //CERROR("bogus lock %p\n", lock); @@ -360,8 +371,8 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, } if (lock->l_random != handle->cookie) { - //CERROR("bogus cookie: lock %p has "LPX64" vs. handle "LPX64"\n", - // lock, lock->l_random, handle->cookie); + //CERROR("bogus cookie: lock %p has "LPX64" vs. handle "LPX64 + // "\n", lock, lock->l_random, handle->cookie); GOTO(out2, NULL); } if (!lock->l_resource) { @@ -376,7 +387,7 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, } l_lock(&lock->l_resource->lr_namespace->ns_lock); - if (strict && lock->l_flags & LDLM_FL_DESTROYED) { + if (strict && lock->l_destroyed) { CERROR("lock already destroyed: lock %p\n", lock); //LDLM_DEBUG(lock, "ldlm_handle2lock(%p)", lock); GOTO(out, NULL); @@ -395,7 +406,6 @@ struct ldlm_lock *__ldlm_handle2lock(struct lustre_handle *handle, out: l_unlock(&lock->l_resource->lr_namespace->ns_lock); out2: - //spin_unlock(&ldlm_handle_lock); return retval; } @@ -455,13 +465,7 @@ void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode) void ldlm_lock_addref_internal(struct ldlm_lock *lock, __u32 mode) { l_lock(&lock->l_resource->lr_namespace->ns_lock); - - if (!list_empty(&lock->l_lru)) { - list_del_init(&lock->l_lru); - lock->l_resource->lr_namespace->ns_nr_unused--; - LASSERT(lock->l_resource->lr_namespace->ns_nr_unused >= 0); - } - + ldlm_lock_remove_from_lru(lock); if (mode == LCK_NL || mode == LCK_CR || mode == LCK_PR) lock->l_readers++; else @@ -612,7 +616,7 @@ static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode, if (lock == old_lock) continue; - if (lock->l_flags & (LDLM_FL_CBPENDING | LDLM_FL_DESTROYED)) + if (lock->l_flags & LDLM_FL_CBPENDING) continue; if (lock->l_req_mode != mode) @@ -623,6 +627,9 @@ static struct ldlm_lock *search_queue(struct list_head *queue, ldlm_mode_t mode, lock->l_extent.end < extent->end)) continue; + if (lock->l_destroyed) + continue; + ldlm_lock_addref_internal(lock, mode); return lock; } @@ -676,7 +683,7 @@ int ldlm_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type, EXIT; out: - ldlm_resource_put(res); + ldlm_resource_putref(res); l_unlock(&ns->ns_lock); if (lock) { @@ -716,7 +723,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, lock = ldlm_lock_new(parent_lock, res); if (lock == NULL) { - ldlm_resource_put(res); + ldlm_resource_putref(res); RETURN(NULL); } @@ -961,7 +968,7 @@ void ldlm_cancel_locks_for_export(struct obd_export *exp) LDLM_DEBUG(lock, "export %p", exp); ldlm_lock_cancel(lock); ldlm_reprocess_all(res); - ldlm_resource_put(res); + ldlm_resource_putref(res); } } diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 892bf9435d6d6935c9c8feee33d32d67bcfd4c2b..bd2dd0914973f1496ce29c7e30f6a41ec0e7c350 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -32,6 +32,7 @@ extern kmem_cache_t *ldlm_resource_slab; extern kmem_cache_t *ldlm_lock_slab; +extern struct lustre_lock ldlm_handle_lock; extern struct list_head ldlm_namespace_list; extern int (*mds_reint_p)(int offset, struct ptlrpc_request *req); extern int (*mds_getattr_name_p)(int offset, struct ptlrpc_request *req); @@ -734,6 +735,8 @@ static int __init ldlm_init(void) return -ENOMEM; } + l_lock_init(&ldlm_handle_lock); + return 0; } diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index ccb7611a94dc530c1ae87bc4a315bbf2af62dc27..7d449ef3b9bc82b807df24e9186877ae6d6a7fe0 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -78,9 +78,9 @@ int ldlm_completion_ast(struct ldlm_lock *lock, int flags) /* Go to sleep until the lock is granted or cancelled. */ rc = l_wait_event(lock->l_waitq, ((lock->l_req_mode == lock->l_granted_mode) || - (lock->l_flags & LDLM_FL_DESTROYED)), &lwi); + lock->l_destroyed), &lwi); - if (lock->l_flags & LDLM_FL_DESTROYED) { + if (lock->l_destroyed) { LDLM_DEBUG(lock, "client-side enqueue waking up: destroyed"); RETURN(-EIO); } @@ -518,7 +518,7 @@ int ldlm_cancel_lru(struct ldlm_namespace *ns) w->w_lock = LDLM_LOCK_GET(lock); list_add(&w->w_list, &list); - list_del_init(&lock->l_lru); + ldlm_lock_remove_from_lru(lock); if (--count == 0) break; @@ -600,7 +600,7 @@ int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, OBD_FREE(w, sizeof(*w)); } - ldlm_resource_put(res); + ldlm_resource_putref(res); RETURN(0); } @@ -614,6 +614,7 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id, int flags) { int i; + ENTRY; if (res_id) RETURN(ldlm_cli_cancel_unused_resource(ns, res_id, flags)); @@ -633,12 +634,12 @@ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, __u64 *res_id, if (rc) CERROR("cancel_unused_res ("LPU64"): %d\n", res->lr_name[0], rc); - ldlm_resource_put(res); + ldlm_resource_putref(res); } } l_unlock(&ns->ns_lock); - return ELDLM_OK; + RETURN(ELDLM_OK); } /* Lock iterators. */ @@ -709,7 +710,7 @@ int ldlm_namespace_foreach(struct ldlm_namespace *ns, ldlm_iterator_t iter, ldlm_resource_getref(res); rc = ldlm_resource_foreach(res, ldlm_iter_helper, &helper); - ldlm_resource_put(res); + ldlm_resource_putref(res); if (rc == LDLM_ITER_STOP) GOTO(out, rc); } diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 60a351fd46b1d20a68f736360d81c57d38a9be60..64ec59126c80043c58e820bb6663ad9a70cf9d73 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -182,13 +182,13 @@ int ldlm_namespace_cleanup(struct ldlm_namespace *ns, int local_only) * local_only (which is only used by recovery). In that * case, we probably still have outstanding lock refs * which reference these resources. -phil */ - if (!ldlm_resource_put(res) && !local_only) { + if (!ldlm_resource_putref(res) && !local_only) { CERROR("Resource refcount nonzero (%d) after " "lock cleanup; forcing cleanup.\n", atomic_read(&res->lr_refcount)); ldlm_resource_dump(res); atomic_set(&res->lr_refcount, 1); - ldlm_resource_put(res); + ldlm_resource_putref(res); } } } @@ -286,6 +286,7 @@ static struct ldlm_resource *ldlm_resource_add(struct ldlm_namespace *ns, ns->ns_resources++; spin_unlock(&ns->ns_counter_lock); + l_lock(&ns->ns_lock); memcpy(res->lr_name, name, sizeof(res->lr_name)); res->lr_namespace = ns; ns->ns_refcount++; @@ -296,12 +297,13 @@ static struct ldlm_resource *ldlm_resource_add(struct ldlm_namespace *ns, bucket = ns->ns_hash + ldlm_hash_fn(parent, name); list_add(&res->lr_hash, bucket); - if (parent == NULL) + if (parent == NULL) { list_add(&res->lr_childof, &ns->ns_root_list); - else { + } else { res->lr_parent = parent; list_add(&res->lr_childof, &parent->lr_children); } + l_unlock(&ns->ns_lock); RETURN(res); } @@ -348,37 +350,49 @@ struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res) { atomic_inc(&res->lr_refcount); + CDEBUG(D_INFO, "getref res: %p count: %d\n", res, + atomic_read(&res->lr_refcount)); return res; } /* Returns 1 if the resource was freed, 0 if it remains. */ -int ldlm_resource_put(struct ldlm_resource *res) +int ldlm_resource_putref(struct ldlm_resource *res) { int rc = 0; if (atomic_dec_and_test(&res->lr_refcount)) { struct ldlm_namespace *ns = res->lr_namespace; ENTRY; + CDEBUG(D_INFO, "putref res: %p count: %d\n", res, + atomic_read(&res->lr_refcount)); l_lock(&ns->ns_lock); if (atomic_read(&res->lr_refcount) != 0) { /* We lost the race. */ l_unlock(&ns->ns_lock); - goto out; + RETURN(rc); } - if (!list_empty(&res->lr_granted)) + if (!list_empty(&res->lr_granted)) { + ldlm_resource_dump(res); LBUG(); + } - if (!list_empty(&res->lr_converting)) + if (!list_empty(&res->lr_converting)) { + ldlm_resource_dump(res); LBUG(); + } - if (!list_empty(&res->lr_waiting)) + if (!list_empty(&res->lr_waiting)) { + ldlm_resource_dump(res); LBUG(); + } - if (!list_empty(&res->lr_children)) + if (!list_empty(&res->lr_children)) { + ldlm_resource_dump(res); LBUG(); + } ns->ns_refcount--; list_del(&res->lr_hash); @@ -395,9 +409,10 @@ int ldlm_resource_put(struct ldlm_resource *res) rc = 1; } else { ENTRY; + CDEBUG(D_INFO, "putref res: %p count: %d\n", res, + atomic_read(&res->lr_refcount)); out: - if (atomic_read(&res->lr_refcount) < 0) - LBUG(); + LASSERT(atomic_read(&res->lr_refcount) >= 0); } RETURN(rc); @@ -411,8 +426,7 @@ void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head, ldlm_resource_dump(res); ldlm_lock_dump(lock); - if (!list_empty(&lock->l_res_link)) - LBUG(); + LASSERT(list_empty(&lock->l_res_link)); list_add(&lock->l_res_link, head); l_unlock(&res->lr_namespace->ns_lock); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index d3e5769fecf3a0c8828ad4799e7d52f3be300afc..9670af03442e76f812660226687284cc8c1acf02 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -306,7 +306,6 @@ int ll_intent_lock(struct inode *parent, struct dentry **de, } offset = 0; } else { - struct ll_inode_info *lli = ll_i2info(parent); obd_flag valid; int mode; @@ -653,7 +652,6 @@ static int ll_create(struct inode *dir, struct dentry *dentry, int mode) RETURN(PTR_ERR(inode)); if (it && it->it_disposition) { - struct ll_inode_info *lli = ll_i2info(inode); d_instantiate(dentry, inode); } else { /* no directory data updates when intents rule */ diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 1b9240944ed360b7514afd37a7783d1045251405..e7cf3cb71460b4bb96cce4d81af82c5028188798 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1378,7 +1378,7 @@ static int lov_statfs(struct lustre_handle *conn, struct obd_statfs *osfs) RETURN(rc); } -static int lov_iocontrol(long cmd, struct lustre_handle *conn, int len, +static int lov_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg) { struct obd_device *obddev = class_conn2obd(conn); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 16f6ca8252434c139052e1b1da57085f637db1a0..79b07ba32684a3c0acf433604d5933db1400a5e5 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -521,6 +521,7 @@ int mdc_close(struct lustre_handle *conn, obd_id ino, int type, struct mds_body *body; int rc, size = sizeof(*body); struct ptlrpc_request *req; + ENTRY; req = ptlrpc_prep_req(class_conn2cliimp(conn), MDS_CLOSE, 1, &size, NULL); diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index bfdb3de2f094f9a911e2bab00b6b63e36f8eea79..ee126528df51f10f46d2d60d0aa8858ab56e0517 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -1783,7 +1783,7 @@ static int mdt_cleanup(struct obd_device *obddev) RETURN(0); } -extern int mds_iocontrol(long cmd, struct lustre_handle *conn, +extern int mds_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg); /* use obd ops to offer management infrastructure */ diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index 811c801338b6b76c6eeaefa75db87c0fa766f87e..163a45fa0e4d0e54fa07c4d9cdbb9a9b4d6fe5ac 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -32,7 +32,8 @@ struct mds_fs_type { char *mft_name; }; -#define MDS_MAX_CLIENTS 1024 +/* This limit is arbitrary, but for now we fit it in 1 page (32k clients) */ +#define MDS_MAX_CLIENTS (PAGE_SIZE * 8) #define MDS_MAX_CLIENT_WORDS (MDS_MAX_CLIENTS / sizeof(unsigned long)) static unsigned long last_rcvd_slots[MDS_MAX_CLIENT_WORDS]; diff --git a/lustre/mds/mds_lov.c b/lustre/mds/mds_lov.c index a7304de7db9136d80f13a2d32f20c4f6e4385d39..ba9a750a47f96609bced87e82f3373a0832eb6aa 100644 --- a/lustre/mds/mds_lov.c +++ b/lustre/mds/mds_lov.c @@ -154,7 +154,7 @@ out: RETURN(rc); } -int mds_iocontrol(long cmd, struct lustre_handle *conn, +int mds_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg) { struct obd_device *obd = class_conn2obd(conn); diff --git a/lustre/obdclass/Makefile.am b/lustre/obdclass/Makefile.am index 44c7ec7cb05f61a92208d1aff0e7e472cb1ba82e..d7df0bbf09c2af277253eae6ed6e1762de78cdf5 100644 --- a/lustre/obdclass/Makefile.am +++ b/lustre/obdclass/Makefile.am @@ -8,6 +8,7 @@ obdclass_SOURCES = debug.c genops.c class_obd.c sysctl.c uuid.c lprocfs_status.c include $(top_srcdir)/Rules lustre_build_version: perl $(top_srcdir)/scripts/version_tag.pl $(top_srcdir) > tmpver - diff -u tmpver $(top_builddir)/include/linux/lustre_build_version.h &&\ + diff -u $(top_builddir)/include/linux/lustre_build_version.h tmpver \ + 2> /dev/null &&\ $(RM) tmpver || \ mv tmpver $(top_builddir)/include/linux/lustre_build_version.h diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index a780f10cc3eb0ebc5a026dc731bb192fe73d14bc..32e8c08be5ac4226c32fe9ee60db1735117a90c9 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -132,10 +132,19 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, struct obd_ioctl_data *data; struct obd_device *obd = filp->private_data; struct lustre_handle conn; - int err = 0, len = 0; + int err = 0, len = 0, serialised = 0; ENTRY; - down(&obd_conf_sem); + switch (cmd) { + case OBD_IOC_BRW_WRITE: + case OBD_IOC_BRW_READ: + case OBD_IOC_GETATTR: + break; + default: + down(&obd_conf_sem); + serialised = 1; + break; + } if (!obd && cmd != OBD_IOC_DEVICE && cmd != TCGETS && cmd != OBD_IOC_LIST && cmd != OBD_GET_VERSION && @@ -519,7 +528,8 @@ static int obd_class_ioctl (struct inode * inode, struct file * filp, out: if (buf) OBD_FREE(buf, len); - up(&obd_conf_sem); + if (serialised) + up(&obd_conf_sem); RETURN(err); } /* obd_class_ioctl */ diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 763ddb80c2f69a34b6d79e24f87830e6c0eda842..4ccc0437171eb0ab1f8341b9db861b13f0809051 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -31,7 +31,7 @@ #include <linux/lustre_debug.h> #include <linux/lprocfs_status.h> -static int echo_iocontrol(long cmd, struct lustre_handle *obdconn, int len, +static int echo_iocontrol(unsigned int cmd, struct lustre_handle *obdconn, int len, void *karg, void *uarg) { struct obd_device *obd = class_conn2obd(obdconn); @@ -182,7 +182,8 @@ static int echo_iocontrol(long cmd, struct lustre_handle *obdconn, int len, GOTO(out, rc); } default: - return -ENOTTY; + CERROR ("echo_ioctl(): unrecognised ioctl %#lx\n", cmd); + GOTO (out, rc = -ENOTTY); } out: diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index a5302ef7f9e6f949f62e400ee06effee6504e085..de403b518aace5289f3cc24d7138884dd0210d54 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -774,7 +774,7 @@ static int osc_statfs(struct lustre_handle *conn, struct obd_statfs *osfs) return rc; } -static int osc_iocontrol(long cmd, struct lustre_handle *conn, int len, +static int osc_iocontrol(unsigned int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg) { struct obd_device *obddev = class_conn2obd(conn); @@ -877,6 +877,7 @@ static int osc_iocontrol(long cmd, struct lustre_handle *conn, int len, GOTO(out, err); } default: + CERROR ("osc_ioctl(): unrecognised ioctl %#lx\n", cmd); GOTO(out, err = -ENOTTY); } out: diff --git a/lustre/ptlrpc/client.c b/lustre/ptlrpc/client.c index 04a76f2711adf4e4bc7ddc95948158c14bdc4b7c..4ab7903da3e69bcefd2cd37d1d22e1386812f12c 100644 --- a/lustre/ptlrpc/client.c +++ b/lustre/ptlrpc/client.c @@ -391,6 +391,7 @@ static int ptlrpc_check_reply(struct ptlrpc_request *req) DEBUG_REQ(D_ERROR, req, "RESTART:"); GOTO(out, rc = 1); } + EXIT; out: DEBUG_REQ(D_NET, req, "rc = %d for", rc); return rc; @@ -443,6 +444,10 @@ void ptlrpc_free_committed(struct obd_import *imp) struct ptlrpc_request *req; ENTRY; +#ifndef __arch_um__ + LASSERT(spin_is_locked(&imp->imp_lock)); +#endif + CDEBUG(D_HA, "committing for xid "LPU64", last_committed "LPU64"\n", imp->imp_peer_last_xid, imp->imp_peer_committed_transno); @@ -455,10 +460,12 @@ void ptlrpc_free_committed(struct obd_import *imp) } /* not yet committed */ - if (req->rq_transno > imp->imp_peer_committed_transno) + if (req->rq_transno > imp->imp_peer_committed_transno) { + DEBUG_REQ(D_HA, req, "stopping search"); break; + } - DEBUG_REQ(D_HA, req, "committing (last_committed %Lu)", + DEBUG_REQ(D_HA, req, "committing (last_committed "LPU64")", imp->imp_peer_committed_transno); __ptlrpc_req_finished(req, 1); } diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index c721993af9b923f72615baf6472e5fa9748b252a..eb6acb1abf10e3e7713d5546e83dcded412d359d 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -71,7 +71,7 @@ int connmgr_cleanup(struct obd_device *dev) RETURN(0); } -int connmgr_iocontrol(long cmd, struct lustre_handle *hdl, int len, void *karg, +int connmgr_iocontrol(unsigned int cmd, struct lustre_handle *hdl, int len, void *karg, void *uarg) { struct ptlrpc_connection *conn = NULL; diff --git a/lustre/scripts/version_tag.pl b/lustre/scripts/version_tag.pl index e810f3f8fa61474c4a07f6202766e85a458166e1..a92fef4b527a223873940033f3cbf6810826b13e 100644 --- a/lustre/scripts/version_tag.pl +++ b/lustre/scripts/version_tag.pl @@ -135,7 +135,8 @@ sub generate_ver($$$) localtime($mtime); $year += 1900; $mon++; - my $show_last = $year . $mon . $mday . $hour . $min . $sec; + my $show_last = sprintf("%04d%02d%02d%02d%02d%02d", $year, $mon, $mday, + $hour, $min, $sec); print "#define BUILD_VERSION \""; if ($pristine) { diff --git a/lustre/tests/.cvsignore b/lustre/tests/.cvsignore index 1ad2510e4e82f8286e69877e338f02db08dafd2f..556392382556579c991cb0be064ce50de3925119 100644 --- a/lustre/tests/.cvsignore +++ b/lustre/tests/.cvsignore @@ -26,3 +26,4 @@ mkdirmany lovstripe *.xml stat +setuid diff --git a/lustre/tests/acceptance-small.sh b/lustre/tests/acceptance-small.sh index 5b8161143d95495122fe285811a2b10d7cfb83b4..06c4a84443099deb1595c8b632f42151b90594e9 100755 --- a/lustre/tests/acceptance-small.sh +++ b/lustre/tests/acceptance-small.sh @@ -9,6 +9,7 @@ set -vxe [ "$RSIZE" ] || RSIZE=64 [ "$UID" ] || UID=1000 [ "$MNT" ] || MNT=/mnt/lustre +[ "$TMP" ] || TMP=/tmp [ "$COUNT" ] || COUNT=1000 [ "$DEBUG_OFF" ] || DEBUG_OFF="eval echo 0 > /proc/sys/portals/debug" @@ -75,7 +76,7 @@ for NAME in $CONFIGS; do fi if [ "$FSX" != "no" ]; then $DEBUG_OFF - ./fsx -c 50 -p 1000 -l 1024000 -N $(($COUNT * 100)) $MNT/fsxfile + ./fsx -c 50 -p 1000 -P $TMP -l 1024000 -N $(($COUNT * 100)) $MNT/fsxfile sh llmountcleanup.sh #sh llrmount.sh fi diff --git a/lustre/tests/fsx.c b/lustre/tests/fsx.c index e7c1495ef0aed6e7c7a93b7c5e6844681276cedb..717b8d4c96b9c401643bbda6f268602c0957613a 100644 --- a/lustre/tests/fsx.c +++ b/lustre/tests/fsx.c @@ -41,6 +41,7 @@ # include <limits.h> # include <time.h> # include <strings.h> +# include <sys/time.h> #endif #include <fcntl.h> #include <sys/mman.h> @@ -64,6 +65,7 @@ struct log_entry { int operation; + struct timeval tv; int args[3]; }; @@ -92,6 +94,8 @@ char *original_buf; /* a pointer to the original data */ char *good_buf; /* a pointer to the correct data */ char *temp_buf; /* a pointer to the current data */ char *fname; /* name of our test file */ +char logfile[1024]; /* name of our log file */ +char goodfile[1024]; /* name of our test file */ int fd; /* fd for our test file */ off_t file_size = 0; @@ -171,11 +175,12 @@ prterr(char *prefix) void -log4(int operation, int arg0, int arg1, int arg2) +log4(int operation, int arg0, int arg1, int arg2, struct timeval *tv) { struct log_entry *le; le = &oplog[logptr]; + le->tv = *tv; le->operation = operation; if (closeopen) le->operation = ~ le->operation; @@ -207,8 +212,9 @@ logdump(void) int opnum; opnum = i+1 + (logcount/LOGSIZE)*LOGSIZE; - prt("%d(%d mod 256): ", opnum, opnum%256); lp = &oplog[i]; + prt("%d(%d mod 256): %lu.%lu ", opnum, opnum%256, + lp->tv.tv_sec, lp->tv.tv_usec); if ((closeopen = lp->operation < 0)) lp->operation = ~ lp->operation; @@ -325,8 +331,8 @@ report_failure(int status) if (good_buf) { save_buffer(good_buf, file_size, fsxgoodfd); prt("Correct content saved for comparison\n"); - prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", - fname, fname); + prt("(maybe hexdump \"%s\" vs \"%s\")\n", + fname, goodfile); } close(fsxgoodfd); } @@ -422,24 +428,26 @@ check_trunc_hack(void) void doread(unsigned offset, unsigned size) { + struct timeval t; off_t ret; unsigned iret; offset -= offset % readbdy; + gettimeofday(&t, NULL); if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_READ, offset, size); + log4(OP_SKIPPED, OP_READ, offset, size, &t); return; } if (size + offset > file_size) { if (!quiet && testcalls > simulatedopcount) prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_READ, offset, size); + log4(OP_SKIPPED, OP_READ, offset, size, &t); return; } - log4(OP_READ, offset, size, 0); + log4(OP_READ, offset, size, 0, &t); if (testcalls <= simulatedopcount) return; @@ -450,8 +458,9 @@ doread(unsigned offset, unsigned size) (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) - prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); + prt("%lu %lu.%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", + testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1, + size); ret = lseek(fd, (off_t)offset, SEEK_SET); if (ret == (off_t)-1) { prterr("doread: lseek"); @@ -473,25 +482,27 @@ doread(unsigned offset, unsigned size) void domapread(unsigned offset, unsigned size) { + struct timeval t; unsigned pg_offset; unsigned map_size; char *p; offset -= offset % readbdy; + gettimeofday(&t, NULL); if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size read\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); + log4(OP_SKIPPED, OP_MAPREAD, offset, size, &t); return; } if (size + offset > file_size) { if (!quiet && testcalls > simulatedopcount) prt("skipping seek/read past end of file\n"); - log4(OP_SKIPPED, OP_MAPREAD, offset, size); + log4(OP_SKIPPED, OP_MAPREAD, offset, size, &t); return; } - log4(OP_MAPREAD, offset, size, 0); + log4(OP_MAPREAD, offset, size, 0, &t); if (testcalls <= simulatedopcount) return; @@ -502,14 +513,14 @@ domapread(unsigned offset, unsigned size) (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); + prt("%lu %lu.%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", + testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1, + size); pg_offset = offset & page_mask; map_size = pg_offset + size; - if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | -MAP_SHARED, fd, + if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, (off_t)(offset - pg_offset))) == (char *)-1) { prterr("domapread: mmap"); report_failure(190); @@ -539,18 +550,20 @@ gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size) void dowrite(unsigned offset, unsigned size) { + struct timeval t; off_t ret; unsigned iret; offset -= offset % writebdy; + gettimeofday(&t, NULL); if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_WRITE, offset, size); + log4(OP_SKIPPED, OP_WRITE, offset, size, &t); return; } - log4(OP_WRITE, offset, size, file_size); + log4(OP_WRITE, offset, size, file_size, &t); gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { @@ -572,8 +585,9 @@ dowrite(unsigned offset, unsigned size) (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) - prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); + prt("%lu %lu.%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", + testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1, + size); ret = lseek(fd, (off_t)offset, SEEK_SET); if (ret == (off_t)-1) { prterr("dowrite: lseek"); @@ -594,21 +608,23 @@ dowrite(unsigned offset, unsigned size) void domapwrite(unsigned offset, unsigned size) { + struct timeval t; unsigned pg_offset; unsigned map_size; off_t cur_filesize; char *p; offset -= offset % writebdy; + gettimeofday(&t, NULL); if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size write\n"); - log4(OP_SKIPPED, OP_MAPWRITE, offset, size); + log4(OP_SKIPPED, OP_MAPWRITE, offset, size, &t); return; } cur_filesize = file_size; - log4(OP_MAPWRITE, offset, size, 0); + log4(OP_MAPWRITE, offset, size, 0, &t); gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { @@ -630,8 +646,9 @@ domapwrite(unsigned offset, unsigned size) (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) - prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, - offset, offset + size - 1, size); + prt("%lu %lu.%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", + testcalls, t.tv_sec, t.tv_usec, offset, offset + size - 1, + size); if (file_size > cur_filesize) { if (ftruncate(fd, file_size) == -1) { @@ -663,16 +680,18 @@ domapwrite(unsigned offset, unsigned size) void dotruncate(unsigned size) { + struct timeval t; int oldsize = file_size; size -= size % truncbdy; + gettimeofday(&t, NULL); if (size > biggest) { biggest = size; if (!quiet && testcalls > simulatedopcount) prt("truncating to largest ever: 0x%x\n", size); } - log4(OP_TRUNCATE, size, (unsigned)file_size, 0); + log4(OP_TRUNCATE, size, (unsigned)file_size, 0, &t); if (size > file_size) memset(good_buf + file_size, '\0', size - file_size); @@ -684,8 +703,8 @@ dotruncate(unsigned size) if ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || monitorend == -1 || size <= monitorend))) - prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, -size); + prt("%lu %lu.%lu trunc\tfrom 0x%x to 0x%x\n", + testcalls, t.tv_sec, t.tv_usec, oldsize, size); if (ftruncate(fd, (off_t)size) == -1) { prt("ftruncate1: %x\n", size); prterr("dotruncate: ftruncate"); @@ -723,11 +742,16 @@ writefileimage() void docloseopen(void) { + struct timeval t; + if (testcalls <= simulatedopcount) return; + log4(OP_CLOSEOPEN, file_size, (unsigned)file_size, 0, &t); + + gettimeofday(&t, NULL); if (debug) - prt("%lu close/open\n", testcalls); + prt("%lu %lu.%lu close/open\n", testcalls, t.tv_sec, t.tv_usec); if (close(fd)) { prterr("docloseopen: close"); report_failure(180); @@ -892,13 +916,19 @@ getnum(char *s, char **e) } +static const char *basename(const char *path) +{ + char *c = strrchr(path, '/'); + + return c ? c++ : path; +} + int main(int argc, char **argv) { int i, style, ch; char *endp; - char goodfile[1024]; - char logfile[1024]; + int dirpath = 0; goodfile[0] = 0; logfile[0] = 0; @@ -1007,6 +1037,7 @@ main(int argc, char **argv) strcat(goodfile, "/"); strncpy(logfile, optarg, sizeof(logfile)); strcat(logfile, "/"); + dirpath = 1; break; case 'R': mapped_reads = 0; @@ -1054,14 +1085,14 @@ main(int argc, char **argv) prterr(fname); exit(91); } - strncat(goodfile, fname, 256); + strncat(goodfile, dirpath ? basename(fname) : fname, 256); strcat (goodfile, ".fsxgood"); fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fsxgoodfd < 0) { prterr(goodfile); exit(92); } - strncat(logfile, fname, 256); + strncat(logfile, dirpath ? basename(fname) : fname, 256); strcat (logfile, ".fsxlog"); fsxlogf = fopen(logfile, "w"); if (fsxlogf == NULL) { diff --git a/lustre/tests/leak_finder.pl b/lustre/tests/leak_finder.pl index 1a923277a17509427910258aa5e894cdf2c5a1b0..fbf1d00a1d198eed8fc271522bf1f34e07ec7ed9 100644 --- a/lustre/tests/leak_finder.pl +++ b/lustre/tests/leak_finder.pl @@ -1,19 +1,24 @@ #!/usr/bin/perl -w +use IO::Handle; + +STDOUT->autoflush(1); +STDERR->autoflush(1); + my ($line, $memory); my $debug_line = 0; while ($line = <>) { $debug_line++; my ($file, $func, $lno, $name, $size, $addr, $type); - if ($line =~ m/^.*\((.*):(\d+):(.*)\(\) \d+\+\d+\): [vk](.*) '(.*)': (\d+) at (.*) \(tot .*$/) { + if ($line =~ m/^.*\((.*):(\d+):(.*)\(\) (\d+ \| )?\d+\+\d+\): [vk](.*) '(.*)': (\d+) at (.*) \(tot .*$/) { $file = $1; $lno = $2; $func = $3; - $type = $4; - $name = $5; - $size = $6; - $addr = $7; + $type = $5; + $name = $6; + $size = $7; + $addr = $8; printf("%8s %6d bytes at %s called %s (%s:%s:%d)\n", $type, $size, $addr, $name, $file, $func, $lno); } else { @@ -29,14 +34,14 @@ while ($line = <>) { $memory->{$addr}->{debug_line} = $debug_line; } else { if (!defined($memory->{$addr})) { - print "*** Free without malloc ($size bytes at $addr, $file:$func:$lno)\n"; + print STDERR "*** Free without malloc ($size bytes at $addr, $file:$func:$lno)\n"; next; } my ($oldname, $oldsize, $oldfile, $oldfunc, $oldlno) = $memory->{$addr}; if ($memory->{$addr}->{size} != $size) { - print "*** Free different size ($memory->{$addr}->{size} alloced, $size freed).\n"; - print " malloc at $memory->{$addr}->{file}:$memory->{$addr}->{func}:$memory->{$addr}->{lno}, free at $file:$func:$lno\n"; + print STDERR "*** Free different size ($memory->{$addr}->{size} alloced, $size freed).\n"; + print STDERR " malloc at $memory->{$addr}->{file}:$memory->{$addr}->{func}:$memory->{$addr}->{lno}, free at $file:$func:$lno\n"; next; } @@ -44,10 +49,15 @@ while ($line = <>) { } } +# Sort leak output by allocation time +my @sorted = sort { + return $memory->{$a}->{debug_line} <=> $memory->{$b}->{debug_line}; +} keys(%{$memory}); + my $key; -foreach $key (keys(%{$memory})) { +foreach $key (@sorted) { my ($oldname, $oldsize, $oldfile, $oldfunc, $oldlno) = $memory->{$key}; - print "*** Leak: $memory->{$key}->{size} bytes allocated at $key ($memory->{$key}->{file}:$memory->{$key}->{func}:$memory->{$key}->{lno}, debug file line $memory->{$key}->{debug_line})\n"; + print STDERR "*** Leak: $memory->{$key}->{size} bytes allocated at $key ($memory->{$key}->{file}:$memory->{$key}->{func}:$memory->{$key}->{lno}, debug file line $memory->{$key}->{debug_line})\n"; } print "Done.\n"; diff --git a/lustre/tests/llmount2-hack.sh b/lustre/tests/llmount2-hack.sh index d17805adbf31d0e6f01d897d8182745a507e2e35..495626c469402a58d43859d1a5e1e03827761842 100644 --- a/lustre/tests/llmount2-hack.sh +++ b/lustre/tests/llmount2-hack.sh @@ -2,16 +2,11 @@ # suggested boilerplate for test script LCONF=${LCONF:-../utils/lconf} -NAME=${NAME:-local2} +NAME=${NAME:-local2-hack} config=$NAME.xml -mkconfig=./$NAME.sh -if [ ! -f $config -o $mkconfig -nt $config ]; then - sh $mkconfig $config || exit 1 -fi - -${LCONF} -v --reformat --gdb $config || exit 2 +${LCONF} --reformat --gdb $config || exit 2 ../utils/lctl <<EOF newdev diff --git a/lustre/tests/lov.xml b/lustre/tests/lov.xml deleted file mode 100644 index 532c1ec29021b9707e564714051dfd752f3062a6..0000000000000000000000000000000000000000 --- a/lustre/tests/lov.xml +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version='1.0' encoding='UTF-8'?> -<!DOCTYPE lustre> -<lustre> - <ldlm name='ldlm' uuid='ldlm_UUID'/> - <node name='localhost' uuid='localhost_UUID'> - <profile> - <ldlm_ref uuidref='ldlm_UUID'/> - <network_ref uuidref='NET_localhost_tcp_UUID'/> - <mds_ref uuidref='mds1_UUID'/> - <lovconfig_ref uuidref='LVCFG_lov1_UUID'/> - <obd_ref uuidref='OBD_localhost_UUID'/> - <ost_ref uuidref='OST_localhost_UUID'/> - <obd_ref uuidref='OBD_localhost_2_UUID'/> - <ost_ref uuidref='OST_localhost_2_UUID'/> - <mountpoint_ref uuidref='MNT_localhost_UUID'/> - </profile> - <network name='NET_localhost_tcp' uuid='NET_localhost_tcp_UUID' type='tcp'> - <server>localhost</server> - <port>988</port> - </network> - </node> - <mds name='mds1' uuid='mds1_UUID'> - <fstype>extN</fstype> - <device size='50000'>/tmp/mds1</device> - <autoformat>yes</autoformat> - <network_ref uuidref='NET_localhost_tcp_UUID'/> - <node_ref uuidref='localhost_UUID'/> - </mds> - <lov name='lov1' uuid='lov1_UUID'> - <mds_ref uuidref='mds1_UUID'/> - <devices stripecount='0' stripesize='65536' pattern='0'> - <osc_ref uuidref='OSC_localhost_UUID'/> - <osc_ref uuidref='OSC_localhost_2_UUID'/> - </devices> - </lov> - <lovconfig name='LVCFG_lov1' uuid='LVCFG_lov1_UUID'> - <lov_ref uuidref='lov1_UUID'/> - </lovconfig> - <obd uuid='OBD_localhost_UUID' name='OBD_localhost' type='obdfilter'> - <fstype>extN</fstype> - <device size='100000'>/tmp/ost1</device> - <autoformat>no</autoformat> - </obd> - <osc name='OSC_localhost' uuid='OSC_localhost_UUID'> - <ost_ref uuidref='OST_localhost_UUID'/> - <obd_ref uuidref='OBD_localhost_UUID'/> - </osc> - <ost name='OST_localhost' uuid='OST_localhost_UUID'> - <network_ref uuidref='NET_localhost_tcp_UUID'/> - <obd_ref uuidref='OBD_localhost_UUID'/> - </ost> - <obd name='OBD_localhost_2' uuid='OBD_localhost_2_UUID' type='obdfilter'> - <fstype>extN</fstype> - <device size='100000'>/tmp/ost2</device> - <autoformat>no</autoformat> - </obd> - <osc name='OSC_localhost_2' uuid='OSC_localhost_2_UUID'> - <ost_ref uuidref='OST_localhost_2_UUID'/> - <obd_ref uuidref='OBD_localhost_2_UUID'/> - </osc> - <ost name='OST_localhost_2' uuid='OST_localhost_2_UUID'> - <network_ref uuidref='NET_localhost_tcp_UUID'/> - <obd_ref uuidref='OBD_localhost_2_UUID'/> - </ost> - <mountpoint name='MNT_localhost' uuid='MNT_localhost_UUID'> - <mds_ref uuidref='mds1_UUID'/> - <osc_ref uuidref='lov1_UUID'/> - <path>/mnt/lustre</path> - </mountpoint> -</lustre> diff --git a/lustre/tests/mcreate.c b/lustre/tests/mcreate.c index bc18aa73ab6456389ab8a3882b2359dd31961d5f..9d48b11b11f8cc39e9e44b20f0ae4a2a87a8a6d4 100644 --- a/lustre/tests/mcreate.c +++ b/lustre/tests/mcreate.c @@ -10,14 +10,14 @@ int main(int argc, char ** argv) { int rc; - if (argc < 2) { + if (argc < 2) { printf("Usage %s filename\n", argv[0]); return 1; } - rc = mknod(argv[1], S_IFREG| 0444, 0); - if (rc) { + rc = mknod(argv[1], S_IFREG | 0644, 0); + if (rc) { printf("mknod(%s) error: %s\n", argv[1], strerror(errno)); } return rc; -} +} diff --git a/lustre/tests/testreq.c b/lustre/tests/testreq.c index bfcbb5e113570b5debeeed65abbd1cf3da1d2b11..a0ce1ded711057e1af8e4a6a39dc091900e1feb9 100644 --- a/lustre/tests/testreq.c +++ b/lustre/tests/testreq.c @@ -52,7 +52,10 @@ static void usage(char *argv0, int status) int main(int argc, char **argv) { - int fd, rc, c, cmd = 0; + int fd = 0; + int rc = 0; + int c = 0; + long cmd = 0; unsigned long arg; char *short_opts = "h", *name = argv[0]; static struct option long_opts[] = { diff --git a/lustre/utils/lfind.c b/lustre/utils/lfind.c index d488748dd9a33b5cb260ff769375ff1ed0777d26..d0b4c49f666f654d5ca097cbbe9c569e9feff0ac 100644 --- a/lustre/utils/lfind.c +++ b/lustre/utils/lfind.c @@ -222,7 +222,7 @@ processFile(const char *path, const struct stat *sp, int flag, struct FTW *ftwp) if (verbose) { printf("lmm_magic: 0x%x\n", lmm->lmm_magic); - printf("lmm_object_id: 0x%llx\n", lmm->lmm_object_id); + printf("lmm_object_id: "LPX64"\n", lmm->lmm_object_id); printf("lmm_stripe_offset: %d\n", lmm->lmm_stripe_offset); printf("lmm_stripe_count: %d\n", lmm->lmm_stripe_count); printf("lmm_ost_count: %d\n", lmm->lmm_ost_count); @@ -241,7 +241,7 @@ processFile(const char *path, const struct stat *sp, int flag, struct FTW *ftwp) for (i = 0; i < count; i++, loi++) if ((oid = loi->l_object_id)) - printf("%6d\t%5lld\n", i, oid); + printf("%6d\t%5lld\n", i, (long long)oid); if (query) return(0); diff --git a/lustre/utils/llanalyze b/lustre/utils/llanalyze index 5548f9b1b9c0472880dd15deb1b30f806d167c0a..d2c92733979923f7bb545f1aa74246939a246389 100644 --- a/lustre/utils/llanalyze +++ b/lustre/utils/llanalyze @@ -61,10 +61,14 @@ $masks->{RPCTRACE} = 1 << 19; # /* recovery and failover */ sub extractpid { - $_ = shift; + $line = shift; # print "$_\n"; - /\(\) ([0-9]*)\+[0-9]*\):/; - return $1; + if ($line =~ m/\(\) ([0-9]*)\+[0-9]*\):/) { + return $1; + } + if ($line =~ m/\(\) ([0-9]*) | [0-9]*\+[0-9]*\):/) { + return $1; + } } sub entering diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index a6ccd29ddbdc8e9bca343f131323a69e78c55772..4a3b336358f5fff5b934c58097c8fc262d521d57 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -293,8 +293,8 @@ int do_disconnect(char *func, int verbose) rc = ioctl(fd, OBD_IOC_DISCONNECT, &data); if (rc < 0) { - fprintf(stderr, "error: %s: %x %s\n", cmdname(func), - OBD_IOC_DISCONNECT, strerror(errno)); + fprintf(stderr, "error: %s: OPD_IOC_DISCONNECT %s\n", + cmdname(func),strerror(errno)); } else { if (verbose) printf("%s: disconnected conn "LPX64"\n", cmdname(func), @@ -452,8 +452,8 @@ int jt_obd_connect(int argc, char **argv) rc = ioctl(fd, OBD_IOC_CONNECT, &data); if (rc < 0) - fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), - OBD_IOC_CONNECT, strerror(rc = errno)); + fprintf(stderr, "error: %s: OBD_IOC_CONNECT %s\n", + cmdname(argv[0]), strerror(rc = errno)); else { conn_addr = data.ioc_addr; conn_cookie = data.ioc_cookie; @@ -741,8 +741,8 @@ int jt_obd_attach(int argc, char **argv) IOC_PACK(argv[0], data); rc = ioctl(fd, OBD_IOC_ATTACH, buf); if (rc < 0) - fprintf(stderr, "error: %s: %x %s\n", cmdname(argv[0]), - OBD_IOC_ATTACH, strerror(rc = errno)); + fprintf(stderr, "error: %s: OBD_IOC_ATTACH %s\n", + cmdname(argv[0]), strerror(rc = errno)); else if (argc == 3) { char name[1024]; if (strlen(argv[2]) > 128) { @@ -1088,8 +1088,8 @@ int jt_obd_test_getattr(int argc, char **argv) rc = ioctl(fd, OBD_IOC_GETATTR, &data); SHMEM_BUMP(); if (rc < 0) { - fprintf(stderr, "error: %s: #"LPD64" - %s\n", - cmdname(argv[0]), i, strerror(rc = errno)); + fprintf(stderr, "error: %s: #"LPD64" - %d:%s\n", + cmdname(argv[0]), i, errno, strerror(rc = errno)); break; } else { if (be_verbose @@ -1272,7 +1272,7 @@ int jt_obd_lov_setconfig(int argc, char **argv) if (strlen(argv[1]) > sizeof(desc.ld_uuid) - 1) { fprintf(stderr, - "error: %s: LOV uuid '%s' longer than %d characters\n", + "error: %s: LOV uuid '%s' longer than %zd characters\n", cmdname(argv[0]), argv[1], sizeof(desc.ld_uuid) - 1); return -EINVAL; } @@ -1383,7 +1383,7 @@ int jt_obd_lov_getconfig(int argc, char **argv) if (strlen(argv[1]) > sizeof(desc.ld_uuid) - 1) { fprintf(stderr, - "error: %s: LOV uuid '%s' longer than %d characters\n", + "error: %s: LOV uuid '%s' longer than %zd characters\n", cmdname(argv[0]), argv[1], sizeof(desc.ld_uuid) - 1); return -EINVAL; }