Whamcloud - gitweb
avoid hard-coded sizes of reply-size arrays
authornikita <nikita>
Thu, 7 Sep 2006 12:10:04 +0000 (12:10 +0000)
committernikita <nikita>
Thu, 7 Sep 2006 12:10:04 +0000 (12:10 +0000)
lustre/cmm/cmm_object.c
lustre/fid/fid_internal.h
lustre/fld/fld_internal.h
lustre/include/lustre_req_layout.h
lustre/mdt/mdt_internal.h
lustre/ptlrpc/layout.c

index 0dabdbd..1ad5b99 100644 (file)
@@ -294,7 +294,7 @@ static int cml_ref_del(const struct lu_context *ctx, struct md_object *mo,
         RETURN(rc);
 }
 
-static int cml_open(const struct lu_context *ctx, struct md_object *mo, 
+static int cml_open(const struct lu_context *ctx, struct md_object *mo,
                     int flags)
 {
         int rc;
@@ -605,7 +605,7 @@ static int cmr_ref_del(const struct lu_context *ctx, struct md_object *mo,
         RETURN(-EFAULT);
 }
 
-static int cmr_open(const struct lu_context *ctx, struct md_object *mo, 
+static int cmr_open(const struct lu_context *ctx, struct md_object *mo,
                     int flags)
 {
         RETURN(-EREMOTE);
index 3152dec..ecc2618 100644 (file)
@@ -44,7 +44,7 @@ struct seq_thread_info {
         struct txn_param        sti_txn;
         struct req_capsule      sti_pill;
         struct seq_store_record sti_record;
-        int                     sti_rep_buf_size[4];
+        int                     sti_rep_buf_size[REQ_MAX_FIELD_NR];
 };
 
 extern struct lu_context_key seq_thread_key;
index f4448db..d7cbef5 100644 (file)
@@ -53,7 +53,7 @@ extern struct lu_fld_hash fld_hash[];
 #ifdef __KERNEL__
 struct fld_thread_info {
         struct req_capsule fti_pill;
-        int                fti_rep_buf_size[4];
+        int                fti_rep_buf_size[REQ_MAX_FIELD_NR];
         __u64              fti_key;
         __u64              fti_rec;
 };
index e9c7fdd..6ea8165 100644 (file)
@@ -49,6 +49,13 @@ struct req_capsule {
         int                     *rc_area;
 };
 
+enum {
+        /*
+         * Maximal number of fields (buffers) in a request message.
+         */
+        REQ_MAX_FIELD_NR = 8
+};
+
 #if !defined(__REQ_LAYOUT_USER__)
 
 /* struct ptlrpc_request, lustre_msg* */
index d2c9064..2bd74d4 100644 (file)
@@ -185,10 +185,6 @@ struct mdt_lock_handle {
 };
 
 enum {
-        MDT_REP_BUF_NR_MAX = 8
-};
-
-enum {
         MDT_LH_PARENT,
         MDT_LH_CHILD,
         MDT_LH_OLD,
@@ -236,7 +232,7 @@ struct mdt_thread_info {
         /*
          * sizes of reply buffers.
          */
-        int                        mti_rep_buf_size[MDT_REP_BUF_NR_MAX];
+        int                        mti_rep_buf_size[REQ_MAX_FIELD_NR];
         /*
          * Body for "habeo corpus" operations.
          */
index 21554fa..76f087e 100644 (file)
@@ -633,6 +633,7 @@ int req_layout_init(void)
                 rf = (struct req_format *)req_formats[i];
                 rf->rf_idx = i;
                 for (j = 0; j < RCL_NR; ++j) {
+                        LASSERT(rf->rf_fields[j].nr <= REQ_MAX_FIELD_NR);
                         for (k = 0; k < rf->rf_fields[j].nr; ++k) {
                                 struct req_msg_field *field;
 
@@ -655,6 +656,12 @@ void req_layout_fini(void)
 }
 EXPORT_SYMBOL(req_layout_fini);
 
+/*
+ * Initialize capsule.
+ *
+ * @area is an array of REQ_MAX_FIELD_NR elements, used to store sizes of
+ * variable-sized fields.
+ */
 void req_capsule_init(struct req_capsule *pill,
                       struct ptlrpc_request *req, enum req_location location,
                       int *area)