]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix setting whole layout in one vxattr 5491/head
authorJohn Spray <john.spray@redhat.com>
Thu, 6 Aug 2015 12:10:08 +0000 (13:10 +0100)
committerJohn Spray <john.spray@redhat.com>
Thu, 6 Aug 2015 12:14:44 +0000 (13:14 +0100)
Previously we were validating the layout
after setting each field, so even when
setting multiple fields in one go (to
something valid) the intermediate states
could be invalid and cause a bogus EINVAL.

For example try setting object_size and stripe_unit
both to 2M in one go.

Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/Server.cc
src/mds/Server.h

index 5fbb5969109f66d3c930855bcbb738dea3ca6a38..8f4ca72c8c699d97e2a7562559d98dcb305241c3 100644 (file)
@@ -3865,7 +3865,7 @@ struct keys_and_values
 };
 
 int Server::parse_layout_vxattr(string name, string value, const OSDMap *osdmap,
-                               ceph_file_layout *layout)
+                               ceph_file_layout *layout, bool validate)
 {
   dout(20) << "parse_layout_vxattr name " << name << " value '" << value << "'" << dendl;
   try {
@@ -3882,7 +3882,10 @@ int Server::parse_layout_vxattr(string name, string value, const OSDMap *osdmap,
       if (begin != end)
        return -EINVAL;
       for (map<string,string>::iterator q = m.begin(); q != m.end(); ++q) {
-       int r = parse_layout_vxattr(string("layout.") + q->first, q->second, osdmap, layout);
+        // Skip validation on each attr, we do it once at the end (avoid
+        // rejecting intermediate states if the overall result is ok)
+       int r = parse_layout_vxattr(string("layout.") + q->first, q->second,
+                                    osdmap, layout, false);
        if (r < 0)
          return r;
       }
@@ -3912,7 +3915,7 @@ int Server::parse_layout_vxattr(string name, string value, const OSDMap *osdmap,
     return -EINVAL;
   }
 
-  if (!ceph_file_layout_is_valid(layout)) {
+  if (validate && !ceph_file_layout_is_valid(layout)) {
     dout(10) << "bad layout" << dendl;
     return -EINVAL;
   }
index 3b575ea2985992e9e33086995bc6be2db67636ca..4cd73d5c50850a3aab8c15b988f8592006600331 100644 (file)
@@ -176,7 +176,7 @@ public:
   void handle_client_setdirlayout(MDRequestRef& mdr);
 
   int parse_layout_vxattr(string name, string value, const OSDMap *osdmap,
-                         ceph_file_layout *layout);
+                         ceph_file_layout *layout, bool validate=true);
   int parse_quota_vxattr(string name, string value, quota_info_t *quota);
   void handle_set_vxattr(MDRequestRef& mdr, CInode *cur,
                         ceph_file_layout *dir_layout,