From 583d44412ae5ffb8b132a70956d79744f3852351 Mon Sep 17 00:00:00 2001 From: nikita Date: Thu, 7 Sep 2006 12:10:04 +0000 Subject: [PATCH] avoid hard-coded sizes of reply-size arrays --- lustre/cmm/cmm_object.c | 4 ++-- lustre/fid/fid_internal.h | 2 +- lustre/fld/fld_internal.h | 2 +- lustre/include/lustre_req_layout.h | 7 +++++++ lustre/mdt/mdt_internal.h | 6 +----- lustre/ptlrpc/layout.c | 7 +++++++ 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lustre/cmm/cmm_object.c b/lustre/cmm/cmm_object.c index 0dabdbd..1ad5b99 100644 --- a/lustre/cmm/cmm_object.c +++ b/lustre/cmm/cmm_object.c @@ -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); diff --git a/lustre/fid/fid_internal.h b/lustre/fid/fid_internal.h index 3152dec..ecc2618 100644 --- a/lustre/fid/fid_internal.h +++ b/lustre/fid/fid_internal.h @@ -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; diff --git a/lustre/fld/fld_internal.h b/lustre/fld/fld_internal.h index f4448db..d7cbef5 100644 --- a/lustre/fld/fld_internal.h +++ b/lustre/fld/fld_internal.h @@ -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; }; diff --git a/lustre/include/lustre_req_layout.h b/lustre/include/lustre_req_layout.h index e9c7fdd..6ea8165 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -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* */ diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index d2c9064..2bd74d4 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -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. */ diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 21554fa..76f087e 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -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) -- 1.8.3.1