diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2013-10-11 15:13:22 +0800 |
---|---|---|
committer | Yan, Zheng <zheng.z.yan@intel.com> | 2013-10-11 17:13:11 +0800 |
commit | eb381ffc8db14f13a7c5e3528a109bf89a7c5b31 (patch) | |
tree | bbbcb291d6419ae533239f3d8ae549fd811ff8bf | |
parent | cb9ebd6f363fb571ecb770eab9ab1313cb407108 (diff) | |
download | ceph-eb381ffc8db14f13a7c5e3528a109bf89a7c5b31.tar.gz |
mds: don't decrease file size when recovering filewip-filerecover
Otherwise we may truncate sparse file to wrong size
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
-rw-r--r-- | src/mds/Locker.cc | 9 | ||||
-rw-r--r-- | src/mds/MDCache.cc | 11 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 19c9176f414..7f852519714 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -2042,10 +2042,15 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock, inode_t *latest = in->get_projected_inode(); map<client_t, client_writeable_range_t> new_ranges; uint64_t size = latest->size; - if (update_size) - size = new_size; bool new_max = update_max; + if (update_size) { + new_size = size = MAX(size, new_size); + new_mtime = MAX(new_mtime, latest->mtime); + if (latest->size == new_size && latest->mtime == new_mtime) + update_size = false; + } + uint64_t client_range_size = update_max ? new_max_size : size; calc_new_client_ranges(in, client_range_size, new_ranges); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 9dc1229fbb9..c83bfcc7154 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -5787,21 +5787,15 @@ void MDCache::do_file_recover() dout(10) << "do_file_recover skipping " << in->inode.size << " " << *in << dendl; in->state_clear(CInode::STATE_RECOVERING); + mds->locker->eval(in, CEPH_LOCK_IFILE); in->auth_unpin(this); - if (in->filelock.is_stable()) { - bool need_issue = false; - mds->locker->eval(&in->filelock, &need_issue); - if (in->is_head() && need_issue) - mds->locker->issue_caps(in); - } else - mds->locker->eval_gather(&in->filelock); } } } void MDCache::_recovered(CInode *in, int r, uint64_t size, utime_t mtime) { - dout(10) << "_recovered r=" << r << " size=" << in->inode.size << " mtime=" << in->inode.mtime + dout(10) << "_recovered r=" << r << " size=" << size << " mtime=" << mtime << " for " << *in << dendl; if (r != 0) { @@ -5823,6 +5817,7 @@ void MDCache::_recovered(CInode *in, int r, uint64_t size, utime_t mtime) } else { // journal mds->locker->check_inode_max_size(in, true, true, size, false, 0, mtime); + mds->locker->eval(in, CEPH_LOCK_IFILE); in->auth_unpin(this); } |