Whamcloud - gitweb
b=22244 ldlm cancel flags cleanup
authorVitaly Fertman <Vitaly.Fertman@sun.com>
Thu, 20 May 2010 15:45:42 +0000 (19:45 +0400)
committerRobert Read <robert.read@oracle.com>
Mon, 24 May 2010 16:12:46 +0000 (09:12 -0700)
i=adilger
i=green

cleanup of cancel flags passed to ldlm lock cancel code

lustre/include/lustre_dlm.h
lustre/include/obd.h
lustre/include/obd_class.h
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lib.c
lustre/ldlm/ldlm_request.c
lustre/lmv/lmv_obd.c
lustre/lov/lov_obd.c
lustre/mdc/mdc_internal.h
lustre/mdc/mdc_locks.c
lustre/osc/osc_request.c

index 200ebb8..27feb6f 100644 (file)
@@ -110,7 +110,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
@@ -118,7 +118,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 2.0.0  0x008000 */
 #define LDLM_FL_DISCARD_DATA   0x010000 /* discard (no writeback) on cancel */
 
 #define LDLM_FL_NO_TIMEOUT     0x020000 /* Blocked by group lock - wait
@@ -168,8 +168,7 @@ typedef enum {
  * w/o involving separate thread. in order to decrease cs rate */
 #define LDLM_FL_ATOMIC_CB      0x4000000
 
-/* Cancel lock asynchronously. See ldlm_cli_cancel_unused_resource. */
-#define LDLM_FL_ASYNC           0x8000000
+/* was LDLM_FL_ASYNC until 2.0.0 0x8000000 */
 
 /* It may happen that a client initiate 2 operations, e.g. unlink and mkdir,
  * such that server send blocking ast for conflict locks to this client for
@@ -551,6 +550,14 @@ struct ldlm_interval_tree {
 
 #define LUSTRE_TRACKS_LOCK_EXP_REFS (1)
 
+/* Cancel flag. */
+typedef enum {
+        LCF_ASYNC      = 0x1, /* 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 {
         /**
          * Must be first in the structure.
@@ -1099,20 +1106,22 @@ int ldlm_handle_convert0(struct ptlrpc_request *req,
                          const struct ldlm_request *dlm_req);
 int ldlm_cli_cancel(struct lustre_handle *lockh);
 int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *,
-                           int flags, void *opaque);
+                           ldlm_cancel_flags_t flags, void *opaque);
 int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
                                     const struct ldlm_res_id *res_id,
                                     ldlm_policy_data_t *policy,
-                                    ldlm_mode_t mode, int flags, void *opaque);
+                                    ldlm_mode_t mode,
+                                    ldlm_cancel_flags_t flags,
+                                    void *opaque);
 int ldlm_cli_cancel_req(struct obd_export *exp, cfs_list_t *head,
-                        int count, int flags);
+                        int count, ldlm_cancel_flags_t flags);
 int ldlm_cancel_resource_local(struct ldlm_resource *res,
                                cfs_list_t *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);
 int ldlm_cli_cancel_list(cfs_list_t *head, int count,
-                         struct ptlrpc_request *req, int flags);
+                         struct ptlrpc_request *req, ldlm_cancel_flags_t flags);
 
 /* mds/handler.c */
 /* This has to be here because recursive inclusion sucks. */
index 258c4d6..5ef03cc 100644 (file)
@@ -1356,7 +1356,7 @@ struct obd_ops {
         int (*o_cancel)(struct obd_export *, struct lov_stripe_md *md,
                         __u32 mode, struct lustre_handle *);
         int (*o_cancel_unused)(struct obd_export *, struct lov_stripe_md *,
-                               int flags, void *opaque);
+                               ldlm_cancel_flags_t flags, void *opaque);
         int (*o_init_export)(struct obd_export *exp);
         int (*o_destroy_export)(struct obd_export *exp);
         int (*o_extent_calc)(struct obd_export *, struct lov_stripe_md *,
@@ -1524,8 +1524,8 @@ struct md_ops {
                                     struct lustre_handle *);
 
         int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *,
-                               ldlm_policy_data_t *, ldlm_mode_t, int flags,
-                               void *opaque);
+                               ldlm_policy_data_t *, ldlm_mode_t,
+                               ldlm_cancel_flags_t flags, void *opaque);
         int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc,
                             renew_capa_cb_t cb);
         int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *,
