From 80786e8223938e1f3379ba409dec61a15dd2fc60 Mon Sep 17 00:00:00 2001 From: Vitaly Fertman Date: Thu, 27 May 2010 00:51:04 +0400 Subject: [PATCH] b=22244 ldlm cancel flags cleanup i=adilger i=green cleanup of cancel flags passed to ldlm lock cancel code --- lustre/include/lustre_dlm.h | 19 ++++++++++++++----- lustre/include/obd.h | 2 +- lustre/include/obd_class.h | 3 ++- lustre/ldlm/ldlm_internal.h | 5 +++-- lustre/ldlm/ldlm_lib.c | 3 +-- lustre/ldlm/ldlm_request.c | 29 ++++++++++++++--------------- lustre/lov/lov_obd.c | 3 ++- lustre/osc/osc_request.c | 4 +++- lustre/tests/it_test.c | 3 ++- lustre/utils/loadgen.c | 2 +- 10 files changed, 43 insertions(+), 30 deletions(-) diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 3939a23..ca3f9c0 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -103,7 +103,7 @@ typedef enum { #define LDLM_FL_REPLAY 0x000100 #define LDLM_FL_INTENT_ONLY 0x000200 /* don't grant lock, just do intent */ -#define LDLM_FL_LOCAL_ONLY 0x000400 /* see ldlm_cli_cancel_unused */ +#define LDLM_FL_LOCAL_ONLY 0x000400 /* don't run the cancel callback under ldlm_cli_cancel_unused */ #define LDLM_FL_FAILED 0x000800 @@ -111,7 +111,7 @@ typedef enum { #define LDLM_FL_HAS_INTENT 0x001000 /* lock request has intent */ #define LDLM_FL_CANCELING 0x002000 /* lock cancel has already been sent */ #define LDLM_FL_LOCAL 0x004000 /* local lock (ie, no srv/cli split) */ -#define LDLM_FL_WARN 0x008000 /* see ldlm_cli_cancel_unused */ +/* was LDLM_FL_WARN until 1.8.4 0x008000 */ #define LDLM_FL_DISCARD_DATA 0x010000 /* discard (no writeback) on cancel */ #define LDLM_FL_NO_TIMEOUT 0x020000 /* Blocked by group lock - wait @@ -499,6 +499,14 @@ struct ldlm_interval_tree { struct interval_node *lit_root; /* actually ldlm_interval */ }; +/* Cancel flag. */ +typedef enum { + /* LCF_ASYNC = 0x1 is used in 2.0 to cancel locks asynchronously. */ + LCF_LOCAL = 0x2, /* Cancel locks locally, not notifing server */ + LCF_BL_AST = 0x4, /* Cancel locks marked as LDLM_FL_BL_AST + * in the same RPC */ +} ldlm_cancel_flags_t; + struct ldlm_lock { struct portals_handle l_handle; // must be first in the structure atomic_t l_refc; @@ -878,14 +886,15 @@ int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags); int ldlm_cli_update_pool(struct ptlrpc_request *req); int ldlm_cli_cancel(struct lustre_handle *lockh); int ldlm_cli_cancel_unused(struct ldlm_namespace *, struct ldlm_res_id *, - int flags, void *opaque); + ldlm_cancel_flags_t flags, void *opaque); int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *head, int count); int ldlm_cli_join_lru(struct ldlm_namespace *, struct ldlm_res_id *, int join); int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, - ldlm_policy_data_t *policy, ldlm_mode_t mode, - int lock_flags, int cancel_flags, void *opaque); + ldlm_policy_data_t *policy, + ldlm_mode_t mode, int lock_flags, + ldlm_cancel_flags_t cancel_flags, void *opaque); int ldlm_cli_cancel_list(struct list_head *head, int count, struct ptlrpc_request *req, int off); diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 7574479..d7d1ec5 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1276,7 +1276,7 @@ struct obd_ops { __u32 mode, struct lustre_handle *, int flags, obd_off end); int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *, - int flags, void *opaque); + ldlm_cancel_flags_t flags, void *opaque); int (*o_join_lru)(struct obd_export *, struct lov_stripe_md *, int join); int (*o_init_export)(struct obd_export *exp); diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 58d0912..09aa5bf 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1454,7 +1454,8 @@ static inline int obd_cancel(struct obd_export *exp, struct lov_stripe_md *ea, } static inline int obd_cancel_unused(struct obd_export *exp, - struct lov_stripe_md *ea, int flags, + struct lov_stripe_md *ea, + ldlm_cancel_flags_t flags, void *opaque) { int rc; diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 12dc18c..4925c78 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -78,8 +78,9 @@ enum { int ldlm_cancel_lru(struct ldlm_namespace *ns, int nr, ldlm_sync_t sync, int flags); -int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, - int count, int max, int cancel_flags, int flags); +int ldlm_cancel_lru_local(struct ldlm_namespace *ns, + struct list_head *cancels, int count, int max, + ldlm_cancel_flags_t cancel_flags, int flags); extern int ldlm_enqueue_min; int ldlm_get_enq_timeout(struct ldlm_lock *lock); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 039de76..e491fb3 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -491,8 +491,7 @@ int client_disconnect_export(struct obd_export *exp) if (obd->obd_namespace != NULL) { /* obd_force == local only */ ldlm_cli_cancel_unused(obd->obd_namespace, NULL, - obd->obd_force ? LDLM_FL_LOCAL_ONLY:0, - NULL); + obd->obd_force ? LCF_LOCAL : 0, NULL); ldlm_namespace_free_prior(obd->obd_namespace, imp, obd->obd_force); } diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index b92c925..88500d5 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -1128,7 +1128,7 @@ int ldlm_cli_cancel(struct lustre_handle *lockh) flags = ns_connect_lru_resize(ns) ? LDLM_CANCEL_LRUR : LDLM_CANCEL_AGED; count += ldlm_cancel_lru_local(ns, &cancels, 0, avail - 1, - LDLM_FL_BL_AST, flags); + LCF_BL_AST, flags); } ldlm_cli_cancel_list(&cancels, count, NULL, 0); RETURN(0); @@ -1136,7 +1136,8 @@ int ldlm_cli_cancel(struct lustre_handle *lockh) /* XXX until we will have compound requests and can cut cancels from generic rpc * we need send cancels with LDLM_FL_BL_AST flag as separate rpc */ -static int ldlm_cancel_list(struct list_head *cancels, int count, int flags) +static int ldlm_cancel_list(struct list_head *cancels, int count, + ldlm_cancel_flags_t flags) { CFS_LIST_HEAD(head); struct ldlm_lock *lock, *next; @@ -1147,13 +1148,13 @@ static int ldlm_cancel_list(struct list_head *cancels, int count, int flags) if (left-- == 0) break; - if (flags & LDLM_FL_LOCAL_ONLY) { + if (flags & LCF_LOCAL) { rc = LDLM_FL_LOCAL_ONLY; ldlm_lock_cancel(lock); } else { rc = ldlm_cli_cancel_local(lock); } - if (!(flags & LDLM_FL_BL_AST) && (rc == LDLM_FL_BL_AST)) { + if (!(flags & LCF_BL_AST) && (rc == LDLM_FL_BL_AST)) { LDLM_DEBUG(lock, "Cancel lock separately"); list_del_init(&lock->l_bl_ast); list_add(&lock->l_bl_ast, &head); @@ -1337,7 +1338,8 @@ ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags) * outstanding rpc to complete */ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, - int count, int max, int cancel_flags, int flags) + int count, int max, ldlm_cancel_flags_t cancel_flags, + int flags) { ldlm_cancel_lru_policy_t pf; struct ldlm_lock *lock, *next; @@ -1492,7 +1494,7 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, struct list_head *cancels, ldlm_policy_data_t *policy, ldlm_mode_t mode, int lock_flags, - int cancel_flags, void *opaque) + ldlm_cancel_flags_t cancel_flags, void *opaque) { struct ldlm_lock *lock; int count = 0; @@ -1507,13 +1509,8 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res, continue; } - if (lock->l_readers || lock->l_writers) { - if (cancel_flags & LDLM_FL_WARN) { - LDLM_ERROR(lock, "lock in use"); - //LBUG(); - } + if (lock->l_readers || lock->l_writers) continue; - } /* If somebody is already doing CANCEL, or blocking ast came, * skip this lock. */ @@ -1592,7 +1589,8 @@ int ldlm_cli_cancel_list(struct list_head *cancels, int count, static int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns, struct ldlm_res_id res_id, - int flags, void *opaque) + ldlm_cancel_flags_t flags, + void *opaque) { struct ldlm_resource *res; CFS_LIST_HEAD(cancels); @@ -1632,10 +1630,11 @@ static inline int have_no_nsresource(struct ldlm_namespace *ns) /* Cancel all locks on a namespace (or a specific resource, if given) * that have 0 readers/writers. * - * If flags & LDLM_FL_LOCAL_ONLY, throw the locks away without trying + * If flags & LCF_LOCAL, throw the locks away without trying * to notify the server. */ int ldlm_cli_cancel_unused(struct ldlm_namespace *ns, - struct ldlm_res_id *res_id, int flags, void *opaque) + struct ldlm_res_id *res_id, + ldlm_cancel_flags_t flags, void *opaque) { int i; ENTRY; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index ecabebb..d86a4ba 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2331,7 +2331,8 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, } static int lov_cancel_unused(struct obd_export *exp, - struct lov_stripe_md *lsm, int flags, void *opaque) + struct lov_stripe_md *lsm, + ldlm_cancel_flags_t flags, void *opaque) { struct lov_obd *lov; struct lov_oinfo *loi; diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 44adfc0..a4f6abd 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3573,7 +3573,9 @@ static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, } static int osc_cancel_unused(struct obd_export *exp, - struct lov_stripe_md *lsm, int flags, void *opaque) + struct lov_stripe_md *lsm, + ldlm_cancel_flags_t flags, + void *opaque) { struct obd_device *obd = class_exp2obd(exp); struct ldlm_res_id res_id, *resp = NULL; diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c index a2997a7..f846a17 100644 --- a/lustre/tests/it_test.c +++ b/lustre/tests/it_test.c @@ -243,8 +243,9 @@ static enum interval_iter sanity_cb(struct interval_node *node, void *args) } if (!has) { - int count = 1; + int count; err: + count = 1; dprintf("node"__S":%llu Child list:\n", node->in_extent.start, node->in_extent.end, diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c index ec84295..73b5a9c 100644 --- a/lustre/utils/loadgen.c +++ b/lustre/utils/loadgen.c @@ -669,7 +669,7 @@ static void *run_one_child(void *threadvp) { struct kid_t *kid; char oname[10], ename[10]; - int thread = (long)threadvp, dev; + int thread = (long)threadvp, dev = 0; int rc = 0, err; if (o_verbose > 2) -- 1.8.3.1