summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-06-08 01:22:27 +0300
committerAmar Tumballi <amarts@redhat.com>2019-08-01 04:12:07 +0000
commitd68e426263708334945dff69b88218ed71a48033 (patch)
treec9739c005f4531493593e07c60594b4ad6944794 /xlators/storage/posix/src/posix-helpers.c
parentd7e449b0da35a30af876aef1bea1fb096d0c06dc (diff)
Multiple files: get trivial stuff done before lock
Initialize a dictionary for example seems to be prefectly fine to be done before taking a lock. Change-Id: Ib29516c4efa8f0e2b526d512beab488fcd16d2e7 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index bb20a93..f35a992 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2956,7 +2956,7 @@ posix_check_internal_writes(xlator_t *this, fd_t *fd, int sysfd, dict_t *xdata)
LOCK(&fd->inode->lock);
{
- val = dict_get(xdata, GF_PROTECT_FROM_EXTERNAL_WRITES);
+ val = dict_get_sizen(xdata, GF_PROTECT_FROM_EXTERNAL_WRITES);
if (val) {
ret = sys_fsetxattr(sysfd, GF_PROTECT_FROM_EXTERNAL_WRITES,
val->data, val->len, 0);
@@ -2969,7 +2969,7 @@ posix_check_internal_writes(xlator_t *this, fd_t *fd, int sysfd, dict_t *xdata)
goto out;
}
- if (dict_get(xdata, GF_AVOID_OVERWRITE)) {
+ if (dict_get_sizen(xdata, GF_AVOID_OVERWRITE)) {
xattrsize = sys_fgetxattr(sysfd, GF_PROTECT_FROM_EXTERNAL_WRITES,
NULL, 0);
if ((xattrsize == -1) &&
@@ -3344,14 +3344,20 @@ posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
{
gf_cs_obj_state state = GF_CS_ERROR;
int ret = 0;
+ gf_boolean_t is_cs_obj_status = _gf_false;
+ gf_boolean_t is_cs_obj_repair = _gf_false;
- if (!(dict_get(xattr_req, GF_CS_OBJECT_STATUS) ||
- dict_get(xattr_req, GF_CS_OBJECT_REPAIR)))
+ if (dict_get_sizen(xattr_req, GF_CS_OBJECT_STATUS))
+ is_cs_obj_status = _gf_true;
+ if (dict_get_sizen(xattr_req, GF_CS_OBJECT_REPAIR))
+ is_cs_obj_repair = _gf_true;
+
+ if (!(is_cs_obj_status || is_cs_obj_repair))
return 0;
if (fd) {
LOCK(&fd->inode->lock);
- if (dict_get(xattr_req, GF_CS_OBJECT_STATUS)) {
+ if (is_cs_obj_status) {
state = posix_cs_check_status(this, NULL, pfd, buf);
gf_msg_debug(this->name, 0, "state : %d", state);
ret = posix_cs_set_state(this, xattr_rsp, state, NULL, pfd);
@@ -3371,7 +3377,7 @@ posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
}
}
- if (dict_get(xattr_req, GF_CS_OBJECT_REPAIR)) {
+ if (is_cs_obj_repair) {
state = posix_cs_check_status(this, NULL, pfd, buf);
gf_msg_debug(this->name, 0, "state : %d", state);
@@ -3402,7 +3408,7 @@ posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
}
LOCK(&loc->inode->lock);
- if (dict_get(xattr_req, GF_CS_OBJECT_STATUS)) {
+ if (is_cs_obj_status) {
state = posix_cs_check_status(this, realpath, NULL, buf);
gf_msg_debug(this->name, 0, "state : %d", state);
ret = posix_cs_set_state(this, xattr_rsp, state, realpath, NULL);
@@ -3422,7 +3428,7 @@ posix_cs_maintenance(xlator_t *this, fd_t *fd, loc_t *loc, int *pfd,
}
}
- if (dict_get(xattr_req, GF_CS_OBJECT_REPAIR)) {
+ if (is_cs_obj_repair) {
state = posix_cs_check_status(this, realpath, NULL, buf);
gf_msg_debug(this->name, 0, "state : %d", state);