Whamcloud - gitweb
LU-9184 grants: move grant code to the target
[fs/lustre-release.git] / lustre / target / tgt_handler.c
index a76c023..2fcb794 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2015, Intel Corporation.
+ * Copyright (c) 2013, 2016, Intel Corporation.
  */
 /*
  * lustre/target/tgt_handler.c
@@ -42,7 +42,6 @@
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_cksum.h>
-#include <md_object.h>
 #include <lustre_lfsck.h>
 #include <lustre_nodemap.h>
 
@@ -536,7 +535,7 @@ static int tgt_handle_recovery(struct ptlrpc_request *req, int reply_fail_id)
        if (req_can_reconstruct(req, NULL)) {
                if (!(lustre_msg_get_flags(req->rq_reqmsg) &
                      (MSG_RESENT | MSG_REPLAY))) {
-                       DEBUG_REQ(D_WARNING, req, "rq_xid "LPU64" matches "
+                       DEBUG_REQ(D_WARNING, req, "rq_xid %llu matches "
                                  "saved xid, expected REPLAY or RESENT flag "
                                  "(%x)", req->rq_xid,
                                  lustre_msg_get_flags(req->rq_reqmsg));
@@ -893,7 +892,7 @@ int tgt_connect_check_sptlrpc(struct ptlrpc_request *req, struct obd_export *exp
        return rc;
 }
 
-int tgt_adapt_sptlrpc_conf(struct lu_target *tgt, int initial)
+int tgt_adapt_sptlrpc_conf(struct lu_target *tgt)
 {
        struct sptlrpc_rule_set  tmp_rset;
        int                      rc;
@@ -904,7 +903,7 @@ int tgt_adapt_sptlrpc_conf(struct lu_target *tgt, int initial)
        }
 
        sptlrpc_rule_set_init(&tmp_rset);
-       rc = sptlrpc_conf_target_get_rules(tgt->lut_obd, &tmp_rset, initial);
+       rc = sptlrpc_conf_target_get_rules(tgt->lut_obd, &tmp_rset);
        if (rc) {
                CERROR("%s: failed get sptlrpc rules: rc = %d\n",
                       tgt_name(tgt), rc);
@@ -1043,13 +1042,13 @@ int tgt_sendpage(struct tgt_session_info *tsi, struct lu_rdpg *rdpg, int nob)
                RETURN(-ENOMEM);
 
        if (!(exp_connect_flags(exp) & OBD_CONNECT_BRW_SIZE))
-               /* old client requires reply size in it's PAGE_CACHE_SIZE,
+               /* old client requires reply size in it's PAGE_SIZE,
                 * which is rdpg->rp_count */
                nob = rdpg->rp_count;
 
        for (i = 0, tmpcount = nob; i < rdpg->rp_npages && tmpcount > 0;
             i++, tmpcount -= tmpsize) {
-               tmpsize = min_t(int, tmpcount, PAGE_CACHE_SIZE);
+               tmpsize = min_t(int, tmpcount, PAGE_SIZE);
                desc->bd_frag_ops->add_kiov_frag(desc, rdpg->rp_pages[i], 0,
                                                 tmpsize);
        }
@@ -1110,7 +1109,7 @@ static int tgt_obd_idx_read(struct tgt_session_info *tsi)
                GOTO(out, rc = -EFAULT);
        rdpg->rp_count = min_t(unsigned int, req_ii->ii_count << LU_PAGE_SHIFT,
                               exp_max_brw_size(tsi->tsi_exp));
