diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2018-03-19 15:12:14 +0530 |
---|---|---|
committer | Pranith Kumar K <pkarampu@redhat.com> | 2018-03-21 10:36:31 +0530 |
commit | 2da6650dfa402143c7b9ea0e67bbda79d0475ddd (patch) | |
tree | 4b778625eaded65bfe998ce8cbcc69e9ce69b4d1 /xlators/storage/posix | |
parent | ade6262cb63b96834dce101a4a237c0c8128077e (diff) |
storage/posix: Add active-fd-count option in gluster
Problem:
when dd happens on sharded replicate volume all the writes on shards happen
through anon-fd. When the writes don't come quick enough, old anon-fd closes
and new fd gets created to serve the new writes. open-fd-count is decremented
only after the fd is closed as part of fd_destroy(). So even when one fd is on
the way to be closed a new fd will be created and during this short period it
appears as though there are multiple fds opened on the file. AFR thinks another
application opened the same file and switches off eager-lock leading to
extra latency.
Fix:
Have a different option called active-fd whose life cycle starts at
fd_bind() and ends just before fd_destroy()
BUG: 1557932
Change-Id: I2e221f6030feeedf29fbb3bd6554673b8a5b9c94
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/storage/posix')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 52 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-inode-fd-ops.c | 12 |
2 files changed, 32 insertions, 32 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 377389d22a3..816fb3587d2 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -392,27 +392,6 @@ _get_filler_inode (posix_xattr_filler_t *filler) } static int -_posix_filler_get_openfd_count (posix_xattr_filler_t *filler, char *key) -{ - inode_t *inode = NULL; - int ret = -1; - - inode = _get_filler_inode (filler); - if (!inode || gf_uuid_is_null (inode->gfid)) - goto out; - - ret = dict_set_uint32 (filler->xattr, key, inode->fd_count); - if (ret < 0) { - gf_msg (filler->this->name, GF_LOG_WARNING, 0, - P_MSG_DICT_SET_FAILED, - "Failed to set dictionary value for %s", key); - goto out; - } -out: - return ret; -} - -static int _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, void *xattrargs) { @@ -420,11 +399,11 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, int ret = -1; char *databuf = NULL; int _fd = -1; - loc_t *loc = NULL; ssize_t req_size = 0; int32_t list_offset = 0; ssize_t remaining_size = 0; char *xattr = NULL; + inode_t *inode = NULL; if (posix_xattr_ignorable (key)) goto out; @@ -500,16 +479,25 @@ _posix_xattr_get_set (dict_t *xattr_req, char *key, data_t *data, GF_FREE (databuf); } } else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) { - ret = _posix_filler_get_openfd_count (filler, key); - loc = filler->loc; - if (loc) { - ret = dict_set_uint32 (filler->xattr, key, - loc->inode->fd_count); - if (ret < 0) - gf_msg (filler->this->name, GF_LOG_WARNING, 0, - P_MSG_XDATA_GETXATTR, - "Failed to set dictionary value for %s", - key); + inode = _get_filler_inode (filler); + if (!inode || gf_uuid_is_null (inode->gfid)) + goto out; + ret = dict_set_uint32 (filler->xattr, key, inode->fd_count); + if (ret < 0) { + gf_msg (filler->this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, + "Failed to set dictionary value for %s", key); + } + } else if (!strcmp (key, GLUSTERFS_ACTIVE_FD_COUNT)) { + inode = _get_filler_inode (filler); + if (!inode || gf_uuid_is_null (inode->gfid)) + goto out; + ret = dict_set_uint32 (filler->xattr, key, + inode->active_fd_count); + if (ret < 0) { + gf_msg (filler->this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, + "Failed to set dictionary value for %s", key); } } else if (!strcmp (key, GET_ANCESTRY_PATH_KEY)) { /* As of now, the only consumers of POSIX_ANCESTRY_PATH attempt diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index bca7419eee0..dafac59fe5b 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -1526,6 +1526,18 @@ _fill_writev_xdata (fd_t *fd, dict_t *xdata, xlator_t *this, int is_append) } } + if (dict_get (xdata, GLUSTERFS_ACTIVE_FD_COUNT)) { + ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_ACTIVE_FD_COUNT, + fd->inode->active_fd_count); + if (ret < 0) { + gf_msg (this->name, GF_LOG_WARNING, 0, + P_MSG_DICT_SET_FAILED, "%s: Failed to set " + "dictionary value for %s", + uuid_utoa (fd->inode->gfid), + GLUSTERFS_ACTIVE_FD_COUNT); + } + } + if (dict_get (xdata, GLUSTERFS_WRITE_IS_APPEND)) { ret = dict_set_uint32 (rsp_xdata, GLUSTERFS_WRITE_IS_APPEND, is_append); |