Here's a fix for bug 1435.  The MDS didn't recover default_layout for
subdirs from dir entries encoded in the parent dir, so layout policies
could be lost upon MDS restart if they didn't happen to be encoded in
some other change still present in the MDS journal.

Fix restoring dir layouts from dir entries

From: Alexandre Oliva <[email protected]>

Signed-off-by: Alexandre Oliva <[email protected]>
---
 src/mds/CDir.cc |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc
index 4b1d3ef..e5a147d 100644
--- a/src/mds/CDir.cc
+++ b/src/mds/CDir.cc
@@ -1566,6 +1566,16 @@ void CDir::_fetched(bufferlist &bl, const string& want_dn)
 	  // symlink?
 	  if (in->is_symlink()) 
 	    in->symlink = symlink;
+	  else if (in->is_dir()) {
+	    default_file_layout dfl;
+	    memset(&dfl, 0, sizeof(dfl));
+	    // FIXME: this should be properly encoded
+	    if (memcmp (&dfl.layout, &in->inode.layout, sizeof(dfl)) != 0) {
+	      in->default_layout = new default_file_layout;
+	      memcpy (&in->default_layout->layout,
+		      &in->inode.layout, sizeof(dfl));
+	    }
+	  }
 	  
 	  in->dirfragtree.swap(fragtree);
 	  in->xattrs.swap(xattrs);

-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Reply via email to