index 7bd0b5e..5b354e1 100644 (file)
@@ -1452,7 +1452,8 @@ static inline int obd_cancel(struct obd_export *exp,
 
 static inline int obd_cancel_unused(struct obd_export *exp,
                                     struct lov_stripe_md *ea,
-                                    int flags, void *opaque)
+                                    ldlm_cancel_flags_t flags,
+                                    void *opaque)
 {
         int rc;
         ENTRY;
@@ -2054,7 +2055,9 @@ static inline int md_set_lock_data(struct obd_export *exp,
 static inline int md_cancel_unused(struct obd_export *exp,
                                    const struct lu_fid *fid,
                                    ldlm_policy_data_t *policy,
-                                   ldlm_mode_t mode, int flags, void *opaque)
+                                   ldlm_mode_t mode,
+                                   ldlm_cancel_flags_t flags,
+                                   void *opaque)
 {
         int rc;
         ENTRY;
index 94cd119..2316e9d 100644 (file)
@@ -79,7 +79,7 @@ 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,
                           cfs_list_t *cancels, int count, int max,
-                          int cancel_flags, int flags);
+                          ldlm_cancel_flags_t cancel_flags, int flags);
 extern int ldlm_enqueue_min;
 int ldlm_get_enq_timeout(struct ldlm_lock *lock);
 
index 5621bd5..330f3a7 100644 (file)
@@ -513,8 +513,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);
         }
 
