diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-07-20 19:27:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-07-20 19:27:58 -0400 |
commit | e0959371b4aaddb9b986019d5cfef93f9801d0ff (patch) | |
tree | 7df35d0e8dc8de31fa19aa0f8f3fad78b2afea11 /fs | |
parent | 83ba37105e262d374b9092a572b8ee6e30aa9f70 (diff) | |
parent | e979cf50395e24c4bdd489f60e2d5dd5ae66d255 (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client:
ceph: do not include cap/dentry releases in replayed messages
ceph: reuse request message when replaying against recovering mds
ceph: fix creation of ipv6 sockets
ceph: fix parsing of ipv6 addresses
ceph: fix printing of ipv6 addrs
ceph: add kfree() to error path
ceph: fix leak of mon authorizer
ceph: fix message revocation
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/auth_x.c | 3 | ||||
-rw-r--r-- | fs/ceph/mds_client.c | 35 | ||||
-rw-r--r-- | fs/ceph/mds_client.h | 1 | ||||
-rw-r--r-- | fs/ceph/messenger.c | 71 | ||||
-rw-r--r-- | fs/ceph/osdmap.c | 1 |
5 files changed, 72 insertions, 39 deletions
diff --git a/fs/ceph/auth_x.c b/fs/ceph/auth_x.c index 3fe49042d8ad..6d44053ecff1 100644 --- a/fs/ceph/auth_x.c +++ b/fs/ceph/auth_x.c | |||
@@ -613,6 +613,9 @@ static void ceph_x_destroy(struct ceph_auth_client *ac) | |||
613 | remove_ticket_handler(ac, th); | 613 | remove_ticket_handler(ac, th); |
614 | } | 614 | } |
615 | 615 | ||
616 | if (xi->auth_authorizer.buf) | ||
617 | ceph_buffer_put(xi->auth_authorizer.buf); | ||
618 | |||
616 | kfree(ac->private); | 619 | kfree(ac->private); |
617 | ac->private = NULL; | 620 | ac->private = NULL; |
618 | } | 621 | } |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 3ab79f6c4ce8..416c08d315db 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
@@ -1514,6 +1514,9 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc, | |||
1514 | ceph_encode_filepath(&p, end, ino1, path1); | 1514 | ceph_encode_filepath(&p, end, ino1, path1); |
1515 | ceph_encode_filepath(&p, end, ino2, path2); | 1515 | ceph_encode_filepath(&p, end, ino2, path2); |
1516 | 1516 | ||
1517 | /* make note of release offset, in case we need to replay */ | ||
1518 | req->r_request_release_offset = p - msg->front.iov_base; | ||
1519 | |||
1517 | /* cap releases */ | 1520 | /* cap releases */ |
1518 | releases = 0; | 1521 | releases = 0; |
1519 | if (req->r_inode_drop) | 1522 | if (req->r_inode_drop) |
@@ -1580,6 +1583,32 @@ static int __prepare_send_request(struct ceph_mds_client *mdsc, | |||
1580 | dout("prepare_send_request %p tid %lld %s (attempt %d)\n", req, | 1583 | dout("prepare_send_request %p tid %lld %s (attempt %d)\n", req, |
1581 | req->r_tid, ceph_mds_op_name(req->r_op), req->r_attempts); | 1584 | req->r_tid, ceph_mds_op_name(req->r_op), req->r_attempts); |
1582 | 1585 | ||
1586 | if (req->r_got_unsafe) { | ||
1587 | /* | ||
1588 | * Replay. Do not regenerate message (and rebuild | ||
1589 | * paths, etc.); just use the original message. | ||
1590 | * Rebuilding paths will break for renames because | ||
1591 | * d_move mangles the src name. | ||
1592 | */ | ||
1593 | msg = req->r_request; | ||
1594 | rhead = msg->front.iov_base; | ||
1595 | |||
1596 | flags = le32_to_cpu(rhead->flags); | ||
1597 | flags |= CEPH_MDS_FLAG_REPLAY; | ||
1598 | rhead->flags = cpu_to_le32(flags); | ||
1599 | |||
1600 | if (req->r_target_inode) | ||
1601 | rhead->ino = cpu_to_le64(ceph_ino(req->r_target_inode)); | ||
1602 | |||
1603 | rhead->num_retry = req->r_attempts - 1; | ||
1604 | |||
1605 | /* remove cap/dentry releases from message */ | ||
1606 | rhead->num_releases = 0; | ||
1607 | msg->hdr.front_len = cpu_to_le32(req->r_request_release_offset); | ||
1608 | msg->front.iov_len = req->r_request_release_offset; | ||
1609 | return 0; | ||
1610 | } | ||
1611 | |||
1583 | if (req->r_request) { | 1612 | if (req->r_request) { |
1584 | ceph_msg_put(req->r_request); | 1613 | ceph_msg_put(req->r_request); |
1585 | req->r_request = NULL; | 1614 | req->r_request = NULL; |
@@ -1601,13 +1630,9 @@ static int __prepare_send_request(struct ceph_mds_client *mdsc, | |||
1601 | rhead->flags = cpu_to_le32(flags); | 1630 | rhead->flags = cpu_to_le32(flags); |
1602 | rhead->num_fwd = req->r_num_fwd; | 1631 | rhead->num_fwd = req->r_num_fwd; |
1603 | rhead->num_retry = req->r_attempts - 1; | 1632 | rhead->num_retry = req->r_attempts - 1; |
1633 | rhead->ino = 0; | ||
1604 | 1634 | ||
1605 | dout(" r_locked_dir = %p\n", req->r_locked_dir); | 1635 | dout(" r_locked_dir = %p\n", req->r_locked_dir); |
1606 | |||
1607 | if (req->r_target_inode && req->r_got_unsafe) | ||
1608 | rhead->ino = cpu_to_le64(ceph_ino(req->r_target_inode)); | ||
1609 | else | ||
1610 | rhead->ino = 0; | ||
1611 | return 0; | 1636 | return 0; |
1612 | } | 1637 | } |
1613 | 1638 | ||
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index b292fa42a66d..952410c60d09 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h | |||
@@ -188,6 +188,7 @@ struct ceph_mds_request { | |||
188 | int r_old_inode_drop, r_old_inode_unless; | 188 | int r_old_inode_drop, r_old_inode_unless; |
189 | 189 | ||
190 | struct ceph_msg *r_request; /* original request */ | 190 | struct ceph_msg *r_request; /* original request */ |
191 | int r_request_release_offset; | ||
191 | struct ceph_msg *r_reply; | 192 | struct ceph_msg *r_reply; |
192 | struct ceph_mds_reply_info_parsed r_reply_info; | 193 | struct ceph_mds_reply_info_parsed r_reply_info; |
193 | int r_err; | 194 | int r_err; |
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index 9ad43a310a41..15167b2daa55 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -43,7 +43,8 @@ static void ceph_fault(struct ceph_connection *con); | |||
43 | * nicely render a sockaddr as a string. | 43 | * nicely render a sockaddr as a string. |
44 | */ | 44 | */ |
45 | #define MAX_ADDR_STR 20 | 45 | #define MAX_ADDR_STR 20 |
46 | static char addr_str[MAX_ADDR_STR][40]; | 46 | #define MAX_ADDR_STR_LEN 60 |
47 | static char addr_str[MAX_ADDR_STR][MAX_ADDR_STR_LEN]; | ||
47 | static DEFINE_SPINLOCK(addr_str_lock); | 48 | static DEFINE_SPINLOCK(addr_str_lock); |
48 | static int last_addr_str; | 49 | static int last_addr_str; |
49 | 50 | ||
@@ -52,7 +53,6 @@ const char *pr_addr(const struct sockaddr_storage *ss) | |||
52 | int i; | 53 | int i; |
53 | char *s; | 54 | char *s; |
54 | struct sockaddr_in *in4 = (void *)ss; | 55 | struct sockaddr_in *in4 = (void *)ss; |
55 | unsigned char *quad = (void *)&in4->sin_addr.s_addr; | ||
56 | struct sockaddr_in6 *in6 = (void *)ss; | 56 | struct sockaddr_in6 *in6 = (void *)ss; |
57 | 57 | ||
58 | spin_lock(&addr_str_lock); | 58 | spin_lock(&addr_str_lock); |
@@ -64,25 +64,13 @@ const char *pr_addr(const struct sockaddr_storage *ss) | |||
64 | 64 | ||
65 | switch (ss->ss_family) { | 65 | switch (ss->ss_family) { |
66 | case AF_INET: | 66 | case AF_INET: |
67 | sprintf(s, "%u.%u.%u.%u:%u", | 67 | snprintf(s, MAX_ADDR_STR_LEN, "%pI4:%u", &in4->sin_addr, |
68 | (unsigned int)quad[0], | 68 | (unsigned int)ntohs(in4->sin_port)); |
69 | (unsigned int)quad[1], | ||
70 | (unsigned int)quad[2], | ||
71 | (unsigned int)quad[3], | ||
72 | (unsigned int)ntohs(in4->sin_port)); | ||
73 | break; | 69 | break; |
74 | 70 | ||
75 | case AF_INET6: | 71 | case AF_INET6: |
76 | sprintf(s, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x:%u", | 72 | snprintf(s, MAX_ADDR_STR_LEN, "[%pI6c]:%u", &in6->sin6_addr, |
77 | in6->sin6_addr.s6_addr16[0], | 73 | (unsigned int)ntohs(in6->sin6_port)); |
78 | in6->sin6_addr.s6_addr16[1], | ||
79 | in6->sin6_addr.s6_addr16[2], | ||
80 | in6->sin6_addr.s6_addr16[3], | ||
81 | in6->sin6_addr.s6_addr16[4], | ||
82 | in6->sin6_addr.s6_addr16[5], | ||
83 | in6->sin6_addr.s6_addr16[6], | ||
84 | in6->sin6_addr.s6_addr16[7], | ||
85 | (unsigned int)ntohs(in6->sin6_port)); | ||
86 | break; | 74 | break; |
87 | 75 | ||
88 | default: | 76 | default: |
@@ -215,12 +203,13 @@ static void set_sock_callbacks(struct socket *sock, | |||
215 | */ | 203 | */ |
216 | static struct socket *ceph_tcp_connect(struct ceph_connection *con) | 204 | static struct socket *ceph_tcp_connect(struct ceph_connection *con) |
217 | { | 205 | { |
218 | struct sockaddr *paddr = (struct sockaddr *)&con->peer_addr.in_addr; | 206 | struct sockaddr_storage *paddr = &con->peer_addr.in_addr; |
219 | struct socket *sock; | 207 | struct socket *sock; |
220 | int ret; | 208 | int ret; |
221 | 209 | ||
222 | BUG_ON(con->sock); | 210 | BUG_ON(con->sock); |
223 | ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock); | 211 | ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM, |
212 | IPPROTO_TCP, &sock); | ||
224 | if (ret) | 213 | if (ret) |
225 | return ERR_PTR(ret); | 214 | return ERR_PTR(ret); |
226 | con->sock = sock; | 215 | con->sock = sock; |
@@ -234,7 +223,8 @@ static struct socket *ceph_tcp_connect(struct ceph_connection *con) | |||
234 | 223 | ||
235 | dout("connect %s\n", pr_addr(&con->peer_addr.in_addr)); | 224 | dout("connect %s\n", pr_addr(&con->peer_addr.in_addr)); |
236 | 225 | ||
237 | ret = sock->ops->connect(sock, paddr, sizeof(*paddr), O_NONBLOCK); | 226 | ret = sock->ops->connect(sock, (struct sockaddr *)paddr, sizeof(*paddr), |
227 | O_NONBLOCK); | ||
238 | if (ret == -EINPROGRESS) { | 228 | if (ret == -EINPROGRESS) { |
239 | dout("connect %s EINPROGRESS sk_state = %u\n", | 229 | dout("connect %s EINPROGRESS sk_state = %u\n", |
240 | pr_addr(&con->peer_addr.in_addr), | 230 | pr_addr(&con->peer_addr.in_addr), |
@@ -1009,19 +999,32 @@ int ceph_parse_ips(const char *c, const char *end, | |||
1009 | struct sockaddr_in *in4 = (void *)ss; | 999 | struct sockaddr_in *in4 = (void *)ss; |
1010 | struct sockaddr_in6 *in6 = (void *)ss; | 1000 | struct sockaddr_in6 *in6 = (void *)ss; |
1011 | int port; | 1001 | int port; |
1002 | char delim = ','; | ||
1003 | |||
1004 | if (*p == '[') { | ||
1005 | delim = ']'; | ||
1006 | p++; | ||
1007 | } | ||
1012 | 1008 | ||
1013 | memset(ss, 0, sizeof(*ss)); | 1009 | memset(ss, 0, sizeof(*ss)); |
1014 | if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr, | 1010 | if (in4_pton(p, end - p, (u8 *)&in4->sin_addr.s_addr, |
1015 | ',', &ipend)) { | 1011 | delim, &ipend)) |
1016 | ss->ss_family = AF_INET; | 1012 | ss->ss_family = AF_INET; |
1017 | } else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr, | 1013 | else if (in6_pton(p, end - p, (u8 *)&in6->sin6_addr.s6_addr, |
1018 | ',', &ipend)) { | 1014 | delim, &ipend)) |
1019 | ss->ss_family = AF_INET6; | 1015 | ss->ss_family = AF_INET6; |
1020 | } else { | 1016 | else |
1021 | goto bad; | 1017 | goto bad; |
1022 | } | ||
1023 | p = ipend; | 1018 | p = ipend; |
1024 | 1019 | ||
1020 | if (delim == ']') { | ||
1021 | if (*p != ']') { | ||
1022 | dout("missing matching ']'\n"); | ||
1023 | goto bad; | ||
1024 | } | ||
1025 | p++; | ||
1026 | } | ||
1027 | |||
1025 | /* port? */ | 1028 | /* port? */ |
1026 | if (p < end && *p == ':') { | 1029 | if (p < end && *p == ':') { |
1027 | port = 0; | 1030 | port = 0; |
@@ -1055,7 +1058,7 @@ int ceph_parse_ips(const char *c, const char *end, | |||
1055 | return 0; | 1058 | return 0; |
1056 | 1059 | ||
1057 | bad: | 1060 | bad: |
1058 | pr_err("parse_ips bad ip '%s'\n", c); | 1061 | pr_err("parse_ips bad ip '%.*s'\n", (int)(end - c), c); |
1059 | return -EINVAL; | 1062 | return -EINVAL; |
1060 | } | 1063 | } |
1061 | 1064 | ||
@@ -2015,20 +2018,20 @@ void ceph_con_revoke(struct ceph_connection *con, struct ceph_msg *msg) | |||
2015 | { | 2018 | { |
2016 | mutex_lock(&con->mutex); | 2019 | mutex_lock(&con->mutex); |
2017 | if (!list_empty(&msg->list_head)) { | 2020 | if (!list_empty(&msg->list_head)) { |
2018 | dout("con_revoke %p msg %p\n", con, msg); | 2021 | dout("con_revoke %p msg %p - was on queue\n", con, msg); |
2019 | list_del_init(&msg->list_head); | 2022 | list_del_init(&msg->list_head); |
2020 | ceph_msg_put(msg); | 2023 | ceph_msg_put(msg); |
2021 | msg->hdr.seq = 0; | 2024 | msg->hdr.seq = 0; |
2022 | if (con->out_msg == msg) { | 2025 | } |
2023 | ceph_msg_put(con->out_msg); | 2026 | if (con->out_msg == msg) { |
2024 | con->out_msg = NULL; | 2027 | dout("con_revoke %p msg %p - was sending\n", con, msg); |
2025 | } | 2028 | con->out_msg = NULL; |
2026 | if (con->out_kvec_is_msg) { | 2029 | if (con->out_kvec_is_msg) { |
2027 | con->out_skip = con->out_kvec_bytes; | 2030 | con->out_skip = con->out_kvec_bytes; |
2028 | con->out_kvec_is_msg = false; | 2031 | con->out_kvec_is_msg = false; |
2029 | } | 2032 | } |
2030 | } else { | 2033 | ceph_msg_put(msg); |
2031 | dout("con_revoke %p msg %p - not queued (sent?)\n", con, msg); | 2034 | msg->hdr.seq = 0; |
2032 | } | 2035 | } |
2033 | mutex_unlock(&con->mutex); | 2036 | mutex_unlock(&con->mutex); |
2034 | } | 2037 | } |
diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c index 50ce64ebd330..277f8b339577 100644 --- a/fs/ceph/osdmap.c +++ b/fs/ceph/osdmap.c | |||
@@ -568,6 +568,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end) | |||
568 | if (ev > CEPH_PG_POOL_VERSION) { | 568 | if (ev > CEPH_PG_POOL_VERSION) { |
569 | pr_warning("got unknown v %d > %d of ceph_pg_pool\n", | 569 | pr_warning("got unknown v %d > %d of ceph_pg_pool\n", |
570 | ev, CEPH_PG_POOL_VERSION); | 570 | ev, CEPH_PG_POOL_VERSION); |
571 | kfree(pi); | ||
571 | goto bad; | 572 | goto bad; |
572 | } | 573 | } |
573 | __decode_pool(p, pi); | 574 | __decode_pool(p, pi); |