From: Sage Weil Date: Thu, 21 Oct 2010 20:07:38 +0000 (-0700) Subject: mds: fix inodestat encoding when frags are present X-Git-Tag: v0.23~152 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=32ba7760dd34eb3e4b92c4e7e0a0bcee8f88fcc1;p=ceph.git mds: fix inodestat encoding when frags are present Also simplify the max_size check calculation. Signed-off-by: Sage Weil --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 6311f39c30e7..7f1ba28872cc 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -2032,8 +2032,6 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, i = plink ? pi:oi; e.nlink = i->nlink; - e.fragtree.nsplits = dirfragtree._splits.size(); - // xattr i = pxattr ? pi:oi; bool had_latest_xattrs = cap && (cap->issued() & CEPH_CAP_XATTR_SHARED) && @@ -2049,25 +2047,13 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, ::encode(*pxattrs, xbl); } - bufferlist splits; - for (map::iterator p = dirfragtree._splits.begin(); - p != dirfragtree._splits.end(); - p++) { - ::encode(p->first, bl); - ::encode(p->second, bl); - } - // do we have room? if (max_bytes) { unsigned bytes = sizeof(e); bytes += sizeof(__u32); - for (map::iterator p = dirfragtree._splits.begin(); - p != dirfragtree._splits.end(); - p++) - bytes += sizeof(p->first) + sizeof(p->second); + bytes += (sizeof(__u32) + sizeof(__u32)) * dirfragtree._splits.size(); bytes += sizeof(__u32) + symlink.length(); bytes += sizeof(__u32) + xbl.length(); - if (bytes > max_bytes) return -ENOSPC; } @@ -2149,6 +2135,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, } // encode + e.fragtree.nsplits = dirfragtree._splits.size(); ::encode(e, bl); for (map::iterator p = dirfragtree._splits.begin(); p != dirfragtree._splits.end();