From 89e685e154daba096c8388e39e279c6e6b342940 Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Fri, 19 Dec 2014 16:42:51 +0300 Subject: [PATCH] LU-5478 lov: get rid of obd_* typedefs We have a bunch of typedefs for common things that made no sense and hid the actual type from plain view. Replace them with proper uXX or sXX types. Exception is in lustre_idl.h and lustre_ioctl.h where they are replaced with __uXX and __sXX to be able to be included in userspace. Replace obd_off with loff_t. patch 3 in series: modify lov/lmv Signed-off-by: Oleg Drokin Signed-off-by: Dmitry Eremin Change-Id: I9dfcc0bac691160c64ef8a120887b160c0c6986f Reviewed-on: http://review.whamcloud.com/13144 Reviewed-by: Bob Glossman Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Simmons --- lustre/include/obd.h | 10 +++---- lustre/lmv/lmv_obd.c | 14 +++++----- lustre/lov/lov_cl_internal.h | 4 +-- lustre/lov/lov_ea.c | 12 ++++----- lustre/lov/lov_internal.h | 21 +++++++-------- lustre/lov/lov_io.c | 10 +++---- lustre/lov/lov_lock.c | 14 +++++----- lustre/lov/lov_merge.c | 23 ++++++++-------- lustre/lov/lov_obd.c | 64 ++++++++++++++++++++++++++------------------ lustre/lov/lov_offset.c | 59 +++++++++++++++++++++------------------- lustre/lov/lov_page.c | 2 +- lustre/lov/lovsub_dev.c | 6 ++--- 12 files changed, 127 insertions(+), 112 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 3b660e9..3f3d2fa 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1143,10 +1143,10 @@ struct md_ops { struct lsm_operations { void (*lsm_free)(struct lov_stripe_md *); - void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, u64 *, - u64 *); - void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, u64 *, - u64 *); + void (*lsm_stripe_by_index)(struct lov_stripe_md *, int *, + loff_t *, loff_t *); + void (*lsm_stripe_by_offset)(struct lov_stripe_md *, int *, + loff_t *, loff_t *); int (*lsm_lmm_verify) (struct lov_mds_md *lmm, int lmm_bytes, __u16 *stripe_count); int (*lsm_unpackmd) (struct lov_obd *lov, struct lov_stripe_md *lsm, @@ -1155,7 +1155,7 @@ struct lsm_operations { extern const struct lsm_operations lsm_v1_ops; extern const struct lsm_operations lsm_v3_ops; -static inline const struct lsm_operations *lsm_op_find(int magic) +static inline const struct lsm_operations *lsm_op_find(u32 magic) { switch(magic) { case LOV_MAGIC_V1: diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 692aaa8..03cacfa 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -1520,9 +1520,9 @@ static int lmv_getstatus(struct obd_export *exp, } static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, obd_valid valid, const char *name, - const char *input, int input_size, int output_size, - int flags, struct ptlrpc_request **request) + struct obd_capa *oc, u64 valid, const char *name, + const char *input, int input_size, int output_size, + int flags, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -1545,10 +1545,10 @@ static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid, } static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid, - struct obd_capa *oc, obd_valid valid, const char *name, - const char *input, int input_size, int output_size, - int flags, __u32 suppgid, - struct ptlrpc_request **request) + struct obd_capa *oc, u64 valid, const char *name, + const char *input, int input_size, int output_size, + int flags, __u32 suppgid, + struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 9ef0a46..16c7708 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -443,12 +443,12 @@ struct lov_io { * starting position within a file, for the current io loop iteration * (stripe), used by ci_io_loop(). */ - obd_off lis_pos; + loff_t lis_pos; /** * end position with in a file, for the current stripe io. This is * exclusive (i.e., next offset after last byte affected by io). */ - obd_off lis_endpos; + loff_t lis_endpos; int lis_mem_frozen; int lis_stripe_count; diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 98506ef..2e2357c 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -138,18 +138,18 @@ static void lsm_unpackmd_common(struct lov_stripe_md *lsm, static void lsm_stripe_by_index_plain(struct lov_stripe_md *lsm, int *stripeno, - obd_off *lov_off, obd_off *swidth) + loff_t *lov_off, loff_t *swidth) { - if (swidth) - *swidth = (obd_off)lsm->lsm_stripe_size * lsm->lsm_stripe_count; + if (swidth != NULL) + *swidth = (loff_t)lsm->lsm_stripe_size * lsm->lsm_stripe_count; } static void lsm_stripe_by_offset_plain(struct lov_stripe_md *lsm, int *stripeno, - obd_off *lov_off, obd_off *swidth) + loff_t *lov_off, loff_t *swidth) { - if (swidth) - *swidth = (obd_off)lsm->lsm_stripe_size * lsm->lsm_stripe_count; + if (swidth != NULL) + *swidth = (loff_t)lsm->lsm_stripe_size * lsm->lsm_stripe_count; } /* Find minimum stripe maxbytes value. For inactive or diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 247f74a..2879f60 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -128,22 +128,21 @@ static inline void lov_put_reqset(struct lov_request_set *set) (char *)((lv)->lov_tgts[index]->ltd_uuid.uuid) /* lov_merge.c */ -void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_valid valid, - struct lov_stripe_md *lsm, int stripeno, int *set); +void lov_merge_attrs(struct obdo *tgt, struct obdo *src, u64 valid, + struct lov_stripe_md *lsm, int stripeno, int *set); int lov_merge_lvb_kms(struct lov_stripe_md *lsm, struct ost_lvb *lvb, __u64 *kms_place); /* lov_offset.c */ -obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, - int stripeno); -int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off, - int stripeno, obd_off *obd_off); -obd_off lov_size_to_stripe(struct lov_stripe_md *lsm, obd_off file_size, - int stripeno); +u64 lov_stripe_size(struct lov_stripe_md *lsm, u64 ost_size, int stripeno); +int lov_stripe_offset(struct lov_stripe_md *lsm, loff_t lov_off, int stripeno, + loff_t *obd_off); +loff_t lov_size_to_stripe(struct lov_stripe_md *lsm, u64 file_size, + int stripeno); int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, - obd_off start, obd_off end, - obd_off *obd_start, obd_off *obd_end); -int lov_stripe_number(struct lov_stripe_md *lsm, obd_off lov_off); + loff_t start, loff_t end, + loff_t *obd_start, loff_t *obd_end); +int lov_stripe_number(struct lov_stripe_md *lsm, loff_t lov_off); pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, int stripe); diff --git a/lustre/lov/lov_io.c b/lustre/lov/lov_io.c index 74b79ce..8448721 100644 --- a/lustre/lov/lov_io.c +++ b/lustre/lov/lov_io.c @@ -393,7 +393,7 @@ static void lov_io_fini(const struct lu_env *env, const struct cl_io_slice *ios) EXIT; } -static obd_off lov_offset_mod(obd_off val, int delta) +static loff_t lov_offset_mod(loff_t val, int delta) { if (val != OBD_OBJECT_EOF) val += delta; @@ -405,10 +405,10 @@ static int lov_io_iter_init(const struct lu_env *env, { struct lov_io *lio = cl2lov_io(env, ios); struct lov_stripe_md *lsm = lio->lis_object->lo_lsm; - struct lov_io_sub *sub; - obd_off endpos; - obd_off start; - obd_off end; + struct lov_io_sub *sub; + loff_t endpos; + loff_t start; + loff_t end; int stripe; int rc = 0; diff --git a/lustre/lov/lov_lock.c b/lustre/lov/lov_lock.c index 178357f..abc0216 100644 --- a/lustre/lov/lov_lock.c +++ b/lustre/lov/lov_lock.c @@ -127,13 +127,13 @@ static struct lov_lock *lov_lock_sub_init(const struct lu_env *env, const struct cl_object *obj, struct cl_lock *lock) { - int result = 0; - int i; - int nr; - obd_off start; - obd_off end; - obd_off file_start; - obd_off file_end; + int result = 0; + int i; + int nr; + loff_t start; + loff_t end; + loff_t file_start; + loff_t file_end; struct lov_object *loo = cl2lov(obj); struct lov_layout_raid0 *r0 = lov_r0(loo); diff --git a/lustre/lov/lov_merge.c b/lustre/lov/lov_merge.c index 5f6f98c..7b1601c 100644 --- a/lustre/lov/lov_merge.c +++ b/lustre/lov/lov_merge.c @@ -49,12 +49,12 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, struct ost_lvb *lvb, __u64 *kms_place) { - __u64 size = 0; - __u64 kms = 0; - __u64 blocks = 0; - obd_time current_mtime = lvb->lvb_mtime; - obd_time current_atime = lvb->lvb_atime; - obd_time current_ctime = lvb->lvb_ctime; + u64 size = 0; + u64 kms = 0; + u64 blocks = 0; + s64 current_mtime = lvb->lvb_mtime; + s64 current_atime = lvb->lvb_atime; + s64 current_ctime = lvb->lvb_ctime; int i; int rc = 0; @@ -66,8 +66,9 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime, lvb->lvb_ctime, lvb->lvb_blocks); for (i = 0; i < lsm->lsm_stripe_count; i++) { - struct lov_oinfo *loi = lsm->lsm_oinfo[i]; - obd_size lov_size, tmpsize; + struct lov_oinfo *loi = lsm->lsm_oinfo[i]; + u64 lov_size; + u64 tmpsize; if (OST_LVB_IS_ERR(loi->loi_lvb.lvb_blocks)) { rc = OST_LVB_GET_ERR(loi->loi_lvb.lvb_blocks); @@ -110,8 +111,8 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, RETURN(rc); } -void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_valid valid, - struct lov_stripe_md *lsm, int stripeno, int *set) +void lov_merge_attrs(struct obdo *tgt, struct obdo *src, u64 valid, + struct lov_stripe_md *lsm, int stripeno, int *set) { valid &= src->o_valid; @@ -119,7 +120,7 @@ void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_valid valid, tgt->o_valid &= valid; if (valid & OBD_MD_FLSIZE) { /* this handles sparse files properly */ - obd_size lov_size; + u64 lov_size; lov_size = lov_stripe_size(lsm, src->o_size, stripeno); if (lov_size > tgt->o_size) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 3f8bbb6..ea39c92 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1466,15 +1466,17 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, * \param fm_end logical end of mapping * \param start_stripe starting stripe will be returned in this */ -static obd_size fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, - struct lov_stripe_md *lsm, - obd_size fm_start, - obd_size fm_end, int *start_stripe) +static loff_t fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, + struct lov_stripe_md *lsm, + loff_t fm_start, + loff_t fm_end, int *start_stripe) { - obd_size local_end = fiemap->fm_extents[0].fe_logical; - obd_off lun_start, lun_end; - obd_size fm_end_offset; - int stripe_no = -1, i; + loff_t local_end = fiemap->fm_extents[0].fe_logical; + loff_t lun_start; + loff_t lun_end; + loff_t fm_end_offset; + int stripe_no = -1; + int i; if (fiemap->fm_extent_count == 0 || fiemap->fm_extents[0].fe_logical == 0) @@ -1529,12 +1531,13 @@ static obd_size fiemap_calc_fm_end_offset(struct ll_user_fiemap *fiemap, * * \retval last_stripe return the last stripe of the mapping */ -static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, obd_size fm_start, - obd_size fm_end, int start_stripe, - int *stripe_count) +static int fiemap_calc_last_stripe(struct lov_stripe_md *lsm, + loff_t fm_start, loff_t fm_end, + int start_stripe, int *stripe_count) { - int last_stripe; - obd_off obd_start, obd_end; + int last_stripe; + loff_t obd_start; + loff_t obd_end; int i, j; if (fm_end - fm_start > lsm->lsm_stripe_size * lsm->lsm_stripe_count) { @@ -1598,8 +1601,11 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, int count_local; unsigned int get_num_extents = 0; int ost_index = 0, actual_start_stripe, start_stripe; - obd_size fm_start, fm_end, fm_length, fm_end_offset; - obd_size curr_loc; + loff_t fm_start; + loff_t fm_end; + loff_t fm_length; + loff_t fm_end_offset; + u64 curr_loc; int current_extent = 0, rc = 0, i; /* Whether have we collected enough extents */ bool enough = false; @@ -1671,9 +1677,11 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, /* Check each stripe */ for (cur_stripe = start_stripe, i = 0; i < stripe_count; i++, cur_stripe = (cur_stripe + 1) % lsm->lsm_stripe_count) { - obd_size req_fm_len; /* Stores length of required mapping */ - obd_size len_mapped_single_call; - obd_off lun_start, lun_end, obd_object_end; + loff_t req_fm_len; /* Stores length of required mapping */ + loff_t len_mapped_single_call; + loff_t lun_start; + loff_t lun_end; + loff_t obd_object_end; unsigned int ext_count; cur_stripe_wrap = cur_stripe; @@ -1845,7 +1853,8 @@ out: } static int lov_get_info(const struct lu_env *env, struct obd_export *exp, - __u32 keylen, void *key, __u32 *vallen, void *val, + __u32 keylen, void *key, + __u32 *vallen, void *val, struct lov_stripe_md *lsm) { struct obd_device *obddev = class_exp2obd(exp); @@ -1879,16 +1888,19 @@ out: } static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, - obd_count keylen, void *key, obd_count vallen, - void *val, struct ptlrpc_request_set *set) + __u32 keylen, void *key, + __u32 vallen, void *val, + struct ptlrpc_request_set *set) { - struct obd_device *obddev = class_exp2obd(exp); - struct lov_obd *lov = &obddev->u.lov; - obd_count count; - int i, rc = 0, err; - struct lov_tgt_desc *tgt; + struct obd_device *obddev = class_exp2obd(exp); + struct lov_obd *lov = &obddev->u.lov; + struct lov_tgt_desc *tgt; int do_inactive = 0; int no_set = 0; + u32 count; + u32 i; + int rc = 0; + int err; ENTRY; if (set == NULL) { diff --git a/lustre/lov/lov_offset.c b/lustre/lov/lov_offset.c index 18ee178..d325e1c 100644 --- a/lustre/lov/lov_offset.c +++ b/lustre/lov/lov_offset.c @@ -43,14 +43,13 @@ #include "lov_internal.h" /* compute object size given "stripeno" and the ost size */ -obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, - int stripeno) +u64 lov_stripe_size(struct lov_stripe_md *lsm, u64 ost_size, int stripeno) { - unsigned long ssize = lsm->lsm_stripe_size; - unsigned long stripe_size; - obd_off swidth; - obd_size lov_size; - int magic = lsm->lsm_magic; + unsigned long ssize = lsm->lsm_stripe_size; + unsigned long stripe_size; + loff_t swidth; + loff_t lov_size; + u32 magic = lsm->lsm_magic; ENTRY; if (ost_size == 0) @@ -75,7 +74,7 @@ obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size, pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, int stripe) { - obd_off offset; + loff_t offset; offset = lov_stripe_size(lsm, stripe_index << PAGE_CACHE_SHIFT, stripe); @@ -130,12 +129,14 @@ pgoff_t lov_stripe_pgoff(struct lov_stripe_md *lsm, pgoff_t stripe_index, * was moved forward to the start of the stripe in question; 0 when it * falls in the stripe and no shifting was done; > 0 when the offset * was outside the stripe and was pulled back to its final byte. */ -int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off, - int stripeno, obd_off *obdoff) +int lov_stripe_offset(struct lov_stripe_md *lsm, loff_t lov_off, int stripeno, + loff_t *obdoff) { - unsigned long ssize = lsm->lsm_stripe_size; - obd_off stripe_off, this_stripe, swidth; - int magic = lsm->lsm_magic; + unsigned long ssize = lsm->lsm_stripe_size; + loff_t stripe_off; + loff_t this_stripe; + loff_t swidth; + u32 magic = lsm->lsm_magic; int ret = 0; if (lov_off == OBD_OBJECT_EOF) { @@ -144,14 +145,13 @@ int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off, } LASSERT(lsm_op_find(magic) != NULL); - lsm_op_find(magic)->lsm_stripe_by_index(lsm, &stripeno, &lov_off, &swidth); /* lov_do_div64(a, b) returns a % b, and a = a / b */ stripe_off = lov_do_div64(lov_off, swidth); - this_stripe = (obd_off)stripeno * ssize; + this_stripe = (loff_t)stripeno * ssize; if (stripe_off < this_stripe) { stripe_off = 0; ret = -1; @@ -187,12 +187,14 @@ int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off, * | 0 | 1 | 2 | 0 | 1 | 2 | * --------------------------------------------------------------------- */ -obd_off lov_size_to_stripe(struct lov_stripe_md *lsm, obd_off file_size, - int stripeno) +loff_t lov_size_to_stripe(struct lov_stripe_md *lsm, u64 file_size, + int stripeno) { - unsigned long ssize = lsm->lsm_stripe_size; - obd_off stripe_off, this_stripe, swidth; - int magic = lsm->lsm_magic; + unsigned long ssize = lsm->lsm_stripe_size; + loff_t stripe_off; + loff_t this_stripe; + loff_t swidth; + u32 magic = lsm->lsm_magic; if (file_size == OBD_OBJECT_EOF) return OBD_OBJECT_EOF; @@ -204,7 +206,7 @@ obd_off lov_size_to_stripe(struct lov_stripe_md *lsm, obd_off file_size, /* lov_do_div64(a, b) returns a % b, and a = a / b */ stripe_off = lov_do_div64(file_size, swidth); - this_stripe = (obd_off)stripeno * ssize; + this_stripe = (loff_t)stripeno * ssize; if (stripe_off < this_stripe) { /* Move to end of previous stripe, or zero */ if (file_size > 0) { @@ -229,16 +231,16 @@ obd_off lov_size_to_stripe(struct lov_stripe_md *lsm, obd_off file_size, * that is contained within the lov extent. this returns true if the given * stripe does intersect with the lov extent. */ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, - obd_off start, obd_off end, - obd_off *obd_start, obd_off *obd_end) + loff_t start, loff_t end, + loff_t *obd_start, loff_t *obd_end) { int start_side, end_side; start_side = lov_stripe_offset(lsm, start, stripeno, obd_start); end_side = lov_stripe_offset(lsm, end, stripeno, obd_end); - CDEBUG(D_INODE, "["LPU64"->"LPU64"] -> [(%d) "LPU64"->"LPU64" (%d)]\n", - start, end, start_side, *obd_start, *obd_end, end_side); + CDEBUG(D_INODE, "["LPD64"->"LPD64"] -> [(%d) "LPD64"->"LPD64" (%d)]\n", + start, end, start_side, *obd_start, *obd_end, end_side); /* this stripe doesn't intersect the file extent when neither * start or the end intersected the stripe and obd_start and @@ -261,11 +263,12 @@ int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno, } /* compute which stripe number "lov_off" will be written into */ -int lov_stripe_number(struct lov_stripe_md *lsm, obd_off lov_off) +int lov_stripe_number(struct lov_stripe_md *lsm, loff_t lov_off) { unsigned long ssize = lsm->lsm_stripe_size; - obd_off stripe_off, swidth; - int magic = lsm->lsm_magic; + loff_t stripe_off; + loff_t swidth; + u32 magic = lsm->lsm_magic; LASSERT(lsm_op_find(magic) != NULL); lsm_op_find(magic)->lsm_stripe_by_offset(lsm, NULL, &lov_off, &swidth); diff --git a/lustre/lov/lov_page.c b/lustre/lov/lov_page.c index 35e1d1a..121ad67 100644 --- a/lustre/lov/lov_page.c +++ b/lustre/lov/lov_page.c @@ -125,7 +125,7 @@ int lov_page_init_raid0(const struct lu_env *env, struct cl_object *obj, struct lov_io_sub *sub; struct lov_page *lpg = cl_object_page_slice(obj, page); loff_t offset; - obd_off suboff; + loff_t suboff; int stripe; int rc; ENTRY; diff --git a/lustre/lov/lovsub_dev.c b/lustre/lov/lovsub_dev.c index 2feecf9..1a42ca9 100644 --- a/lustre/lov/lovsub_dev.c +++ b/lustre/lov/lovsub_dev.c @@ -69,9 +69,9 @@ static void lovsub_req_completion(const struct lu_env *env, * field, which is filled there. */ static void lovsub_req_attr_set(const struct lu_env *env, - const struct cl_req_slice *slice, - const struct cl_object *obj, - struct cl_req_attr *attr, obd_valid flags) + const struct cl_req_slice *slice, + const struct cl_object *obj, + struct cl_req_attr *attr, u64 flags) { struct lovsub_object *subobj; -- 1.8.3.1