Whamcloud - gitweb
LU-13783 osc: handle removal of NR_UNSTABLE_NFS
[fs/lustre-release.git] / lustre / mdc / mdc_dev.c
index 54ccb02..72cf45c 100644 (file)
@@ -172,8 +172,8 @@ again:
 /**
  * Check if page @page is covered by an extra lock or discard it.
  */
-static int mdc_check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
-                                   struct osc_page *ops, void *cbdata)
+static bool mdc_check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
+                                    struct osc_page *ops, void *cbdata)
 {
        struct osc_thread_info *info = osc_env_info(env);
        struct osc_object *osc = cbdata;
@@ -200,7 +200,7 @@ static int mdc_check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
        }
 
        info->oti_next_index = index + 1;
-       return CLP_GANG_OKAY;
+       return true;
 }
 
 /**
@@ -219,7 +219,6 @@ static int mdc_lock_discard_pages(const struct lu_env *env,
        struct osc_thread_info *info = osc_env_info(env);
        struct cl_io *io = &info->oti_io;
        osc_page_gang_cbt cb;
-       int res;
        int result;
 
        ENTRY;
@@ -232,15 +231,9 @@ static int mdc_lock_discard_pages(const struct lu_env *env,
 
        cb = discard ? osc_discard_cb : mdc_check_and_discard_cb;
        info->oti_fn_index = info->oti_next_index = start;
-       do {
-               res = osc_page_gang_lookup(env, io, osc, info->oti_next_index,
-                                          end, cb, (void *)osc);
-               if (info->oti_next_index > end)
-                       break;
 
-               if (res == CLP_GANG_RESCHED)
-                       cond_resched();
-       } while (res != CLP_GANG_OKAY);
+       osc_page_gang_lookup(env, io, osc, info->oti_next_index,
+                            end, cb, (void *)osc);
 out:
        cl_io_fini(env, io);
        RETURN(result);
@@ -323,7 +316,6 @@ static int mdc_dlm_blocking_ast0(const struct lu_env *env,
 
        if (dlmlock->l_ast_data != NULL) {
                obj = osc2cl(dlmlock->l_ast_data);
-               dlmlock->l_ast_data = NULL;
                cl_object_get(obj);
        }
        unlock_res_and_lock(dlmlock);
@@ -341,6 +333,7 @@ static int mdc_dlm_blocking_ast0(const struct lu_env *env,
                 */
                /* losing a lock, update kms */
                lock_res_and_lock(dlmlock);
+               dlmlock->l_ast_data = NULL;
                cl_object_attr_lock(obj);
                attr->cat_kms = 0;
                cl_object_attr_update(env, obj, attr, CAT_KMS);
@@ -1441,6 +1434,11 @@ int mdc_object_prune(const struct lu_env *env, struct cl_object *obj)
 static int mdc_object_flush(const struct lu_env *env, struct cl_object *obj,
                            struct ldlm_lock *lock)
 {
+       /* if lock cancel is initiated from llite then it is combined
+        * lock with DOM bit and it may have no l_ast_data initialized yet,
+        * so init it here with given osc_object.
+        */
+       mdc_set_dom_lock_data(lock, cl2osc(obj));
        RETURN(mdc_dlm_blocking_ast0(env, lock, LDLM_CB_CANCELING));
 }