]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix stray purging in 'stripe_count > 1' case 8042/head
authorYan, Zheng <zyan@redhat.com>
Fri, 11 Mar 2016 03:13:43 +0000 (11:13 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 30 Mar 2016 02:09:41 +0000 (10:09 +0800)
Fixes: #15050
Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 99ec183973e0f4686673d93df02e5381543be51f)

src/mds/MDCache.cc

index f62afae4e4ab0e326ba93fec4a92201362230776..65847ba2a5937b22e7c0d4c8af8f655874bbde96 100644 (file)
@@ -9113,27 +9113,26 @@ void MDCache::truncate_stray(CDentry *dn)
   dout(10) << " realm " << *realm << dendl;
   const SnapContext *snapc = &realm->get_snap_context();
 
-  uint64_t period = (uint64_t)in->inode.layout.fl_object_size *
-                   (uint64_t)in->inode.layout.fl_stripe_count;
   uint64_t to = in->inode.get_max_size();
   to = MAX(in->inode.size, to);
   // when truncating a file, the filer does not delete stripe objects that are
   // truncated to zero. so we need to purge stripe objects up to the max size
   // the file has ever been.
   to = MAX(in->inode.max_size_ever, to);
-  if (period && to > period) {
-    uint64_t num = (to - 1) / period;
+  if (to > 0) {
+    uint64_t num = Striper::get_num_objects(in->inode.layout, to);
     dout(10) << "purge_stray 0~" << to << " objects 0~" << num
-      << " snapc " << snapc << " on " << *in << dendl;
-    mds->filer->purge_range(in->ino(), &in->inode.layout, *snapc,
-                           1, num, ceph_clock_now(g_ceph_context),
-                           0, gather.new_sub());
-  }
+            << " snapc " << snapc << " on " << *in << dendl;
 
-  // keep backtrace object
-  if (period && to > 0) {
+    // keep backtrace object
+    if (num > 1) {
+      mds->filer->purge_range(in->ino(), &in->inode.layout, *snapc,
+                             1, num - 1, ceph_clock_now(g_ceph_context),
+                             0, gather.new_sub());
+    }
     mds->filer->zero(in->ino(), &in->inode.layout, *snapc,
-                    0, period, ceph_clock_now(g_ceph_context),
+                    0, (uint64_t)in->inode.layout.fl_object_size,
+                    ceph_clock_now(g_ceph_context),
                     0, true, NULL, gather.new_sub());
   }
 
@@ -9205,16 +9204,14 @@ void MDCache::purge_stray(CDentry *dn)
   }
 
   if (in->is_file()) {
-    uint64_t period = (uint64_t)in->inode.layout.fl_object_size *
-                     (uint64_t)in->inode.layout.fl_stripe_count;
     uint64_t to = in->inode.get_max_size();
     to = MAX(in->inode.size, to);
     // when truncating a file, the filer does not delete stripe objects that are
     // truncated to zero. so we need to purge stripe objects up to the max size
     // the file has ever been.
     to = MAX(in->inode.max_size_ever, to);
-    if (to && period) {
-      uint64_t num = (to + period - 1) / period;
+    if (to > 0) {
+      uint64_t num = Striper::get_num_objects(in->inode.layout, to);
       dout(10) << "purge_stray 0~" << to << " objects 0~" << num
               << " snapc " << snapc << " on " << *in << dendl;
       mds->filer->purge_range(in->inode.ino, &in->inode.layout, *snapc,