]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
client: update the 'approaching max_size' code
authorYan, Zheng <zyan@redhat.com>
Fri, 19 May 2017 01:37:15 +0000 (09:37 +0800)
committerYan, Zheng <zyan@redhat.com>
Mon, 22 May 2017 08:46:02 +0000 (16:46 +0800)
The old 'approaching max_size' code expects MDS set max_size to
'2 x reported_size'. This is no longer true. The new code reports
file size when half of previous max_size increment has been used.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/client/Client.cc

index 98c987b00e92ccecb24f78765074278b9269bef7..287957856a536fa388c2d7eb67e811679ea179e4 100644 (file)
@@ -3280,6 +3280,19 @@ void Client::send_cap(Inode *in, MetaSession *session, Cap *cap,
   session->con->send_message(m);
 }
 
+static bool is_max_size_approaching(Inode *in)
+{
+  /* mds will adjust max size according to the reported size */
+  if (in->flushing_caps & CEPH_CAP_FILE_WR)
+    return false;
+  if (in->size >= in->max_size)
+    return true;
+  /* half of previous max_size increment has been used */
+  if (in->max_size > in->reported_size &&
+      (in->size << 1) >= in->max_size + in->reported_size)
+    return true;
+  return false;
+}
 
 /**
  * check_caps
@@ -3370,11 +3383,10 @@ void Client::check_caps(Inode *in, unsigned flags)
 
     /* approaching file_max? */
     if ((cap->issued & CEPH_CAP_FILE_WR) &&
-       (in->size << 1) >= in->max_size &&
-       (in->reported_size << 1) < in->max_size &&
-       cap == in->auth_cap) {
+       cap == in->auth_cap &&
+       is_max_size_approaching(in)) {
       ldout(cct, 10) << "size " << in->size << " approaching max_size " << in->max_size
-              << ", reported " << in->reported_size << dendl;
+                    << ", reported " << in->reported_size << dendl;
       goto ack;
     }
 
@@ -9002,10 +9014,8 @@ success:
 
     if (is_quota_bytes_approaching(in, f->actor_perms)) {
       check_caps(in, CHECK_CAPS_NODELAY);
-    } else {
-      if ((in->size << 1) >= in->max_size &&
-          (in->reported_size << 1) < in->max_size)
-        check_caps(in, 0);
+    } else if (is_max_size_approaching(in)) {
+      check_caps(in, 0);
     }
 
     ldout(cct, 7) << "wrote to " << totalwritten+offset << ", extending file size" << dendl;
@@ -12399,10 +12409,8 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length)
 
       if (is_quota_bytes_approaching(in, fh->actor_perms)) {
         check_caps(in, CHECK_CAPS_NODELAY);
-      } else {
-        if ((in->size << 1) >= in->max_size &&
-            (in->reported_size << 1) < in->max_size)
-          check_caps(in, 0);
+      } else if (is_max_size_approaching(in)) {
+       check_caps(in, 0);
       }
     }
   }