From 2714d02cfd570b9fadb5b66483160f1c56e3c5fe Mon Sep 17 00:00:00 2001 From: Ben Evans Date: Fri, 22 Jul 2016 11:39:47 -0500 Subject: [PATCH] LU-6401 headers: Move functions out of lustre_idl.h Migrate functions lma_to_lustre_flags, lustre_to_lma_flags set/get_mrc_cr_flags ldlm_res_eq ldlm_extent_overlap ldlm_extent_contain ldlm_request_bufsize rec_tail agent_req_in_final_state lustre_print_user_md all PTLRPC dump_* functions lovea_slot_is_dummy Delete unused lmv_mds_md_stripe_count Signed-off-by: Ben Evans Change-Id: If65e9f63b727889f4952d5c326b18356cc4dae9d Reviewed-on: http://review.whamcloud.com/21484 Reviewed-by: Frank Zago Tested-by: Jenkins Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: John L. Hammond --- lustre/include/lustre/lustre_idl.h | 101 ------------------------------------- lustre/include/lustre_dlm.h | 13 +++++ lustre/include/lustre_lfsck.h | 10 ++++ lustre/include/lustre_swab.h | 9 ++++ lustre/include/obd_support.h | 12 +++++ lustre/ldlm/ldlm_internal.h | 6 +++ lustre/ldlm/ldlm_request.c | 27 ++++++++++ lustre/mdc/mdc_lib.c | 5 ++ lustre/mdt/mdt_internal.h | 6 +++ lustre/mdt/mdt_lib.c | 5 ++ lustre/obdclass/llog_osd.c | 6 +++ 11 files changed, 99 insertions(+), 101 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 16c0d98..505b46c 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -2152,19 +2152,6 @@ enum { LUSTRE_LMA_FL_MASKS = LUSTRE_ORPHAN_FL, }; -/* LUSTRE_LMA_FL_MASKS defines which flags will be stored in LMA */ - -static inline int lma_to_lustre_flags(__u32 lma_flags) -{ - return (lma_flags & LMAI_ORPHAN) ? LUSTRE_ORPHAN_FL : 0; -} - -static inline int lustre_to_lma_flags(__u32 la_flags) -{ - return (la_flags & LUSTRE_ORPHAN_FL) ? LMAI_ORPHAN : 0; -} - - #ifdef __KERNEL__ /* Convert wire LUSTRE_*_FL to corresponding client local VFS S_* values * for the client inode i_flags. The LUSTRE_*_FL are the Lustre wire @@ -2402,17 +2389,6 @@ struct mdt_rec_create { __u32 cr_padding_4; /* rr_padding_4 */ }; -static inline void set_mrc_cr_flags(struct mdt_rec_create *mrc, __u64 flags) -{ - mrc->cr_flags_l = (__u32)(flags & 0xFFFFFFFFUll); - mrc->cr_flags_h = (__u32)(flags >> 32); -} - -static inline __u64 get_mrc_cr_flags(struct mdt_rec_create *mrc) -{ - return ((__u64)(mrc->cr_flags_l) | ((__u64)mrc->cr_flags_h << 32)); -} - /* instance of mdt_reint_rec */ struct mdt_rec_link { __u32 lk_opcode; @@ -2681,22 +2657,6 @@ static inline int lmv_mds_md_stripe_count_get(const union lmv_mds_md *lmm) } } -static inline int lmv_mds_md_stripe_count_set(union lmv_mds_md *lmm, - unsigned int stripe_count) -{ - switch (le32_to_cpu(lmm->lmv_magic)) { - case LMV_MAGIC_V1: - lmm->lmv_md_v1.lmv_stripe_count = cpu_to_le32(stripe_count); - break; - case LMV_USER_MAGIC: - lmm->lmv_user_md.lum_stripe_count = cpu_to_le32(stripe_count); - break; - default: - return -EINVAL; - } - return 0; -} - enum fld_rpc_opc { FLD_QUERY = 900, FLD_READ = 901, @@ -2786,12 +2746,6 @@ struct ldlm_res_id { (unsigned long long)(res)->lr_name.name[2], \ (unsigned long long)(res)->lr_name.name[3] -static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, - const struct ldlm_res_id *res1) -{ - return memcmp(res0, res1, sizeof(*res0)) == 0; -} - /* lock types */ typedef enum ldlm_mode { LCK_MINMODE = 0, @@ -2824,19 +2778,6 @@ struct ldlm_extent { __u64 gid; }; -static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return ex1->start <= ex2->end && ex2->start <= ex1->end; -} - -/* check if @ex1 contains @ex2 */ -static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, - const struct ldlm_extent *ex2) -{ - return ex1->start <= ex2->start && ex1->end >= ex2->end; -} - struct ldlm_inodebits { __u64 bits; }; @@ -2910,17 +2851,6 @@ struct ldlm_request { struct lustre_handle lock_handle[LDLM_LOCKREQ_HANDLES]; }; -/* If LDLM_ENQUEUE, 1 slot is already occupied, 1 is available. - * Otherwise, 2 are available. */ -#define ldlm_request_bufsize(count,type) \ -({ \ - int _avail = LDLM_LOCKREQ_HANDLES; \ - _avail -= (type == LDLM_ENQUEUE ? LDLM_ENQUEUE_CANCEL_OFF : 0); \ - sizeof(struct ldlm_request) + \ - (count > _avail ? count - _avail : 0) * \ - sizeof(struct lustre_handle); \ -}) - struct ldlm_reply { __u32 lock_flags; __u32 lock_padding; /* also fix lustre_swab_ldlm_reply */ @@ -3130,12 +3060,6 @@ struct llog_rec_tail { (rec->lrh_len - sizeof(struct llog_rec_hdr) - \ sizeof(struct llog_rec_tail)) -static inline void *rec_tail(struct llog_rec_hdr *rec) -{ - return (void *)((char *)rec + rec->lrh_len - - sizeof(struct llog_rec_tail)); -} - struct llog_logid_rec { struct llog_rec_hdr lid_hdr; struct llog_logid lid_id; @@ -3246,12 +3170,6 @@ static inline const char *agent_req_status2name(enum agent_req_status ars) } } -static inline bool agent_req_in_final_state(enum agent_req_status ars) -{ - return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || - (ars == ARS_CANCELED)); -} - struct llog_agent_req_rec { struct llog_rec_hdr arr_hdr; /**< record header */ __u32 arr_status; /**< status of the request */ @@ -3493,15 +3411,6 @@ struct ll_fiemap_info_key { struct fiemap lfik_fiemap; }; -void lustre_print_user_md(unsigned int level, struct lov_user_md *lum, - const char *msg); - -/* Functions for dumping PTLRPC fields */ -void dump_rniobuf(struct niobuf_remote *rnb); -void dump_ioo(struct obd_ioobj *nb); -void dump_ost_body(struct ost_body *ob); -void dump_rcs(__u32 *rc); - #define IDX_INFO_MAGIC 0x3D37CC37 /* Index file transfer through the network. The server serializes the index into @@ -3641,16 +3550,6 @@ enum { #define CAPA_OPC_MDS_DEFAULT ~CAPA_OPC_OSS_ONLY #define CAPA_OPC_OSS_DEFAULT ~(CAPA_OPC_MDS_ONLY | CAPA_OPC_OSS_ONLY) -static inline bool lovea_slot_is_dummy(const struct lov_ost_data_v1 *obj) -{ - /* zero area does not care about the bytes-order. */ - if (obj->l_ost_oi.oi.oi_id == 0 && obj->l_ost_oi.oi.oi_seq == 0 && - obj->l_ost_idx == 0 && obj->l_ost_gen == 0) - return true; - - return false; -} - /* lustre_capa::lc_hmac_alg */ enum { CAPA_HMAC_ALG_SHA1 = 1, /**< sha1 algorithm */ diff --git a/lustre/include/lustre_dlm.h b/lustre/include/lustre_dlm.h index 4594387..6c6a0ec 100644 --- a/lustre/include/lustre_dlm.h +++ b/lustre/include/lustre_dlm.h @@ -1600,5 +1600,18 @@ void ldlm_pool_add(struct ldlm_pool *pl, struct ldlm_lock *lock); void ldlm_pool_del(struct ldlm_pool *pl, struct ldlm_lock *lock); /** @} */ +static inline int ldlm_extent_overlap(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->end && ex2->start <= ex1->end; +} + +/* check if @ex1 contains @ex2 */ +static inline int ldlm_extent_contain(const struct ldlm_extent *ex1, + const struct ldlm_extent *ex2) +{ + return ex1->start <= ex2->start && ex1->end >= ex2->end; +} + #endif /** @} LDLM */ diff --git a/lustre/include/lustre_lfsck.h b/lustre/include/lustre_lfsck.h index 55ec284..26d2789 100644 --- a/lustre/include/lustre_lfsck.h +++ b/lustre/include/lustre_lfsck.h @@ -94,4 +94,14 @@ static inline void lfsck_pack_rfa(struct lfsck_request *lr, lr->lr_active = com; } +static inline bool lovea_slot_is_dummy(const struct lov_ost_data_v1 *obj) +{ + /* zero area does not care about the bytes-order. */ + if (obj->l_ost_oi.oi.oi_id == 0 && obj->l_ost_oi.oi.oi_seq == 0 && + obj->l_ost_idx == 0 && obj->l_ost_gen == 0) + return true; + + return false; +} + #endif /* _LUSTRE_LFSCK_H */ diff --git a/lustre/include/lustre_swab.h b/lustre/include/lustre_swab.h index 8fb884c..a9d600c 100644 --- a/lustre/include/lustre_swab.h +++ b/lustre/include/lustre_swab.h @@ -118,4 +118,13 @@ void lustre_swab_lmv_user_md(struct lmv_user_md *lum); void lustre_swab_ladvise(struct lu_ladvise *ladvise); void lustre_swab_ladvise_hdr(struct ladvise_hdr *ladvise_hdr); +/* Functions for dumping PTLRPC fields */ +void dump_rniobuf(struct niobuf_remote *rnb); +void dump_ioo(struct obd_ioobj *nb); +void dump_ost_body(struct ost_body *ob); +void dump_rcs(__u32 *rc); + +void lustre_print_user_md(unsigned int level, struct lov_user_md *lum, + const char *msg); + #endif diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h index a60467f..db88c9f 100644 --- a/lustre/include/obd_support.h +++ b/lustre/include/obd_support.h @@ -885,4 +885,16 @@ do { \ #define KEY_IS(str) \ (keylen >= (sizeof(str)-1) && memcmp(key, str, (sizeof(str)-1)) == 0) +/* LUSTRE_LMA_FL_MASKS defines which flags will be stored in LMA */ + +static inline int lma_to_lustre_flags(__u32 lma_flags) +{ + return (lma_flags & LMAI_ORPHAN) ? LUSTRE_ORPHAN_FL : 0; +} + +static inline int lustre_to_lma_flags(__u32 la_flags) +{ + return (la_flags & LUSTRE_ORPHAN_FL) ? LMAI_ORPHAN : 0; +} + #endif diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 3107b24..ee21829 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -355,3 +355,9 @@ void ldlm_reclaim_cleanup(void); void ldlm_reclaim_add(struct ldlm_lock *lock); void ldlm_reclaim_del(struct ldlm_lock *lock); bool ldlm_reclaim_full(void); + +static inline bool ldlm_res_eq(const struct ldlm_res_id *res0, + const struct ldlm_res_id *res1) +{ + return memcmp(res0, res1, sizeof(*res0)) == 0; +} diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 6560196..279baee 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -87,6 +87,33 @@ struct ldlm_async_args { struct lustre_handle lock_handle; }; +/** + * ldlm_request_bufsize + * + * If opcode=LDLM_ENQUEUE, 1 slot is already occupied, + * LDLM_LOCKREQ_HANDLE -1 slots are available. + * Otherwise, LDLM_LOCKREQ_HANDLE slots are available. + * + * \param[in] count + * \param[in] type + * + * \retval size of the request buffer + */ + +int ldlm_request_bufsize(int count, int type) +{ + int avail = LDLM_LOCKREQ_HANDLES; + if (type == LDLM_ENQUEUE) + avail -= LDLM_ENQUEUE_CANCEL_OFF; + + if (count > avail) + avail = (count - avail) * sizeof(struct lustre_handle); + else + avail = 0; + + return sizeof(struct ldlm_request) + avail; +} + int ldlm_expired_completion_wait(void *data) { struct lock_wait_data *lwd = data; diff --git a/lustre/mdc/mdc_lib.c b/lustre/mdc/mdc_lib.c index f79c3a9..fe8fd57 100644 --- a/lustre/mdc/mdc_lib.c +++ b/lustre/mdc/mdc_lib.c @@ -46,6 +46,11 @@ #include #include "mdc_internal.h" +static void set_mrc_cr_flags(struct mdt_rec_create *mrc, __u64 flags) +{ + mrc->cr_flags_l = (__u32)(flags & 0xFFFFFFFFUll); + mrc->cr_flags_h = (__u32)(flags >> 32); +} static void __mdc_pack_body(struct mdt_body *b, __u32 suppgid) { diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 3c8ffba..91c4b19 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -760,6 +760,12 @@ static inline struct dt_object *mdt_obj2dt(struct mdt_object *mo) return lu2dt(lo); } +static inline bool agent_req_in_final_state(enum agent_req_status ars) +{ + return ((ars == ARS_SUCCEED) || (ars == ARS_FAILED) || + (ars == ARS_CANCELED)); +} + /* mdt/mdt_identity.c */ #define MDT_IDENTITY_UPCALL_PATH "/usr/sbin/l_getidentity" diff --git a/lustre/mdt/mdt_lib.c b/lustre/mdt/mdt_lib.c index de68b11..12cf245 100644 --- a/lustre/mdt/mdt_lib.c +++ b/lustre/mdt/mdt_lib.c @@ -62,6 +62,11 @@ typedef enum ucred_init_type { REC_INIT = 2 } ucred_init_type_t; +static __u64 get_mrc_cr_flags(struct mdt_rec_create *mrc) +{ + return (__u64)(mrc->cr_flags_l) | ((__u64)mrc->cr_flags_h << 32); +} + void mdt_exit_ucred(struct mdt_thread_info *info) { struct lu_ucred *uc = mdt_ucred(info); diff --git a/lustre/obdclass/llog_osd.c b/lustre/obdclass/llog_osd.c index 0523075..4fc0b4e 100644 --- a/lustre/obdclass/llog_osd.c +++ b/lustre/obdclass/llog_osd.c @@ -128,6 +128,12 @@ static int llog_osd_exist(struct llog_handle *handle) !lu_object_is_dying(handle->lgh_obj->do_lu.lo_header); } +static void *rec_tail(struct llog_rec_hdr *rec) +{ + return (void *)((char *)rec + rec->lrh_len - + sizeof(struct llog_rec_tail)); +} + /** * Write a padding record to the llog * -- 1.8.3.1