Whamcloud - gitweb
LU-1378 fid: Add console info for super seq allocation
authorwangdi <di.wang@whamcloud.com>
Wed, 9 May 2012 05:18:20 +0000 (22:18 -0700)
committerOleg Drokin <green@whamcloud.com>
Thu, 7 Jun 2012 17:59:42 +0000 (13:59 -0400)
Add console information for super sequence allocation. Because
one super sequence will include 1 billion sequences, it rarely
happens in reality, so it will not cause the flood of console
msg.

Signed-off-by: Di Wang <di.wang@whamcloud.com>
Change-Id: I5154ee2a03006680b6a08d588287bf3941149457
Reviewed-on: http://review.whamcloud.com/2701
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/fid/fid_handler.c
lustre/fid/fid_request.c

index e0a3bfa..b831b3a 100644 (file)
@@ -121,26 +121,26 @@ static int __seq_server_alloc_super(struct lu_server_seq *seq,
                                     struct lu_seq_range *out,
                                     const struct lu_env *env)
 {
                                     struct lu_seq_range *out,
                                     const struct lu_env *env)
 {
-        struct lu_seq_range *space = &seq->lss_space;
-        int rc;
-        ENTRY;
+       struct lu_seq_range *space = &seq->lss_space;
+       int rc;
+       ENTRY;
 
 
-        LASSERT(range_is_sane(space));
+       LASSERT(range_is_sane(space));
 
 
-        if (range_is_exhausted(space)) {
-                CERROR("%s: Sequences space is exhausted\n",
-                       seq->lss_name);
-                RETURN(-ENOSPC);
-        } else {
-                range_alloc(out, space, seq->lss_width);
-        }
+       if (range_is_exhausted(space)) {
+               CERROR("%s: Sequences space is exhausted\n",
+                      seq->lss_name);
+               RETURN(-ENOSPC);
+       } else {
+               range_alloc(out, space, seq->lss_width);
+       }
 
 
-        rc = seq_store_update(env, seq, out, 1 /* sync */);
+       rc = seq_store_update(env, seq, out, 1 /* sync */);
 
 
-        CDEBUG(D_INFO, "%s: super-sequence allocation rc = %d "
-               DRANGE"\n", seq->lss_name, rc, PRANGE(out));
+       LCONSOLE_INFO("%s: super-sequence allocation rc = %d " DRANGE"\n",
+                     seq->lss_name, rc, PRANGE(out));
 
 
-        RETURN(rc);
+       RETURN(rc);
 }
 
 int seq_server_alloc_super(struct lu_server_seq *seq,
 }
 
 int seq_server_alloc_super(struct lu_server_seq *seq,
@@ -234,40 +234,44 @@ static int __seq_server_alloc_meta(struct lu_server_seq *seq,
                                    struct lu_seq_range *out,
                                    const struct lu_env *env)
 {
                                    struct lu_seq_range *out,
                                    const struct lu_env *env)
 {
-        struct lu_seq_range *space = &seq->lss_space;
-        int rc = 0;
-
-        ENTRY;
-
-        LASSERT(range_is_sane(space));
-
-        /* Check if available space ends and allocate new super seq */
-        if (range_is_exhausted(space)) {
-                if (!seq->lss_cli) {
-                        CERROR("%s: No sequence controller is attached.\n",
-                               seq->lss_name);
-                        RETURN(-ENODEV);
-                }
-
-                rc = seq_client_alloc_super(seq->lss_cli, env);
-                if (rc) {
-                        CERROR("%s: Can't allocate super-sequence, rc %d\n",
-                               seq->lss_name, rc);
-                        RETURN(rc);
-                }
-
-                /* Saving new range to allocation space. */
-                *space = seq->lss_cli->lcs_space;
-                LASSERT(range_is_sane(space));
-        }
-
-        rc = range_alloc_set(env, out, seq);
-        if (rc == 0) {
-                CDEBUG(D_INFO, "%s: Allocated meta-sequence "
-                       DRANGE"\n", seq->lss_name, PRANGE(out));
-        }
-
-        RETURN(rc);
+       struct lu_seq_range *space = &seq->lss_space;
+       int rc = 0;
+
+       ENTRY;
+
+       LASSERT(range_is_sane(space));
+
+       /* Check if available space ends and allocate new super seq */
+       if (range_is_exhausted(space)) {
+               if (!seq->lss_cli) {
+                       CERROR("%s: No sequence controller is attached.\n",
+                              seq->lss_name);
+                       RETURN(-ENODEV);
+               }
+
+               rc = seq_client_alloc_super(seq->lss_cli, env);
+               if (rc) {
+                       CERROR("%s: Can't allocate super-sequence, rc %d\n",
+                              seq->lss_name, rc);
+                       RETURN(rc);
+               }
+
+               /* Saving new range to allocation space. */
+               *space = seq->lss_cli->lcs_space;
+               LASSERT(range_is_sane(space));
+       }
+
+       rc = range_alloc_set(env, out, seq);
+       if (rc != 0) {
+               CERROR("%s: Allocated meta-sequence failed: rc = %d\n",
+                       seq->lss_name, rc);
+               RETURN(rc);
+       }
+
+       CDEBUG(D_INFO, "%s: Allocated meta-sequence " DRANGE"\n",
+               seq->lss_name, PRANGE(out));
+
+       RETURN(rc);
 }
 
 int seq_server_alloc_meta(struct lu_server_seq *seq,
 }
 
 int seq_server_alloc_meta(struct lu_server_seq *seq,
index 5f5f0f4..6a177b4 100644 (file)
@@ -64,79 +64,82 @@ static int seq_client_rpc(struct lu_client_seq *seq,
                           struct lu_seq_range *output, __u32 opc,
                           const char *opcname)
 {
                           struct lu_seq_range *output, __u32 opc,
                           const char *opcname)
 {
-        struct obd_export     *exp = seq->lcs_exp;
-        struct ptlrpc_request *req;
-        struct lu_seq_range   *out, *in;
-        __u32                 *op;
-        int                    rc;
-        ENTRY;
-
-        req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY,
-                                        LUSTRE_MDS_VERSION, SEQ_QUERY);
-        if (req == NULL)
-                RETURN(-ENOMEM);
-
-        /* Init operation code */
-        op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC);
-        *op = opc;
-
-        /* Zero out input range, this is not recovery yet. */
-        in = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_RANGE);
-        range_init(in);
-
-        ptlrpc_request_set_replen(req);
-
-       if (seq->lcs_type == LUSTRE_SEQ_METADATA) {
-                req->rq_request_portal = SEQ_METADATA_PORTAL;
-                in->lsr_flags = LU_SEQ_RANGE_MDT;
-        } else {
-                LASSERTF(seq->lcs_type == LUSTRE_SEQ_DATA,
-                         "unknown lcs_type %u\n", seq->lcs_type);
-                req->rq_request_portal = SEQ_DATA_PORTAL;
-                in->lsr_flags = LU_SEQ_RANGE_OST;
-        }
-
-        if (opc == SEQ_ALLOC_SUPER) {
-                /* Update index field of *in, it is required for
-                 * FLD update on super sequence allocator node. */
-                in->lsr_index = seq->lcs_space.lsr_index;
-                req->rq_request_portal = SEQ_CONTROLLER_PORTAL;
-        } else {
-                LASSERTF(opc == SEQ_ALLOC_META,
-                         "unknown opcode %u\n, opc", opc);
-        }
-
-        ptlrpc_at_set_req_timeout(req);
-
-        mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
-        rc = ptlrpc_queue_wait(req);
-        mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
-
-        if (rc)
-                GOTO(out_req, rc);
-
-        out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE);
-        *output = *out;
-
-        if (!range_is_sane(output)) {
-                CERROR("%s: Invalid range received from server: "
-                       DRANGE"\n", seq->lcs_name, PRANGE(output));
-                GOTO(out_req, rc = -EINVAL);
-        }
-
-        if (range_is_exhausted(output)) {
-                CERROR("%s: Range received from server is exhausted: "
-                       DRANGE"]\n", seq->lcs_name, PRANGE(output));
-                GOTO(out_req, rc = -EINVAL);
-        }
-
-        CDEBUG(D_INFO, "%s: Allocated %s-sequence "DRANGE"]\n",
-               seq->lcs_name, opcname, PRANGE(output));
-
-        EXIT;
+       struct obd_export     *exp = seq->lcs_exp;
+       struct ptlrpc_request *req;
+       struct lu_seq_range   *out, *in;
+       __u32                 *op;
+       unsigned int           debug_mask;
+       int                    rc;
+       ENTRY;
+
+       req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY,
+                                       LUSTRE_MDS_VERSION, SEQ_QUERY);
+       if (req == NULL)
+               RETURN(-ENOMEM);
+
+       /* Init operation code */
+       op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC);
+       *op = opc;
+
+       /* Zero out input range, this is not recovery yet. */
+       in = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_RANGE);
+       range_init(in);
+
+       ptlrpc_request_set_replen(req);
+
+       if (seq->lcs_type == LUSTRE_SEQ_METADATA) {
+               req->rq_request_portal = SEQ_METADATA_PORTAL;
+               in->lsr_flags = LU_SEQ_RANGE_MDT;
+       } else {
+               LASSERTF(seq->lcs_type == LUSTRE_SEQ_DATA,
+                        "unknown lcs_type %u\n", seq->lcs_type);
+               req->rq_request_portal = SEQ_DATA_PORTAL;
+               in->lsr_flags = LU_SEQ_RANGE_OST;
+       }
+
+       if (opc == SEQ_ALLOC_SUPER) {
+               /* Update index field of *in, it is required for
+                * FLD update on super sequence allocator node. */
+               in->lsr_index = seq->lcs_space.lsr_index;
+               req->rq_request_portal = SEQ_CONTROLLER_PORTAL;
+               debug_mask = D_CONSOLE;
+       } else {
+               debug_mask = D_INFO;
+               LASSERTF(opc == SEQ_ALLOC_META,
+                        "unknown opcode %u\n, opc", opc);
+       }
+
+       ptlrpc_at_set_req_timeout(req);
+
+       mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+       rc = ptlrpc_queue_wait(req);
+       mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
+
+       if (rc)
+               GOTO(out_req, rc);
+
+       out = req_capsule_server_get(&req->rq_pill, &RMF_SEQ_RANGE);
+       *output = *out;
+
+       if (!range_is_sane(output)) {
+               CERROR("%s: Invalid range received from server: "
+                      DRANGE"\n", seq->lcs_name, PRANGE(output));
+               GOTO(out_req, rc = -EINVAL);
+       }
+
+       if (range_is_exhausted(output)) {
+               CERROR("%s: Range received from server is exhausted: "
+                      DRANGE"]\n", seq->lcs_name, PRANGE(output));
+               GOTO(out_req, rc = -EINVAL);
+       }
+
+       CDEBUG_LIMIT(debug_mask, "%s: Allocated %s-sequence "DRANGE"]\n",
+                    seq->lcs_name, opcname, PRANGE(output));
+
+       EXIT;
 out_req:
 out_req:
-        ptlrpc_req_finished(req);
-        return rc;
+       ptlrpc_req_finished(req);
+       return rc;
 }
 
 /* Request sequence-controller node to allocate new super-sequence. */
 }
 
 /* Request sequence-controller node to allocate new super-sequence. */