Whamcloud - gitweb
LU-12321 mdc: allow ELC for DOM file unlink
[fs/lustre-release.git] / lustre / mdc / mdc_reint.c
index 07c3e05..f32d2fb 100644 (file)
@@ -46,9 +46,9 @@ static int mdc_reint(struct ptlrpc_request *request, int level)
 
         request->rq_send_state = level;
 
-       mdc_get_mod_rpc_slot(request, NULL);
+       ptlrpc_get_mod_rpc_slot(request);
        rc = ptlrpc_queue_wait(request);
-       mdc_put_mod_rpc_slot(request, NULL);
+       ptlrpc_put_mod_rpc_slot(request);
         if (rc)
                 CDEBUG(D_INFO, "error in handling %d\n", rc);
         else if (!req_capsule_server_get(&request->rq_pill, &RMF_MDT_BODY)) {
@@ -107,7 +107,7 @@ int mdc_resource_get_unused(struct obd_export *exp, const struct lu_fid *fid,
 int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data,
                void *ea, size_t ealen, struct ptlrpc_request **request)
 {
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
         struct ptlrpc_request *req;
         int count = 0, rc;
         __u64 bits;
@@ -169,7 +169,7 @@ int mdc_create(struct obd_export *exp, struct md_op_data *op_data,
         int count, resends = 0;
         struct obd_import *import = exp->exp_obd->u.cli.cl_import;
         int generation = import->imp_generation;
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
         ENTRY;
 
        /* For case if upper layer did not alloc fid, do it now. */
@@ -279,7 +279,7 @@ rebuild:
 int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
                struct ptlrpc_request **request)
 {
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
         struct obd_device *obd = class_exp2obd(exp);
         struct ptlrpc_request *req = *request;
         int count = 0, rc;
@@ -294,10 +294,13 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
                                                MDS_INODELOCK_UPDATE);
        if ((op_data->op_flags & MF_MDC_CANCEL_FID3) &&
            (fid_is_sane(&op_data->op_fid3)))
-               /* don't cancel DoM lock which may cause data flush */
+               /* cancel DOM lock only if it has no data to flush */
                count += mdc_resource_get_unused(exp, &op_data->op_fid3,
                                                 &cancels, LCK_EX,
-                                                MDS_INODELOCK_ELC);
+                                                op_data->op_cli_flags &
+                                                CLI_DIRTY_DATA ?
+                                                MDS_INODELOCK_ELC :
+                                                MDS_INODELOCK_FULL);
         req = ptlrpc_request_alloc(class_exp2cliimp(exp),
                                    &RQF_MDS_REINT_UNLINK);
         if (req == NULL) {
@@ -341,7 +344,7 @@ int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data,
 int mdc_link(struct obd_export *exp, struct md_op_data *op_data,
              struct ptlrpc_request **request)
 {
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
         struct ptlrpc_request *req;
         int count = 0, rc;
         ENTRY;
@@ -397,7 +400,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data,
                const char *old, size_t oldlen, const char *new, size_t newlen,
                struct ptlrpc_request **request)
 {
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
        struct obd_device *obd = exp->exp_obd;
        struct ptlrpc_request *req;
        int count = 0, rc;
@@ -477,7 +480,7 @@ int mdc_rename(struct obd_export *exp, struct md_op_data *op_data,
 
 int mdc_file_resync(struct obd_export *exp, struct md_op_data *op_data)
 {
-       struct list_head cancels = LIST_HEAD_INIT(cancels);
+       LIST_HEAD(cancels);
        struct ptlrpc_request *req;
        struct ldlm_lock *lock;
        struct mdt_rec_resync *rec;
@@ -503,7 +506,7 @@ int mdc_file_resync(struct obd_export *exp, struct md_op_data *op_data)
                RETURN(rc);
        }
 
-       CLASSERT(sizeof(*rec) == sizeof(struct mdt_rec_reint));
+       BUILD_BUG_ON(sizeof(*rec) != sizeof(struct mdt_rec_reint));
        rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
        rec->rs_opcode  = REINT_RESYNC;
        rec->rs_fsuid   = op_data->op_fsuid;