From b2c762beccf8ca260e3d2ad25ee9b7c62eeedbbb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 1 Sep 2011 13:01:06 -0700 Subject: [PATCH] mds: truncate sanity checks Hunting #1472. Signed-off-by: Sage Weil --- src/mds/CInode.cc | 4 ++++ src/mds/MDCache.cc | 2 ++ src/mds/mdstypes.h | 1 + 3 files changed, 7 insertions(+) diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index aa306adfcb868..528d1f8b9708f 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -129,6 +129,10 @@ ostream& operator<<(ostream& out, CInode& in) if (in.is_freezing_inode()) out << " FREEZING=" << in.auth_pin_freeze_allowance; if (in.is_frozen_inode()) out << " FROZEN"; + inode_t *pi = in.get_projected_inode(); + if (pi->is_truncating()) + out << " truncating(" << pi->truncate_from << " to " << pi->truncate_size << ")"; + // anchors if (in.is_anchored()) out << " anc"; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index e07479e2fe48b..5422f5b4992f4 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -5232,6 +5232,8 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) << pi->truncate_from << " -> " << pi->truncate_size << " on " << *in << dendl; + assert(pi->is_truncating()); + in->auth_pin(this); SnapRealm *realm = in->find_snaprealm(); diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 70f029740d04b..32f597277a175 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -430,6 +430,7 @@ struct inode_t { bool is_truncating() const { return (truncate_pending > 0); } void truncate(uint64_t old_size, uint64_t new_size) { + assert(new_size < old_size); truncate_from = old_size; size = new_size; rstat.rbytes = new_size; -- 2.39.5