diff options
author | chenglin130 <35245387+chenglin130@users.noreply.github.com> | 2021-04-01 22:03:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-01 19:33:34 +0530 |
commit | a23fcdf13fce0c9c606ac18b791ceccc3bceb7eb (patch) | |
tree | f8cb581248bd68ac76a224629883976d5e3564e8 | |
parent | 7f313485ce018a0ddf7d2f0f745a9fb70bc4b3a6 (diff) | |
download | glusterfs-a23fcdf13fce0c9c606ac18b791ceccc3bceb7eb.tar.gz glusterfs-a23fcdf13fce0c9c606ac18b791ceccc3bceb7eb.tar.xz glusterfs-a23fcdf13fce0c9c606ac18b791ceccc3bceb7eb.zip |
marker: initiate xattrs QUOTA_SIZE_KEY for empty volume (#2261)
* marker: initiate quota xattrs for empty volume
When a VOL is empty, it's failed to list quota info after setting limit-usage.
# gluster volume quota gv0 list
/ N/A N/A N/A N/A N/A N/A
Because there is no QUOTA_SIZE_KEY in the xattrs of the VOL directory.
# getfattr -d -m. -e hex /data/brick2/gv0
getfattr: Removing leading '/' from absolute path names
# file: data/brick2/gv0
security.selinux=0x73797374656d5f753a6f626a6563745f723a676c7573746572645f627269636b5f743a733000
trusted.gfid=0x00000000000000000000000000000001
trusted.glusterfs.mdata=0x01000000000000000000000000603e70f6000000003b3f3c8000000000603e70f6000000003351d14000000000603e70f9000000000ff95b00
trusted.glusterfs.quota.limit-set.1=0x0000000000a00000ffffffffffffffff
trusted.glusterfs.volume-id=0xe27d61be048c4195a9e1ee349775eb59
This patch fix it by setting QUOTA_SIZE_KEY for the empty VOL directory when quota enable.
# gluster volume quota gv0 list
Path Hard-limit Soft-limit Used Available Soft-limit exceeded? Hard-limit exceeded?
-------------------------------------------------------------------------------------------------------------------------------
/ 4.0MB 80%(3.2MB) 0Bytes 4.0MB No No
Fixes: #2260
Change-Id: I6ab3e43d6ef33e5ce9531b48e62fce9e8b3fc555
Signed-off-by: Cheng Lin <cheng.lin130@zte.com.cn>
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 10 | ||||
-rw-r--r-- | xlators/features/marker/src/marker.c | 7 |
2 files changed, 12 insertions, 5 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index 3de2ea1c92..a8456d215b 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -1017,11 +1017,6 @@ mq_update_size(xlator_t *this, loc_t *loc, quota_meta_t *delta) GF_VALIDATE_OR_GOTO("marker", loc->inode, out); GF_VALIDATE_OR_GOTO("marker", delta, out); - if (quota_meta_is_null(delta)) { - ret = 0; - goto out; - } - ret = mq_inode_ctx_get(loc->inode, this, &ctx); if (ret < 0) { gf_log(this->name, GF_LOG_ERROR, @@ -1031,6 +1026,11 @@ mq_update_size(xlator_t *this, loc_t *loc, quota_meta_t *delta) goto out; } + if (quota_meta_is_null(delta) && (ctx->dir_count != 0)) { + ret = 0; + goto out; + } + dict = dict_new(); if (!dict) { gf_log(this->name, GF_LOG_ERROR, "dict_new failed"); diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 9b273464aa..9269abec9d 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -3068,6 +3068,7 @@ marker_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int ret = -1; char *resolvedpath = NULL; quota_inode_ctx_t *ctx = NULL; + int no_found_entry = 1; if (op_ret <= 0) goto unwind; @@ -3085,6 +3086,9 @@ marker_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, (strcmp(entry->d_name, "..") == 0) || entry->inode == NULL) continue; + if (no_found_entry) + no_found_entry = 0; + loc.parent = inode_ref(local->loc.inode); loc.inode = inode_ref(entry->inode); ret = inode_path(loc.parent, entry->d_name, &resolvedpath); @@ -3118,6 +3122,9 @@ marker_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, } } + if (no_found_entry && loc_is_root(&local->loc)) + mq_create_xattrs_txn(this, &local->loc, NULL); + unwind: MARKER_STACK_UNWIND(readdirp, frame, op_ret, op_errno, entries, xdata); |