]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Setting pool on a file requires latest osdmap
authorSam Lang <sam.lang@inktank.com>
Tue, 12 Feb 2013 22:33:58 +0000 (16:33 -0600)
committerSage Weil <sage@inktank.com>
Tue, 12 Feb 2013 22:44:24 +0000 (14:44 -0800)
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 <sam.lang@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/mds/MDS.cc
src/mds/MDS.h
src/mds/Mutation.h
src/mds/Server.cc

index 0a3480ebced1ba15982bf38c7aa1f305ab7a2da6..e59f595591659669b31949ad62fc78ce853367af 100644 (file)
@@ -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)
 {
index f61ad8ddac55fa4406231cc8279ade32a82538a7..50555e831d9e3d71e37d3e5060ab822b1b1a8902 100644 (file)
@@ -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);
 
index 8866f6850c612415069c1c5732813f5fad7daa80..313edef30d8da24d930e80f26709dd3899b4bfe9 100644 (file)
@@ -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; 
   }
index 92f5bf6426838cfe40338f1c1e9c455f14849b3c..54585128eda064fa81674ac7fc8bd465c195f4d3 100644 (file)
@@ -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;
       }