diff mbox

[bug,#1435] fix loss of dir layout info on mds restart

Message ID or38wsgn3v.fsf@livre.home (mailing list archive)
State New, archived
Headers show

Commit Message

Alexandre Oliva Feb. 19, 2013, 6:44 p.m. UTC
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.
diff mbox

Patch

Fix restoring dir layouts from dir entries

From: Alexandre Oliva <oliva@gnu.org>

Signed-off-by: Alexandre Oliva <oliva@gnu.org>
---
 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);