From b5624b418b645b1ac86e735413c9c7bbb93ef97c Mon Sep 17 00:00:00 2001 From: pravins <pravins> Date: Tue, 11 Nov 2008 06:51:43 +0000 Subject: [PATCH] b=16461 i=umka i=h.huang patch to add lr_padding to lu_range struct. this field will be used by compact fld work. --- lustre/fid/fid_handler.c | 2 +- lustre/fid/fid_lib.c | 28 +++++++++------- lustre/fid/fid_request.c | 4 +-- lustre/include/lustre/lustre_idl.h | 51 +++++++++++++++++++----------- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/lustre/fid/fid_handler.c b/lustre/fid/fid_handler.c index d52b77007f..774aaccfa5 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 f4720119ed..254a4e1a77 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 426635887d..c6c3881436 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 63dab1bfbe..4169b19441 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]" -- GitLab