diff options
| author | David Teigland <teigland@redhat.com> | 2007-04-26 14:46:49 -0400 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-05-01 04:11:51 -0400 |
| commit | 617e82e10ccf96a13eb2efd5eac4abef44a87d02 (patch) | |
| tree | 9528cdfae4fd8a03ff4edb4acc76d4e9d9e4b71c | |
| parent | f391a4ead61e4510ff385815ddaf3c0777fbad1b (diff) | |
[DLM] lowcomms style
Replace some printk with log_print, and fix some simple cases of lines
over 80. Also, return -ENOTCONN if lowcomms_start fails due to no local
IP address being available.
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
| -rw-r--r-- | fs/dlm/lowcomms.c | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 5c33233bc2d5..27970a58d29b 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c | |||
| @@ -395,7 +395,8 @@ static void sctp_init_failed(void) | |||
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | /* Something happened to an association */ | 397 | /* Something happened to an association */ |
| 398 | static void process_sctp_notification(struct connection *con, struct msghdr *msg, char *buf) | 398 | static void process_sctp_notification(struct connection *con, |
| 399 | struct msghdr *msg, char *buf) | ||
| 399 | { | 400 | { |
| 400 | union sctp_notification *sn = (union sctp_notification *)buf; | 401 | union sctp_notification *sn = (union sctp_notification *)buf; |
| 401 | 402 | ||
| @@ -422,7 +423,7 @@ static void process_sctp_notification(struct connection *con, struct msghdr *msg | |||
| 422 | */ | 423 | */ |
| 423 | if ((int)sn->sn_assoc_change.sac_assoc_id <= 0) { | 424 | if ((int)sn->sn_assoc_change.sac_assoc_id <= 0) { |
| 424 | log_print("COMM_UP for invalid assoc ID %d", | 425 | log_print("COMM_UP for invalid assoc ID %d", |
| 425 | (int)sn->sn_assoc_change.sac_assoc_id); | 426 | (int)sn->sn_assoc_change.sac_assoc_id); |
| 426 | sctp_init_failed(); | 427 | sctp_init_failed(); |
| 427 | return; | 428 | return; |
| 428 | } | 429 | } |
| @@ -465,10 +466,12 @@ static void process_sctp_notification(struct connection *con, struct msghdr *msg | |||
| 465 | 466 | ||
| 466 | /* Peel off a new sock */ | 467 | /* Peel off a new sock */ |
| 467 | parg.associd = sn->sn_assoc_change.sac_assoc_id; | 468 | parg.associd = sn->sn_assoc_change.sac_assoc_id; |
| 468 | ret = kernel_getsockopt(con->sock, IPPROTO_SCTP, SCTP_SOCKOPT_PEELOFF, | 469 | ret = kernel_getsockopt(con->sock, IPPROTO_SCTP, |
| 470 | SCTP_SOCKOPT_PEELOFF, | ||
| 469 | (void *)&parg, &parglen); | 471 | (void *)&parg, &parglen); |
| 470 | if (ret) { | 472 | if (ret) { |
| 471 | log_print("Can't peel off a socket for connection %d to node %d: err=%d\n", | 473 | log_print("Can't peel off a socket for " |
| 474 | "connection %d to node %d: err=%d\n", | ||
| 472 | parg.associd, nodeid, ret); | 475 | parg.associd, nodeid, ret); |
| 473 | } | 476 | } |
| 474 | file = fget(parg.sd); | 477 | file = fget(parg.sd); |
| @@ -478,7 +481,7 @@ static void process_sctp_notification(struct connection *con, struct msghdr *msg | |||
| 478 | put_unused_fd(parg.sd); | 481 | put_unused_fd(parg.sd); |
| 479 | 482 | ||
| 480 | log_print("got new/restarted association %d nodeid %d", | 483 | log_print("got new/restarted association %d nodeid %d", |
| 481 | (int)sn->sn_assoc_change.sac_assoc_id, nodeid); | 484 | (int)sn->sn_assoc_change.sac_assoc_id, nodeid); |
| 482 | 485 | ||
| 483 | /* Send any pending writes */ | 486 | /* Send any pending writes */ |
| 484 | clear_bit(CF_CONNECT_PENDING, &new_con->flags); | 487 | clear_bit(CF_CONNECT_PENDING, &new_con->flags); |
| @@ -587,7 +590,7 @@ static int receive_from_sock(struct connection *con) | |||
| 587 | msg.msg_controllen = sizeof(incmsg); | 590 | msg.msg_controllen = sizeof(incmsg); |
| 588 | 591 | ||
| 589 | process_sctp_notification(con, &msg, | 592 | process_sctp_notification(con, &msg, |
| 590 | page_address(con->rx_page) + con->cb.base); | 593 | page_address(con->rx_page) + con->cb.base); |
| 591 | mutex_unlock(&con->sock_mutex); | 594 | mutex_unlock(&con->sock_mutex); |
| 592 | return 0; | 595 | return 0; |
| 593 | } | 596 | } |
| @@ -601,10 +604,10 @@ static int receive_from_sock(struct connection *con) | |||
| 601 | con->cb.base, con->cb.len, | 604 | con->cb.base, con->cb.len, |
| 602 | PAGE_CACHE_SIZE); | 605 | PAGE_CACHE_SIZE); |
| 603 | if (ret == -EBADMSG) { | 606 | if (ret == -EBADMSG) { |
| 604 | printk(KERN_INFO "dlm: lowcomms: addr=%p, base=%u, len=%u, " | 607 | log_print("lowcomms: addr=%p, base=%u, len=%u, " |
| 605 | "iov_len=%u, iov_base[0]=%p, read=%d\n", | 608 | "iov_len=%u, iov_base[0]=%p, read=%d", |
| 606 | page_address(con->rx_page), con->cb.base, con->cb.len, | 609 | page_address(con->rx_page), con->cb.base, con->cb.len, |
| 607 | len, iov[0].iov_base, r); | 610 | len, iov[0].iov_base, r); |
| 608 | } | 611 | } |
| 609 | if (ret < 0) | 612 | if (ret < 0) |
| 610 | goto out_close; | 613 | goto out_close; |
| @@ -680,7 +683,7 @@ static int tcp_accept_from_sock(struct connection *con) | |||
| 680 | /* Get the new node's NODEID */ | 683 | /* Get the new node's NODEID */ |
| 681 | make_sockaddr(&peeraddr, 0, &len); | 684 | make_sockaddr(&peeraddr, 0, &len); |
| 682 | if (dlm_addr_to_nodeid(&peeraddr, &nodeid)) { | 685 | if (dlm_addr_to_nodeid(&peeraddr, &nodeid)) { |
| 683 | printk("dlm: connect from non cluster node\n"); | 686 | log_print("connect from non cluster node"); |
| 684 | sock_release(newsock); | 687 | sock_release(newsock); |
| 685 | mutex_unlock(&con->sock_mutex); | 688 | mutex_unlock(&con->sock_mutex); |
| 686 | return -1; | 689 | return -1; |
| @@ -705,7 +708,7 @@ static int tcp_accept_from_sock(struct connection *con) | |||
| 705 | if (!othercon) { | 708 | if (!othercon) { |
| 706 | othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL); | 709 | othercon = kmem_cache_zalloc(con_cache, GFP_KERNEL); |
| 707 | if (!othercon) { | 710 | if (!othercon) { |
| 708 | printk("dlm: failed to allocate incoming socket\n"); | 711 | log_print("failed to allocate incoming socket"); |
| 709 | mutex_unlock(&newcon->sock_mutex); | 712 | mutex_unlock(&newcon->sock_mutex); |
| 710 | result = -ENOMEM; | 713 | result = -ENOMEM; |
| 711 | goto accept_err; | 714 | goto accept_err; |
| @@ -748,7 +751,7 @@ accept_err: | |||
| 748 | sock_release(newsock); | 751 | sock_release(newsock); |
| 749 | 752 | ||
| 750 | if (result != -EAGAIN) | 753 | if (result != -EAGAIN) |
| 751 | printk("dlm: error accepting connection from node: %d\n", result); | 754 | log_print("error accepting connection from node: %d", result); |
| 752 | return result; | 755 | return result; |
| 753 | } | 756 | } |
| 754 | 757 | ||
| @@ -826,7 +829,8 @@ static void sctp_init_assoc(struct connection *con) | |||
| 826 | 829 | ||
| 827 | ret = kernel_sendmsg(base_con->sock, &outmessage, iov, 1, len); | 830 | ret = kernel_sendmsg(base_con->sock, &outmessage, iov, 1, len); |
| 828 | if (ret < 0) { | 831 | if (ret < 0) { |
| 829 | log_print("Send first packet to node %d failed: %d", con->nodeid, ret); | 832 | log_print("Send first packet to node %d failed: %d", |
| 833 | con->nodeid, ret); | ||
| 830 | 834 | ||
| 831 | /* Try again later */ | 835 | /* Try again later */ |
| 832 | clear_bit(CF_CONNECT_PENDING, &con->flags); | 836 | clear_bit(CF_CONNECT_PENDING, &con->flags); |
| @@ -929,9 +933,10 @@ static struct socket *tcp_create_listen_sock(struct connection *con, | |||
| 929 | addr_len = sizeof(struct sockaddr_in6); | 933 | addr_len = sizeof(struct sockaddr_in6); |
| 930 | 934 | ||
| 931 | /* Create a socket to communicate with */ | 935 | /* Create a socket to communicate with */ |
| 932 | result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, IPPROTO_TCP, &sock); | 936 | result = sock_create_kern(dlm_local_addr[0]->ss_family, SOCK_STREAM, |
| 937 | IPPROTO_TCP, &sock); | ||
| 933 | if (result < 0) { | 938 | if (result < 0) { |
| 934 | printk("dlm: Can't create listening comms socket\n"); | 939 | log_print("Can't create listening comms socket"); |
| 935 | goto create_out; | 940 | goto create_out; |
| 936 | } | 941 | } |
| 937 | 942 | ||
| @@ -939,8 +944,7 @@ static struct socket *tcp_create_listen_sock(struct connection *con, | |||
| 939 | (char *)&one, sizeof(one)); | 944 | (char *)&one, sizeof(one)); |
| 940 | 945 | ||
| 941 | if (result < 0) { | 946 | if (result < 0) { |
| 942 | printk("dlm: Failed to set SO_REUSEADDR on socket: result=%d\n", | 947 | log_print("Failed to set SO_REUSEADDR on socket: %d", result); |
| 943 | result); | ||
| 944 | } | 948 | } |
| 945 | sock->sk->sk_user_data = con; | 949 | sock->sk->sk_user_data = con; |
| 946 | con->rx_action = tcp_accept_from_sock; | 950 | con->rx_action = tcp_accept_from_sock; |
| @@ -951,7 +955,7 @@ static struct socket *tcp_create_listen_sock(struct connection *con, | |||
| 951 | make_sockaddr(saddr, dlm_config.ci_tcp_port, &addr_len); | 955 | make_sockaddr(saddr, dlm_config.ci_tcp_port, &addr_len); |
| 952 | result = sock->ops->bind(sock, (struct sockaddr *) saddr, addr_len); | 956 | result = sock->ops->bind(sock, (struct sockaddr *) saddr, addr_len); |
| 953 | if (result < 0) { | 957 | if (result < 0) { |
| 954 | printk("dlm: Can't bind to port %d\n", dlm_config.ci_tcp_port); | 958 | log_print("Can't bind to port %d", dlm_config.ci_tcp_port); |
| 955 | sock_release(sock); | 959 | sock_release(sock); |
| 956 | sock = NULL; | 960 | sock = NULL; |
| 957 | con->sock = NULL; | 961 | con->sock = NULL; |
| @@ -960,12 +964,12 @@ static struct socket *tcp_create_listen_sock(struct connection *con, | |||
| 960 | result = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, | 964 | result = kernel_setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, |
| 961 | (char *)&one, sizeof(one)); | 965 | (char *)&one, sizeof(one)); |
| 962 | if (result < 0) { | 966 | if (result < 0) { |
| 963 | printk("dlm: Set keepalive failed: %d\n", result); | 967 | log_print("Set keepalive failed: %d", result); |
| 964 | } | 968 | } |
| 965 | 969 | ||
| 966 | result = sock->ops->listen(sock, 5); | 970 | result = sock->ops->listen(sock, 5); |
| 967 | if (result < 0) { | 971 | if (result < 0) { |
| 968 | printk("dlm: Can't listen on port %d\n", dlm_config.ci_tcp_port); | 972 | log_print("Can't listen on port %d", dlm_config.ci_tcp_port); |
| 969 | sock_release(sock); | 973 | sock_release(sock); |
| 970 | sock = NULL; | 974 | sock = NULL; |
| 971 | goto create_out; | 975 | goto create_out; |
| @@ -994,8 +998,11 @@ static void init_local(void) | |||
| 994 | } | 998 | } |
| 995 | } | 999 | } |
| 996 | 1000 | ||
| 997 | /* Bind to an IP address. SCTP allows multiple address so it can do multi-homing */ | 1001 | /* Bind to an IP address. SCTP allows multiple address so it can do |
| 998 | static int add_sctp_bind_addr(struct connection *sctp_con, struct sockaddr_storage *addr, int addr_len, int num) | 1002 | multi-homing */ |
| 1003 | static int add_sctp_bind_addr(struct connection *sctp_con, | ||
| 1004 | struct sockaddr_storage *addr, | ||
| 1005 | int addr_len, int num) | ||
| 999 | { | 1006 | { |
| 1000 | int result = 0; | 1007 | int result = 0; |
| 1001 | 1008 | ||
| @@ -1048,10 +1055,10 @@ static int sctp_listen_for_all(void) | |||
| 1048 | result = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, | 1055 | result = kernel_setsockopt(sock, SOL_SOCKET, SO_RCVBUF, |
| 1049 | (char *)&bufsize, sizeof(bufsize)); | 1056 | (char *)&bufsize, sizeof(bufsize)); |
| 1050 | if (result) | 1057 | if (result) |
| 1051 | log_print("Error increasing buffer space on socket: %d", result); | 1058 | log_print("Error increasing buffer space on socket %d", result); |
| 1052 | 1059 | ||
| 1053 | result = kernel_setsockopt(sock, SOL_SCTP, SCTP_EVENTS, | 1060 | result = kernel_setsockopt(sock, SOL_SCTP, SCTP_EVENTS, |
| 1054 | (char *)&subscribe, sizeof(subscribe)); | 1061 | (char *)&subscribe, sizeof(subscribe)); |
| 1055 | if (result < 0) { | 1062 | if (result < 0) { |
| 1056 | log_print("Failed to set SCTP_EVENTS on socket: result=%d", | 1063 | log_print("Failed to set SCTP_EVENTS on socket: result=%d", |
| 1057 | result); | 1064 | result); |
| @@ -1102,7 +1109,8 @@ static int tcp_listen_for_all(void) | |||
| 1102 | 1109 | ||
| 1103 | /* We don't support multi-homed hosts */ | 1110 | /* We don't support multi-homed hosts */ |
| 1104 | if (dlm_local_addr[1] != NULL) { | 1111 | if (dlm_local_addr[1] != NULL) { |
| 1105 | log_print("TCP protocol can't handle multi-homed hosts, try SCTP"); | 1112 | log_print("TCP protocol can't handle multi-homed hosts, " |
| 1113 | "try SCTP"); | ||
| 1106 | return -EINVAL; | 1114 | return -EINVAL; |
| 1107 | } | 1115 | } |
| 1108 | 1116 | ||
| @@ -1148,8 +1156,7 @@ static struct writequeue_entry *new_writequeue_entry(struct connection *con, | |||
| 1148 | return entry; | 1156 | return entry; |
| 1149 | } | 1157 | } |
| 1150 | 1158 | ||
| 1151 | void *dlm_lowcomms_get_buffer(int nodeid, int len, | 1159 | void *dlm_lowcomms_get_buffer(int nodeid, int len, gfp_t allocation, char **ppc) |
| 1152 | gfp_t allocation, char **ppc) | ||
| 1153 | { | 1160 | { |
| 1154 | struct connection *con; | 1161 | struct connection *con; |
| 1155 | struct writequeue_entry *e; | 1162 | struct writequeue_entry *e; |
| @@ -1253,8 +1260,7 @@ static void send_to_sock(struct connection *con) | |||
| 1253 | goto out; | 1260 | goto out; |
| 1254 | if (ret <= 0) | 1261 | if (ret <= 0) |
| 1255 | goto send_error; | 1262 | goto send_error; |
| 1256 | } | 1263 | } else { |
| 1257 | else { | ||
| 1258 | /* Don't starve people filling buffers */ | 1264 | /* Don't starve people filling buffers */ |
| 1259 | cond_resched(); | 1265 | cond_resched(); |
| 1260 | } | 1266 | } |
| @@ -1426,6 +1432,7 @@ int dlm_lowcomms_start(void) | |||
| 1426 | 1432 | ||
| 1427 | init_local(); | 1433 | init_local(); |
| 1428 | if (!dlm_local_count) { | 1434 | if (!dlm_local_count) { |
| 1435 | error = -ENOTCONN; | ||
| 1429 | log_print("no local IP address has been set"); | 1436 | log_print("no local IP address has been set"); |
| 1430 | goto out; | 1437 | goto out; |
| 1431 | } | 1438 | } |
