From: Sage Weil Date: Sat, 19 Jan 2013 18:04:05 +0000 (-0800) Subject: mds: fix client view of dir layout when layout is removed X-Git-Tag: v0.57~84^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09f28541e374ffac198e4d48082b064aae93cb2c;p=ceph.git mds: fix client view of dir layout when layout is removed 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 --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index ebc94ba3615f..33b4bfd23401 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -2679,13 +2679,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; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index f2de6e572c50..8b18ce72f1e9 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -283,7 +283,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; @@ -292,7 +293,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() {