diff options
Diffstat (limited to 'xlators/cluster/dht/src/dht-common.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-common.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c index 4f02d18f..722d891d 100644 --- a/xlators/cluster/dht/src/dht-common.c +++ b/xlators/cluster/dht/src/dht-common.c @@ -2891,11 +2891,16 @@ int dht_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, struct statvfs *statvfs, dict_t *xdata) { - dht_local_t *local = NULL; - int this_call_cnt = 0; - int bsize = 0; - int frsize = 0; + dht_local_t *local = NULL; + int this_call_cnt = 0; + int bsize = 0; + int frsize = 0; + int8_t quota_deem_statfs = 0; + GF_UNUSED int ret = 0; + unsigned long new_usage = 0; + unsigned long cur_usage = 0; + ret = dict_get_int8 (xdata, "quota-deem-statfs", "a_deem_statfs); local = frame->local; @@ -2905,8 +2910,22 @@ dht_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->op_errno = op_errno; goto unlock; } + if (!statvfs) { + op_errno = EINVAL; + local->op_ret = -1; + goto unlock; + } local->op_ret = 0; + if (quota_deem_statfs) { + new_usage = statvfs->f_blocks - statvfs->f_bfree; + cur_usage = local->statvfs.f_blocks - local->statvfs.f_bfree; + /* We take the maximux of the usage from the subvols */ + if (new_usage >= cur_usage) + local->statvfs = *statvfs; + goto unlock; + } + if (local->statvfs.f_bsize != 0) { bsize = max(local->statvfs.f_bsize, statvfs->f_bsize); frsize = max(local->statvfs.f_frsize, statvfs->f_frsize); @@ -2927,6 +2946,7 @@ dht_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this, local->statvfs.f_flag = statvfs->f_flag; local->statvfs.f_namemax = statvfs->f_namemax; + } unlock: UNLOCK (&frame->lock); |