From 81e27655e4c9a04b04b2c704bf57754566feaa49 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Fri, 7 Feb 2014 14:08:12 +0000 Subject: [PATCH] Revert "LU-1778 libcfs: add a service that prints a nidlist" Whoops, this patch broke build: http://build.whamcloud.com/job/lustre-master/arch=x86_64,build_type=client,distro=ubuntu1004,ib_stack=inkernel/1879/changes So I am reverting it. This reverts commit 874f67c06da8304a194df5fc0dd5a2c61937076c. Change-Id: Ieb36ba5c909bc3731dc4a925d89773be89ab64ec Reviewed-on: http://review.whamcloud.com/9178 Reviewed-by: Oleg Drokin Tested-by: Oleg Drokin --- libcfs/include/libcfs/libcfs_private.h | 2 - libcfs/include/libcfs/libcfs_string.h | 3 +- libcfs/libcfs/libcfs_string.c | 83 ++++----------------- libcfs/libcfs/nidstrings.c | 132 +-------------------------------- 4 files changed, 19 insertions(+), 201 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 7557c62..a906d9c 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -549,8 +549,6 @@ int libcfs_str2anynid(lnet_nid_t *nid, const char *str); char *libcfs_id2str(lnet_process_id_t id); void cfs_free_nidlist(struct list_head *list); int cfs_parse_nidlist(char *str, int len, struct list_head *list); -int cfs_print_nidlist(char *buffer, int count, - struct list_head *list); int cfs_match_nid(lnet_nid_t nid, struct list_head *list); /** \addtogroup lnet_addr diff --git a/libcfs/include/libcfs/libcfs_string.h b/libcfs/include/libcfs/libcfs_string.h index 5afaec7..82c5c27 100644 --- a/libcfs/include/libcfs/libcfs_string.h +++ b/libcfs/include/libcfs/libcfs_string.h @@ -113,8 +113,6 @@ int cfs_str2num_check(char *str, int nob, unsigned *num, int cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max, int single_tok, struct cfs_range_expr **expr); int cfs_expr_list_match(__u32 value, struct cfs_expr_list *expr_list); -int cfs_expr_list_print(char *buffer, int count, - struct cfs_expr_list *expr_list); int cfs_expr_list_values(struct cfs_expr_list *expr_list, int max, __u32 **values); static inline void @@ -127,6 +125,7 @@ cfs_expr_list_values_free(__u32 *values, int num) } void cfs_expr_list_free(struct cfs_expr_list *expr_list); +void cfs_expr_list_print(struct cfs_expr_list *expr_list); int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, struct cfs_expr_list **elpp); void cfs_expr_list_free_list(struct list_head *list); diff --git a/libcfs/libcfs/libcfs_string.c b/libcfs/libcfs/libcfs_string.c index ae6a9e3..1d7a941 100644 --- a/libcfs/libcfs/libcfs_string.c +++ b/libcfs/libcfs/libcfs_string.c @@ -419,73 +419,6 @@ cfs_range_expr_parse(struct cfs_lstr *src, unsigned min, unsigned max, EXPORT_SYMBOL(cfs_range_expr_parse); /** - * Print the range expression \a re into specified \a buffer. - * If \a bracketed is true, expression does not need additional - * brackets. - * - * \retval number of characters written - */ -static int -cfs_range_expr_print(char *buffer, int count, struct cfs_range_expr *expr, - bool bracketed) -{ - int i; - char s[] = "["; - char e[] = "]"; - - if (bracketed) - s[0] = e[0] = '\0'; - - if (expr->re_lo == expr->re_hi) - i = cfs_snprintf(buffer, count, "%u", expr->re_lo); - else if (expr->re_stride == 1) - i = cfs_snprintf(buffer, count, "%s%u-%u%s", - s, expr->re_lo, expr->re_hi, e); - else - i = cfs_snprintf(buffer, count, "%s%u-%u/%u%s", - s, expr->re_lo, expr->re_hi, - expr->re_stride, e); - return i; -} - -/** - * Print a list of range expressions (\a expr_list) into specified \a buffer. - * If the list contains several expressions, separate them with comma - * and surround the list with brackets. - * - * \retval number of characters written - */ -int -cfs_expr_list_print(char *buffer, int count, struct cfs_expr_list *expr_list) -{ - struct cfs_range_expr *expr; - int i = 0, j = 0; - int numexprs = 0; - - if (count <= 0) - return 0; - - list_for_each_entry(expr, &expr_list->el_exprs, re_link) - numexprs++; - - if (numexprs > 1) - i += cfs_snprintf(buffer + i, count - i, "["); - - list_for_each_entry(expr, &expr_list->el_exprs, re_link) { - if (j++ != 0) - i += cfs_snprintf(buffer + i, count - i, ","); - i += cfs_range_expr_print(buffer + i, count - i, expr, - numexprs > 1); - } - - if (numexprs > 1) - i += cfs_snprintf(buffer + i, count - i, "]"); - - return i; -} -EXPORT_SYMBOL(cfs_expr_list_print); - -/** * Matches value (\a value) against ranges expression list \a expr_list. * * \retval 1 if \a value matches @@ -575,11 +508,23 @@ cfs_expr_list_free(struct cfs_expr_list *expr_list) } EXPORT_SYMBOL(cfs_expr_list_free); +void +cfs_expr_list_print(struct cfs_expr_list *expr_list) +{ + struct cfs_range_expr *expr; + + list_for_each_entry(expr, &expr_list->el_exprs, re_link) { + CDEBUG(D_WARNING, "%d-%d/%d\n", + expr->re_lo, expr->re_hi, expr->re_stride); + } +} +EXPORT_SYMBOL(cfs_expr_list_print); + /** * Parses \ token of the syntax. * - * \retval 0 if \a str parses to \ | \ - * \retval -errno otherwise + * \retval 1 if \a str parses to \ | \ + * \retval 0 otherwise */ int cfs_expr_list_parse(char *str, int len, unsigned min, unsigned max, diff --git a/libcfs/libcfs/nidstrings.c b/libcfs/libcfs/nidstrings.c index c413636..7606d73 100644 --- a/libcfs/libcfs/nidstrings.c +++ b/libcfs/libcfs/nidstrings.c @@ -103,10 +103,6 @@ static void libcfs_hexnum_addr2str(__u32 addr, char *str); static int libcfs_num_str2addr(const char *str, int nob, __u32 *addr); static int libcfs_num_parse(char *str, int len, struct list_head *list); static int libcfs_num_match(__u32 addr, struct list_head *list); -static int libcfs_num_addr_range_print(char *buffer, int count, - struct list_head *list); -static int libcfs_ip_addr_range_print(char *buffer, int count, - struct list_head *list); struct netstrfns { int nf_type; @@ -116,8 +112,6 @@ struct netstrfns { int (*nf_str2addr)(const char *str, int nob, __u32 *addr); int (*nf_parse_addrlist)(char *str, int len, struct list_head *list); - int (*nf_print_addrlist)(char *buffer, int count, - struct list_head *list); int (*nf_match_addr)(__u32 addr, struct list_head *list); }; @@ -128,7 +122,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_decnum_addr2str, /* .nf_str2addr */ libcfs_lo_str2addr, /* .nf_parse_addr*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, /* .nf_match_addr*/ libcfs_num_match}, {/* .nf_type */ SOCKLND, /* .nf_name */ "tcp", @@ -136,7 +129,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ O2IBLND, /* .nf_name */ "o2ib", @@ -144,7 +136,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ CIBLND, /* .nf_name */ "cib", @@ -152,7 +143,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ OPENIBLND, /* .nf_name */ "openib", @@ -160,7 +150,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ IIBLND, /* .nf_name */ "iib", @@ -168,7 +157,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ VIBLND, /* .nf_name */ "vib", @@ -176,7 +164,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ RALND, /* .nf_name */ "ra", @@ -184,7 +171,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ QSWLND, /* .nf_name */ "elan", @@ -192,7 +178,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_decnum_addr2str, /* .nf_str2addr */ libcfs_num_str2addr, /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, /* .nf_match_addr*/ libcfs_num_match}, {/* .nf_type */ GMLND, /* .nf_name */ "gm", @@ -200,7 +185,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_hexnum_addr2str, /* .nf_str2addr */ libcfs_num_str2addr, /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, /* .nf_match_addr*/ libcfs_num_match}, {/* .nf_type */ MXLND, /* .nf_name */ "mx", @@ -208,7 +192,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_ip_addr2str, /* .nf_str2addr */ libcfs_ip_str2addr, /* .nf_parse_addrlist*/ cfs_ip_addr_parse, - /* .nf_print_addrlist*/ libcfs_ip_addr_range_print, /* .nf_match_addr*/ cfs_ip_addr_match}, {/* .nf_type */ PTLLND, /* .nf_name */ "ptl", @@ -216,7 +199,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_decnum_addr2str, /* .nf_str2addr */ libcfs_num_str2addr, /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, /* .nf_match_addr*/ libcfs_num_match}, {/* .nf_type */ GNILND, /* .nf_name */ "gni", @@ -224,7 +206,6 @@ static struct netstrfns libcfs_netstrfns[] = { /* .nf_addr2str */ libcfs_decnum_addr2str, /* .nf_str2addr */ libcfs_num_str2addr, /* .nf_parse_addrlist*/ libcfs_num_parse, - /* .nf_print_addrlist*/ libcfs_num_addr_range_print, /* .nf_match_addr*/ libcfs_num_match}, {/* .nf_type */ GNIIPLND, /* .nf_name */ "gip", @@ -677,8 +658,8 @@ libcfs_num_parse(char *str, int len, struct list_head *list) * Allocates struct addrrange and links to \a nidrange via * (nidrange::nr_addrranges) * - * \retval 0 if \a src parses to '*' | \ | \ - * \retval -errno otherwise + * \retval 1 if \a src parses to '*' | \ | \ + * \retval 0 otherwise */ static int parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange) @@ -687,12 +668,12 @@ parse_addrange(const struct cfs_lstr *src, struct nidrange *nidrange) if (src->ls_len == 1 && src->ls_str[0] == '*') { nidrange->nr_all = 1; - return 0; + return 1; } LIBCFS_ALLOC(addrrange, sizeof(struct addrrange)); if (addrrange == NULL) - return -ENOMEM; + return 0; list_add_tail(&addrrange->ar_link, &nidrange->nr_addrranges); INIT_LIST_HEAD(&addrrange->ar_numaddr_ranges); @@ -922,110 +903,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist) RETURN(0); } -static int -libcfs_num_addr_range_print(char *buffer, int count, struct list_head *list) -{ - int i = 0, j = 0; - struct cfs_expr_list *el; - - list_for_each_entry(el, list, el_link) { - LASSERT(j++ < 1); - i += cfs_expr_list_print(buffer + i, count - i, el); - } - return i; -} - -static int -libcfs_ip_addr_range_print(char *buffer, int count, struct list_head *list) -{ - int i = 0, j = 0; - struct cfs_expr_list *el; - - list_for_each_entry(el, list, el_link) { - LASSERT(j++ < 4); - if (i != 0) - i += cfs_snprintf(buffer + i, count - i, "."); - i += cfs_expr_list_print(buffer + i, count - i, el); - } - return i; -} - - -/** - * Print the network part of the nidrange \a nr into the specified \a buffer. - * - * \retval number of characters written - */ -static int -cfs_print_network(char *buffer, int count, struct nidrange *nr) -{ - struct netstrfns *nf = nr->nr_netstrfns; - - if (nr->nr_netnum == 0) - return cfs_snprintf(buffer, count, "@%s", nf->nf_name); - else - return cfs_snprintf(buffer, count, "@%s%u", - nf->nf_name, nr->nr_netnum); -} - - -/** - * Print a list of addrrange (\a addrranges) into the specified \a buffer. - * At max \a count characters can be printed into \a buffer. - * - * \retval number of characters written - */ -static int -cfs_print_addrranges(char *buffer, int count, struct list_head *addrranges, - struct nidrange *nr) -{ - int i = 0; - struct addrrange *ar; - struct netstrfns *nf = nr->nr_netstrfns; - - list_for_each_entry(ar, addrranges, ar_link) { - if (i != 0) - i += cfs_snprintf(buffer + i, count - i, " "); - i += nf->nf_print_addrlist(buffer + i, count - i, - &ar->ar_numaddr_ranges); - i += cfs_print_network(buffer + i, count - i, nr); - } - return i; -} - - -/** - * Print a list of nidranges (\a nidlist) into the specified \a buffer. - * At max \a count characters can be printed into \a buffer. - * Nidranges are separated by a space character. - * - * \retval number of characters written - */ -int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist) -{ - int i = 0; - struct nidrange *nr; - ENTRY; - - if (count <= 0) - RETURN(0); - - list_for_each_entry(nr, nidlist, nr_link) { - if (i != 0) - i += cfs_snprintf(buffer + i, count - i, " "); - - if (nr->nr_all != 0) { - LASSERT(list_empty(&nr->nr_addrranges)); - i += cfs_snprintf(buffer + i, count - i, "*"); - i += cfs_print_network(buffer + i, count - i, nr); - } else { - i += cfs_print_addrranges(buffer + i, count - i, - &nr->nr_addrranges, nr); - } - } - RETURN(i); -} - #ifdef __KERNEL__ EXPORT_SYMBOL(libcfs_isknown_lnd); @@ -1040,7 +917,6 @@ EXPORT_SYMBOL(libcfs_id2str); EXPORT_SYMBOL(libcfs_str2anynid); EXPORT_SYMBOL(cfs_free_nidlist); EXPORT_SYMBOL(cfs_parse_nidlist); -EXPORT_SYMBOL(cfs_print_nidlist); EXPORT_SYMBOL(cfs_match_nid); #endif -- 1.8.3.1