Whamcloud - gitweb
LU-1889 build: fix false 'uninitialized scalar variable' errs
[fs/lustre-release.git] / lustre / ptlrpc / client.c
index 8305110..f8561b9 100644 (file)
@@ -76,6 +76,9 @@ struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid)
         lnet_process_id_t         peer;
         int                       err;
 
+       /* ptlrpc_uuid_to_peer() initializes its 2nd parameter
+        * before accessing its values. */
+       /* coverity[uninit_use_in_call] */
         err = ptlrpc_uuid_to_peer(uuid, &peer, &self);
         if (err != 0) {
                 CNETERR("cannot find peer %s!\n", uuid->uuid);
@@ -155,8 +158,8 @@ EXPORT_SYMBOL(ptlrpc_prep_bulk_imp);
  * Data to transfer in the page starts at offset \a pageoffset and
  * amount of data to transfer from the page is \a len
  */
-void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
-                           cfs_page_t *page, int pageoffset, int len)
+void __ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
+                            cfs_page_t *page, int pageoffset, int len, int pin)
 {
         LASSERT(desc->bd_iov_count < desc->bd_max_iov);
         LASSERT(page != NULL);
@@ -166,16 +169,18 @@ void ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
 
         desc->bd_nob += len;
 
-        cfs_page_pin(page);
+       if (pin)
+               cfs_page_pin(page);
+
         ptlrpc_add_bulk_page(desc, page, pageoffset, len);
 }
-EXPORT_SYMBOL(ptlrpc_prep_bulk_page);
+EXPORT_SYMBOL(__ptlrpc_prep_bulk_page);
 
 /**
  * Uninitialize and free bulk descriptor \a desc.
  * Works on bulk descriptors both from server and client side.
  */
-void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
+void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin)
 {
         int i;
         ENTRY;
@@ -192,14 +197,16 @@ void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
         else
                 class_import_put(desc->bd_import);
 
-        for (i = 0; i < desc->bd_iov_count ; i++)
-                cfs_page_unpin(desc->bd_iov[i].kiov_page);
+       if (unpin) {
+               for (i = 0; i < desc->bd_iov_count ; i++)
+                       cfs_page_unpin(desc->bd_iov[i].kiov_page);
+       }
 
         OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc,
                                 bd_iov[desc->bd_max_iov]));
         EXIT;
 }
-EXPORT_SYMBOL(ptlrpc_free_bulk);
+EXPORT_SYMBOL(__ptlrpc_free_bulk);
 
 /**
  * Set server timelimit for this req, i.e. how long are we willing to wait
@@ -1027,7 +1034,6 @@ EXPORT_SYMBOL(ptlrpc_set_add_cb);
 void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
                         struct ptlrpc_request *req)
 {
-       char jobid[JOBSTATS_JOBID_SIZE];
        LASSERT(cfs_list_empty(&req->rq_set_chain));
 
        /* The set takes over the caller's request reference */
@@ -1036,10 +1042,8 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
        cfs_atomic_inc(&set->set_remaining);
        req->rq_queued_time = cfs_time_current();
 
-       if (req->rq_reqmsg) {
-               lustre_get_jobid(jobid);
-               lustre_msg_set_jobid(req->rq_reqmsg, jobid);
-       }
+       if (req->rq_reqmsg != NULL)
+               lustre_msg_set_jobid(req->rq_reqmsg, NULL);
 
        if (set->set_producer != NULL)
                /* If the request set has a producer callback, the RPC must be
@@ -1194,24 +1198,6 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
         if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
                 struct obd_import *imp = req->rq_import;
                 __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
-                LCONSOLE_ERROR_MSG(0x011,"an error occurred while communicating"
-                                " with %s. The %s operation failed with %d\n",
-                                libcfs_nid2str(imp->imp_connection->c_peer.nid),
-                                ll_opcode2str(opc), err);
-                RETURN(err < 0 ? err : -EINVAL);
-        }
-
-        if (err < 0) {
-                DEBUG_REQ(D_INFO, req, "status is %d", err);
-        } else if (err > 0) {
-                /* XXX: translate this error from net to host */
-                DEBUG_REQ(D_INFO, req, "status is %d", err);
-        }
-
-        if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
-                struct obd_import *imp = req->rq_import;
-                __u32 opc = lustre_msg_get_opc(req->rq_reqmsg);
-
                 if (ptlrpc_console_allow(req))
                         LCONSOLE_ERROR_MSG(0x011,"an error occurred while "
                                            "communicating with %s. The %s "
@@ -1219,10 +1205,16 @@ static int ptlrpc_check_status(struct ptlrpc_request *req)
                                            libcfs_nid2str(
                                            imp->imp_connection->c_peer.nid),
                                            ll_opcode2str(opc), err);
-
                 RETURN(err < 0 ? err : -EINVAL);
         }
 
+        if (err < 0) {
+                DEBUG_REQ(D_INFO, req, "status is %d", err);
+        } else if (err > 0) {
+                /* XXX: translate this error from net to host */
+                DEBUG_REQ(D_INFO, req, "status is %d", err);
+        }
+
         RETURN(err);
 }
 
@@ -1847,13 +1839,13 @@ int ptlrpc_check_set(const struct lu_env *env, struct ptlrpc_request_set *set)
 
                 ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);
 
-                CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:nid:"
-                       "opc %s:%s:%d:"LPU64":%s:%d\n", cfs_curproc_comm(),
-                       imp->imp_obd->obd_uuid.uuid,
-                       req->rq_reqmsg ? lustre_msg_get_status(req->rq_reqmsg):-1,
-                       req->rq_xid,
-                       libcfs_nid2str(imp->imp_connection->c_peer.nid),
-                       req->rq_reqmsg ? lustre_msg_get_opc(req->rq_reqmsg) : -1);
+               CDEBUG(req->rq_reqmsg != NULL ? D_RPCTRACE : 0,
+                       "Completed RPC pname:cluuid:pid:xid:nid:"
+                       "opc %s:%s:%d:"LPU64":%s:%d\n",
+                       cfs_curproc_comm(), imp->imp_obd->obd_uuid.uuid,
+                       lustre_msg_get_status(req->rq_reqmsg), req->rq_xid,
+                       libcfs_nid2str(imp->imp_connection->c_peer.nid),
+                       lustre_msg_get_opc(req->rq_reqmsg));
 
                 cfs_spin_lock(&imp->imp_lock);
                 /* Request already may be not on sending or delaying list. This
@@ -2287,8 +2279,8 @@ static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
                 class_import_put(request->rq_import);
                 request->rq_import = NULL;
         }
-        if (request->rq_bulk != NULL)
-                ptlrpc_free_bulk(request->rq_bulk);
+       if (request->rq_bulk != NULL)
+               ptlrpc_free_bulk_pin(request->rq_bulk);
 
         if (request->rq_reqbuf != NULL || request->rq_clrbuf != NULL)
                 sptlrpc_cli_free_reqbuf(request);