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
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);
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;