From: Li Wei Date: Mon, 22 Jul 2013 14:35:45 +0000 (+0800) Subject: LU-3539 protocol: Change UPDATE_OBJ RPC format X-Git-Tag: 2.5.57~66 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8abb5a19e4375f194f3f7d304ad46ec7120e733f LU-3539 protocol: Change UPDATE_OBJ RPC format This patch updates struct update for DNE phase II. See the DNE phase II HLD for more information. The comment describing the UPDATE_OBJ RPC format is already a bit out of date. This patch simplies and updates it so that the overall structure is easier to see while the details are commented in-line. The related type names are modified to be more consistent with the terminology used in the HLD and the comment. Change OBJ_XXX-->OUT_XXX, and refine a few update structures to object_update_xxx. And there are no logic changes in this patch. Change-Id: I4355b4c863abb448713115f17b80402ec96009f8 Signed-off-by: Di Wang Signed-off-by: Li Wei Reviewed-on: http://review.whamcloud.com/7128 Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Alex Zhuravlev Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index ffb85ca..978b10c 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -302,9 +302,9 @@ static inline int opcode_offset(__u32 opc) { OPC_RANGE(LDLM) + OPC_RANGE(MDS) + OPC_RANGE(OST)); - } else if (opc < UPDATE_LAST_OPC) { + } else if (opc < OUT_UPDATE_LAST_OPC) { /* update opcode */ - return (opc - UPDATE_FIRST_OPC + + return (opc - OUT_UPDATE_FIRST_OPC + OPC_RANGE(FLD) + OPC_RANGE(SEC) + OPC_RANGE(SEQ) + @@ -318,7 +318,7 @@ static inline int opcode_offset(__u32 opc) { } else if (opc < LFSCK_LAST_OPC) { /* LFSCK opcode */ return (opc - LFSCK_FIRST_OPC + - OPC_RANGE(UPDATE) + + OPC_RANGE(OUT_UPDATE) + OPC_RANGE(FLD) + OPC_RANGE(SEC) + OPC_RANGE(SEQ) + @@ -346,7 +346,7 @@ static inline int opcode_offset(__u32 opc) { OPC_RANGE(SEQ) + \ OPC_RANGE(SEC) + \ OPC_RANGE(FLD) + \ - OPC_RANGE(UPDATE) + \ + OPC_RANGE(OUT_UPDATE) + \ OPC_RANGE(LFSCK)) #define EXTRA_MAX_OPCODES ((PTLRPC_LAST_CNTR - PTLRPC_FIRST_CNTR) + \ diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index 34b8fcb..af242c3 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -335,19 +335,20 @@ int tgt_truncate_last_rcvd(const struct lu_env *env, struct lu_target *tg, loff_t off); /* target/out_lib.c */ -struct update_request * +struct dt_update_request * out_find_update(struct thandle_update *tu, struct dt_device *dt_dev); -void out_destroy_update_req(struct update_request *update); -struct update_request *out_create_update_req(struct dt_device *dt); -struct update_request *out_find_create_update_loc(struct thandle *th, +void out_destroy_update_req(struct dt_update_request *update); +struct dt_update_request *out_create_update_req(struct dt_device *dt); +struct dt_update_request *out_find_create_update_loc(struct thandle *th, struct dt_object *dt); int out_prep_update_req(const struct lu_env *env, struct obd_import *imp, - const struct update_buf *ubuf, int ubuf_len, + const struct object_update_request *ureq, struct ptlrpc_request **reqp); int out_remote_sync(const struct lu_env *env, struct obd_import *imp, - struct update_request *update, + struct dt_update_request *update, struct ptlrpc_request **reqp); -int out_insert_update(const struct lu_env *env, struct update_request *update, +int out_insert_update(const struct lu_env *env, + struct dt_update_request *update, int op, const struct lu_fid *fid, int count, int *lens, const char **bufs); @@ -485,7 +486,7 @@ static inline void tgt_drop_id(struct obd_export *exp, struct obdo *oa) /* Request with a format known in advance */ #define TGT_UPDATE_HDL(flags, name, fn) \ - TGT_RPC_HANDLER(UPDATE_OBJ, flags, name, fn, &RQF_ ## name, \ + TGT_RPC_HANDLER(OUT_UPDATE, flags, name, fn, &RQF_ ## name, \ LUSTRE_MDS_VERSION) #endif /* __LUSTRE_LU_TARGET_H */ diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index cff332c..48e326d 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2144,11 +2144,11 @@ typedef enum { /* opcodes for object update */ typedef enum { - UPDATE_OBJ = 1000, - UPDATE_LAST_OPC + OUT_UPDATE = 1000, + OUT_UPDATE_LAST_OPC } update_cmd_t; -#define UPDATE_FIRST_OPC UPDATE_OBJ +#define OUT_UPDATE_FIRST_OPC OUT_UPDATE /* * Do not exceed 63 @@ -3850,90 +3850,121 @@ extern void lustre_swab_hsm_user_item(struct hsm_user_item *hui); extern void lustre_swab_hsm_request(struct hsm_request *hr); /** - * These are object update opcode under UPDATE_OBJ, which is currently - * being used by cross-ref operations between MDT. + * OUT_UPDATE RPC Format * * During the cross-ref operation, the Master MDT, which the client send the * request to, will disassembly the operation into object updates, then OSP * will send these updates to the remote MDT to be executed. * - * Update request format - * magic: UPDATE_BUFFER_MAGIC_V1 - * Count: How many updates in the req. - * bufs[0] : following are packets of object. - * update[0]: - * type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * update[1]: - * type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * .......... - * update[7]: type: object_update_op, the op code of update - * fid: The object fid of the update. - * lens/bufs: other parameters of the update. - * Current 8 maxim updates per object update request. + * An UPDATE_OBJ RPC does a list of updates. Each update belongs to an + * operation and does a type of modification to an object. * - ******************************************************************* - * update reply format: + * Request Format * - * ur_version: UPDATE_REPLY_V1 - * ur_count: The count of the reply, which is usually equal - * to the number of updates in the request. - * ur_lens: The reply lengths of each object update. + * update_buf + * update (1st) + * update (2nd) + * ... + * update (ub_count-th) * - * replies: 1st update reply [4bytes_ret: other body] - * 2nd update reply [4bytes_ret: other body] - * ..... - * nth update reply [4bytes_ret: other body] + * ub_count must be less than or equal to UPDATE_PER_RPC_MAX. * - * For each reply of the update, the format would be - * result(4 bytes):Other stuff + * Reply Format + * + * update_reply + * rc [+ buffers] (1st) + * rc [+ buffers] (2st) + * ... + * rc [+ buffers] (nr_count-th) + * + * ur_count must be less than or equal to UPDATE_PER_RPC_MAX and should usually + * be equal to ub_count. */ -#define UPDATE_MAX_OPS 10 -#define UPDATE_BUFFER_MAGIC_V1 0xBDDE0001 -#define UPDATE_BUFFER_MAGIC UPDATE_BUFFER_MAGIC_V1 -#define UPDATE_BUF_COUNT 8 -enum object_update_op { - OBJ_CREATE = 1, - OBJ_DESTROY = 2, - OBJ_REF_ADD = 3, - OBJ_REF_DEL = 4, - OBJ_ATTR_SET = 5, - OBJ_ATTR_GET = 6, - OBJ_XATTR_SET = 7, - OBJ_XATTR_GET = 8, - OBJ_INDEX_LOOKUP = 9, - OBJ_INDEX_INSERT = 10, - OBJ_INDEX_DELETE = 11, - OBJ_LAST -}; - -struct update { - __u32 u_type; - __u32 u_batchid; - struct lu_fid u_fid; - __u32 u_lens[UPDATE_BUF_COUNT]; - __u32 u_bufs[0]; -}; - -struct update_buf { - __u32 ub_magic; - __u32 ub_count; - __u32 ub_bufs[0]; -}; - -#define UPDATE_REPLY_V1 0x00BD0001 -struct update_reply { - __u32 ur_version; - __u32 ur_count; - __u32 ur_lens[0]; -}; - -void lustre_swab_update_buf(struct update_buf *ub); -void lustre_swab_update_reply_buf(struct update_reply *ur); +/** + * Maximum number of updates per UPDATE_OBJ RPC + */ +#define OUT_UPDATE_PER_TRANS_MAX 10 + +/** + * Type of each update + */ +enum update_type { + OUT_CREATE = 1, + OUT_DESTROY = 2, + OUT_REF_ADD = 3, + OUT_REF_DEL = 4, + OUT_ATTR_SET = 5, + OUT_ATTR_GET = 6, + OUT_XATTR_SET = 7, + OUT_XATTR_GET = 8, + OUT_INDEX_LOOKUP = 9, + OUT_INDEX_INSERT = 10, + OUT_INDEX_DELETE = 11, + OUT_LAST +}; + +enum update_flag { + UPDATE_FL_OST = 0x00000001, /* op from OST (not MDT) */ + UPDATE_FL_SYNC = 0x00000002, /* commit before replying */ + UPDATE_FL_COMMITTED = 0x00000004, /* op committed globally */ + UPDATE_FL_NOLOG = 0x00000008 /* for idempotent updates */ +}; + +struct object_update_param { + __u16 oup_len; /* length of this parameter */ + __u16 oup_padding; + __u32 oup_padding2; + char oup_buf[0]; +}; + +/* object update */ +struct object_update { + __u16 ou_type; /* enum update_type */ + __u16 ou_params_count; /* update parameters count */ + __u32 ou_master_index; /* master MDT/OST index */ + __u32 ou_flags; /* enum update_flag */ + __u32 ou_padding1; /* padding 1 */ + __u64 ou_batchid; /* op transno on master */ + struct lu_fid ou_fid; /* object to be updated */ + struct object_update_param ou_params[0]; /* update params */ +}; + +#define UPDATE_REQUEST_MAGIC_V1 0xBDDE0001 +#define UPDATE_REQUEST_MAGIC_V2 0xBDDE0002 +#define UPDATE_REQUEST_MAGIC UPDATE_REQUEST_MAGIC_V2 +/* Hold object_updates sending to the remote OUT in single RPC */ +struct object_update_request { + __u32 ourq_magic; + __u16 ourq_count; /* number of ourq_updates[] */ + __u16 ourq_padding; + struct object_update ourq_updates[0]; +}; + +void lustre_swab_object_update(struct object_update *ou); +void lustre_swab_object_update_request(struct object_update_request *our); + +/* the result of object update */ +struct object_update_result { + __u32 our_rc; + __u16 our_datalen; + __u16 our_padding; + __u32 our_data[0]; +}; + +#define UPDATE_REPLY_MAGIC_V1 0x00BD0001 +#define UPDATE_REPLY_MAGIC_V2 0x00BD0002 +#define UPDATE_REPLY_MAGIC UPDATE_REPLY_MAGIC_V2 +/* Hold object_update_results being replied from the remote OUT. */ +struct object_update_reply { + __u32 ourp_magic; + __u16 ourp_count; + __u16 ourp_padding; + __u16 ourp_lens[0]; +}; + +void lustre_swab_object_update_result(struct object_update_result *our); +void lustre_swab_object_update_reply(struct object_update_reply *our); /** layout swap request structure * fid1 and fid2 are in mdt_body diff --git a/lustre/include/lustre_req_layout.h b/lustre/include/lustre_req_layout.h index 936476e..1a834ea 100644 --- a/lustre/include/lustre_req_layout.h +++ b/lustre/include/lustre_req_layout.h @@ -158,7 +158,7 @@ extern struct req_format RQF_MDS_GETSTATUS; extern struct req_format RQF_MDS_SYNC; extern struct req_format RQF_MDS_GETXATTR; extern struct req_format RQF_MDS_GETATTR; -extern struct req_format RQF_UPDATE_OBJ; +extern struct req_format RQF_OUT_UPDATE; /* * This is format of direct (non-intent) MDS_GETATTR_NAME request. @@ -339,8 +339,8 @@ extern struct req_msg_field RMF_MGS_CONFIG_RES; extern struct req_msg_field RMF_U32; /* OBJ update format */ -extern struct req_msg_field RMF_UPDATE; -extern struct req_msg_field RMF_UPDATE_REPLY; +extern struct req_msg_field RMF_OUT_UPDATE; +extern struct req_msg_field RMF_OUT_UPDATE_REPLY; /* LFSCK format */ extern struct req_msg_field RMF_LFSCK_REQUEST; diff --git a/lustre/include/lustre_update.h b/lustre/include/lustre_update.h index f507bbc..d99e141 100644 --- a/lustre/include/lustre_update.h +++ b/lustre/include/lustre_update.h @@ -31,173 +31,190 @@ #ifndef _LUSTRE_UPDATE_H #define _LUSTRE_UPDATE_H -#define UPDATE_BUFFER_SIZE 8192 -struct update_request { - struct dt_device *ur_dt; - struct list_head ur_list; /* attached itself to thandle */ - int ur_flags; - int ur_rc; /* request result */ - int ur_batchid; /* Current batch(trans) id */ - struct update_buf *ur_buf; /* Holding the update req */ - struct list_head ur_cb_items; +#define OUT_UPDATE_INIT_BUFFER_SIZE 8192 +#define OUT_UPDATE_REPLY_SIZE 8192 +struct dt_update_request { + struct dt_device *dur_dt; + /* attached itself to thandle */ + struct list_head dur_list; + int dur_flags; + /* update request result */ + int dur_rc; + /* Current batch(transaction) id */ + __u64 dur_batchid; + /* Holding the update req */ + struct object_update_request *dur_req; + int dur_req_len; + struct list_head dur_cb_items; }; -static inline unsigned long update_size(struct update *update) +static inline unsigned long +object_update_param_size(const struct object_update_param *param) { - unsigned long size; - int i; + return cfs_size_round(sizeof(*param) + param->oup_len); +} - size = cfs_size_round(offsetof(struct update, u_bufs[0])); - for (i = 0; i < UPDATE_BUF_COUNT; i++) - size += cfs_size_round(update->u_lens[i]); +static inline unsigned long +object_update_size(const struct object_update *update) +{ + const struct object_update_param *param; + unsigned long size; + int i; + + size = offsetof(struct object_update, ou_params[0]); + for (i = 0; i < update->ou_params_count; i++) { + param = (struct object_update_param *)((char *)update + size); + size += object_update_param_size(param); + } return size; } -static inline void *update_param_buf(struct update *update, int index, - int *size) +static inline void +*object_update_param_get(const struct object_update *update, int index, + int *size) { - int i; - void *ptr; + const struct object_update_param *param; + int i; - if (index >= UPDATE_BUF_COUNT) + if (index >= update->ou_params_count) return NULL; - if (unlikely(update->u_lens[index] == 0)) { - ptr = NULL; - } else { - ptr = (char *)update + - cfs_size_round(offsetof(struct update, u_bufs[0])); - for (i = 0; i < index; i++) - ptr += cfs_size_round(update->u_lens[i]); - } + param = &update->ou_params[0]; + for (i = 0; i < index; i++) + param = (struct object_update_param *)((char *)param + + object_update_param_size(param)); if (size != NULL) - *size = update->u_lens[index]; + *size = param->oup_len; - return ptr; + if (param->oup_len == 0) + return NULL; + + return (void *)¶m->oup_buf[0]; } -static inline unsigned long update_buf_size(struct update_buf *buf) +static inline unsigned long +object_update_request_size(const struct object_update_request *our) { unsigned long size; int i = 0; - size = cfs_size_round(offsetof(struct update_buf, ub_bufs[0])); - for (i = 0; i < buf->ub_count; i++) { - struct update *update; + size = offsetof(struct object_update_request, ourq_updates[0]); + for (i = 0; i < our->ourq_count; i++) { + struct object_update *update; - update = (struct update *)((char *)buf + size); - size += update_size(update); + update = (struct object_update *)((char *)our + size); + size += object_update_size(update); } - LASSERT(size <= UPDATE_BUFFER_SIZE); return size; } -static inline void *update_buf_get(struct update_buf *buf, int index, int *size) +static inline struct object_update +*object_update_request_get(const struct object_update_request *our, + int index, int *size) { - int count = buf->ub_count; void *ptr; - int i = 0; + int i; - if (index >= count) + if (index >= our->ourq_count) return NULL; - ptr = (char *)buf + cfs_size_round(offsetof(struct update_buf, - ub_bufs[0])); + ptr = (char *)our + offsetof(struct object_update_request, + ourq_updates[0]); for (i = 0; i < index; i++) - ptr += update_size((struct update *)ptr); + ptr += object_update_size((struct object_update *)ptr); if (size != NULL) - *size = update_size((struct update *)ptr); + *size = object_update_size((struct object_update *)ptr); return ptr; } -static inline void update_init_reply_buf(struct update_reply *reply, int count) +static inline void +object_update_reply_init(struct object_update_reply *reply, int count) { - reply->ur_version = UPDATE_REPLY_V1; - reply->ur_count = count; + reply->ourp_magic = UPDATE_REPLY_MAGIC; + reply->ourp_count = count; } -static inline void *update_get_buf_internal(struct update_reply *reply, - int index, int *size) +static inline struct object_update_result +*object_update_result_get(const struct object_update_reply *reply, + int index, int *size) { char *ptr; - int count = reply->ur_count; + int count = reply->ourp_count; int i; if (index >= count) return NULL; - ptr = (char *)reply + cfs_size_round(offsetof(struct update_reply, - ur_lens[count])); + ptr = (char *)reply + + cfs_size_round(offsetof(struct object_update_reply, + ourp_lens[count])); for (i = 0; i < index; i++) { - LASSERT(reply->ur_lens[i] > 0); - ptr += cfs_size_round(reply->ur_lens[i]); + LASSERT(reply->ourp_lens[i] > 0); + ptr += cfs_size_round(reply->ourp_lens[i]); } if (size != NULL) - *size = reply->ur_lens[index]; + *size = reply->ourp_lens[index]; - return ptr; + return (struct object_update_result *)ptr; } -static inline void update_insert_reply(struct update_reply *reply, void *data, - int data_len, int index, int rc) +static inline void +object_update_result_insert(struct object_update_reply *reply, + void *data, int data_len, int index, + int rc) { + struct object_update_result *update_result; char *ptr; - ptr = update_get_buf_internal(reply, index, NULL); - LASSERT(ptr != NULL); + update_result = object_update_result_get(reply, index, NULL); + LASSERT(update_result != NULL); - *(int *)ptr = cpu_to_le32(rc); - ptr += sizeof(int); + update_result->our_rc = ptlrpc_status_hton(rc); if (data_len > 0) { LASSERT(data != NULL); + ptr = (char *)update_result + + cfs_size_round(sizeof(struct object_update_reply)); + update_result->our_datalen = data_len; memcpy(ptr, data, data_len); } - reply->ur_lens[index] = data_len + sizeof(int); + + reply->ourp_lens[index] = cfs_size_round(data_len + + sizeof(struct object_update_result)); } -static inline int update_get_reply_buf(struct update_reply *reply, - struct lu_buf *lbuf, int index) +static inline int +object_update_result_data_get(const struct object_update_reply *reply, + struct lu_buf *lbuf, int index) { - char *ptr; + struct object_update_result *update_result; int size = 0; int result; LASSERT(lbuf != NULL); + update_result = object_update_result_get(reply, index, &size); + if (update_result == NULL || + size < cfs_size_round(sizeof(struct object_update_reply)) || + update_result->our_datalen > size) + RETURN(-EFAULT); - ptr = update_get_buf_internal(reply, index, &size); - LASSERT(ptr != NULL); - result = *(int *)ptr; - + result = ptlrpc_status_ntoh(update_result->our_rc); if (result < 0) return result; - LASSERT(size >= sizeof(int)); - - lbuf->lb_buf = ptr + sizeof(int); - lbuf->lb_len = size - sizeof(int); + lbuf->lb_buf = update_result->our_data; + lbuf->lb_len = update_result->our_datalen; return 0; } -static inline int update_get_reply_result(struct update_reply *reply, - void **buf, int index) -{ - void *ptr; - int size; - - ptr = update_get_buf_internal(reply, index, &size); - LASSERT(ptr != NULL && size > sizeof(int)); - return *(int *)ptr; -} - -static inline void update_inc_batchid(struct update_request *update) +static inline void update_inc_batchid(struct dt_update_request *update) { - update->ur_batchid++; + update->dur_batchid++; } #endif diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index 6e1cd54..d33d85d 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -515,8 +515,8 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type, #define OBD_FAIL_LFSCK_QUERY_NET 0x16f1 /* UPDATE */ -#define OBD_FAIL_UPDATE_OBJ_NET 0x1700 -#define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701 +#define OBD_FAIL_OUT_UPDATE_NET 0x1700 +#define OBD_FAIL_OUT_UPDATE_NET_REP 0x1701 /* Assign references to moved code to reduce code changes */ diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index a451462..1d4849f 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -421,12 +421,12 @@ static int lod_trans_start(const struct lu_env *env, struct dt_device *dev, if (unlikely(th->th_update != NULL)) { struct thandle_update *tu = th->th_update; - struct update_request *update; + struct dt_update_request *update; list_for_each_entry(update, &tu->tu_remote_update_list, - ur_list) { - LASSERT(update->ur_dt != NULL); - rc = dt_trans_start(env, update->ur_dt, th); + dur_list) { + LASSERT(update->dur_dt != NULL); + rc = dt_trans_start(env, update->dur_dt, th); if (rc != 0) return rc; } @@ -437,21 +437,22 @@ static int lod_trans_start(const struct lu_env *env, struct dt_device *dev, static int lod_trans_stop(const struct lu_env *env, struct dt_device *dt, struct thandle *th) { - struct thandle_update *tu = th->th_update; - struct update_request *update; - struct update_request *tmp; - int rc2 = 0; - int rc; + struct thandle_update *tu = th->th_update; + struct dt_update_request *update; + struct dt_update_request *tmp; + int rc2 = 0; + int rc; ENTRY; rc = dt_trans_stop(env, th->th_dev, th); if (likely(tu == NULL)) RETURN(rc); - list_for_each_entry_safe(update, tmp, &tu->tu_remote_update_list, - ur_list) { + list_for_each_entry_safe(update, tmp, + &tu->tu_remote_update_list, + dur_list) { /* update will be freed inside dt_trans_stop */ - rc2 = dt_trans_stop(env, update->ur_dt, th); + rc2 = dt_trans_stop(env, update->dur_dt, th); if (unlikely(rc2 != 0 && rc == 0)) rc = rc2; } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 17b7605..f771629 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4203,8 +4203,8 @@ static struct tgt_opc_slice mdt_common_slice[] = { .tos_hs = mdt_sec_ctx_ops }, { - .tos_opc_start = UPDATE_OBJ, - .tos_opc_end = UPDATE_LAST_OPC, + .tos_opc_start = OUT_UPDATE_FIRST_OPC, + .tos_opc_end = OUT_UPDATE_LAST_OPC, .tos_hs = tgt_out_handlers }, { diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 9900bed..a8f193b 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2063,8 +2063,8 @@ static struct tgt_opc_slice ofd_common_slice[] = { .tos_hs = tgt_dlm_handlers }, { - .tos_opc_start = UPDATE_OBJ, - .tos_opc_end = UPDATE_LAST_OPC, + .tos_opc_start = OUT_UPDATE_FIRST_OPC, + .tos_opc_end = OUT_UPDATE_LAST_OPC, .tos_hs = tgt_out_handlers }, { diff --git a/lustre/osp/osp_internal.h b/lustre/osp/osp_internal.h index c040efa..78c9bbc 100644 --- a/lustre/osp/osp_internal.h +++ b/lustre/osp/osp_internal.h @@ -192,7 +192,7 @@ struct osp_device { * osp_device::opd_async_requests via declare() functions, these * requests can be packed together and sent to the remote server * via single OUT RPC later. */ - struct update_request *opd_async_requests; + struct dt_update_request *opd_async_requests; /* Protect current operations on opd_async_requests. */ struct mutex opd_async_requests_mutex; struct semaphore opd_async_fc_sem; @@ -452,7 +452,7 @@ static inline int osp_is_fid_client(struct osp_device *osp) } typedef int (*osp_async_update_interpterer_t)(const struct lu_env *env, - struct update_reply *reply, + struct object_update_reply *reply, struct osp_object *obj, void *data, int index, int rc); @@ -461,16 +461,16 @@ void osp_update_last_id(struct osp_device *d, obd_id objid); extern struct llog_operations osp_mds_ost_orig_logops; /* osp_trans.c */ -struct update_request * +struct dt_update_request * osp_find_or_create_async_update_request(struct osp_device *osp); int osp_insert_async_update(const struct lu_env *env, - struct update_request *update, int op, + struct dt_update_request *update, int op, struct osp_object *obj, int count, int *lens, const char **bufs, void *data, osp_async_update_interpterer_t interpterer); int osp_unplug_async_update(const struct lu_env *env, struct osp_device *osp, - struct update_request *update); + struct dt_update_request *update); struct thandle *osp_trans_create(const struct lu_env *env, struct dt_device *d); int osp_trans_start(const struct lu_env *env, struct dt_device *dt, @@ -511,6 +511,7 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt, const struct lu_attr *attr, struct thandle *th, struct lustre_capa *capa); + /* osp_precreate.c */ int osp_init_precreate(struct osp_device *d); int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d); diff --git a/lustre/osp/osp_md_object.c b/lustre/osp/osp_md_object.c index fc468d3..6a265dd 100644 --- a/lustre/osp/osp_md_object.c +++ b/lustre/osp/osp_md_object.c @@ -45,13 +45,13 @@ int osp_md_declare_object_create(const struct lu_env *env, struct dt_object_format *dof, struct thandle *th) { - struct osp_thread_info *osi = osp_env_info(env); - struct update_request *update; - struct lu_fid *fid1; - int sizes[2] = {sizeof(struct obdo), 0}; - char *bufs[2] = {NULL, NULL}; - int buf_count; - int rc; + struct osp_thread_info *osi = osp_env_info(env); + struct dt_update_request *update; + struct lu_fid *fid1; + int sizes[2] = {sizeof(struct obdo), 0}; + char *bufs[2] = {NULL, NULL}; + int buf_count; + int rc; update = out_find_create_update_loc(th, dt); if (IS_ERR(update)) { @@ -97,20 +97,20 @@ int osp_md_declare_object_create(const struct lu_env *env, CDEBUG(D_HA, "%s: object "DFID" exists, destroy this orphan\n", dt->do_lu.lo_dev->ld_obd->obd_name, PFID(fid1)); - rc = out_insert_update(env, update, OBJ_REF_DEL, fid1, 0, + rc = out_insert_update(env, update, OUT_REF_DEL, fid1, 0, NULL, NULL); if (rc != 0) GOTO(out, rc); if (S_ISDIR(lu_object_attr(&dt->do_lu))) { /* decrease for ".." */ - rc = out_insert_update(env, update, OBJ_REF_DEL, fid1, + rc = out_insert_update(env, update, OUT_REF_DEL, fid1, 0, NULL, NULL); if (rc != 0) GOTO(out, rc); } - rc = out_insert_update(env, update, OBJ_DESTROY, fid1, 0, NULL, + rc = out_insert_update(env, update, OUT_DESTROY, fid1, 0, NULL, NULL); if (rc != 0) GOTO(out, rc); @@ -121,7 +121,7 @@ int osp_md_declare_object_create(const struct lu_env *env, update_inc_batchid(update); } - rc = out_insert_update(env, update, OBJ_CREATE, fid1, buf_count, sizes, + rc = out_insert_update(env, update, OUT_CREATE, fid1, buf_count, sizes, (const char **)bufs); out: if (rc) @@ -153,9 +153,9 @@ static int osp_md_declare_object_ref_del(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - struct update_request *update; - struct lu_fid *fid; - int rc; + struct dt_update_request *update; + struct lu_fid *fid; + int rc; update = out_find_create_update_loc(th, dt); if (IS_ERR(update)) { @@ -167,7 +167,7 @@ static int osp_md_declare_object_ref_del(const struct lu_env *env, fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); - rc = out_insert_update(env, update, OBJ_REF_DEL, fid, 0, NULL, NULL); + rc = out_insert_update(env, update, OUT_REF_DEL, fid, 0, NULL, NULL); return rc; } @@ -185,9 +185,9 @@ static int osp_md_object_ref_del(const struct lu_env *env, static int osp_md_declare_ref_add(const struct lu_env *env, struct dt_object *dt, struct thandle *th) { - struct update_request *update; - struct lu_fid *fid; - int rc; + struct dt_update_request *update; + struct lu_fid *fid; + int rc; update = out_find_create_update_loc(th, dt); if (IS_ERR(update)) { @@ -199,7 +199,7 @@ static int osp_md_declare_ref_add(const struct lu_env *env, fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); - rc = out_insert_update(env, update, OBJ_REF_ADD, fid, 0, NULL, NULL); + rc = out_insert_update(env, update, OUT_REF_ADD, fid, 0, NULL, NULL); return rc; } @@ -230,12 +230,12 @@ static void osp_md_ah_init(const struct lu_env *env, int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, const struct lu_attr *attr, struct thandle *th) { - struct osp_thread_info *osi = osp_env_info(env); - struct update_request *update; - struct lu_fid *fid; - int size = sizeof(struct obdo); - char *buf; - int rc; + struct osp_thread_info *osi = osp_env_info(env); + struct dt_update_request *update; + struct lu_fid *fid; + int size = sizeof(struct obdo); + char *buf; + int rc; update = out_find_create_update_loc(th, dt); if (IS_ERR(update)) { @@ -254,7 +254,7 @@ int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt, buf = (char *)&osi->osi_obdo; fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); - rc = out_insert_update(env, update, OBJ_ATTR_SET, fid, 1, &size, + rc = out_insert_update(env, update, OUT_ATTR_SET, fid, 1, &size, (const char **)&buf); return rc; @@ -325,13 +325,12 @@ static int osp_md_index_lookup(const struct lu_env *env, struct dt_object *dt, struct lu_buf *lbuf = &osp_env_info(env)->osi_lb2; struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); struct dt_device *dt_dev = &osp->opd_dt_dev; - struct update_request *update; - struct ptlrpc_request *req = NULL; - int size = strlen((char *)key) + 1; - int rc; - struct update_reply *reply; - struct lu_fid *fid; - + struct dt_update_request *update; + struct object_update_reply *reply; + struct ptlrpc_request *req = NULL; + int size = strlen((char *)key) + 1; + struct lu_fid *fid; + int rc; ENTRY; /* Because it needs send the update buffer right away, @@ -342,9 +341,9 @@ static int osp_md_index_lookup(const struct lu_env *env, struct dt_object *dt, if (IS_ERR(update)) RETURN(PTR_ERR(update)); - rc = out_insert_update(env, update, OBJ_INDEX_LOOKUP, - lu_object_fid(&dt->do_lu), 1, &size, - (const char **)&key); + rc = out_insert_update(env, update, OUT_INDEX_LOOKUP, + lu_object_fid(&dt->do_lu), + 1, &size, (const char **)&key); if (rc) { CERROR("%s: Insert update error: rc = %d\n", dt_dev->dd_lu_dev.ld_obd->obd_name, rc); @@ -355,26 +354,19 @@ static int osp_md_index_lookup(const struct lu_env *env, struct dt_object *dt, if (rc < 0) GOTO(out, rc); - reply = req_capsule_server_sized_get(&req->rq_pill, &RMF_UPDATE_REPLY, - UPDATE_BUFFER_SIZE); - if (reply->ur_version != UPDATE_REPLY_V1) { + reply = req_capsule_server_sized_get(&req->rq_pill, + &RMF_OUT_UPDATE_REPLY, + OUT_UPDATE_REPLY_SIZE); + if (reply->ourp_magic != UPDATE_REPLY_MAGIC) { CERROR("%s: Wrong version %x expected %x: rc = %d\n", dt_dev->dd_lu_dev.ld_obd->obd_name, - reply->ur_version, UPDATE_REPLY_V1, -EPROTO); + reply->ourp_magic, UPDATE_REPLY_MAGIC, -EPROTO); GOTO(out, rc = -EPROTO); } - rc = update_get_reply_result(reply, NULL, 0); - if (rc < 0) { - CERROR("%s: wrong version lookup "DFID" %s: rc = %d\n", - dt_dev->dd_lu_dev.ld_obd->obd_name, - PFID(lu_object_fid(&dt->do_lu)), (char *)key, rc); - GOTO(out, rc); - } - - rc = update_get_reply_buf(reply, lbuf, 0); + rc = object_update_result_data_get(reply, lbuf, 0); if (rc < 0) - GOTO(out, rc); + GOTO(out, rc = size); if (lbuf->lb_len != sizeof(*fid)) { CERROR("%s: lookup "DFID" %s wrong size %d\n", @@ -412,13 +404,13 @@ static int osp_md_declare_insert(const struct lu_env *env, const struct dt_key *key, struct thandle *th) { - struct update_request *update; - struct lu_fid *fid; - struct lu_fid *rec_fid = (struct lu_fid *)rec; - int size[2] = {strlen((char *)key) + 1, + struct dt_update_request *update; + struct lu_fid *fid; + struct lu_fid *rec_fid = (struct lu_fid *)rec; + int size[2] = {strlen((char *)key) + 1, sizeof(*rec_fid)}; - const char *bufs[2] = {(char *)key, (char *)rec_fid}; - int rc; + const char *bufs[2] = {(char *)key, (char *)rec_fid}; + int rc; update = out_find_create_update_loc(th, dt); if (IS_ERR(update)) { @@ -436,7 +428,7 @@ static int osp_md_declare_insert(const struct lu_env *env, fid_cpu_to_le(rec_fid, rec_fid); - rc = out_insert_update(env, update, OBJ_INDEX_INSERT, fid, + rc = out_insert_update(env, update, OUT_INDEX_INSERT, fid, ARRAY_SIZE(size), size, bufs); return rc; } @@ -457,7 +449,7 @@ static int osp_md_declare_delete(const struct lu_env *env, const struct dt_key *key, struct thandle *th) { - struct update_request *update; + struct dt_update_request *update; struct lu_fid *fid; int size = strlen((char *)key) + 1; int rc; @@ -472,7 +464,7 @@ static int osp_md_declare_delete(const struct lu_env *env, fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); - rc = out_insert_update(env, update, OBJ_INDEX_DELETE, fid, 1, &size, + rc = out_insert_update(env, update, OUT_INDEX_DELETE, fid, 1, &size, (const char **)&key); return rc; @@ -495,7 +487,7 @@ static int osp_md_index_delete(const struct lu_env *env, * * Note: for OSP, these index iterate api is only used to check * whether the directory is empty now (see mdd_dir_is_empty). - * Since dir_empty will be return by OBJ_ATTR_GET(see osp_attr_get/ + * Since dir_empty will be return by OUT_ATTR_GET(see osp_attr_get/ * out_attr_get). So the implementation of these iterator is simplied * to make mdd_dir_is_empty happy. The real iterator should be * implemented, if we need it one day. diff --git a/lustre/osp/osp_object.c b/lustre/osp/osp_object.c index f705813..9aed2c2 100644 --- a/lustre/osp/osp_object.c +++ b/lustre/osp/osp_object.c @@ -207,7 +207,7 @@ static inline void osp_oac_xattr_put(struct osp_xattr_entry *oxe) } static int osp_get_attr_from_reply(const struct lu_env *env, - struct update_reply *reply, + struct object_update_reply *reply, struct lu_attr *attr, struct osp_object *obj, int index) { @@ -215,9 +215,9 @@ static int osp_get_attr_from_reply(const struct lu_env *env, struct lu_buf *rbuf = &osi->osi_lb2; struct obdo *lobdo = &osi->osi_obdo; struct obdo *wobdo; - int rc; + int rc; - rc = update_get_reply_buf(reply, rbuf, index); + rc = object_update_result_data_get(reply, rbuf, index); if (rc < 0) return rc; @@ -243,7 +243,7 @@ static int osp_get_attr_from_reply(const struct lu_env *env, } static int osp_attr_get_interpterer(const struct lu_env *env, - struct update_reply *reply, + struct object_update_reply *reply, struct osp_object *obj, void *data, int index, int rc) { @@ -275,7 +275,7 @@ static int osp_declare_attr_get(const struct lu_env *env, struct dt_object *dt, { struct osp_object *obj = dt2osp_obj(dt); struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); - struct update_request *update; + struct dt_update_request *update; int rc = 0; if (obj->opo_ooa == NULL) { @@ -289,7 +289,7 @@ static int osp_declare_attr_get(const struct lu_env *env, struct dt_object *dt, if (IS_ERR(update)) rc = PTR_ERR(update); else - rc = osp_insert_async_update(env, update, OBJ_ATTR_GET, obj, 0, + rc = osp_insert_async_update(env, update, OUT_ATTR_GET, obj, 0, NULL, NULL, &obj->opo_ooa->ooa_attr, osp_attr_get_interpterer); @@ -301,13 +301,13 @@ static int osp_declare_attr_get(const struct lu_env *env, struct dt_object *dt, int osp_attr_get(const struct lu_env *env, struct dt_object *dt, struct lu_attr *attr, struct lustre_capa *capa) { - struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); - struct osp_object *obj = dt2osp_obj(dt); - struct dt_device *dev = &osp->opd_dt_dev; - struct update_request *update; - struct update_reply *reply; - struct ptlrpc_request *req = NULL; - int rc = 0; + struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); + struct osp_object *obj = dt2osp_obj(dt); + struct dt_device *dev = &osp->opd_dt_dev; + struct dt_update_request *update; + struct object_update_reply *reply; + struct ptlrpc_request *req = NULL; + int rc = 0; ENTRY; if (is_ost_obj(&dt->do_lu) && obj->opo_non_exist) @@ -328,7 +328,7 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt, if (IS_ERR(update)) RETURN(PTR_ERR(update)); - rc = out_insert_update(env, update, OBJ_ATTR_GET, + rc = out_insert_update(env, update, OUT_ATTR_GET, lu_object_fid(&dt->do_lu), 0, NULL, NULL); if (rc != 0) { CERROR("%s: Insert update error "DFID": rc = %d\n", @@ -354,9 +354,10 @@ int osp_attr_get(const struct lu_env *env, struct dt_object *dt, osp2lu_obj(obj)->lo_header->loh_attr |= LOHA_EXISTS; obj->opo_non_exist = 0; - reply = req_capsule_server_sized_get(&req->rq_pill, &RMF_UPDATE_REPLY, - UPDATE_BUFFER_SIZE); - if (reply == NULL || reply->ur_version != UPDATE_REPLY_V1) + reply = req_capsule_server_sized_get(&req->rq_pill, + &RMF_OUT_UPDATE_REPLY, + OUT_UPDATE_REPLY_SIZE); + if (reply == NULL || reply->ourp_magic != UPDATE_REPLY_MAGIC) GOTO(out, rc = -EPROTO); rc = osp_get_attr_from_reply(env, reply, attr, obj, 0); @@ -498,7 +499,7 @@ static int osp_attr_set(const struct lu_env *env, struct dt_object *dt, } static int osp_xattr_get_interpterer(const struct lu_env *env, - struct update_reply *reply, + struct object_update_reply *reply, struct osp_object *obj, void *data, int index, int rc) { @@ -511,7 +512,7 @@ static int osp_xattr_get_interpterer(const struct lu_env *env, if (rc == 0) { int len = sizeof(*oxe) + oxe->oxe_namelen + 1; - rc = update_get_reply_buf(reply, rbuf, index); + rc = object_update_result_data_get(reply, rbuf, index); if (rc < 0 || rbuf->lb_len > (oxe->oxe_buflen - len)) { spin_lock(&obj->opo_lock); oxe->oxe_ready = 0; @@ -549,7 +550,7 @@ static int osp_declare_xattr_get(const struct lu_env *env, struct dt_object *dt, { struct osp_object *obj = dt2osp_obj(dt); struct osp_device *osp = lu2osp_dev(dt->do_lu.lo_dev); - struct update_request *update; + struct dt_update_request *update; struct osp_xattr_entry *oxe; int namelen = strlen(name); int rc = 0; @@ -578,7 +579,7 @@ static int osp_declare_xattr_get(const struct lu_env *env, struct dt_object *dt, mutex_unlock(&osp->opd_async_requests_mutex); osp_oac_xattr_put(oxe); } else { - rc = osp_insert_async_update(env, update, OBJ_XATTR_GET, obj, + rc = osp_insert_async_update(env, update, OUT_XATTR_GET, obj, 1, &namelen, &name, oxe, osp_xattr_get_interpterer); if (rc != 0) { @@ -591,8 +592,8 @@ static int osp_declare_xattr_get(const struct lu_env *env, struct dt_object *dt, * * We will improve it in the future. */ update = osp->opd_async_requests; - if (update != NULL && update->ur_buf != NULL && - update->ur_buf->ub_count > 0) { + if (update != NULL && update->dur_req != NULL && + update->dur_req->ourq_count > 0) { osp->opd_async_requests = NULL; mutex_unlock(&osp->opd_async_requests_mutex); rc = osp_unplug_async_update(env, osp, update); @@ -613,9 +614,9 @@ int osp_xattr_get(const struct lu_env *env, struct dt_object *dt, struct osp_object *obj = dt2osp_obj(dt); struct dt_device *dev = &osp->opd_dt_dev; struct lu_buf *rbuf = &osp_env_info(env)->osi_lb2; - struct update_request *update = NULL; + struct dt_update_request *update = NULL; struct ptlrpc_request *req = NULL; - struct update_reply *reply; + struct object_update_reply *reply; struct osp_xattr_entry *oxe = NULL; const char *dname = dt->do_lu.lo_dev->ld_obd->obd_name; int namelen; @@ -658,8 +659,8 @@ unlock: if (IS_ERR(update)) GOTO(out, rc = PTR_ERR(update)); - namelen = strlen(name); - rc = out_insert_update(env, update, OBJ_XATTR_GET, + namelen = strlen(name) + 1; + rc = out_insert_update(env, update, OUT_XATTR_GET, lu_object_fid(&dt->do_lu), 1, &namelen, &name); if (rc != 0) { CERROR("%s: Insert update error "DFID": rc = %d\n", @@ -696,22 +697,21 @@ unlock: GOTO(out, rc); } - reply = req_capsule_server_sized_get(&req->rq_pill, &RMF_UPDATE_REPLY, - UPDATE_BUFFER_SIZE); - if (reply->ur_version != UPDATE_REPLY_V1) { + reply = req_capsule_server_sized_get(&req->rq_pill, + &RMF_OUT_UPDATE_REPLY, + OUT_UPDATE_REPLY_SIZE); + if (reply->ourp_magic != UPDATE_REPLY_MAGIC) { CERROR("%s: Wrong version %x expected %x "DFID": rc = %d\n", - dname, reply->ur_version, UPDATE_REPLY_V1, + dname, reply->ourp_magic, UPDATE_REPLY_MAGIC, PFID(lu_object_fid(&dt->do_lu)), -EPROTO); GOTO(out, rc = -EPROTO); } - rc = update_get_reply_buf(reply, rbuf, 0); + rc = object_update_result_data_get(reply, rbuf, 0); if (rc < 0) GOTO(out, rc); - LASSERT(rbuf->lb_len > 0 && rbuf->lb_len < PAGE_CACHE_SIZE); - if (buf->lb_buf == NULL) GOTO(out, rc = rbuf->lb_len); @@ -783,7 +783,7 @@ int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, int flag, struct thandle *th) { struct osp_object *o = dt2osp_obj(dt); - struct update_request *update; + struct dt_update_request *update; struct lu_fid *fid; struct osp_xattr_entry *oxe; int sizes[3] = {strlen(name), buf->lb_len, @@ -807,7 +807,7 @@ int osp_declare_xattr_set(const struct lu_env *env, struct dt_object *dt, bufs[2] = (char *)&flag; fid = (struct lu_fid *)lu_object_fid(&dt->do_lu); - rc = out_insert_update(env, update, OBJ_XATTR_SET, fid, + rc = out_insert_update(env, update, OUT_XATTR_SET, fid, ARRAY_SIZE(sizes), sizes, (const char **)bufs); if (rc != 0 || o->opo_ooa == NULL) return rc; diff --git a/lustre/osp/osp_sync.c b/lustre/osp/osp_sync.c index 9573273..e311801 100644 --- a/lustre/osp/osp_sync.c +++ b/lustre/osp/osp_sync.c @@ -530,7 +530,7 @@ static int osp_prep_unlink_update_req(const struct lu_env *env, struct ptlrpc_request **reqp) { struct llog_unlink64_rec *rec = (struct llog_unlink64_rec *)h; - struct update_request *update = NULL; + struct dt_update_request *update = NULL; struct ptlrpc_request *req; const char *buf; struct llog_cookie lcookie; @@ -544,12 +544,12 @@ static int osp_prep_unlink_update_req(const struct lu_env *env, /* This can only happens for unlink slave directory, so decrease * ref for ".." and "." */ - rc = out_insert_update(env, update, OBJ_REF_DEL, &rec->lur_fid, 0, + rc = out_insert_update(env, update, OUT_REF_DEL, &rec->lur_fid, 0, NULL, NULL); if (rc != 0) GOTO(out, rc); - rc = out_insert_update(env, update, OBJ_REF_DEL, &rec->lur_fid, 0, + rc = out_insert_update(env, update, OUT_REF_DEL, &rec->lur_fid, 0, NULL, NULL); if (rc != 0) GOTO(out, rc); @@ -560,13 +560,15 @@ static int osp_prep_unlink_update_req(const struct lu_env *env, size = sizeof(lcookie); buf = (const char *)&lcookie; - rc = out_insert_update(env, update, OBJ_DESTROY, &rec->lur_fid, 1, + rc = out_insert_update(env, update, OUT_DESTROY, &rec->lur_fid, 1, &size, &buf); if (rc != 0) GOTO(out, rc); rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import, - update->ur_buf, UPDATE_BUFFER_SIZE, &req); + update->dur_req, &req); + if (rc != 0) + GOTO(out, rc); INIT_LIST_HEAD(&req->rq_exp_list); req->rq_svc_thread = (void *)OSP_JOB_MAGIC; @@ -762,18 +764,19 @@ static void osp_sync_process_committed(const struct lu_env *env, cfs_list_del_init(&req->rq_exp_list); if (d->opd_connect_mdt) { - struct update_buf *ubuf; - struct update *update; - ubuf = req_capsule_client_get(&req->rq_pill, - &RMF_UPDATE); - LASSERT(ubuf != NULL && - ubuf->ub_magic == UPDATE_BUFFER_MAGIC); + struct object_update_request *ureq; + struct object_update *update; + ureq = req_capsule_client_get(&req->rq_pill, + &RMF_OUT_UPDATE); + LASSERT(ureq != NULL && + ureq->ourq_magic == UPDATE_REQUEST_MAGIC); + /* 1st/2nd is for decref . and .., 3rd one is for * destroy, where the log cookie is stored. * See osp_prep_unlink_update_req */ - update = update_buf_get(ubuf, 2, NULL); + update = object_update_request_get(ureq, 2, NULL); LASSERT(update != NULL); - lcookie = update_param_buf(update, 0, NULL); + lcookie = object_update_param_get(update, 0, NULL); LASSERT(lcookie != NULL); } else { body = req_capsule_client_get(&req->rq_pill, diff --git a/lustre/osp/osp_trans.c b/lustre/osp/osp_trans.c index 3b560f8..896f2d0 100644 --- a/lustre/osp/osp_trans.c +++ b/lustre/osp/osp_trans.c @@ -34,7 +34,7 @@ #include "osp_internal.h" struct osp_async_update_args { - struct update_request *oaua_update; + struct dt_update_request *oaua_update; unsigned int oaua_fc:1; }; @@ -77,12 +77,12 @@ static int osp_async_update_interpret(const struct lu_env *env, struct ptlrpc_request *req, void *arg, int rc) { - struct update_reply *reply = NULL; + struct object_update_reply *reply = NULL; struct osp_async_update_args *oaua = arg; - struct update_request *update = oaua->oaua_update; + struct dt_update_request *dt_update = oaua->oaua_update; struct osp_async_update_item *oaui; struct osp_async_update_item *next; - struct osp_device *osp = dt2osp_dev(update->ur_dt); + struct osp_device *osp = dt2osp_dev(dt_update->dur_dt); int count = 0; int index = 0; int rc1 = 0; @@ -92,24 +92,27 @@ static int osp_async_update_interpret(const struct lu_env *env, if (rc == 0 || req->rq_repmsg != NULL) { reply = req_capsule_server_sized_get(&req->rq_pill, - &RMF_UPDATE_REPLY, - UPDATE_BUFFER_SIZE); - if (reply == NULL || reply->ur_version != UPDATE_REPLY_V1) + &RMF_OUT_UPDATE_REPLY, + OUT_UPDATE_REPLY_SIZE); + if (reply == NULL || reply->ourp_magic != UPDATE_REPLY_MAGIC) rc1 = -EPROTO; else - count = reply->ur_count; + count = reply->ourp_count; } else { rc1 = rc; } - list_for_each_entry_safe(oaui, next, &update->ur_cb_items, oaui_list) { + list_for_each_entry_safe(oaui, next, &dt_update->dur_cb_items, + oaui_list) { list_del_init(&oaui->oaui_list); - if (index < count && reply->ur_lens[index] > 0) { - char *ptr = update_get_buf_internal(reply, index, NULL); - - LASSERT(ptr != NULL); - - rc1 = le32_to_cpu(*(int *)ptr); + if (index < count && reply->ourp_lens[index] > 0) { + struct object_update_result *result; + + result = object_update_result_get(reply, index, NULL); + if (result == NULL) + rc1 = -EPROTO; + else + rc1 = result->our_rc; } else { rc1 = rc; if (unlikely(rc1 == 0)) @@ -122,27 +125,27 @@ static int osp_async_update_interpret(const struct lu_env *env, index++; } - out_destroy_update_req(update); + out_destroy_update_req(dt_update); return 0; } int osp_unplug_async_update(const struct lu_env *env, struct osp_device *osp, - struct update_request *update) + struct dt_update_request *update) { struct osp_async_update_args *args; struct ptlrpc_request *req = NULL; int rc; rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import, - update->ur_buf, UPDATE_BUFFER_SIZE, &req); + update->dur_req, &req); if (rc != 0) { struct osp_async_update_item *oaui; struct osp_async_update_item *next; list_for_each_entry_safe(oaui, next, - &update->ur_cb_items, oaui_list) { + &update->dur_cb_items, oaui_list) { list_del_init(&oaui->oaui_list); oaui->oaui_interpterer(env, NULL, oaui->oaui_obj, oaui->oaui_data, 0, rc); @@ -150,7 +153,7 @@ int osp_unplug_async_update(const struct lu_env *env, } out_destroy_update_req(update); } else { - LASSERT(list_empty(&update->ur_list)); + LASSERT(list_empty(&update->dur_list)); args = ptlrpc_req_async_args(req); args->oaua_update = update; @@ -162,10 +165,10 @@ int osp_unplug_async_update(const struct lu_env *env, } /* with osp::opd_async_requests_mutex held */ -struct update_request * +struct dt_update_request * osp_find_or_create_async_update_request(struct osp_device *osp) { - struct update_request *update = osp->opd_async_requests; + struct dt_update_request *update = osp->opd_async_requests; if (update != NULL) return update; @@ -179,7 +182,7 @@ osp_find_or_create_async_update_request(struct osp_device *osp) /* with osp::opd_async_requests_mutex held */ int osp_insert_async_update(const struct lu_env *env, - struct update_request *update, int op, + struct dt_update_request *update, int op, struct osp_object *obj, int count, int *lens, const char **bufs, void *data, osp_async_update_interpterer_t interpterer) @@ -213,7 +216,7 @@ again: } if (rc == 0) - list_add_tail(&oaui->oaui_list, &update->ur_cb_items); + list_add_tail(&oaui->oaui_list, &update->dur_cb_items); GOTO(out, rc); @@ -265,8 +268,8 @@ out: } static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp, - struct update_request *update, struct thandle *th, - bool fc) + struct dt_update_request *dt_update, + struct thandle *th, bool fc) { struct thandle_update *tu = th->th_update; int rc = 0; @@ -279,26 +282,25 @@ static int osp_trans_trigger(const struct lu_env *env, struct osp_device *osp, struct osp_async_update_args *args; struct ptlrpc_request *req; - list_del_init(&update->ur_list); + list_del_init(&dt_update->dur_list); rc = out_prep_update_req(env, osp->opd_obd->u.cli.cl_import, - update->ur_buf, - UPDATE_BUFFER_SIZE, &req); + dt_update->dur_req, &req); if (rc == 0) { args = ptlrpc_req_async_args(req); - args->oaua_update = update; + args->oaua_update = dt_update; args->oaua_fc = !!fc; req->rq_interpret_reply = osp_async_update_interpret; ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); } else { - out_destroy_update_req(update); + out_destroy_update_req(dt_update); } } else { /* Before we support async update, the cross MDT transaction * has to been synchronized */ th->th_sync = 1; rc = out_remote_sync(env, osp->opd_obd->u.cli.cl_import, - update, NULL); + dt_update, NULL); } return rc; @@ -308,15 +310,15 @@ int osp_trans_start(const struct lu_env *env, struct dt_device *dt, struct thandle *th) { struct thandle_update *tu = th->th_update; - struct update_request *update; + struct dt_update_request *dt_update; int rc = 0; if (tu == NULL) return rc; /* Check whether there are updates related with this OSP */ - update = out_find_update(tu, dt); - if (update == NULL) + dt_update = out_find_update(tu, dt); + if (dt_update == NULL) return rc; /* Note: some updates needs to send before local transaction, @@ -333,7 +335,8 @@ int osp_trans_start(const struct lu_env *env, struct dt_device *dt, * the local transaction, i.e. delete the name entry remote * first, then destroy the local object. */ if (!is_only_remote_trans(th) && !tu->tu_sent_after_local_trans) - rc = osp_trans_trigger(env, dt2osp_dev(dt), update, th, false); + rc = osp_trans_trigger(env, dt2osp_dev(dt), dt_update, th, + false); return rc; } @@ -341,21 +344,21 @@ int osp_trans_start(const struct lu_env *env, struct dt_device *dt, int osp_trans_stop(const struct lu_env *env, struct dt_device *dt, struct thandle *th) { - struct thandle_update *tu = th->th_update; - struct update_request *update; + struct thandle_update *tu = th->th_update; + struct dt_update_request *dt_update; int rc = 0; LASSERT(tu != NULL); /* Check whether there are updates related with this OSP */ - update = out_find_update(tu, dt); - if (update == NULL) { + dt_update = out_find_update(tu, dt); + if (dt_update == NULL) { if (!is_only_remote_trans(th)) return rc; goto put; } - if (update->ur_buf->ub_count == 0) { - out_destroy_update_req(update); + if (dt_update->dur_req->ourq_count == 0) { + out_destroy_update_req(dt_update); goto put; } @@ -366,7 +369,7 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt, do { if (!osp->opd_imp_active || osp->opd_got_disconnected) { - out_destroy_update_req(update); + out_destroy_update_req(dt_update); GOTO(put, rc = -ENOTCONN); } @@ -377,19 +380,19 @@ int osp_trans_stop(const struct lu_env *env, struct dt_device *dt, } while (rc != 0); rc = osp_trans_trigger(env, dt2osp_dev(dt), - update, th, true); + dt_update, th, true); if (rc != 0) up(&osp->opd_async_fc_sem); } else { rc = th->th_result; - out_destroy_update_req(update); + out_destroy_update_req(dt_update); } } else { if (tu->tu_sent_after_local_trans) rc = osp_trans_trigger(env, dt2osp_dev(dt), - update, th, false); - rc = update->ur_rc; - out_destroy_update_req(update); + dt_update, th, false); + rc = dt_update->dur_rc; + out_destroy_update_req(dt_update); } put: diff --git a/lustre/ptlrpc/layout.c b/lustre/ptlrpc/layout.c index 13b10e7..8a861ee 100644 --- a/lustre/ptlrpc/layout.c +++ b/lustre/ptlrpc/layout.c @@ -530,12 +530,12 @@ static const struct req_msg_field *mds_setattr_server[] = { static const struct req_msg_field *mds_update_client[] = { &RMF_PTLRPC_BODY, - &RMF_UPDATE, + &RMF_OUT_UPDATE, }; static const struct req_msg_field *mds_update_server[] = { &RMF_PTLRPC_BODY, - &RMF_UPDATE_REPLY, + &RMF_OUT_UPDATE_REPLY, }; static const struct req_msg_field *llog_origin_handle_create_client[] = { @@ -753,7 +753,7 @@ static struct req_format *req_formats[] = { &RQF_MDS_HSM_ACTION, &RQF_MDS_HSM_REQUEST, &RQF_MDS_SWAP_LAYOUTS, - &RQF_UPDATE_OBJ, + &RQF_OUT_UPDATE, &RQF_QC_CALLBACK, &RQF_OST_CONNECT, &RQF_OST_DISCONNECT, @@ -1190,14 +1190,14 @@ struct req_msg_field RMF_MDS_HSM_REQUEST = lustre_swab_hsm_request, NULL); EXPORT_SYMBOL(RMF_MDS_HSM_REQUEST); -struct req_msg_field RMF_UPDATE = DEFINE_MSGF("update", 0, -1, - lustre_swab_update_buf, NULL); -EXPORT_SYMBOL(RMF_UPDATE); +struct req_msg_field RMF_OUT_UPDATE = DEFINE_MSGF("object_update", 0, -1, + lustre_swab_object_update_request, NULL); +EXPORT_SYMBOL(RMF_OUT_UPDATE); -struct req_msg_field RMF_UPDATE_REPLY = DEFINE_MSGF("update_reply", 0, -1, - lustre_swab_update_reply_buf, - NULL); -EXPORT_SYMBOL(RMF_UPDATE_REPLY); +struct req_msg_field RMF_OUT_UPDATE_REPLY = + DEFINE_MSGF("object_update_reply", 0, -1, + lustre_swab_object_update_reply, NULL); +EXPORT_SYMBOL(RMF_OUT_UPDATE_REPLY); struct req_msg_field RMF_SWAP_LAYOUTS = DEFINE_MSGF("swap_layouts", 0, sizeof(struct mdc_swap_layouts), @@ -1417,10 +1417,10 @@ struct req_format RQF_MDS_GET_INFO = mds_getinfo_server); EXPORT_SYMBOL(RQF_MDS_GET_INFO); -struct req_format RQF_UPDATE_OBJ = - DEFINE_REQ_FMT0("OBJECT_UPDATE_OBJ", mds_update_client, +struct req_format RQF_OUT_UPDATE = + DEFINE_REQ_FMT0("OUT_UPDATE_OBJ", mds_update_client, mds_update_server); -EXPORT_SYMBOL(RQF_UPDATE_OBJ); +EXPORT_SYMBOL(RQF_OUT_UPDATE); struct req_format RQF_LDLM_ENQUEUE = DEFINE_REQ_FMT0("LDLM_ENQUEUE", diff --git a/lustre/ptlrpc/lproc_ptlrpc.c b/lustre/ptlrpc/lproc_ptlrpc.c index 8e5a397..7691728 100644 --- a/lustre/ptlrpc/lproc_ptlrpc.c +++ b/lustre/ptlrpc/lproc_ptlrpc.c @@ -137,7 +137,7 @@ struct ll_rpc_opcode { { SEC_CTX_FINI, "sec_ctx_fini" }, { FLD_QUERY, "fld_query" }, { FLD_READ, "fld_read" }, - { UPDATE_OBJ, "update_obj" }, + { OUT_UPDATE, "out_update" }, { LFSCK_NOTIFY, "lfsck_notify" }, { LFSCK_QUERY, "lfsck_query" }, }; diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index 8f2b24c..dd0a253 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -54,6 +54,7 @@ #include #include #include +#include static inline int lustre_msg_hdr_size_v2(int count) { @@ -2572,23 +2573,72 @@ void lustre_swab_hsm_request(struct hsm_request *hr) } EXPORT_SYMBOL(lustre_swab_hsm_request); -void lustre_swab_update_buf(struct update_buf *ub) +void lustre_swab_object_update(struct object_update *ou) +{ + struct object_update_param *param; + int i; + + __swab16s(&ou->ou_type); + __swab16s(&ou->ou_params_count); + __swab32s(&ou->ou_master_index); + __swab32s(&ou->ou_flags); + __swab32s(&ou->ou_padding1); + __swab64s(&ou->ou_batchid); + lustre_swab_lu_fid(&ou->ou_fid); + param = &ou->ou_params[0]; + for (i = 0; i < ou->ou_params_count; i++) { + __swab16s(¶m->oup_len); + __swab16s(¶m->oup_padding); + __swab32s(¶m->oup_padding2); + param = (struct object_update_param *)((char *)param + + object_update_param_size(param)); + } +} +EXPORT_SYMBOL(lustre_swab_object_update); + +void lustre_swab_object_update_request(struct object_update_request *our) +{ + int i; + __swab32s(&our->ourq_magic); + __swab16s(&our->ourq_count); + __swab16s(&our->ourq_padding); + for (i = 0; i < our->ourq_count; i++) { + struct object_update *ou; + + ou = object_update_request_get(our, i, NULL); + if (ou == NULL) + return; + lustre_swab_object_update(ou); + } +} +EXPORT_SYMBOL(lustre_swab_object_update_request); + +void lustre_swab_object_update_result(struct object_update_result *our) { - __swab32s(&ub->ub_magic); - __swab32s(&ub->ub_count); + __swab32s(&our->our_rc); + __swab16s(&our->our_datalen); + __swab16s(&our->our_padding); } -EXPORT_SYMBOL(lustre_swab_update_buf); +EXPORT_SYMBOL(lustre_swab_object_update_result); -void lustre_swab_update_reply_buf(struct update_reply *ur) +void lustre_swab_object_update_reply(struct object_update_reply *our) { int i; - __swab32s(&ur->ur_version); - __swab32s(&ur->ur_count); - for (i = 0; i < ur->ur_count; i++) - __swab32s(&ur->ur_lens[i]); + __swab32s(&our->ourp_magic); + __swab16s(&our->ourp_count); + __swab16s(&our->ourp_padding); + for (i = 0; i < our->ourp_count; i++) { + struct object_update_result *ourp; + + __swab16s(&our->ourp_lens[i]); + ourp = object_update_result_get(our, i, NULL); + if (ourp == NULL) + return; + lustre_swab_object_update_result(ourp); + } } -EXPORT_SYMBOL(lustre_swab_update_reply_buf); +EXPORT_SYMBOL(lustre_swab_object_update_reply); void lustre_swab_swap_layouts(struct mdc_swap_layouts *msl) { diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 5e074d9..1a1b767 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -346,10 +346,10 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_MAX_TYPE == 14); CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - LASSERTF(UPDATE_OBJ == 1000, "found %lld\n", - (long long)UPDATE_OBJ); - LASSERTF(UPDATE_LAST_OPC == 1001, "found %lld\n", - (long long)UPDATE_LAST_OPC); + LASSERTF(OUT_UPDATE == 1000, "found %lld\n", + (long long)OUT_UPDATE); + LASSERTF(OUT_UPDATE_LAST_OPC == 1001, "found %lld\n", + (long long)OUT_UPDATE_LAST_OPC); CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); @@ -450,30 +450,30 @@ void lustre_assert_wire_constants(void) (unsigned)LMAC_NOT_IN_OI); LASSERTF(LMAC_FID_ON_OST == 0x00000008UL, "found 0x%.8xUL\n", (unsigned)LMAC_FID_ON_OST); - LASSERTF(OBJ_CREATE == 1, "found %lld\n", - (long long)OBJ_CREATE); - LASSERTF(OBJ_DESTROY == 2, "found %lld\n", - (long long)OBJ_DESTROY); - LASSERTF(OBJ_REF_ADD == 3, "found %lld\n", - (long long)OBJ_REF_ADD); - LASSERTF(OBJ_REF_DEL == 4, "found %lld\n", - (long long)OBJ_REF_DEL); - LASSERTF(OBJ_ATTR_SET == 5, "found %lld\n", - (long long)OBJ_ATTR_SET); - LASSERTF(OBJ_ATTR_GET == 6, "found %lld\n", - (long long)OBJ_ATTR_GET); - LASSERTF(OBJ_XATTR_SET == 7, "found %lld\n", - (long long)OBJ_XATTR_SET); - LASSERTF(OBJ_XATTR_GET == 8, "found %lld\n", - (long long)OBJ_XATTR_GET); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_INSERT == 10, "found %lld\n", - (long long)OBJ_INDEX_INSERT); - LASSERTF(OBJ_INDEX_DELETE == 11, "found %lld\n", - (long long)OBJ_INDEX_DELETE); + LASSERTF(OUT_CREATE == 1, "found %lld\n", + (long long)OUT_CREATE); + LASSERTF(OUT_DESTROY == 2, "found %lld\n", + (long long)OUT_DESTROY); + LASSERTF(OUT_REF_ADD == 3, "found %lld\n", + (long long)OUT_REF_ADD); + LASSERTF(OUT_REF_DEL == 4, "found %lld\n", + (long long)OUT_REF_DEL); + LASSERTF(OUT_ATTR_SET == 5, "found %lld\n", + (long long)OUT_ATTR_SET); + LASSERTF(OUT_ATTR_GET == 6, "found %lld\n", + (long long)OUT_ATTR_GET); + LASSERTF(OUT_XATTR_SET == 7, "found %lld\n", + (long long)OUT_XATTR_SET); + LASSERTF(OUT_XATTR_GET == 8, "found %lld\n", + (long long)OUT_XATTR_GET); + LASSERTF(OUT_INDEX_LOOKUP == 9, "found %lld\n", + (long long)OUT_INDEX_LOOKUP); + LASSERTF(OUT_INDEX_LOOKUP == 9, "found %lld\n", + (long long)OUT_INDEX_LOOKUP); + LASSERTF(OUT_INDEX_INSERT == 10, "found %lld\n", + (long long)OUT_INDEX_INSERT); + LASSERTF(OUT_INDEX_DELETE == 11, "found %lld\n", + (long long)OUT_INDEX_DELETE); /* Checks for struct som_attrs */ LASSERTF((int)sizeof(struct som_attrs) == 40, "found %lld\n", @@ -4463,61 +4463,121 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n", (long long)(int)sizeof(((struct hsm_user_import *)0)->hui_archive_id)); - /* Checks for struct update_buf */ - LASSERTF((int)sizeof(struct update_buf) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_buf)); - LASSERTF((int)offsetof(struct update_buf, ub_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_magic)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_magic)); - LASSERTF((int)offsetof(struct update_buf, ub_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_count)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_count)); - LASSERTF((int)offsetof(struct update_buf, ub_bufs) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_bufs)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_bufs)); + /* Checks for struct object_update_param */ + LASSERTF((int)sizeof(struct object_update_param) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_param)); + LASSERTF((int)offsetof(struct object_update_param, oup_len) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_len)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_len) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_len)); + LASSERTF((int)offsetof(struct object_update_param, oup_padding) == 2, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_padding)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding)); + LASSERTF((int)offsetof(struct object_update_param, oup_padding2) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_padding2)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_padding2) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding2)); + LASSERTF((int)offsetof(struct object_update_param, oup_buf) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_buf)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_buf) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_buf)); - /* Checks for struct update_reply */ - LASSERTF((int)sizeof(struct update_reply) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_reply)); - LASSERTF((int)offsetof(struct update_reply, ur_version) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_version)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_version) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_version)); - LASSERTF((int)offsetof(struct update_reply, ur_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_count)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_count)); - LASSERTF((int)offsetof(struct update_reply, ur_lens) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_lens)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_lens) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_lens)); + /* Checks for struct object_update */ + LASSERTF((int)sizeof(struct object_update) == 40, "found %lld\n", + (long long)(int)sizeof(struct object_update)); + LASSERTF((int)offsetof(struct object_update, ou_type) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_type)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_type) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_type)); + LASSERTF((int)offsetof(struct object_update, ou_params_count) == 2, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_params_count)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_params_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_params_count)); + LASSERTF((int)offsetof(struct object_update, ou_master_index) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_master_index)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_master_index) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_master_index)); + LASSERTF((int)offsetof(struct object_update, ou_flags) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_flags)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_flags) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_flags)); + LASSERTF((int)offsetof(struct object_update, ou_padding1) == 12, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_padding1)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_padding1) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_padding1)); + LASSERTF((int)offsetof(struct object_update, ou_batchid) == 16, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_batchid)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_batchid) == 8, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_batchid)); + LASSERTF((int)offsetof(struct object_update, ou_fid) == 24, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_fid)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_fid) == 16, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_fid)); + LASSERTF((int)offsetof(struct object_update, ou_params) == 40, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_params)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_params) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_params)); - /* Checks for struct update */ - LASSERTF((int)sizeof(struct update) == 56, "found %lld\n", - (long long)(int)sizeof(struct update)); - LASSERTF((int)offsetof(struct update, u_type) == 0, "found %lld\n", - (long long)(int)offsetof(struct update, u_type)); - LASSERTF((int)sizeof(((struct update *)0)->u_type) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_type)); - LASSERTF((int)offsetof(struct update, u_batchid) == 4, "found %lld\n", - (long long)(int)offsetof(struct update, u_batchid)); - LASSERTF((int)sizeof(((struct update *)0)->u_batchid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_batchid)); - LASSERTF((int)offsetof(struct update, u_fid) == 8, "found %lld\n", - (long long)(int)offsetof(struct update, u_fid)); - LASSERTF((int)sizeof(((struct update *)0)->u_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_fid)); - LASSERTF((int)offsetof(struct update, u_lens) == 24, "found %lld\n", - (long long)(int)offsetof(struct update, u_lens)); - LASSERTF((int)sizeof(((struct update *)0)->u_lens) == 32, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_lens)); - LASSERTF((int)offsetof(struct update, u_bufs) == 56, "found %lld\n", - (long long)(int)offsetof(struct update, u_bufs)); - LASSERTF((int)sizeof(((struct update *)0)->u_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_bufs)); + /* Checks for struct object_update_request */ + LASSERTF((int)sizeof(struct object_update_request) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_request)); + LASSERTF((int)offsetof(struct object_update_request, ourq_magic) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_magic)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_magic) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_magic)); + LASSERTF((int)offsetof(struct object_update_request, ourq_count) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_count)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_count)); + LASSERTF((int)offsetof(struct object_update_request, ourq_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_padding)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_padding)); + LASSERTF((int)offsetof(struct object_update_request, ourq_updates) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_updates)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_updates) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_updates)); + + /* Checks for struct object_update_result */ + LASSERTF((int)sizeof(struct object_update_result) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_result)); + LASSERTF((int)offsetof(struct object_update_result, our_rc) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_rc)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_rc) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_rc)); + LASSERTF((int)offsetof(struct object_update_result, our_datalen) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_datalen)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_datalen) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_datalen)); + LASSERTF((int)offsetof(struct object_update_result, our_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_padding)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_padding)); + LASSERTF((int)offsetof(struct object_update_result, our_data) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_data)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_data) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_data)); + + /* Checks for struct object_update_reply */ + LASSERTF((int)sizeof(struct object_update_reply) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_reply)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_magic) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_magic)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_magic) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_magic)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_count) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_count)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_count)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_padding)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_padding)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_lens) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_lens)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_lens) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_lens)); /* Checks for struct lfsck_request */ LASSERTF((int)sizeof(struct lfsck_request) == 64, "found %lld\n", @@ -4591,4 +4651,3 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct lfsck_reply *)0)->lr_padding_2) == 8, "found %lld\n", (long long)(int)sizeof(((struct lfsck_reply *)0)->lr_padding_2)); } - diff --git a/lustre/target/out_handler.c b/lustre/target/out_handler.c index 1d65bed..11be1cd 100644 --- a/lustre/target/out_handler.c +++ b/lustre/target/out_handler.c @@ -44,8 +44,9 @@ struct tx_arg *tx_add_exec(struct thandle_exec_args *ta, tx_exec_func_t func, LASSERT(ta); LASSERT(func); + LASSERTF(ta->ta_argno + 1 <= TX_MAX_OPS, + "Too many updates(%d) in one trans\n", ta->ta_argno); i = ta->ta_argno; - LASSERT(i < UPDATE_MAX_OPS); ta->ta_argno++; @@ -63,9 +64,13 @@ static int out_tx_start(const struct lu_env *env, struct dt_device *dt, memset(ta, 0, sizeof(*ta)); ta->ta_handle = dt_trans_create(env, dt); if (IS_ERR(ta->ta_handle)) { + int rc; + CERROR("%s: start handle error: rc = %ld\n", dt_obd_name(dt), PTR_ERR(ta->ta_handle)); - return PTR_ERR(ta->ta_handle); + rc = PTR_ERR(ta->ta_handle); + ta->ta_handle = NULL; + return rc; } ta->ta_dev = dt; if (exp->exp_need_sync) @@ -131,7 +136,7 @@ int out_tx_end(const struct lu_env *env, struct thandle_exec_args *ta) } /* Only fail for real update */ - tsi->tsi_reply_fail_id = OBD_FAIL_UPDATE_OBJ_NET_REP; + tsi->tsi_reply_fail_id = OBD_FAIL_OUT_UPDATE_NET_REP; stop: CDEBUG(D_INFO, "%s: executed %u/%u: rc = %d\n", dt_obd_name(ta->ta_dev), i, ta->ta_argno, rc); @@ -144,20 +149,21 @@ stop: } static void out_reconstruct(const struct lu_env *env, struct dt_device *dt, - struct dt_object *obj, struct update_reply *reply, + struct dt_object *obj, + struct object_update_reply *reply, int index) { CDEBUG(D_INFO, "%s: fork reply reply %p index %d: rc = %d\n", dt_obd_name(dt), reply, index, 0); - update_insert_reply(reply, NULL, 0, index, 0); + object_update_result_insert(reply, NULL, 0, index, 0); return; } typedef void (*out_reconstruct_t)(const struct lu_env *env, struct dt_device *dt, struct dt_object *obj, - struct update_reply *reply, + struct object_update_reply *reply, int index); static inline int out_check_resent(const struct lu_env *env, @@ -165,7 +171,7 @@ static inline int out_check_resent(const struct lu_env *env, struct dt_object *obj, struct ptlrpc_request *req, out_reconstruct_t reconstruct, - struct update_reply *reply, + struct object_update_reply *reply, int index) { if (likely(!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_RESENT))) @@ -235,7 +241,7 @@ int out_tx_create_exec(const struct lu_env *env, struct thandle *th, CDEBUG(D_INFO, "%s: insert create reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -244,7 +250,7 @@ static int __out_tx_create(const struct lu_env *env, struct dt_object *obj, struct lu_attr *attr, struct lu_fid *parent_fid, struct dt_object_format *dof, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -276,7 +282,7 @@ static int __out_tx_create(const struct lu_env *env, struct dt_object *obj, static int out_create(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; struct dt_object_format *dof = &tti->tti_u.update.tti_update_dof; struct obdo *lobdo = &tti->tti_u.update.tti_obdo; @@ -288,7 +294,7 @@ static int out_create(struct tgt_session_info *tsi) ENTRY; - wobdo = update_param_buf(update, 0, &size); + wobdo = object_update_param_get(update, 0, &size); if (wobdo == NULL || size != sizeof(*wobdo)) { CERROR("%s: obdo is NULL, invalid RPC: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); @@ -300,16 +306,17 @@ static int out_create(struct tgt_session_info *tsi) la_from_obdo(attr, lobdo, lobdo->o_valid); dof->dof_type = dt_mode_to_dft(attr->la_mode); - if (update->u_lens[1] > 0) { + if (update->ou_params_count > 1) { int size; - fid = update_param_buf(update, 1, &size); + fid = object_update_param_get(update, 1, &size); if (fid == NULL || size != sizeof(*fid)) { CERROR("%s: invalid fid: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - fid_le_to_cpu(fid, fid); + if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req)) + lustre_swab_lu_fid(fid); if (!fid_is_sane(fid)) { CERROR("%s: invalid fid "DFID": rc = %d\n", tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO); @@ -354,7 +361,7 @@ static int out_tx_attr_set_exec(const struct lu_env *env, struct thandle *th, CDEBUG(D_INFO, "%s: insert attr_set reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -363,8 +370,8 @@ static int __out_tx_attr_set(const struct lu_env *env, struct dt_object *dt_obj, const struct lu_attr *attr, struct thandle_exec_args *th, - struct update_reply *reply, int index, - char *file, int line) + struct object_update_reply *reply, + int index, char *file, int line) { struct tx_arg *arg; @@ -387,7 +394,7 @@ static int __out_tx_attr_set(const struct lu_env *env, static int out_attr_set(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct lu_attr *attr = &tti->tti_attr; struct dt_object *obj = tti->tti_u.update.tti_dt_object; struct obdo *lobdo = &tti->tti_u.update.tti_obdo; @@ -397,7 +404,7 @@ static int out_attr_set(struct tgt_session_info *tsi) ENTRY; - wobdo = update_param_buf(update, 0, &size); + wobdo = object_update_param_get(update, 0, &size); if (wobdo == NULL || size != sizeof(*wobdo)) { CERROR("%s: empty obdo in the update: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); @@ -424,6 +431,7 @@ static int out_attr_get(struct tgt_session_info *tsi) struct obdo *obdo = &tti->tti_u.update.tti_obdo; struct lu_attr *la = &tti->tti_attr; struct dt_object *obj = tti->tti_u.update.tti_dt_object; + int idx = tti->tti_u.update.tti_update_reply_index; int rc; ENTRY; @@ -484,40 +492,45 @@ out_unlock: tgt_name(tsi->tsi_tgt), tti->tti_u.update.tti_update_reply, 0, rc); - update_insert_reply(tti->tti_u.update.tti_update_reply, obdo, - sizeof(*obdo), - tti->tti_u.update.tti_update_reply_index, rc); + object_update_result_insert(tti->tti_u.update.tti_update_reply, obdo, + sizeof(*obdo), idx, rc); + RETURN(rc); } static int out_xattr_get(struct tgt_session_info *tsi) { - const struct lu_env *env = tsi->tsi_env; - struct tgt_thread_info *tti = tgt_th_info(env); - struct update *update = tti->tti_u.update.tti_update; - struct lu_buf *lbuf = &tti->tti_buf; - struct update_reply *reply = tti->tti_u.update.tti_update_reply; - struct dt_object *obj = tti->tti_u.update.tti_dt_object; - char *name; - void *ptr; - int idx = tti->tti_u.update.tti_update_reply_index; - int rc; + const struct lu_env *env = tsi->tsi_env; + struct tgt_thread_info *tti = tgt_th_info(env); + struct object_update *update = tti->tti_u.update.tti_update; + struct lu_buf *lbuf = &tti->tti_buf; + struct object_update_reply *reply = tti->tti_u.update.tti_update_reply; + struct dt_object *obj = tti->tti_u.update.tti_dt_object; + char *name; + struct object_update_result *update_result; + int idx = tti->tti_u.update.tti_update_reply_index; + int rc; ENTRY; - name = (char *)update_param_buf(update, 0, NULL); + name = object_update_param_get(update, 0, NULL); if (name == NULL) { CERROR("%s: empty name for xattr get: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - ptr = update_get_buf_internal(reply, idx, NULL); - LASSERT(ptr != NULL); + update_result = object_update_result_get(reply, 0, NULL); + if (update_result == NULL) { + CERROR("%s: empty name for xattr get: rc = %d\n", + tgt_name(tsi->tsi_tgt), -EPROTO); + RETURN(err_serious(-EPROTO)); + } - /* The first 4 bytes(int) are used to store the result */ - lbuf->lb_buf = (char *)ptr + sizeof(int); - lbuf->lb_len = UPDATE_BUFFER_SIZE - sizeof(struct update_reply); + lbuf->lb_buf = update_result->our_data; + lbuf->lb_len = OUT_UPDATE_REPLY_SIZE - + cfs_size_round((unsigned long)update_result->our_data - + (unsigned long)update_result); dt_read_lock(env, obj, MOR_TGT_CHILD); rc = dt_xattr_get(env, obj, lbuf, name, NULL); dt_read_unlock(env, obj); @@ -538,17 +551,15 @@ static int out_xattr_get(struct tgt_session_info *tsi) GOTO(out, rc); out: - *(int *)ptr = rc; - reply->ur_lens[idx] = lbuf->lb_len + sizeof(int); - - return rc; + object_update_result_insert(reply, lbuf->lb_buf, lbuf->lb_len, idx, rc); + RETURN(rc); } static int out_index_lookup(struct tgt_session_info *tsi) { const struct lu_env *env = tsi->tsi_env; struct tgt_thread_info *tti = tgt_th_info(env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; char *name; int rc; @@ -558,7 +569,7 @@ static int out_index_lookup(struct tgt_session_info *tsi) if (!lu_object_exists(&obj->do_lu)) RETURN(-ENOENT); - name = (char *)update_param_buf(update, 0, NULL); + name = object_update_param_get(update, 0, NULL); if (name == NULL) { CERROR("%s: empty name for lookup: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); @@ -581,7 +592,6 @@ static int out_index_lookup(struct tgt_session_info *tsi) CDEBUG(D_INFO, "lookup "DFID" %s get "DFID" rc %d\n", PFID(lu_object_fid(&obj->do_lu)), name, PFID(&tti->tti_fid1), rc); - fid_cpu_to_le(&tti->tti_fid1, &tti->tti_fid1); out_unlock: dt_read_unlock(env, obj); @@ -590,7 +600,7 @@ out_unlock: tgt_name(tsi->tsi_tgt), tti->tti_u.update.tti_update_reply, 0, rc); - update_insert_reply(tti->tti_u.update.tti_update_reply, + object_update_result_insert(tti->tti_u.update.tti_update_reply, &tti->tti_fid1, sizeof(tti->tti_fid1), tti->tti_u.update.tti_update_reply_index, rc); RETURN(rc); @@ -621,7 +631,7 @@ static int out_tx_xattr_set_exec(const struct lu_env *env, CDEBUG(D_INFO, "%s: insert xattr set reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -631,8 +641,8 @@ static int __out_tx_xattr_set(const struct lu_env *env, const struct lu_buf *buf, const char *name, int flags, struct thandle_exec_args *ta, - struct update_reply *reply, int index, - char *file, int line) + struct object_update_reply *reply, + int index, char *file, int line) { struct tx_arg *arg; @@ -658,7 +668,7 @@ static int __out_tx_xattr_set(const struct lu_env *env, static int out_xattr_set(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; struct lu_buf *lbuf = &tti->tti_buf; char *name; @@ -669,14 +679,14 @@ static int out_xattr_set(struct tgt_session_info *tsi) int rc; ENTRY; - name = update_param_buf(update, 0, NULL); + name = object_update_param_get(update, 0, NULL); if (name == NULL) { CERROR("%s: empty name for xattr set: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - buf = (char *)update_param_buf(update, 1, &buf_len); + buf = object_update_param_get(update, 1, &buf_len); if (buf == NULL || buf_len == 0) { CERROR("%s: empty buf for xattr set: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); @@ -686,14 +696,16 @@ static int out_xattr_set(struct tgt_session_info *tsi) lbuf->lb_buf = buf; lbuf->lb_len = buf_len; - tmp = (char *)update_param_buf(update, 2, NULL); + tmp = (char *)object_update_param_get(update, 2, NULL); if (tmp == NULL) { CERROR("%s: empty flag for xattr set: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - flag = le32_to_cpu(*(int *)tmp); + if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req)) + __swab32s((__u32 *)tmp); + flag = *(int *)tmp; rc = out_tx_xattr_set(tsi->tsi_env, obj, lbuf, name, flag, &tti->tti_tea, @@ -739,7 +751,7 @@ static int out_tx_ref_add_exec(const struct lu_env *env, struct thandle *th, CDEBUG(D_INFO, "%s: insert ref_add reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -752,7 +764,7 @@ static int out_tx_ref_add_undo(const struct lu_env *env, struct thandle *th, static int __out_tx_ref_add(const struct lu_env *env, struct dt_object *dt_obj, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -800,7 +812,7 @@ static int out_tx_ref_del_exec(const struct lu_env *env, struct thandle *th, CDEBUG(D_INFO, "%s: insert ref_del reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, 0); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -814,7 +826,7 @@ static int out_tx_ref_del_undo(const struct lu_env *env, struct thandle *th, static int __out_tx_ref_del(const struct lu_env *env, struct dt_object *dt_obj, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -906,7 +918,7 @@ static int out_tx_index_insert_exec(const struct lu_env *env, CDEBUG(D_INFO, "%s: insert idx insert reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -921,7 +933,7 @@ static int __out_tx_index_insert(const struct lu_env *env, struct dt_object *dt_obj, char *name, struct lu_fid *fid, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -959,7 +971,7 @@ static int __out_tx_index_insert(const struct lu_env *env, static int out_index_insert(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; struct lu_fid *fid; char *name; @@ -968,21 +980,23 @@ static int out_index_insert(struct tgt_session_info *tsi) ENTRY; - name = (char *)update_param_buf(update, 0, NULL); + name = object_update_param_get(update, 0, NULL); if (name == NULL) { CERROR("%s: empty name for index insert: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - fid = (struct lu_fid *)update_param_buf(update, 1, &size); + fid = object_update_param_get(update, 1, &size); if (fid == NULL || size != sizeof(*fid)) { CERROR("%s: invalid fid: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); RETURN(err_serious(-EPROTO)); } - fid_le_to_cpu(fid, fid); + if (ptlrpc_req_need_swab(tsi->tsi_pill->rc_req)) + lustre_swab_lu_fid(fid); + if (!fid_is_sane(fid)) { CERROR("%s: invalid FID "DFID": rc = %d\n", tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO); @@ -1007,7 +1021,7 @@ static int out_tx_index_delete_exec(const struct lu_env *env, CDEBUG(D_INFO, "%s: insert idx insert reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); return rc; } @@ -1024,7 +1038,7 @@ static int out_tx_index_delete_undo(const struct lu_env *env, static int __out_tx_index_delete(const struct lu_env *env, struct dt_object *dt_obj, char *name, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -1056,7 +1070,7 @@ static int __out_tx_index_delete(const struct lu_env *env, static int out_index_delete(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; char *name; int rc = 0; @@ -1064,7 +1078,7 @@ static int out_index_delete(struct tgt_session_info *tsi) if (!lu_object_exists(&obj->do_lu)) RETURN(-ENOENT); - name = (char *)update_param_buf(update, 0, NULL); + name = object_update_param_get(update, 0, NULL); if (name == NULL) { CERROR("%s: empty name for index delete: rc = %d\n", tgt_name(tsi->tsi_tgt), -EPROTO); @@ -1088,7 +1102,7 @@ static int out_tx_destroy_exec(const struct lu_env *env, struct thandle *th, CDEBUG(D_INFO, "%s: insert destroy reply %p index %d: rc = %d\n", dt_obd_name(th->th_dev), arg->reply, arg->index, rc); - update_insert_reply(arg->reply, NULL, 0, arg->index, rc); + object_update_result_insert(arg->reply, NULL, 0, arg->index, rc); RETURN(rc); } @@ -1103,7 +1117,7 @@ static int out_tx_destroy_undo(const struct lu_env *env, struct thandle *th, static int __out_tx_destroy(const struct lu_env *env, struct dt_object *dt_obj, struct thandle_exec_args *ta, - struct update_reply *reply, + struct object_update_reply *reply, int index, char *file, int line) { struct tx_arg *arg; @@ -1126,14 +1140,13 @@ static int __out_tx_destroy(const struct lu_env *env, struct dt_object *dt_obj, static int out_destroy(struct tgt_session_info *tsi) { struct tgt_thread_info *tti = tgt_th_info(tsi->tsi_env); - struct update *update = tti->tti_u.update.tti_update; + struct object_update *update = tti->tti_u.update.tti_update; struct dt_object *obj = tti->tti_u.update.tti_dt_object; struct lu_fid *fid; int rc; ENTRY; - fid = &update->u_fid; - fid_le_to_cpu(fid, fid); + fid = &update->ou_fid; if (!fid_is_sane(fid)) { CERROR("%s: invalid FID "DFID": rc = %d\n", tgt_name(tsi->tsi_tgt), PFID(fid), -EPROTO); @@ -1151,7 +1164,7 @@ static int out_destroy(struct tgt_session_info *tsi) } #define DEF_OUT_HNDL(opc, name, flags, fn) \ -[opc - OBJ_CREATE] = { \ +[opc - OUT_CREATE] = { \ .th_name = name, \ .th_fail_id = 0, \ .th_opc = opc, \ @@ -1163,27 +1176,27 @@ static int out_destroy(struct tgt_session_info *tsi) #define out_handler mdt_handler static struct tgt_handler out_update_ops[] = { - DEF_OUT_HNDL(OBJ_CREATE, "obj_create", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_CREATE, "out_create", MUTABOR | HABEO_REFERO, out_create), - DEF_OUT_HNDL(OBJ_DESTROY, "obj_create", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_DESTROY, "out_create", MUTABOR | HABEO_REFERO, out_destroy), - DEF_OUT_HNDL(OBJ_REF_ADD, "obj_ref_add", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_REF_ADD, "out_ref_add", MUTABOR | HABEO_REFERO, out_ref_add), - DEF_OUT_HNDL(OBJ_REF_DEL, "obj_ref_del", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_REF_DEL, "out_ref_del", MUTABOR | HABEO_REFERO, out_ref_del), - DEF_OUT_HNDL(OBJ_ATTR_SET, "obj_attr_set", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_ATTR_SET, "out_attr_set", MUTABOR | HABEO_REFERO, out_attr_set), - DEF_OUT_HNDL(OBJ_ATTR_GET, "obj_attr_get", HABEO_REFERO, + DEF_OUT_HNDL(OUT_ATTR_GET, "out_attr_get", HABEO_REFERO, out_attr_get), - DEF_OUT_HNDL(OBJ_XATTR_SET, "obj_xattr_set", MUTABOR | HABEO_REFERO, + DEF_OUT_HNDL(OUT_XATTR_SET, "out_xattr_set", MUTABOR | HABEO_REFERO, out_xattr_set), - DEF_OUT_HNDL(OBJ_XATTR_GET, "obj_xattr_get", HABEO_REFERO, + DEF_OUT_HNDL(OUT_XATTR_GET, "out_xattr_get", HABEO_REFERO, out_xattr_get), - DEF_OUT_HNDL(OBJ_INDEX_LOOKUP, "obj_index_lookup", HABEO_REFERO, + DEF_OUT_HNDL(OUT_INDEX_LOOKUP, "out_index_lookup", HABEO_REFERO, out_index_lookup), - DEF_OUT_HNDL(OBJ_INDEX_INSERT, "obj_index_insert", + DEF_OUT_HNDL(OUT_INDEX_INSERT, "out_index_insert", MUTABOR | HABEO_REFERO, out_index_insert), - DEF_OUT_HNDL(OBJ_INDEX_DELETE, "obj_index_delete", + DEF_OUT_HNDL(OUT_INDEX_DELETE, "out_index_delete", MUTABOR | HABEO_REFERO, out_index_delete), }; @@ -1192,8 +1205,8 @@ struct tgt_handler *out_handler_find(__u32 opc) struct tgt_handler *h; h = NULL; - if (OBJ_CREATE <= opc && opc < OBJ_LAST) { - h = &out_update_ops[opc - OBJ_CREATE]; + if (OUT_CREATE <= opc && opc < OUT_LAST) { + h = &out_update_ops[opc - OUT_CREATE]; LASSERTF(h->th_opc == opc, "opcode mismatch %d != %d\n", h->th_opc, opc); } else { @@ -1220,50 +1233,49 @@ int out_handle(struct tgt_session_info *tsi) struct thandle_exec_args *ta = &tti->tti_tea; struct req_capsule *pill = tsi->tsi_pill; struct dt_device *dt = tsi->tsi_tgt->lut_bottom; - struct update_buf *ubuf; - struct update *update; - struct update_reply *update_reply; + struct object_update_request *ureq; + struct object_update *update; + struct object_update_reply *reply; int bufsize; int count; int old_batchid = -1; - unsigned off; int i; int rc = 0; int rc1 = 0; ENTRY; - req_capsule_set(pill, &RQF_UPDATE_OBJ); - bufsize = req_capsule_get_size(pill, &RMF_UPDATE, RCL_CLIENT); - if (bufsize != UPDATE_BUFFER_SIZE) { - CERROR("%s: invalid bufsize %d: rc = %d\n", - tgt_name(tsi->tsi_tgt), bufsize, -EPROTO); + req_capsule_set(pill, &RQF_OUT_UPDATE); + ureq = req_capsule_client_get(pill, &RMF_OUT_UPDATE); + if (ureq == NULL) { + CERROR("%s: No buf!: rc = %d\n", tgt_name(tsi->tsi_tgt), + -EPROTO); RETURN(err_serious(-EPROTO)); } - ubuf = req_capsule_client_get(pill, &RMF_UPDATE); - if (ubuf == NULL) { - CERROR("%s: No buf!: rc = %d\n", tgt_name(tsi->tsi_tgt), - -EPROTO); + bufsize = req_capsule_get_size(pill, &RMF_OUT_UPDATE, RCL_CLIENT); + if (bufsize != object_update_request_size(ureq)) { + CERROR("%s: invalid bufsize %d: rc = %d\n", + tgt_name(tsi->tsi_tgt), bufsize, -EPROTO); RETURN(err_serious(-EPROTO)); } - if (ubuf->ub_magic != UPDATE_BUFFER_MAGIC) { - CERROR("%s: invalid magic %x expect %x: rc = %d\n", - tgt_name(tsi->tsi_tgt), ubuf->ub_magic, - UPDATE_BUFFER_MAGIC, -EPROTO); + if (ureq->ourq_magic != UPDATE_REQUEST_MAGIC) { + CERROR("%s: invalid update buffer magic %x expect %x: " + "rc = %d\n", tgt_name(tsi->tsi_tgt), ureq->ourq_magic, + UPDATE_REQUEST_MAGIC, -EPROTO); RETURN(err_serious(-EPROTO)); } - count = ubuf->ub_count; + count = ureq->ourq_count; if (count <= 0) { - CERROR("%s: No update!: rc = %d\n", - tgt_name(tsi->tsi_tgt), -EPROTO); + CERROR("%s: empty update: rc = %d\n", tgt_name(tsi->tsi_tgt), + -EPROTO); RETURN(err_serious(-EPROTO)); } - req_capsule_set_size(pill, &RMF_UPDATE_REPLY, RCL_SERVER, - UPDATE_BUFFER_SIZE); + req_capsule_set_size(pill, &RMF_OUT_UPDATE_REPLY, RCL_SERVER, + OUT_UPDATE_REPLY_SIZE); rc = req_capsule_server_pack(pill); if (rc != 0) { CERROR("%s: Can't pack response: rc = %d\n", @@ -1272,11 +1284,11 @@ int out_handle(struct tgt_session_info *tsi) } /* Prepare the update reply buffer */ - update_reply = req_capsule_server_get(pill, &RMF_UPDATE_REPLY); - if (update_reply == NULL) + reply = req_capsule_server_get(pill, &RMF_OUT_UPDATE_REPLY); + if (reply == NULL) RETURN(err_serious(-EPROTO)); - update_init_reply_buf(update_reply, count); - tti->tti_u.update.tti_update_reply = update_reply; + object_update_reply_init(reply, count); + tti->tti_u.update.tti_update_reply = reply; rc = out_tx_start(env, dt, ta, tsi->tsi_exp); if (rc != 0) @@ -1285,15 +1297,20 @@ int out_handle(struct tgt_session_info *tsi) tti->tti_mult_trans = !req_is_replay(tgt_ses_req(tsi)); /* Walk through updates in the request to execute them synchronously */ - off = cfs_size_round(offsetof(struct update_buf, ub_bufs[0])); for (i = 0; i < count; i++) { struct tgt_handler *h; struct dt_object *dt_obj; - update = (struct update *)((char *)ubuf + off); + update = object_update_request_get(ureq, i, NULL); + if (update == NULL) + GOTO(out, rc = -EPROTO); + + if (ptlrpc_req_need_swab(pill->rc_req)) + lustre_swab_object_update(update); + if (old_batchid == -1) { - old_batchid = update->u_batchid; - } else if (old_batchid != update->u_batchid) { + old_batchid = update->ou_batchid; + } else if (old_batchid != update->ou_batchid) { /* Stop the current update transaction, * create a new one */ rc = out_tx_end(env, ta); @@ -1303,18 +1320,17 @@ int out_handle(struct tgt_session_info *tsi) rc = out_tx_start(env, dt, ta, tsi->tsi_exp); if (rc != 0) RETURN(rc); - old_batchid = update->u_batchid; + old_batchid = update->ou_batchid; } - fid_le_to_cpu(&update->u_fid, &update->u_fid); - if (!fid_is_sane(&update->u_fid)) { + if (!fid_is_sane(&update->ou_fid)) { CERROR("%s: invalid FID "DFID": rc = %d\n", - tgt_name(tsi->tsi_tgt), PFID(&update->u_fid), + tgt_name(tsi->tsi_tgt), PFID(&update->ou_fid), -EPROTO); GOTO(out, rc = err_serious(-EPROTO)); } - dt_obj = dt_locate(env, dt, &update->u_fid); + dt_obj = dt_locate(env, dt, &update->ou_fid); if (IS_ERR(dt_obj)) GOTO(out, rc = PTR_ERR(dt_obj)); @@ -1328,7 +1344,7 @@ int out_handle(struct tgt_session_info *tsi) tti->tti_u.update.tti_update = update; tti->tti_u.update.tti_update_reply_index = i; - h = out_handler_find(update->u_type); + h = out_handler_find(update->ou_type); if (likely(h != NULL)) { /* For real modification RPC, check if the update * has been executed */ @@ -1336,15 +1352,14 @@ int out_handle(struct tgt_session_info *tsi) struct ptlrpc_request *req = tgt_ses_req(tsi); if (out_check_resent(env, dt, dt_obj, req, - out_reconstruct, - update_reply, i)) + out_reconstruct, reply, i)) GOTO(next, rc); } rc = h->th_act(tsi); } else { CERROR("%s: The unsupported opc: 0x%x\n", - tgt_name(tsi->tsi_tgt), update->u_type); + tgt_name(tsi->tsi_tgt), update->ou_type); lu_object_put(env, &dt_obj->do_lu); GOTO(out, rc = -ENOTSUPP); } @@ -1352,7 +1367,6 @@ next: lu_object_put(env, &dt_obj->do_lu); if (rc < 0) GOTO(out, rc); - off += update_size(update); } out: rc1 = out_tx_end(env, ta); @@ -1362,7 +1376,7 @@ out: } struct tgt_handler tgt_out_handlers[] = { -TGT_UPDATE_HDL(MUTABOR, UPDATE_OBJ, out_handle), +TGT_UPDATE_HDL(MUTABOR, OUT_UPDATE, out_handle), }; EXPORT_SYMBOL(tgt_out_handlers); diff --git a/lustre/target/out_lib.c b/lustre/target/out_lib.c index a335050..1b70916 100644 --- a/lustre/target/out_lib.c +++ b/lustre/target/out_lib.c @@ -35,58 +35,57 @@ #include #include -struct update_request *out_find_update(struct thandle_update *tu, - struct dt_device *dt_dev) +struct dt_update_request* +out_find_update(struct thandle_update *tu, struct dt_device *dt_dev) { - struct update_request *update; + struct dt_update_request *dt_update; - LASSERT(tu != NULL); - list_for_each_entry(update, &tu->tu_remote_update_list, ur_list) { - if (update->ur_dt == dt_dev) - return update; + list_for_each_entry(dt_update, &tu->tu_remote_update_list, + dur_list) { + if (dt_update->dur_dt == dt_dev) + return dt_update; } - return NULL; } EXPORT_SYMBOL(out_find_update); -void out_destroy_update_req(struct update_request *update) +void out_destroy_update_req(struct dt_update_request *dt_update) { - if (update == NULL) + if (dt_update == NULL) return; - LASSERT(list_empty(&update->ur_cb_items)); - - list_del(&update->ur_list); - if (update->ur_buf != NULL) - OBD_FREE_LARGE(update->ur_buf, UPDATE_BUFFER_SIZE); + cfs_list_del(&dt_update->dur_list); + if (dt_update->dur_req != NULL) + OBD_FREE_LARGE(dt_update->dur_req, dt_update->dur_req_len); - OBD_FREE_PTR(update); + OBD_FREE_PTR(dt_update); + return; } EXPORT_SYMBOL(out_destroy_update_req); -struct update_request *out_create_update_req(struct dt_device *dt) +struct dt_update_request *out_create_update_req(struct dt_device *dt) { - struct update_request *update; + struct dt_update_request *dt_update; - OBD_ALLOC_PTR(update); - if (update == NULL) + OBD_ALLOC_PTR(dt_update); + if (!dt_update) return ERR_PTR(-ENOMEM); - OBD_ALLOC_LARGE(update->ur_buf, UPDATE_BUFFER_SIZE); - if (update->ur_buf == NULL) { - OBD_FREE_PTR(update); - + OBD_ALLOC_LARGE(dt_update->dur_req, OUT_UPDATE_INIT_BUFFER_SIZE); + if (dt_update->dur_req == NULL) { + OBD_FREE_PTR(dt_update); return ERR_PTR(-ENOMEM); } - INIT_LIST_HEAD(&update->ur_list); - update->ur_dt = dt; - update->ur_buf->ub_magic = UPDATE_BUFFER_MAGIC; - update->ur_buf->ub_count = 0; - INIT_LIST_HEAD(&update->ur_cb_items); + dt_update->dur_req_len = OUT_UPDATE_INIT_BUFFER_SIZE; + INIT_LIST_HEAD(&dt_update->dur_list); + dt_update->dur_dt = dt; + dt_update->dur_batchid = 0; + dt_update->dur_req->ourq_magic = UPDATE_REQUEST_MAGIC; + dt_update->dur_req->ourq_count = 0; + INIT_LIST_HEAD(&dt_update->dur_cb_items); - return update; + return dt_update; } EXPORT_SYMBOL(out_create_update_req); @@ -95,12 +94,12 @@ EXPORT_SYMBOL(out_create_update_req); * Because only one thread can access this thandle, no need * lock now. */ -struct update_request *out_find_create_update_loc(struct thandle *th, +struct dt_update_request *out_find_create_update_loc(struct thandle *th, struct dt_object *dt) { struct dt_device *dt_dev = lu2dt_dev(dt->do_lu.lo_dev); struct thandle_update *tu = th->th_update; - struct update_request *update; + struct dt_update_request *update; ENTRY; if (tu == NULL) { @@ -121,7 +120,7 @@ struct update_request *out_find_create_update_loc(struct thandle *th, if (IS_ERR(update)) RETURN(update); - list_add_tail(&update->ur_list, &tu->tu_remote_update_list); + list_add_tail(&update->dur_list, &tu->tu_remote_update_list); if (!tu->tu_only_remote_trans) thandle_get(th); @@ -131,32 +130,35 @@ struct update_request *out_find_create_update_loc(struct thandle *th, EXPORT_SYMBOL(out_find_create_update_loc); int out_prep_update_req(const struct lu_env *env, struct obd_import *imp, - const struct update_buf *ubuf, int ubuf_len, + const struct object_update_request *ureq, struct ptlrpc_request **reqp) { - struct ptlrpc_request *req; - struct update_buf *tmp; - int rc; + struct ptlrpc_request *req; + struct object_update_request *tmp; + int ureq_len; + int rc; ENTRY; - req = ptlrpc_request_alloc(imp, &RQF_UPDATE_OBJ); + req = ptlrpc_request_alloc(imp, &RQF_OUT_UPDATE); if (req == NULL) RETURN(-ENOMEM); - req_capsule_set_size(&req->rq_pill, &RMF_UPDATE, RCL_CLIENT, - UPDATE_BUFFER_SIZE); + ureq_len = object_update_request_size(ureq); + req_capsule_set_size(&req->rq_pill, &RMF_OUT_UPDATE, RCL_CLIENT, + ureq_len); - rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, UPDATE_OBJ); + rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, OUT_UPDATE); if (rc != 0) { ptlrpc_req_finished(req); RETURN(rc); } - req_capsule_set_size(&req->rq_pill, &RMF_UPDATE_REPLY, RCL_SERVER, - UPDATE_BUFFER_SIZE); + req_capsule_set_size(&req->rq_pill, &RMF_OUT_UPDATE_REPLY, + RCL_SERVER, OUT_UPDATE_REPLY_SIZE); + + tmp = req_capsule_client_get(&req->rq_pill, &RMF_OUT_UPDATE); + memcpy(tmp, ureq, ureq_len); - tmp = req_capsule_client_get(&req->rq_pill, &RMF_UPDATE); - memcpy(tmp, ubuf, ubuf_len); ptlrpc_request_set_replen(req); req->rq_request_portal = OUT_PORTAL; req->rq_reply_portal = OSC_REPLY_PORTAL; @@ -167,15 +169,14 @@ int out_prep_update_req(const struct lu_env *env, struct obd_import *imp, EXPORT_SYMBOL(out_prep_update_req); int out_remote_sync(const struct lu_env *env, struct obd_import *imp, - struct update_request *update, + struct dt_update_request *dt_update, struct ptlrpc_request **reqp) { struct ptlrpc_request *req = NULL; - int rc; + int rc; ENTRY; - rc = out_prep_update_req(env, imp, update->ur_buf, - UPDATE_BUFFER_SIZE, &req); + rc = out_prep_update_req(env, imp, dt_update->dur_req, &req); if (rc != 0) RETURN(rc); @@ -184,65 +185,123 @@ int out_remote_sync(const struct lu_env *env, struct obd_import *imp, rc = ptlrpc_queue_wait(req); if (rc < 0) { ptlrpc_req_finished(req); - update->ur_rc = rc; + dt_update->dur_rc = rc; RETURN(rc); } if (reqp != NULL) { *reqp = req; - } else { - update->ur_rc = rc; - ptlrpc_req_finished(req); + RETURN(rc); } + dt_update->dur_rc = rc; + + ptlrpc_req_finished(req); + RETURN(rc); } EXPORT_SYMBOL(out_remote_sync); -int out_insert_update(const struct lu_env *env, struct update_request *update, - int op, const struct lu_fid *fid, int count, - int *lens, const char **bufs) +static int out_resize_update_req(struct dt_update_request *dt_update, + int new_size) { - struct update_buf *ubuf = update->ur_buf; - struct update *obj_update; - char *ptr; - int i; - int update_length; - ENTRY; + struct object_update_request *ureq; - obj_update = (struct update *)((char *)ubuf + update_buf_size(ubuf)); + LASSERT(new_size > dt_update->dur_req_len); - /* Check update size to make sure it can fit into the buffer */ - update_length = cfs_size_round(offsetof(struct update, - u_bufs[0])); - for (i = 0; i < count; i++) - update_length += cfs_size_round(lens[i]); + CDEBUG(D_INFO, "%s: resize update_size from %d to %d\n", + dt_update->dur_dt->dd_lu_dev.ld_obd->obd_name, + dt_update->dur_req_len, new_size); - if (cfs_size_round(update_buf_size(ubuf)) + update_length > - UPDATE_BUFFER_SIZE || ubuf->ub_count >= UPDATE_MAX_OPS) - RETURN(-E2BIG); + OBD_ALLOC_LARGE(ureq, new_size); + if (ureq == NULL) + return -ENOMEM; + + memcpy(ureq, dt_update->dur_req, + object_update_request_size(dt_update->dur_req)); + + OBD_FREE_LARGE(dt_update->dur_req, dt_update->dur_req_len); + + dt_update->dur_req = ureq; + dt_update->dur_req_len = new_size; - if (count > UPDATE_BUF_COUNT) + return 0; +} + +#define OUT_UPDATE_BUFFER_SIZE_ADD 4096 +#define OUT_UPDATE_BUFFER_SIZE_MAX (64 * 4096) /* 64KB update size now */ +/** + * Insert the update into the th_bufs for the device. + */ + +int out_insert_update(const struct lu_env *env, + struct dt_update_request *update, int op, + const struct lu_fid *fid, int params_count, int *lens, + const char **bufs) +{ + struct object_update_request *ureq = update->dur_req; + int ureq_len; + struct object_update *obj_update; + struct object_update_param *param; + int update_length; + int rc = 0; + char *ptr; + int i; + ENTRY; + + if (ureq->ourq_count >= OUT_UPDATE_PER_TRANS_MAX) { + CERROR("%s: too much params %d or update %d "DFID" op %d: " + "rc = %d\n", + update->dur_dt->dd_lu_dev.ld_obd->obd_name, + params_count, ureq->ourq_count, PFID(fid), op, -E2BIG); RETURN(-E2BIG); + } - /* fill the update into the update buffer */ - fid_cpu_to_le(&obj_update->u_fid, fid); - obj_update->u_type = cpu_to_le32(op); - obj_update->u_batchid = update->ur_batchid; - for (i = 0; i < count; i++) - obj_update->u_lens[i] = cpu_to_le32(lens[i]); + /* Check update size to make sure it can fit into the buffer */ + ureq_len = object_update_request_size(ureq); + update_length = offsetof(struct object_update, ou_params[0]); + for (i = 0; i < params_count; i++) + update_length += cfs_size_round(lens[i] + sizeof(*param)); + + if (unlikely(cfs_size_round(ureq_len + update_length) > + update->dur_req_len)) { + int new_size = update->dur_req_len; + + /* enlarge object update request size */ + while (new_size < + cfs_size_round(ureq_len + update_length)) + new_size += OUT_UPDATE_BUFFER_SIZE_ADD; + if (new_size >= OUT_UPDATE_BUFFER_SIZE_MAX) + RETURN(-E2BIG); + + rc = out_resize_update_req(update, new_size); + if (rc != 0) + RETURN(rc); + + ureq = update->dur_req; + } - ptr = (char *)obj_update + - cfs_size_round(offsetof(struct update, u_bufs[0])); - for (i = 0; i < count; i++) - LOGL(bufs[i], lens[i], ptr); + /* fill the update into the update buffer */ + obj_update = (struct object_update *)((char *)ureq + ureq_len); + obj_update->ou_fid = *fid; + obj_update->ou_type = op; + obj_update->ou_params_count = (__u16)params_count; + obj_update->ou_batchid = update->dur_batchid; + param = &obj_update->ou_params[0]; + for (i = 0; i < params_count; i++) { + param->oup_len = lens[i]; + ptr = ¶m->oup_buf[0]; + memcpy(¶m->oup_buf[0], bufs[i], lens[i]); + param = (struct object_update_param *)((char *)param + + object_update_param_size(param)); + } - ubuf->ub_count++; + ureq->ourq_count++; - CDEBUG(D_INFO, "%s: %p "DFID" idx %d: op %d params %d:%lu\n", - update->ur_dt->dd_lu_dev.ld_obd->obd_name, ubuf, PFID(fid), - ubuf->ub_count, op, count, update_buf_size(ubuf)); + CDEBUG(D_INFO, "%s: %p "DFID" idx %d: op %d params %d:%d\n", + update->dur_dt->dd_lu_dev.ld_obd->obd_name, ureq, PFID(fid), + ureq->ourq_count, op, params_count, ureq_len + update_length); - RETURN(0); + RETURN(rc); } EXPORT_SYMBOL(out_insert_update); diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index a69d4c5..3d3c690 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -461,7 +461,7 @@ static int tgt_filter_recovery_request(struct ptlrpc_request *req, case MDS_SYNC: /* used in unmounting */ case OBD_PING: case MDS_REINT: - case UPDATE_OBJ: + case OUT_UPDATE: case SEQ_QUERY: case FLD_QUERY: case LDLM_ENQUEUE: diff --git a/lustre/target/tgt_internal.h b/lustre/target/tgt_internal.h index 7241a3e..070ec04 100644 --- a/lustre/target/tgt_internal.h +++ b/lustre/target/tgt_internal.h @@ -56,7 +56,7 @@ struct tx_arg { tx_exec_func_t undo_fn; struct dt_object *object; char *file; - struct update_reply *reply; + struct object_update_reply *reply; int line; int index; union { @@ -129,12 +129,12 @@ struct tgt_thread_info { struct l_wait_info tti_wait_info; } rdpg; struct { - struct dt_object_format tti_update_dof; - struct update_reply *tti_update_reply; - struct update *tti_update; - int tti_update_reply_index; - struct obdo tti_obdo; - struct dt_object *tti_dt_object; + struct dt_object_format tti_update_dof; + struct object_update_reply *tti_update_reply; + struct object_update *tti_update; + int tti_update_reply_index; + struct obdo tti_obdo; + struct dt_object *tti_dt_object; } update; } tti_u; struct lfsck_request tti_lr; diff --git a/lustre/utils/req-layout.c b/lustre/utils/req-layout.c index 5c2d555..ae2202a 100644 --- a/lustre/utils/req-layout.c +++ b/lustre/utils/req-layout.c @@ -91,9 +91,11 @@ #define lustre_swab_hsm_state_set NULL #define lustre_swab_hsm_current_action NULL #define lustre_swab_hsm_request NULL -#define lustre_swab_update_buf NULL -#define lustre_swab_update_reply_buf NULL #define lustre_swab_close_data NULL +#define lustre_swab_object_update NULL +#define lustre_swab_object_update_result NULL +#define lustre_swab_object_update_reply NULL +#define lustre_swab_object_update_request NULL #define dump_rniobuf NULL #define dump_ioo NULL diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 5a999a1..c41395c 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -2000,33 +2000,58 @@ static void check_hsm_user_import(void) CHECK_MEMBER(hsm_user_import, hui_archive_id); } -static void check_update_buf(void) +static void check_object_update_param(void) { BLANK_LINE(); - CHECK_STRUCT(update_buf); - CHECK_MEMBER(update_buf, ub_magic); - CHECK_MEMBER(update_buf, ub_count); - CHECK_MEMBER(update_buf, ub_bufs); + CHECK_STRUCT(object_update_param); + CHECK_MEMBER(object_update_param, oup_len); + CHECK_MEMBER(object_update_param, oup_padding); + CHECK_MEMBER(object_update_param, oup_padding2); + CHECK_MEMBER(object_update_param, oup_buf); } -static void check_update_reply(void) +static void check_object_update(void) { BLANK_LINE(); - CHECK_STRUCT(update_reply); - CHECK_MEMBER(update_reply, ur_version); - CHECK_MEMBER(update_reply, ur_count); - CHECK_MEMBER(update_reply, ur_lens); + CHECK_STRUCT(object_update); + CHECK_MEMBER(object_update, ou_type); + CHECK_MEMBER(object_update, ou_params_count); + CHECK_MEMBER(object_update, ou_master_index); + CHECK_MEMBER(object_update, ou_flags); + CHECK_MEMBER(object_update, ou_padding1); + CHECK_MEMBER(object_update, ou_batchid); + CHECK_MEMBER(object_update, ou_fid); + CHECK_MEMBER(object_update, ou_params); } -static void check_update(void) +static void check_object_update_request(void) { BLANK_LINE(); - CHECK_STRUCT(update); - CHECK_MEMBER(update, u_type); - CHECK_MEMBER(update, u_batchid); - CHECK_MEMBER(update, u_fid); - CHECK_MEMBER(update, u_lens); - CHECK_MEMBER(update, u_bufs); + CHECK_STRUCT(object_update_request); + CHECK_MEMBER(object_update_request, ourq_magic); + CHECK_MEMBER(object_update_request, ourq_count); + CHECK_MEMBER(object_update_request, ourq_padding); + CHECK_MEMBER(object_update_request, ourq_updates); +} + +static void check_object_update_result(void) +{ + BLANK_LINE(); + CHECK_STRUCT(object_update_result); + CHECK_MEMBER(object_update_result, our_rc); + CHECK_MEMBER(object_update_result, our_datalen); + CHECK_MEMBER(object_update_result, our_padding); + CHECK_MEMBER(object_update_result, our_data); +} + +static void check_object_update_reply(void) +{ + BLANK_LINE(); + CHECK_STRUCT(object_update_reply); + CHECK_MEMBER(object_update_reply, ourp_magic); + CHECK_MEMBER(object_update_reply, ourp_count); + CHECK_MEMBER(object_update_reply, ourp_padding); + CHECK_MEMBER(object_update_reply, ourp_lens); } static void check_lfsck_request(void) @@ -2299,8 +2324,8 @@ main(int argc, char **argv) CHECK_CVALUE(LUSTRE_RES_ID_VER_OID_OFF); /* CHECK_CVALUE(LUSTRE_RES_ID_WAS_VER_OFF); packed with OID */ - CHECK_VALUE(UPDATE_OBJ); - CHECK_VALUE(UPDATE_LAST_OPC); + CHECK_VALUE(OUT_UPDATE); + CHECK_VALUE(OUT_UPDATE_LAST_OPC); CHECK_CVALUE(LUSTRE_RES_ID_QUOTA_SEQ_OFF); CHECK_CVALUE(LUSTRE_RES_ID_QUOTA_VER_OID_OFF); CHECK_CVALUE(LUSTRE_RES_ID_HSH_OFF); @@ -2340,18 +2365,18 @@ main(int argc, char **argv) check_lu_seq_range(); check_lustre_mdt_attrs(); - CHECK_VALUE(OBJ_CREATE); - CHECK_VALUE(OBJ_DESTROY); - CHECK_VALUE(OBJ_REF_ADD); - CHECK_VALUE(OBJ_REF_DEL); - CHECK_VALUE(OBJ_ATTR_SET); - CHECK_VALUE(OBJ_ATTR_GET); - CHECK_VALUE(OBJ_XATTR_SET); - CHECK_VALUE(OBJ_XATTR_GET); - CHECK_VALUE(OBJ_INDEX_LOOKUP); - CHECK_VALUE(OBJ_INDEX_LOOKUP); - CHECK_VALUE(OBJ_INDEX_INSERT); - CHECK_VALUE(OBJ_INDEX_DELETE); + CHECK_VALUE(OUT_CREATE); + CHECK_VALUE(OUT_DESTROY); + CHECK_VALUE(OUT_REF_ADD); + CHECK_VALUE(OUT_REF_DEL); + CHECK_VALUE(OUT_ATTR_SET); + CHECK_VALUE(OUT_ATTR_GET); + CHECK_VALUE(OUT_XATTR_SET); + CHECK_VALUE(OUT_XATTR_GET); + CHECK_VALUE(OUT_INDEX_LOOKUP); + CHECK_VALUE(OUT_INDEX_LOOKUP); + CHECK_VALUE(OUT_INDEX_INSERT); + CHECK_VALUE(OUT_INDEX_DELETE); check_som_attrs(); check_hsm_attrs(); @@ -2452,9 +2477,11 @@ main(int argc, char **argv) check_hsm_user_request(); check_hsm_user_import(); - check_update_buf(); - check_update_reply(); - check_update(); + check_object_update_param(); + check_object_update(); + check_object_update_request(); + check_object_update_result(); + check_object_update_reply(); check_lfsck_request(); check_lfsck_reply(); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 347e987..28a5a2e 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -355,10 +355,10 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_MAX_TYPE == 14); CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); - LASSERTF(UPDATE_OBJ == 1000, "found %lld\n", - (long long)UPDATE_OBJ); - LASSERTF(UPDATE_LAST_OPC == 1001, "found %lld\n", - (long long)UPDATE_LAST_OPC); + LASSERTF(OUT_UPDATE == 1000, "found %lld\n", + (long long)OUT_UPDATE); + LASSERTF(OUT_UPDATE_LAST_OPC == 1001, "found %lld\n", + (long long)OUT_UPDATE_LAST_OPC); CLASSERT(LUSTRE_RES_ID_QUOTA_SEQ_OFF == 2); CLASSERT(LUSTRE_RES_ID_QUOTA_VER_OID_OFF == 3); CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); @@ -459,30 +459,30 @@ void lustre_assert_wire_constants(void) (unsigned)LMAC_NOT_IN_OI); LASSERTF(LMAC_FID_ON_OST == 0x00000008UL, "found 0x%.8xUL\n", (unsigned)LMAC_FID_ON_OST); - LASSERTF(OBJ_CREATE == 1, "found %lld\n", - (long long)OBJ_CREATE); - LASSERTF(OBJ_DESTROY == 2, "found %lld\n", - (long long)OBJ_DESTROY); - LASSERTF(OBJ_REF_ADD == 3, "found %lld\n", - (long long)OBJ_REF_ADD); - LASSERTF(OBJ_REF_DEL == 4, "found %lld\n", - (long long)OBJ_REF_DEL); - LASSERTF(OBJ_ATTR_SET == 5, "found %lld\n", - (long long)OBJ_ATTR_SET); - LASSERTF(OBJ_ATTR_GET == 6, "found %lld\n", - (long long)OBJ_ATTR_GET); - LASSERTF(OBJ_XATTR_SET == 7, "found %lld\n", - (long long)OBJ_XATTR_SET); - LASSERTF(OBJ_XATTR_GET == 8, "found %lld\n", - (long long)OBJ_XATTR_GET); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_LOOKUP == 9, "found %lld\n", - (long long)OBJ_INDEX_LOOKUP); - LASSERTF(OBJ_INDEX_INSERT == 10, "found %lld\n", - (long long)OBJ_INDEX_INSERT); - LASSERTF(OBJ_INDEX_DELETE == 11, "found %lld\n", - (long long)OBJ_INDEX_DELETE); + LASSERTF(OUT_CREATE == 1, "found %lld\n", + (long long)OUT_CREATE); + LASSERTF(OUT_DESTROY == 2, "found %lld\n", + (long long)OUT_DESTROY); + LASSERTF(OUT_REF_ADD == 3, "found %lld\n", + (long long)OUT_REF_ADD); + LASSERTF(OUT_REF_DEL == 4, "found %lld\n", + (long long)OUT_REF_DEL); + LASSERTF(OUT_ATTR_SET == 5, "found %lld\n", + (long long)OUT_ATTR_SET); + LASSERTF(OUT_ATTR_GET == 6, "found %lld\n", + (long long)OUT_ATTR_GET); + LASSERTF(OUT_XATTR_SET == 7, "found %lld\n", + (long long)OUT_XATTR_SET); + LASSERTF(OUT_XATTR_GET == 8, "found %lld\n", + (long long)OUT_XATTR_GET); + LASSERTF(OUT_INDEX_LOOKUP == 9, "found %lld\n", + (long long)OUT_INDEX_LOOKUP); + LASSERTF(OUT_INDEX_LOOKUP == 9, "found %lld\n", + (long long)OUT_INDEX_LOOKUP); + LASSERTF(OUT_INDEX_INSERT == 10, "found %lld\n", + (long long)OUT_INDEX_INSERT); + LASSERTF(OUT_INDEX_DELETE == 11, "found %lld\n", + (long long)OUT_INDEX_DELETE); /* Checks for struct som_attrs */ LASSERTF((int)sizeof(struct som_attrs) == 40, "found %lld\n", @@ -4472,61 +4472,121 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n", (long long)(int)sizeof(((struct hsm_user_import *)0)->hui_archive_id)); - /* Checks for struct update_buf */ - LASSERTF((int)sizeof(struct update_buf) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_buf)); - LASSERTF((int)offsetof(struct update_buf, ub_magic) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_magic)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_magic) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_magic)); - LASSERTF((int)offsetof(struct update_buf, ub_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_count)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_count)); - LASSERTF((int)offsetof(struct update_buf, ub_bufs) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_buf, ub_bufs)); - LASSERTF((int)sizeof(((struct update_buf *)0)->ub_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_buf *)0)->ub_bufs)); + /* Checks for struct object_update_param */ + LASSERTF((int)sizeof(struct object_update_param) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_param)); + LASSERTF((int)offsetof(struct object_update_param, oup_len) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_len)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_len) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_len)); + LASSERTF((int)offsetof(struct object_update_param, oup_padding) == 2, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_padding)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding)); + LASSERTF((int)offsetof(struct object_update_param, oup_padding2) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_padding2)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_padding2) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_padding2)); + LASSERTF((int)offsetof(struct object_update_param, oup_buf) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_param, oup_buf)); + LASSERTF((int)sizeof(((struct object_update_param *)0)->oup_buf) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_param *)0)->oup_buf)); - /* Checks for struct update_reply */ - LASSERTF((int)sizeof(struct update_reply) == 8, "found %lld\n", - (long long)(int)sizeof(struct update_reply)); - LASSERTF((int)offsetof(struct update_reply, ur_version) == 0, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_version)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_version) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_version)); - LASSERTF((int)offsetof(struct update_reply, ur_count) == 4, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_count)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_count) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_count)); - LASSERTF((int)offsetof(struct update_reply, ur_lens) == 8, "found %lld\n", - (long long)(int)offsetof(struct update_reply, ur_lens)); - LASSERTF((int)sizeof(((struct update_reply *)0)->ur_lens) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update_reply *)0)->ur_lens)); + /* Checks for struct object_update */ + LASSERTF((int)sizeof(struct object_update) == 40, "found %lld\n", + (long long)(int)sizeof(struct object_update)); + LASSERTF((int)offsetof(struct object_update, ou_type) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_type)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_type) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_type)); + LASSERTF((int)offsetof(struct object_update, ou_params_count) == 2, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_params_count)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_params_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_params_count)); + LASSERTF((int)offsetof(struct object_update, ou_master_index) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_master_index)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_master_index) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_master_index)); + LASSERTF((int)offsetof(struct object_update, ou_flags) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_flags)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_flags) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_flags)); + LASSERTF((int)offsetof(struct object_update, ou_padding1) == 12, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_padding1)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_padding1) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_padding1)); + LASSERTF((int)offsetof(struct object_update, ou_batchid) == 16, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_batchid)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_batchid) == 8, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_batchid)); + LASSERTF((int)offsetof(struct object_update, ou_fid) == 24, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_fid)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_fid) == 16, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_fid)); + LASSERTF((int)offsetof(struct object_update, ou_params) == 40, "found %lld\n", + (long long)(int)offsetof(struct object_update, ou_params)); + LASSERTF((int)sizeof(((struct object_update *)0)->ou_params) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update *)0)->ou_params)); - /* Checks for struct update */ - LASSERTF((int)sizeof(struct update) == 56, "found %lld\n", - (long long)(int)sizeof(struct update)); - LASSERTF((int)offsetof(struct update, u_type) == 0, "found %lld\n", - (long long)(int)offsetof(struct update, u_type)); - LASSERTF((int)sizeof(((struct update *)0)->u_type) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_type)); - LASSERTF((int)offsetof(struct update, u_batchid) == 4, "found %lld\n", - (long long)(int)offsetof(struct update, u_batchid)); - LASSERTF((int)sizeof(((struct update *)0)->u_batchid) == 4, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_batchid)); - LASSERTF((int)offsetof(struct update, u_fid) == 8, "found %lld\n", - (long long)(int)offsetof(struct update, u_fid)); - LASSERTF((int)sizeof(((struct update *)0)->u_fid) == 16, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_fid)); - LASSERTF((int)offsetof(struct update, u_lens) == 24, "found %lld\n", - (long long)(int)offsetof(struct update, u_lens)); - LASSERTF((int)sizeof(((struct update *)0)->u_lens) == 32, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_lens)); - LASSERTF((int)offsetof(struct update, u_bufs) == 56, "found %lld\n", - (long long)(int)offsetof(struct update, u_bufs)); - LASSERTF((int)sizeof(((struct update *)0)->u_bufs) == 0, "found %lld\n", - (long long)(int)sizeof(((struct update *)0)->u_bufs)); + /* Checks for struct object_update_request */ + LASSERTF((int)sizeof(struct object_update_request) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_request)); + LASSERTF((int)offsetof(struct object_update_request, ourq_magic) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_magic)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_magic) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_magic)); + LASSERTF((int)offsetof(struct object_update_request, ourq_count) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_count)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_count)); + LASSERTF((int)offsetof(struct object_update_request, ourq_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_padding)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_padding)); + LASSERTF((int)offsetof(struct object_update_request, ourq_updates) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_request, ourq_updates)); + LASSERTF((int)sizeof(((struct object_update_request *)0)->ourq_updates) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_request *)0)->ourq_updates)); + + /* Checks for struct object_update_result */ + LASSERTF((int)sizeof(struct object_update_result) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_result)); + LASSERTF((int)offsetof(struct object_update_result, our_rc) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_rc)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_rc) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_rc)); + LASSERTF((int)offsetof(struct object_update_result, our_datalen) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_datalen)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_datalen) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_datalen)); + LASSERTF((int)offsetof(struct object_update_result, our_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_padding)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_padding)); + LASSERTF((int)offsetof(struct object_update_result, our_data) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_result, our_data)); + LASSERTF((int)sizeof(((struct object_update_result *)0)->our_data) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_result *)0)->our_data)); + + /* Checks for struct object_update_reply */ + LASSERTF((int)sizeof(struct object_update_reply) == 8, "found %lld\n", + (long long)(int)sizeof(struct object_update_reply)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_magic) == 0, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_magic)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_magic) == 4, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_magic)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_count) == 4, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_count)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_count) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_count)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_padding) == 6, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_padding)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_padding) == 2, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_padding)); + LASSERTF((int)offsetof(struct object_update_reply, ourp_lens) == 8, "found %lld\n", + (long long)(int)offsetof(struct object_update_reply, ourp_lens)); + LASSERTF((int)sizeof(((struct object_update_reply *)0)->ourp_lens) == 0, "found %lld\n", + (long long)(int)sizeof(((struct object_update_reply *)0)->ourp_lens)); /* Checks for struct lfsck_request */ LASSERTF((int)sizeof(struct lfsck_request) == 64, "found %lld\n",