]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: Conditionally encode default dir layout.
authorGreg Farnum <gregf@hq.newdream.net>
Wed, 29 Sep 2010 21:18:23 +0000 (14:18 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Mon, 4 Oct 2010 18:04:45 +0000 (11:04 -0700)
Previously we unconditionally encoded the standard layout, which
on a directory inode is meaningless. So, use that spot to fill
in the default dir layout, if it exists. Otherwise, zero-fill.
This lets us display default directory layouts without changing
the protocol, which is good.

src/mds/CInode.cc

index 62ea66976fac4b465f5f3bd379894304fddf3966..6f72923db4557c61bbbe81acce8c8ba596595b20 100644 (file)
@@ -1915,6 +1915,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
   bool pxattr = xattrlock.is_xlocked_by_client(client) || get_loner() == client;
 
   bool plocal = versionlock.get_last_wrlock_client() == client;
+  bool ppolicy = policylock.is_xlocked_by_client(client) || get_loner()==client;
   
   inode_t *i = (pfile|pauth|plink|pxattr|plocal) ? pi : oi;
   i->ctime.encode_timeval(&e.ctime);
@@ -1926,7 +1927,16 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session,
 
   // file
   i = pfile ? pi:oi;
-  e.layout = i->layout;
+  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
+      memset(&e.layout, 0, sizeof(e.layout));
+  }
   e.size = i->size;
   e.truncate_seq = i->truncate_seq;
   e.truncate_size = i->truncate_size;