From: Yan, Zheng Date: Fri, 19 May 2017 01:37:15 +0000 (+0800) Subject: client: update the 'approaching max_size' code X-Git-Tag: v12.1.0~434^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=9316b0442c6f828dcf8da952e4c7a63c4db1398d;p=ceph-ci.git client: update the 'approaching max_size' code 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" --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 98c987b00e9..287957856a5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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); } } }