From 45fa4a2f4ebddd3d3a69c43fcb7ed031e04dad31 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Wed, 29 Sep 2010 14:18:23 -0700 Subject: [PATCH] mds: Conditionally encode default dir layout. 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 62ea66976fa..6f72923db45 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -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;