From c14ca19ed42cde552ec8d1f933aa209e891040e8 Mon Sep 17 00:00:00 2001 From: Tang Junhui Date: Thu, 15 Nov 2018 15:16:44 +0800 Subject: [PATCH] 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 --- src/client/Client.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 426abac9cfe3..c52c88424698 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; -- 2.47.3