diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/ceph/messenger.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index e1e53bb2d0cf..44d8c77cabdd 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c | |||
@@ -80,8 +80,8 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss) | |||
80 | break; | 80 | break; |
81 | 81 | ||
82 | default: | 82 | default: |
83 | snprintf(s, MAX_ADDR_STR_LEN, "(unknown sockaddr family %d)", | 83 | snprintf(s, MAX_ADDR_STR_LEN, "(unknown sockaddr family %hu)", |
84 | (int)ss->ss_family); | 84 | ss->ss_family); |
85 | } | 85 | } |
86 | 86 | ||
87 | return s; | 87 | return s; |
@@ -101,8 +101,10 @@ static struct workqueue_struct *ceph_msgr_wq; | |||
101 | 101 | ||
102 | void _ceph_msgr_exit(void) | 102 | void _ceph_msgr_exit(void) |
103 | { | 103 | { |
104 | if (ceph_msgr_wq) | 104 | if (ceph_msgr_wq) { |
105 | destroy_workqueue(ceph_msgr_wq); | 105 | destroy_workqueue(ceph_msgr_wq); |
106 | ceph_msgr_wq = NULL; | ||
107 | } | ||
106 | 108 | ||
107 | BUG_ON(zero_page_address == NULL); | 109 | BUG_ON(zero_page_address == NULL); |
108 | zero_page_address = NULL; | 110 | zero_page_address = NULL; |
@@ -167,8 +169,7 @@ static void ceph_data_ready(struct sock *sk, int count_unused) | |||
167 | /* socket has buffer space for writing */ | 169 | /* socket has buffer space for writing */ |
168 | static void ceph_write_space(struct sock *sk) | 170 | static void ceph_write_space(struct sock *sk) |
169 | { | 171 | { |
170 | struct ceph_connection *con = | 172 | struct ceph_connection *con = sk->sk_user_data; |
171 | (struct ceph_connection *)sk->sk_user_data; | ||
172 | 173 | ||
173 | /* only queue to workqueue if there is data we want to write, | 174 | /* only queue to workqueue if there is data we want to write, |
174 | * and there is sufficient space in the socket buffer to accept | 175 | * and there is sufficient space in the socket buffer to accept |
@@ -216,6 +217,8 @@ static void ceph_state_change(struct sock *sk) | |||
216 | dout("ceph_state_change TCP_ESTABLISHED\n"); | 217 | dout("ceph_state_change TCP_ESTABLISHED\n"); |
217 | queue_con(con); | 218 | queue_con(con); |
218 | break; | 219 | break; |
220 | default: /* Everything else is uninteresting */ | ||
221 | break; | ||
219 | } | 222 | } |
220 | } | 223 | } |
221 | 224 | ||
@@ -420,22 +423,23 @@ bool ceph_con_opened(struct ceph_connection *con) | |||
420 | */ | 423 | */ |
421 | struct ceph_connection *ceph_con_get(struct ceph_connection *con) | 424 | struct ceph_connection *ceph_con_get(struct ceph_connection *con) |
422 | { | 425 | { |
423 | dout("con_get %p nref = %d -> %d\n", con, | 426 | int nref = __atomic_add_unless(&con->nref, 1, 0); |
424 | atomic_read(&con->nref), atomic_read(&con->nref) + 1); | 427 | |
425 | if (atomic_inc_not_zero(&con->nref)) | 428 | dout("con_get %p nref = %d -> %d\n", con, nref, nref + 1); |
426 | return con; | 429 | |
427 | return NULL; | 430 | return nref ? con : NULL; |
428 | } | 431 | } |
429 | 432 | ||
430 | void ceph_con_put(struct ceph_connection *con) | 433 | void ceph_con_put(struct ceph_connection *con) |
431 | { | 434 | { |
432 | dout("con_put %p nref = %d -> %d\n", con, | 435 | int nref = atomic_dec_return(&con->nref); |
433 | atomic_read(&con->nref), atomic_read(&con->nref) - 1); | 436 | |
434 | BUG_ON(atomic_read(&con->nref) == 0); | 437 | BUG_ON(nref < 0); |
435 | if (atomic_dec_and_test(&con->nref)) { | 438 | if (nref == 0) { |
436 | BUG_ON(con->sock); | 439 | BUG_ON(con->sock); |
437 | kfree(con); | 440 | kfree(con); |
438 | } | 441 | } |
442 | dout("con_put %p nref = %d -> %d\n", con, nref + 1, nref); | ||
439 | } | 443 | } |
440 | 444 | ||
441 | /* | 445 | /* |