diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index d52b77007f95007d36defaa8c6d5e66d1bbeea4e..774aaccfa581db02a942c6e8550693e7cfd278ea 100644 --- a/lustre/fid/fid_handler.c +++ b/lustre/fid/fid_handler.c @@ -485,7 +485,7 @@ int seq_server_init(struct lu_server_seq *seq, seq->lss_cli = NULL; seq->lss_type = type; - range_zero(&seq->lss_space); + range_init(&seq->lss_space); sema_init(&seq->lss_sem, 1); seq->lss_width = is_srv ? diff --git a/lustre/fid/fid_lib.c b/lustre/fid/fid_lib.c index f4720119ed4763b4efe9dcce4c38200d8d67ffa8..254a4e1a77eed4c4506c76750dc9d7a40fee2fe0 100644 --- a/lustre/fid/fid_lib.c +++ b/lustre/fid/fid_lib.c @@ -92,9 +92,10 @@ EXPORT_SYMBOL(LUSTRE_BFL_FID); void range_cpu_to_le(struct lu_range *dst, const struct lu_range *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof src->lr_start + - sizeof src->lr_end); + CLASSERT(sizeof(*src) == + sizeof(src->lr_start) + + sizeof(src->lr_end) + + sizeof(src->lr_padding)); dst->lr_start = cpu_to_le64(src->lr_start); dst->lr_end = cpu_to_le64(src->lr_end); } @@ -103,9 +104,10 @@ EXPORT_SYMBOL(range_cpu_to_le); void range_le_to_cpu(struct lu_range *dst, const struct lu_range *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof src->lr_start + - sizeof src->lr_end); + CLASSERT(sizeof(*src) == + sizeof(src->lr_start) + + sizeof(src->lr_end) + + sizeof(src->lr_padding)); dst->lr_start = le64_to_cpu(src->lr_start); dst->lr_end = le64_to_cpu(src->lr_end); } @@ -115,9 +117,10 @@ EXPORT_SYMBOL(range_le_to_cpu); void range_cpu_to_be(struct lu_range *dst, const struct lu_range *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof src->lr_start + - sizeof src->lr_end); + CLASSERT(sizeof(*src) == + sizeof(src->lr_start) + + sizeof(src->lr_end) + + sizeof(src->lr_padding)); dst->lr_start = cpu_to_be64(src->lr_start); dst->lr_end = cpu_to_be64(src->lr_end); } @@ -126,9 +129,10 @@ EXPORT_SYMBOL(range_cpu_to_be); void range_be_to_cpu(struct lu_range *dst, const struct lu_range *src) { /* check that all fields are converted */ - CLASSERT(sizeof *src == - sizeof src->lr_start + - sizeof src->lr_end); + CLASSERT(sizeof(*src) == + sizeof(src->lr_start) + + sizeof(src->lr_end) + + sizeof(src->lr_padding)); dst->lr_start = be64_to_cpu(src->lr_start); dst->lr_end = be64_to_cpu(src->lr_end); } diff --git a/lustre/fid/fid_request.c b/lustre/fid/fid_request.c index 426635887d254789949ed83b0e8999d156dbe7dd..c6c3881436ead78126dfacf9f1055b09079ecc70 100644 --- a/lustre/fid/fid_request.c +++ b/lustre/fid/fid_request.c @@ -88,7 +88,7 @@ static int seq_client_rpc(struct lu_client_seq *seq, struct lu_range *input, if (input != NULL) *in = *input; else - range_zero(in); + range_init(in); ptlrpc_request_set_replen(req); @@ -280,7 +280,7 @@ void seq_client_flush(struct lu_client_seq *seq) LASSERT(seq != NULL); down(&seq->lcs_sem); fid_zero(&seq->lcs_fid); - range_zero(&seq->lcs_space); + range_init(&seq->lcs_space); up(&seq->lcs_sem); } EXPORT_SYMBOL(seq_client_flush); diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index 63dab1bfbe93e772450acc1c1706910977a53f86..4169b19441fe76d87576735c10e1a5b66c5dd711 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -174,46 +174,61 @@ typedef __u64 seqno_t; struct lu_range { __u64 lr_start; __u64 lr_end; + /** stub for compact fld work. */ + __u64 lr_padding; }; -static inline __u64 range_space(struct lu_range *r) +/** + * returns width of given range \a r + */ + +static inline __u64 range_space(const struct lu_range *range) { - return r->lr_end - r->lr_start; + return range->lr_end - range->lr_start; } -static inline void range_zero(struct lu_range *r) +/** + * initialize range to zero + */ +static inline void range_init(struct lu_range *range) { - r->lr_start = r->lr_end = 0; + range->lr_start = range->lr_end = 0; } -static inline int range_within(struct lu_range *r, +/** + * check if given seq id \a s is within given range \a r + */ +static inline int range_within(struct lu_range *range, __u64 s) { - return s >= r->lr_start && s < r->lr_end; + return s >= range->lr_start && s < range->lr_end; } -static inline void range_alloc(struct lu_range *r, - struct lu_range *s, - __u64 w) +/** + * allocate \a w units of sequence from range \a from. + */ +static inline void range_alloc(struct lu_range *to, + struct lu_range *from, + __u64 width) { - r->lr_start = s->lr_start; - r->lr_end = s->lr_start + w; - s->lr_start += w; + to->lr_start = from->lr_start; + to->lr_end = from->lr_start + width; + from->lr_start += width; } -static inline int range_is_sane(struct lu_range *r) +static inline int range_is_sane(const struct lu_range *range) { - return (r->lr_end >= r->lr_start); + return (range->lr_end >= range->lr_start); } -static inline int range_is_zero(struct lu_range *r) +static inline int range_is_zero(const struct lu_range *range) { - return (r->lr_start == 0 && r->lr_end == 0); + return (range->lr_start == 0 && range->lr_end == 0); } -static inline int range_is_exhausted(struct lu_range *r) +static inline int range_is_exhausted(const struct lu_range *range) { - return range_space(r) == 0; + return range_space(range) == 0; } #define DRANGE "[%#16.16"LPF64"x-%#16.16"LPF64"x]"