]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix failure in quota size limitation when using samba 25110/head
authorTang Junhui <tangjunhui@sangfor.com>
Thu, 15 Nov 2018 07:16:44 +0000 (15:16 +0800)
committerJunhui Tang <tangjunhui@sangfor.com.cn>
Sun, 9 Dec 2018 02:08:28 +0000 (10:08 +0800)
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 <tangjunhui@sangfor.com.cn>
Fixes: http://tracker.ceph.com/issues/37547
src/client/Client.cc

index 426abac9cfe3cb9d27b639798f4a63ee9bbc8cd4..c52c88424698f00ce86f387a7a023e5538fdc975 100644 (file)
@@ -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;