fixes for 3.6-rc3
Subsystems (2)
cover fixes for 3.6-rc3
These fixes are queued for 3.6-rc3. Please take a look before I send them to Linus.
Thanks!
sage
Jim Schutt (1):
libceph: avoid truncation due to racing banners
Sage Weil (3):
libceph: delay debugfs initialization until we learn global_id
ceph: tolerate (and warn on) extraneous dentry from mds
ceph: avoid divide by zero in __validate_layout()
fs/ceph/debugfs.c | 1 + fs/ceph/inode.c | 15 +++++++++---- fs/ceph/ioctl.c | 3 +- net/ceph/ceph_common.c | 1 - net/ceph/debugfs.c | 4 +++ net/ceph/messenger.c | 11 ++++++++- net/ceph/mon_client.c | 51 +++++++++++++++++++++++++++++++++++++++++++---- 7 files changed, 72 insertions(+), 14 deletions(-)
Signature · 1 line
1.7.9
PATCH 1/4 libceph: delay debugfs initialization until we learn global_id
The debugfs directory includes the cluster fsid and our unique global_id. We need to delay the initialization of the debug entry until we have learned both the fsid and our global_id from the monitor or else the second client can't create its debugfs entry and will fail (and multiple client instances aren't properly reflected in debugfs).
Reported by: Yan, Zheng <[email protected]>
--- fs/ceph/debugfs.c | 1 + net/ceph/ceph_common.c | 1 - net/ceph/debugfs.c | 4 +++ net/ceph/mon_client.c | 51 +++++++++++++++++++++++++++++++++++++++++++---- 4 files changed, 51 insertions(+), 6 deletions(-)
fs/ceph/debugfs.c +1 -0
@@ -201,6 +201,7 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc)int err = -ENOMEM ;dout ("ceph_fs_debugfs_init\n" ); +BUG_ON (!fsc->client->debugfs_dir); fsc->debugfs_congestion_kb = debugfs_create_file("writeback_congestion_kb", 0600,
net/ceph/ceph_common.c +0 -1
@@ -84,7 +84,6 @@ int ceph_check_fsid(struct ceph_client *client, struct ceph_fsid *fsid)return -1 ; } }else { -pr_info ("client%lld fsid %pU\n" ,ceph_client_id (client), fsid);memcpy (&client->fsid, fsid,sizeof (*fsid)); }return 0 ;
net/ceph/debugfs.c +4 -0
@@ -189,6 +189,9 @@ int ceph_debugfs_client_init(struct ceph_client *client)snprintf (name,sizeof (name),"%pU.client%lld" , &client->fsid, client->monc.auth->global_id); +dout ("ceph_debugfs_client_init %p %s\n" , client, name); + +BUG_ON (client->debugfs_dir); client->debugfs_dir =debugfs_create_dir (name, ceph_debugfs_dir);if (!client->debugfs_dir) goto out;
@@ -234,6 +237,7 @@ out:void ceph_debugfs_client_cleanup (struct ceph_client *client) { +dout ("ceph_debugfs_client_cleanup %p\n" , client);debugfs_remove (client->debugfs_osdmap);debugfs_remove (client->debugfs_monmap);debugfs_remove (client->osdc.debugfs_file);
net/ceph/mon_client.c +46 -5
88 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 2/4 ceph: tolerate (and warn on) extraneous dentry from mds
In reply to Sage WeilIf the MDS gives us a dentry and we weren't prepared to handle it, WARN_ON_ONCE instead of crashing.
--- fs/ceph/inode.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
fs/ceph/inode.c +10 -5
@@ -992,11 +992,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,if (rinfo->head->is_dentry) {struct inode *dir = req->r_locked_dir; - err =fill_inode (dir, &rinfo->diri, rinfo->dirfrag, - session, req->r_request_started,-1 , - &req->r_caps_reservation); -if (err <0 ) -return err; +if (dir) { + err =fill_inode (dir, &rinfo->diri, rinfo->dirfrag, + session, req->r_request_started,-1 , + &req->r_caps_reservation); +if (err <0 ) +return err; + }else { +WARN_ON_ONCE (1 ); + } }/*
@@ -1004,6 +1008,7 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,* will have trouble splicing in the virtual snapdir later */ if (rinfo->head->is_dentry && !req->r_aborted && + req->r_locked_dir && (rinfo->head->is_target ||strncmp (req->r_dentry->d_name.name, fsc->mount_options->snapdir_name, req->r_dentry->d_name.len))) {
Signature · 1 line
1.7.9
PATCH 3/4 libceph: avoid truncation due to racing banners
In reply to Sage WeilFrom: Jim Schutt <[email protected]>
Because the Ceph client messenger uses a non-blocking connect, it is possible for the sending of the client banner to race with the arrival of the banner sent by the peer.
When ceph_sock_state_change() notices the connect has completed, it schedules work to process the socket via con_work(). During this time the peer is writing its banner, and arrival of the peer banner races with con_work().
If con_work() calls try_read() before the peer banner arrives, there is nothing for it to do, after which con_work() calls try_write() to send the client's banner. In this case Ceph's protocol negotiation can complete succesfully.
The server-side messenger immediately sends its banner and addresses after accepting a connect request, *before* actually attempting to read or verify the banner from the client. As a result, it is possible for the banner from the server to arrive before con_work() calls try_read(). If that happens, try_read() will read the banner and prepare protocol negotiation info via prepare_write_connect(). prepare_write_connect() calls con_out_kvec_reset(), which discards the as-yet-unsent client banner. Next, con_work() calls try_write(), which sends the protocol negotiation info rather than the banner that the peer is expecting.
The result is that the peer sees an invalid banner, and the client reports "negotiation failed".
Fix this by moving con_out_kvec_reset() out of prepare_write_connect() to its callers at all locations except the one where the banner might still need to be sent.
[[email protected]: added note about server-side behavior]
--- net/ceph/messenger.c | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-)
net/ceph/messenger.c +9 -2
@@ -915,7 +915,6 @@ static int prepare_write_connect(struct ceph_connection *con) con->out_connect.authorizer_len = auth ?cpu_to_le32 (auth->authorizer_buf_len) :0 ; -con_out_kvec_reset (con);con_out_kvec_add (con,sizeof (con->out_connect), &con->out_connect);if (auth && auth->authorizer_buf_len)
@@ -1557,6 +1556,7 @@ static int process_connect(struct ceph_connection *con)return -1 ; } con->auth_retry =1 ; +con_out_kvec_reset (con); ret =prepare_write_connect (con);if (ret <0 )return ret;
@@ -1577,6 +1577,7 @@ static int process_connect(struct ceph_connection *con)ENTITY_NAME (con->peer_name), ceph_pr_addr(&con->peer_addr.in_addr));reset_connection (con); +con_out_kvec_reset (con); ret =prepare_write_connect (con);if (ret <0 )return ret;
@@ -1601,6 +1602,7 @@ static int process_connect(struct ceph_connection *con)le32_to_cpu (con->out_connect.connect_seq), le32_to_cpu(con->in_reply.connect_seq)); con->connect_seq =le32_to_cpu (con->in_reply.connect_seq); +con_out_kvec_reset (con); ret =prepare_write_connect (con);if (ret <0 )return ret;
@@ -1617,6 +1619,7 @@ static int process_connect(struct ceph_connection *con) le32_to_cpu(con->in_reply.global_seq));get_global_seq (con->msgr,le32_to_cpu (con->in_reply.global_seq)); +con_out_kvec_reset (con); ret =prepare_write_connect (con);if (ret <0 )return ret;
@@ -2135,7 +2138,11 @@ more:BUG_ON (con->state !=CON_STATE_CONNECTING ); con->state =CON_STATE_NEGOTIATING ; -/* Banner is good, exchange connection info */ +/* +* Received banner is good, exchange connection info. +* Do not reset out_kvec, as sending our banner raced +* with receiving peer banner after connect completed. +*/ ret =prepare_write_connect (con);if (ret <0 ) goto out;
Signature · 1 line
1.7.9
PATCH 4/4 ceph: avoid divide by zero in __validate_layout()
In reply to Sage WeilIf "l->stripe_unit" is zero the the mod on the next line will cause a divide by zero bug. This comes from the copy_from_user() in ceph_ioctl_set_layout_policy(). Passing 0 is valid, though (it means "do not change") so avoid the % check in that case.
--- fs/ceph/ioctl.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/ceph/ioctl.c +2 -1
@@ -42,7 +42,8 @@ static long __validate_layout(struct ceph_mds_client *mdsc,/* validate striping parameters */ if ((l->object_size & ~PAGE_MASK ) || (l->stripe_unit & ~PAGE_MASK ) || - ((unsigned )l->object_size % (unsigned )l->stripe_unit)) + (l->stripe_unit !=0 && + ((unsigned )l->object_size % (unsigned )l->stripe_unit)))return -EINVAL ;/* make sure it's a valid data pool */
Signature · 1 line
1.7.9