]> git-server-git.apps.pok.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>
Mon, 4 Feb 2013 20:09:51 +0000 (12:09 -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>
(cherry picked from commit 09f28541e374ffac198e4d48082b064aae93cb2c)

src/mds/CInode.cc
src/mds/CInode.h

index af70b681ffc750f3f74c395b5e80862beef63ca0..e72d419784cde0cf34f37fe7bf13901740a5b6a5 100644 (file)
@@ -2663,13 +2663,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 e43ecf50fa33ba4add1cc16430ac23c50e1f462d..ceb551071a419e74b88683725d23f88b0d188518 100644 (file)
@@ -279,7 +279,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;
@@ -288,7 +289,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() {