From: John Spray Date: Mon, 22 Jun 2015 15:05:35 +0000 (+0100) Subject: mds: add damage_flags_t to inode+frag X-Git-Tag: v9.0.3~38^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d44c7844e5e45809acf775f02df1a914bef3a9dd;p=ceph.git mds: add damage_flags_t to inode+frag Used to mark inodes+fnodes with flags indicating that particular types of damage have either been detected (scrub/fetch) or caused (cephfs-data-scan inject). This should serve as a cue to the MDS to do online repair of stats for the nodes that have been injected. Signed-off-by: John Spray --- diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 58ebf3f96643..858076a98cfb 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -1284,11 +1284,12 @@ void InodeStoreBase::encode_bare(bufferlist &bl, const bufferlist *snap_blob) co ::encode(bufferlist(), bl); ::encode(old_inodes, bl); ::encode(oldest_snap, bl); + ::encode(damage_flags, bl); } void InodeStoreBase::encode(bufferlist &bl, const bufferlist *snap_blob) const { - ENCODE_START(5, 4, bl); + ENCODE_START(6, 4, bl); encode_bare(bl, snap_blob); ENCODE_FINISH(bl); } @@ -1319,8 +1320,18 @@ void InodeStoreBase::decode_bare(bufferlist::iterator &bl, ::decode(inode.layout, bl); // but we only care about the layout portion } } - if (struct_v >= 5 && !bl.end()) - ::decode(oldest_snap, bl); + + if (struct_v >= 5) { + // InodeStore is embedded in dentries without proper versioning, so + // we consume up to the end of the buffer + if (!bl.end()) { + ::decode(oldest_snap, bl); + } + + if (!bl.end()) { + ::decode(damage_flags, bl); + } + } } diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 8b7a38db83f8..586ad3091d10 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -78,6 +78,7 @@ public: fragtree_t dirfragtree; // dir frag tree, if any. always consistent with our dirfrag map. compact_map old_inodes; // key = last, value.first = first snapid_t oldest_snap; + damage_flags_t damage_flags; InodeStoreBase() : oldest_snap(CEPH_NOSNAP) { } diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 370b11671e97..7a54915b379c 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -551,25 +551,29 @@ void old_inode_t::generate_test_instances(list& ls) */ void fnode_t::encode(bufferlist &bl) const { - ENCODE_START(2, 2, bl); + ENCODE_START(3, 2, bl); ::encode(version, bl); ::encode(snap_purged_thru, bl); ::encode(fragstat, bl); ::encode(accounted_fragstat, bl); ::encode(rstat, bl); ::encode(accounted_rstat, bl); + ::encode(damage_flags, bl); ENCODE_FINISH(bl); } void fnode_t::decode(bufferlist::iterator &bl) { - DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); + DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); ::decode(version, bl); ::decode(snap_purged_thru, bl); ::decode(fragstat, bl); ::decode(accounted_fragstat, bl); ::decode(rstat, bl); ::decode(accounted_rstat, bl); + if (struct_v >= 3) { + ::decode(damage_flags, bl); + } DECODE_FINISH(bl); } diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 55fd69eeb268..fbba7887d73d 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -405,6 +405,13 @@ public: }; WRITE_CLASS_ENCODER(inline_data_t) +enum { + DAMAGE_STATS, // statistics (dirstat, size, etc) + DAMAGE_RSTATS, // recursive statistics (rstat, accounted_rstat) + DAMAGE_FRAGTREE // fragtree -- repair by searching +}; +typedef uint32_t damage_flags_t; + /* * inode_t */ @@ -599,6 +606,7 @@ struct fnode_t { snapid_t snap_purged_thru; // the max_last_destroy snapid we've been purged thru frag_info_t fragstat, accounted_fragstat; nest_info_t rstat, accounted_rstat; + damage_flags_t damage_flags; void encode(bufferlist &bl) const; void decode(bufferlist::iterator& bl);