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
/* 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;
}
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;
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);
}
}
}