Whamcloud - gitweb
LU-15401 fld: don't obtain a slot for fld request
[fs/lustre-release.git] / lustre / fld / fld_request.c
index c1d8fa9..e381eb8 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/fld/fld_request.c
  *
@@ -41,6 +40,7 @@
 #include <libcfs/libcfs.h>
 #include <linux/module.h>
 #include <linux/math64.h>
+#include <linux/delay.h>
 
 #include <obd.h>
 #include <obd_class.h>
@@ -225,24 +225,14 @@ int fld_client_del_target(struct lu_client_fld *fld, u64 idx)
 
 struct dentry *fld_debugfs_dir;
 
-static int fld_client_debugfs_init(struct lu_client_fld *fld)
+static void fld_client_debugfs_init(struct lu_client_fld *fld)
 {
-       int rc;
-
        ENTRY;
-       fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name,
-                                                  fld_debugfs_dir,
-                                                  fld_client_debugfs_list,
-                                                  fld);
-       if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) {
-               CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name);
-               rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry)
-                                           : -ENOMEM;
-               fld->lcf_debugfs_entry = NULL;
-               RETURN(rc);
-       }
-
-       return 0;
+       fld->lcf_debugfs_entry = debugfs_create_dir(fld->lcf_name,
+                                                  fld_debugfs_dir);
+       ldebugfs_add_vars(fld->lcf_debugfs_entry,
+                         fld_client_debugfs_list,
+                         fld);
 }
 
 void fld_client_debugfs_fini(struct lu_client_fld *fld)
@@ -260,7 +250,7 @@ int fld_client_init(struct lu_client_fld *fld,
                    const char *prefix, int hash)
 {
        int cache_size, cache_threshold;
-       int rc;
+       int rc = 0;
 
        ENTRY;
        snprintf(fld->lcf_name, sizeof(fld->lcf_name),
@@ -291,9 +281,7 @@ int fld_client_init(struct lu_client_fld *fld,
                GOTO(out, rc);
        }
 
-       rc = fld_client_debugfs_init(fld);
-       if (rc)
-               GOTO(out, rc);
+       fld_client_debugfs_init(fld);
        EXIT;
 out:
        if (rc)
@@ -346,6 +334,7 @@ int fld_client_rpc(struct obd_export *exp,
        LASSERT(exp != NULL);
 
        imp = class_exp2cliimp(exp);
+again:
        switch (fld_op) {
        case FLD_QUERY:
                req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY,
@@ -395,14 +384,12 @@ int fld_client_rpc(struct obd_export *exp,
        req->rq_reply_portal = MDC_REPLY_PORTAL;
        ptlrpc_at_set_req_timeout(req);
 
-       if (OBD_FAIL_CHECK(OBD_FAIL_FLD_QUERY_REQ && req->rq_no_delay)) {
+       if (OBD_FAIL_CHECK(OBD_FAIL_FLD_QUERY_REQ) && req->rq_no_delay) {
                /* the same error returned by ptlrpc_import_delay_req */
-               rc = -EWOULDBLOCK;
+               rc = -EAGAIN;
                req->rq_status = rc;
        } else {
-               obd_get_request_slot(&exp->exp_obd->u.cli);
                rc = ptlrpc_queue_wait(req);
-               obd_put_request_slot(&exp->exp_obd->u.cli);
        }
 
        if (rc == -ENOENT) {
@@ -416,12 +403,16 @@ int fld_client_rpc(struct obd_export *exp,
                    imp->imp_connect_flags_orig & OBD_CONNECT_MDS_MDS &&
                    OCD_HAS_FLAG(&imp->imp_connect_data, LIGHTWEIGHT) &&
                    rc != -ENOTSUPP) {
-                       /*
-                        * Since LWP is not replayable, so notify the caller
-                        * to retry if needed after a while.
-                        */
+                       /* LWP is not replayable, retry after a while */
                        rc = -EAGAIN;
                }
+               if (rc == -EAGAIN) {
+                       ptlrpc_req_finished(req);
+                       if (msleep_interruptible(2 * MSEC_PER_SEC))
+                               GOTO(out_req, rc = -EINTR);
+                       rc = 0;
+                       goto again;
+               }
                GOTO(out_req, rc);
        }