From: Tang Junhui Date: Thu, 15 Nov 2018 07:16:44 +0000 (+0800) Subject: client: fix failure in quota size limitation when using samba X-Git-Tag: v14.1.0~596^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c14ca19ed42cde552ec8d1f933aa209e891040e8;p=ceph.git client: fix failure in quota size limitation when using samba In samba, Client::_write may be called with the offset a negative number, and use the f->pos as the real write offset, in such condition, quota size can not limite the writes enven it exceeds the size limitation. Signed-off-by: Junhui Tang Fixes: http://tracker.ceph.com/issues/37547 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 426abac9cfe..c52c8842469 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -9408,13 +9408,6 @@ int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, if ((f->mode & CEPH_FILE_MODE_WR) == 0) return -EBADF; - // check quota - uint64_t endoff = offset + size; - if (endoff > in->size && is_quota_bytes_exceeded(in, endoff - in->size, - f->actor_perms)) { - return -EDQUOT; - } - // use/adjust fd pos? if (offset < 0) { lock_fh_pos(f); @@ -9434,6 +9427,13 @@ int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, unlock_fh_pos(f); } + // check quota + uint64_t endoff = offset + size; + if (endoff > in->size && is_quota_bytes_exceeded(in, endoff - in->size, + f->actor_perms)) { + return -EDQUOT; + } + //bool lazy = f->mode == CEPH_FILE_MODE_LAZY; ldout(cct, 10) << "cur file size is " << in->size << dendl;