-       rdpg->rp_npages = (rdpg->rp_count + PAGE_CACHE_SIZE -1) >> PAGE_CACHE_SHIFT;
+       rdpg->rp_npages = (rdpg->rp_count + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
        /* allocate pages to store the containers */
        OBD_ALLOC(rdpg->rp_pages, rdpg->rp_npages * sizeof(rdpg->rp_pages[0]));
@@ -1241,7 +1240,7 @@ static int tgt_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
 
                rc = tgt_sync(&env, tgt, obj, start, end);
                if (rc < 0) {
-                       CERROR("%s: syncing "DFID" ("LPU64"-"LPU64") on lock "
+                       CERROR("%s: syncing "DFID" (%llu-%llu) on lock "
                               "cancel: rc = %d\n",
                               tgt_name(tgt), PFID(&fid),
                               lock->l_policy_data.l_extent.start,
@@ -1249,7 +1248,7 @@ static int tgt_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
                }
 err_put:
                if (obj != NULL)
-                       lu_object_put(&env, &obj->do_lu);
+                       dt_object_put(&env, obj);
 err_env:
                lu_env_fini(&env);
        }
@@ -1433,15 +1432,27 @@ TGT_SEC_HDL_VAR(0,      SEC_CTX_FINI,           tgt_sec_ctx_handle),
 };
 EXPORT_SYMBOL(tgt_sec_ctx_handlers);
 
+int (*tgt_lfsck_in_notify_local)(const struct lu_env *env,
+                                struct dt_device *key,
+                                struct lfsck_req_local *lrl,
+                                struct thandle *th) = NULL;
+
+void tgt_register_lfsck_in_notify_local(int (*notify)(const struct lu_env *,
+                                                     struct dt_device *,
+                                                     struct lfsck_req_local *,
+                                                     struct thandle *))
+{
+       tgt_lfsck_in_notify_local = notify;
+}
+EXPORT_SYMBOL(tgt_register_lfsck_in_notify_local);
+
 int (*tgt_lfsck_in_notify)(const struct lu_env *env,
                           struct dt_device *key,
-                          struct lfsck_request *lr,
-                          struct thandle *th) = NULL;
+                          struct lfsck_request *lr) = NULL;
 
 void tgt_register_lfsck_in_notify(int (*notify)(const struct lu_env *,
                                                struct dt_device *,
-                                               struct lfsck_request *,
-                                               struct thandle *))
+                                               struct lfsck_request *))
 {
        tgt_lfsck_in_notify = notify;
 }
@@ -1476,7 +1487,7 @@ static int tgt_handle_lfsck_notify(struct tgt_session_info *tsi)
        if (lr == NULL)
                RETURN(-EPROTO);
 
-       rc = tgt_lfsck_in_notify(env, key, lr, NULL);
+       rc = tgt_lfsck_in_notify(env, key, lr);
 
        RETURN(rc);
 }
@@ -1608,6 +1619,9 @@ int tgt_brw_lock(struct ldlm_namespace *ns, struct ldlm_res_id *res_id,
        LASSERT(mode == LCK_PR || mode == LCK_PW);
        LASSERT(!lustre_handle_is_used(lh));
 
+       if (ns->ns_obd->obd_recovering)
+               RETURN(0);
+
        if (nrbufs == 0 || !(nb[0].rnb_flags & OBD_BRW_SRVLOCK))
                RETURN(0);
 
@@ -1934,7 +1948,7 @@ static void tgt_warn_on_cksum(struct ptlrpc_request *req,
        }
 
        LCONSOLE_ERROR_MSG(0x168, "BAD WRITE CHECKSUM: %s from %s%s%s inode "
-                          DFID" object "DOSTID" extent ["LPU64"-"LPU64
+                          DFID" object "DOSTID" extent [%llu-%llu"
                           "]: client csum %x, server csum %x\n",
                           exp->exp_obd->obd_name, libcfs_id2str(req->rq_peer),
                           via, router,
@@ -1968,6 +1982,7 @@ int tgt_brw_write(struct tgt_session_info *tsi)
        cksum_type_t             cksum_type = OBD_CKSUM_CRC32;
        bool                     no_reply = false, mmap;
        struct tgt_thread_big_cache *tbc = req->rq_svc_thread->t_data;
+       bool wait_sync = false;
 
        ENTRY;
 
@@ -2135,6 +2150,12 @@ skip_transfer:
                 * has timed out the request already */
                no_reply = true;
 
+       for (i = 0; i < niocount; i++) {
+               if (!(local_nb[i].lnb_flags & OBD_BRW_ASYNC)) {
+                       wait_sync = true;
+                       break;
+               }
+       }
        /*
         * Disable sending mtime back to the client. If the client locked the
         * whole object, then it has already updated the mtime on its side,
@@ -2168,15 +2189,16 @@ out_lock:
        if (desc)
                ptlrpc_free_bulk(desc);
 out:
-       if (no_reply) {
+       if (unlikely(no_reply || (exp->exp_obd->obd_no_transno && wait_sync))) {
                req->rq_no_reply = 1;
                /* reply out callback would free */
                ptlrpc_req_drop_rs(req);
-               LCONSOLE_WARN("%s: Bulk IO write error with %s (at %s), "
-                             "client will retry: rc %d\n",
-                             exp->exp_obd->obd_name,
-                             obd_uuid2str(&exp->exp_client_uuid),
-                             obd_export_nid2str(exp), rc);
+               if (!exp->exp_obd->obd_no_transno)
+                       LCONSOLE_WARN("%s: Bulk IO write error with %s (at %s),"
+                                     " client will retry: rc = %d\n",
+                                     exp->exp_obd->obd_name,
+                                     obd_uuid2str(&exp->exp_client_uuid),
+                                     obd_export_nid2str(exp), rc);
        }
        memory_pressure_clr();
        RETURN(rc);