X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Finclude%2Flustre_update.h;h=78cd3d4bfdd5190667774d291a0b3d751ebfca84;hb=HEAD;hp=f6e1d2beacc761be69d427c793698fbff65f31f6;hpb=c965fc8af8641cc810f6ff5c01cefceeaa79cb74;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_update.h b/lustre/include/lustre_update.h index f6e1d2b..da90e7a 100644 --- a/lustre/include/lustre_update.h +++ b/lustre/include/lustre_update.h @@ -20,7 +20,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2013, 2015, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. */ /* * lustre/include/lustre_update.h @@ -30,10 +30,10 @@ #ifndef _LUSTRE_UPDATE_H #define _LUSTRE_UPDATE_H -#include #include +#include +#include -#define OUT_UPDATE_INIT_BUFFER_SIZE 4096 #define OUT_UPDATE_REPLY_SIZE 4096 #define OUT_BULK_BUFFER_SIZE 4096 @@ -130,6 +130,20 @@ update_records_get_params(const struct update_records *record) update_ops_size(&record->ur_ops, record->ur_update_count)); } +static inline struct update_param * +update_param_next_param(const struct update_param *param) +{ + return (struct update_param *)((char *)param + + object_update_param_size( + (struct object_update_param *)param)); +} + +static inline size_t +__update_records_size(size_t raw_size) +{ + return round_up(offsetof(struct update_records, ur_ops) + raw_size, 8); +} + static inline size_t update_records_size(const struct update_records *record) { @@ -146,16 +160,21 @@ update_records_size(const struct update_records *record) param_size = update_params_size(params, record->ur_param_count); } - return cfs_size_round(offsetof(struct update_records, ur_ops) + - op_size + param_size); + return __update_records_size(op_size + param_size); +} + +static inline size_t +__llog_update_record_size(size_t records_size) +{ + return round_up(sizeof(struct llog_rec_hdr) + records_size + + sizeof(struct llog_rec_tail), 8); } static inline size_t llog_update_record_size(const struct llog_update_record *lur) { - return cfs_size_round(sizeof(lur->lur_hdr) + - update_records_size(&lur->lur_update_rec) + - sizeof(struct llog_rec_tail)); + return __llog_update_record_size( + update_records_size(&lur->lur_update_rec)); } static inline struct update_op * @@ -221,22 +240,20 @@ object_update_result_insert(struct object_update_reply *reply, int rc) { struct object_update_result *update_result; - char *ptr; update_result = object_update_result_get(reply, index, NULL); - LASSERT(update_result != NULL); + LASSERT(update_result); update_result->our_rc = ptlrpc_status_hton(rc); - if (data != NULL && data_len > 0) { - LASSERT(data != NULL); - ptr = (char *)update_result + - cfs_size_round(sizeof(struct object_update_reply)); + if (rc >= 0) { + if (data_len > 0 && data) + memcpy(update_result->our_data, data, data_len); update_result->our_datalen = data_len; - memcpy(ptr, data, data_len); } - reply->ourp_lens[index] = cfs_size_round(data_len + - sizeof(struct object_update_result)); + reply->ourp_lens[index] = round_up(data_len + + sizeof(struct object_update_result), + 8); } static inline int @@ -250,7 +267,7 @@ object_update_result_data_get(const struct object_update_reply *reply, 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)) || + size < round_up(sizeof(struct object_update_reply), 8) || update_result->our_datalen > size) RETURN(-EFAULT); @@ -269,11 +286,11 @@ object_update_result_data_get(const struct object_update_reply *reply, * distribution. */ struct thandle_update_records { - /* All of updates for the cross-MDT operation. */ + /* All of updates for the cross-MDT operation, vmalloc'd. */ struct llog_update_record *tur_update_records; size_t tur_update_records_buf_size; - /* All of parameters for the cross-MDT operation */ + /* All of parameters for the cross-MDT operation, vmalloc'd */ struct update_params *tur_update_params; unsigned int tur_update_param_count; size_t tur_update_params_buf_size; @@ -282,7 +299,7 @@ struct thandle_update_records { #define TOP_THANDLE_MAGIC 0x20140917 struct top_multiple_thandle { struct dt_device *tmt_master_sub_dt; - atomic_t tmt_refcount; + struct kref tmt_refcount; /* Other sub transactions will be listed here. */ struct list_head tmt_sub_thandle_list; spinlock_t tmt_sub_lock; @@ -301,7 +318,8 @@ struct top_multiple_thandle { /* {top,sub}_thandle are used to manage distributed transactions which * include updates on several nodes. A top_handle represents the - * whole operation, and sub_thandle represents updates on each node. */ + * whole operation, and sub_thandle represents updates on each node. + */ struct top_thandle { struct thandle tt_super; /* The master sub transaction. */ @@ -315,8 +333,7 @@ struct sub_thandle_cookie { struct list_head stc_list; }; -/* Sub thandle is used to track multiple sub thandles under one parent - * thandle */ +/* Sub thandle used to track multiple sub thandles under one parent thandle */ struct sub_thandle { struct thandle *st_sub_th; struct dt_device *st_dt; @@ -397,10 +414,8 @@ int out_create_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, const struct lu_attr *attr, struct dt_allocation_hint *hint, struct dt_object_format *dof); -int out_object_destroy_pack(const struct lu_env *env, - struct object_update *update, - size_t *max_update_size, - const struct lu_fid *fid); +int out_destroy_pack(const struct lu_env *env, struct object_update *update, + size_t *max_update_size, const struct lu_fid *fid); int out_index_delete_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, const struct dt_key *key); @@ -439,6 +454,9 @@ int out_xattr_get_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_size, const struct lu_fid *fid, const char *name, const int bufsize); +int out_xattr_list_pack(const struct lu_env *env, struct object_update *update, + size_t *max_update_size, const struct lu_fid *fid, + const int bufsize); int out_read_pack(const struct lu_env *env, struct object_update *update, size_t *max_update_length, const struct lu_fid *fid, size_t size, loff_t pos); @@ -463,17 +481,16 @@ int top_trans_start(const struct lu_env *env, struct dt_device *master_dev, struct thandle *th); int top_trans_stop(const struct lu_env *env, struct dt_device *master_dev, struct thandle *th); -void top_multiple_thandle_destroy(struct top_multiple_thandle *tmt); +void top_multiple_thandle_destroy(struct kref *kref); static inline void top_multiple_thandle_get(struct top_multiple_thandle *tmt) { - atomic_inc(&tmt->tmt_refcount); + kref_get(&tmt->tmt_refcount); } static inline void top_multiple_thandle_put(struct top_multiple_thandle *tmt) { - if (atomic_dec_and_test(&tmt->tmt_refcount)) - top_multiple_thandle_destroy(tmt); + kref_put(&tmt->tmt_refcount, top_multiple_thandle_destroy); } struct sub_thandle *lookup_sub_thandle(struct top_multiple_thandle *tmt, @@ -495,8 +512,8 @@ size_t update_records_ref_add_size(const struct lu_env *env, const struct lu_fid *fid); size_t update_records_ref_del_size(const struct lu_env *env, const struct lu_fid *fid); -size_t update_records_object_destroy_size(const struct lu_env *env, - const struct lu_fid *fid); +size_t update_records_destroy_size(const struct lu_env *env, + const struct lu_fid *fid); size_t update_records_index_insert_size(const struct lu_env *env, const struct lu_fid *fid, const struct dt_rec *rec, @@ -556,14 +573,13 @@ int update_records_ref_del_pack(const struct lu_env *env, unsigned int *param_count, size_t *max_param_size, const struct lu_fid *fid); -int update_records_object_destroy_pack(const struct lu_env *env, - struct update_ops *ops, - unsigned int *op_count, - size_t *max_ops_size, - struct update_params *params, - unsigned int *param_count, - size_t *max_param_size, - const struct lu_fid *fid); +int update_records_destroy_pack(const struct lu_env *env, + struct update_ops *ops, unsigned int *op_count, + size_t *max_ops_size, + struct update_params *params, + unsigned int *param_count, + size_t *max_param_size, + const struct lu_fid *fid); int update_records_index_insert_pack(const struct lu_env *env, struct update_ops *ops, unsigned int *op_count,