From: Sam Lang Date: Tue, 12 Feb 2013 22:33:58 +0000 (-0600) Subject: mds: Setting pool on a file requires latest osdmap X-Git-Tag: v0.57~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=78ff229afae8eecd69bfab40e20925b00888894a;p=ceph.git mds: Setting pool on a file requires latest osdmap If we create a file, then create a pool, then try to set the pool on the file with the vxattr, no mds operation triggers a request for the latest osdmap, so we get back EINVAL. So if we fail to find the pool initially, fall back to requesting a new osdmap and trying the vxattr again. We don't wait for a new map if we don't get anything newer than what we already have. Signed-off-by: Sam Lang Reviewed-by: Sage Weil --- diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 0a3480ebced1..e59f59559165 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -690,6 +690,10 @@ void MDS::handle_mds_beacon(MMDSBeacon *m) m->put(); } +void MDS::request_osdmap(Context *c) { + objecter->wait_for_new_map(c, osdmap->get_epoch()); +} + /* This function DOES put the passed message before returning*/ void MDS::handle_command(MMonCommand *m) { diff --git a/src/mds/MDS.h b/src/mds/MDS.h index f61ad8ddac55..50555e831d9e 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -394,6 +394,8 @@ class MDS : public Dispatcher { void beacon_send(); void handle_mds_beacon(MMDSBeacon *m); + void request_osdmap(Context *c); + // messages bool _dispatch(Message *m); diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h index 8866f6850c61..313edef30d8d 100644 --- a/src/mds/Mutation.h +++ b/src/mds/Mutation.h @@ -191,6 +191,9 @@ struct MDRequest : public Mutation { // indicates how may retries of request have been made int retry; + // indicator for vxattr osdmap update + bool waited_for_osdmap; + // break rarely-used fields into a separately allocated structure // to save memory for most ops struct More { @@ -245,6 +248,7 @@ struct MDRequest : public Mutation { slave_request(0), internal_op(-1), retry(0), + waited_for_osdmap(false), _more(0) { in[0] = in[1] = 0; } @@ -257,6 +261,7 @@ struct MDRequest : public Mutation { slave_request(0), internal_op(-1), retry(0), + waited_for_osdmap(false), _more(0) { in[0] = in[1] = 0; } @@ -269,6 +274,7 @@ struct MDRequest : public Mutation { slave_request(0), internal_op(-1), retry(0), + waited_for_osdmap(false), _more(0) { in[0] = in[1] = 0; } diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 92f5bf642683..54585128eda0 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -3523,7 +3523,7 @@ int Server::parse_layout_vxattr(string name, string value, ceph_file_layout *lay int64_t pool = mds->osdmap->lookup_pg_pool_name(value); if (pool < 0) { dout(10) << " unknown pool " << value << dendl; - return -EINVAL; + return -ENOENT; } layout->fl_pg_pool = pool; } @@ -3581,6 +3581,17 @@ void Server::handle_set_vxattr(MDRequest *mdr, CInode *cur, rest = name.substr(name.find("layout")); int r = parse_layout_vxattr(rest, value, &dlayout->layout); if (r < 0) { + if (r == -ENOENT) { + if (!mdr->waited_for_osdmap) { + // send request to get latest map, but don't wait if + // we don't get anything newer than what we have + mdr->waited_for_osdmap = true; + mds->request_osdmap( + new C_MDS_RetryRequest(mdcache, mdr)); + return; + } + r = -EINVAL; + } reply_request(mdr, r); return; } @@ -3600,6 +3611,17 @@ void Server::handle_set_vxattr(MDRequest *mdr, CInode *cur, rest = name.substr(name.find("layout")); int r = parse_layout_vxattr(rest, value, &layout); if (r < 0) { + if (r == -ENOENT) { + if (!mdr->waited_for_osdmap) { + // send request to get latest map, but don't wait if + // we don't get anything newer than what we have + mdr->waited_for_osdmap = true; + mds->request_osdmap( + new C_MDS_RetryRequest(mdcache, mdr)); + return; + } + r = -EINVAL; + } reply_request(mdr, r); return; }