]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix client view of dir layout when layout is removed
authorSage Weil <sage@inktank.com>
Sat, 19 Jan 2013 18:04:05 +0000 (10:04 -0800)
committerSage Weil <sage@inktank.com>
Wed, 30 Jan 2013 00:25:05 +0000 (16:25 -0800)
We weren't handling the case where the projected node has NULL for the
layout properly.  Fixes the client's view when we remove the dir layout.

Signed-off-by: Sage Weil <sage@inktank.com>
src/mds/CInode.cc
src/mds/CInode.h

index ebc94ba3615f3924b4ac9bd750b69aaedd35d049..33b4bfd23401a82369b535920c46d733e260c245 100644 (file)
@@ -2679,13 +2679,14 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
   i = pfile ? pi:oi;
   if (is_file()) {
     e.layout = i->layout;
-  } else {
-    if (ppolicy && get_projected_dir_layout())
-      e.layout = *get_projected_dir_layout();
-    else if (default_layout)
-      e.layout = default_layout->layout;
+  } else if (is_dir()) {
+    ceph_file_layout *l = ppolicy ? get_projected_dir_layout() : ( default_layout ? &default_layout->layout : NULL );
+    if (l)
+      e.layout = *l;
     else
       memset(&e.layout, 0, sizeof(e.layout));
+  } else {
+    memset(&e.layout, 0, sizeof(e.layout));
   }
   e.size = i->size;
   e.truncate_seq = i->truncate_seq;
index f2de6e572c509e4d1717c540b5197561f33a0b0e..8b18ce72f1e9d5fd56a8e68476c31c271dcbb401 100644 (file)
@@ -283,7 +283,8 @@ public:
   }
 
   ceph_file_layout *get_projected_dir_layout() {
-    if (!inode.is_dir()) return NULL;
+    if (!inode.is_dir())
+      return NULL;
     if (projected_nodes.empty()) {
       if (default_layout)
         return &default_layout->layout;
@@ -292,7 +293,8 @@ public:
     }
     else if (projected_nodes.back()->dir_layout)
       return &projected_nodes.back()->dir_layout->layout;
-    else return NULL;
+    else
+      return NULL;
   }
 
   version_t get_projected_version() {