index a723f42..f8a5b7a 100644 (file)
@@ -1076,7 +1076,7 @@ static void ldlm_cancel_pack(struct ptlrpc_request *req,
 /* Prepare and send a batched cancel rpc, it will include count lock handles
  * of locks given in @head. */
 int ldlm_cli_cancel_req(struct obd_export *exp, cfs_list_t *cancels,
-                        int count, int flags)
+                        int count, ldlm_cancel_flags_t flags)
 {
         struct ptlrpc_request *req = NULL;
         struct obd_import *imp;
@@ -1130,7 +1130,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, cfs_list_t *cancels,
                 ldlm_cancel_pack(req, cancels, count);
 
                 ptlrpc_request_set_replen(req);
-                if (flags & LDLM_FL_ASYNC) {
+                if (flags & LCF_ASYNC) {
                         ptlrpcd_add_req(req, PSCOPE_OTHER);
                         sent = count;
                         GOTO(out, 0);
@@ -1261,7 +1261,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);
@@ -1269,7 +1269,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(cfs_list_t *cancels, int count, int flags)
+static int ldlm_cancel_list(cfs_list_t *cancels, int count,
+                            ldlm_cancel_flags_t flags)
 {
         CFS_LIST_HEAD(head);
         struct ldlm_lock *lock, *next;
@@ -1280,13 +1281,13 @@ static int ldlm_cancel_list(cfs_list_t *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");
                         cfs_list_del_init(&lock->l_bl_ast);
                         cfs_list_add(&lock->l_bl_ast, &head);
@@ -1473,7 +1474,8 @@ ldlm_cancel_lru_policy(struct ldlm_namespace *ns, int flags)
  * flags & LDLM_CANCEL_AGED -   cancel alocks according to "aged policy".
  */
 int ldlm_cancel_lru_local(struct ldlm_namespace *ns, cfs_list_t *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;
@@ -1616,7 +1618,7 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res,
                                cfs_list_t *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;
@@ -1631,13 +1633,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. */
@@ -1676,7 +1673,7 @@ int ldlm_cancel_resource_local(struct ldlm_resource *res,
  * buffer at the offset @off.
  * Destroy @cancels at the end. */
 int ldlm_cli_cancel_list(cfs_list_t *cancels, int count,
-                         struct ptlrpc_request *req, int flags)
+                         struct ptlrpc_request *req, ldlm_cancel_flags_t flags)
 {
         struct ldlm_lock *lock;
         int res = 0;
@@ -1724,7 +1721,9 @@ int ldlm_cli_cancel_list(cfs_list_t *cancels, int count,
 int ldlm_cli_cancel_unused_resource(struct ldlm_namespace *ns,
                                     const struct ldlm_res_id *res_id,
                                     ldlm_policy_data_t *policy,
-                                    ldlm_mode_t mode, int flags, void *opaque)
+                                    ldlm_mode_t mode,
+                                    ldlm_cancel_flags_t flags,
+                                    void *opaque)
 {
         struct ldlm_resource *res;
         CFS_LIST_HEAD(cancels);
@@ -1766,11 +1765,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,
                            const struct ldlm_res_id *res_id,
-                           int flags, void *opaque)
+                           ldlm_cancel_flags_t flags, void *opaque)
 {
         int i;
         ENTRY;
index 36594af..d5778ee 100644 (file)
@@ -1913,7 +1913,7 @@ static int lmv_early_cancel_slaves(struct obd_export *exp,
                         CDEBUG(D_INODE, "EARLY_CANCEL slave "DFID" -> mds #%d\n",
                                PFID(st_fid), tgt->ltd_idx);
                         rc = md_cancel_unused(tgt->ltd_exp, st_fid, &policy,
-                                              mode, LDLM_FL_ASYNC, NULL);
+                                              mode, LCF_ASYNC, NULL);
                         if (rc)
                                 GOTO(out_put_obj, rc);
                 } else {
@@ -1964,7 +1964,7 @@ static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
                         CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid));
                         policy.l_inodebits.bits = bits;
                         rc = md_cancel_unused(tgt->ltd_exp, fid, &policy,
-                                              mode, LDLM_FL_ASYNC, NULL);
+                                              mode, LCF_ASYNC, NULL);
                 } else {
                         CDEBUG(D_INODE,
                                "EARLY_CANCEL skip operation target %d on "DFID"\n",
@@ -2778,7 +2778,7 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
 
 static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
                              ldlm_policy_data_t *policy, ldlm_mode_t mode,
-                             int flags, void *opaque)
+                             ldlm_cancel_flags_t flags, void *opaque)
 {
         struct obd_device       *obd = exp->exp_obd;
         struct lmv_obd          *lmv = &obd->u.lmv;
index 53a0343..8046d85 100644 (file)
@@ -1834,7 +1834,7 @@ 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)
+                             ldlm_cancel_flags_t flags, void *opaque)
 {
         struct lov_obd *lov;
         int rc = 0, i;
index 5e38c50..1b7da75 100644 (file)
@@ -142,7 +142,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
                struct ptlrpc_request **request);
 int mdc_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
                       ldlm_policy_data_t *policy, ldlm_mode_t mode,
-                      int flags, void *opaque);
+                      ldlm_cancel_flags_t flags, void *opaque);
 
 static inline void mdc_set_capa_size(struct ptlrpc_request *req,
                                      const struct req_msg_field *field,
index 5a378d3..bf35450 100644 (file)
@@ -169,7 +169,9 @@ ldlm_mode_t mdc_lock_match(struct obd_export *exp, int flags,
 int mdc_cancel_unused(struct obd_export *exp,
                       const struct lu_fid *fid,
                       ldlm_policy_data_t *policy,
-                      ldlm_mode_t mode, int flags, void *opaque)
+                      ldlm_mode_t mode,
+                      ldlm_cancel_flags_t flags,
+                      void *opaque)
 {
         struct ldlm_res_id res_id;
         struct obd_device *obd = class_exp2obd(exp);
index 014edf2..bc6583d 100644 (file)
@@ -3463,7 +3463,8 @@ 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,
+                             struct lov_stripe_md *lsm,
+                             ldlm_cancel_flags_t flags,
                              void *opaque)
 {
         struct obd_device *obd = class_exp2obd(exp);