posix: Convert several posix_private members to gf_atomic
Change-Id: I629698d8ddf6f15428880bdc1501d36bc37b8ebb fixes: bz#1657607 Signed-off-by: Mohit Agrawal <moagrawal@redhat.com>
This commit is contained in:
parent
f578cdad23
commit
2261e444a4
@ -133,11 +133,7 @@ posix_aio_readv_complete(struct posix_aio_cb *paiocb, int res, int res2)
|
||||
if (!postbuf.ia_size || (offset + iov.iov_len) >= postbuf.ia_size)
|
||||
op_errno = ENOENT;
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->read_value += op_ret;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_ADD(priv->read_value, op_ret);
|
||||
|
||||
out:
|
||||
STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, &iov, 1, &postbuf,
|
||||
@ -301,11 +297,7 @@ posix_aio_writev_complete(struct posix_aio_cb *paiocb, int res, int res2)
|
||||
op_ret = res;
|
||||
op_errno = 0;
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->write_value += op_ret;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_ADD(priv->write_value, op_ret);
|
||||
|
||||
out:
|
||||
STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, &prebuf, &postbuf,
|
||||
|
@ -125,9 +125,10 @@ posix_priv(xlator_t *this)
|
||||
|
||||
gf_proc_dump_write("base_path", "%s", priv->base_path);
|
||||
gf_proc_dump_write("base_path_length", "%d", priv->base_path_length);
|
||||
gf_proc_dump_write("max_read", "%" PRId64, priv->read_value);
|
||||
gf_proc_dump_write("max_write", "%" PRId64, priv->write_value);
|
||||
gf_proc_dump_write("nr_files", "%" PRId64, priv->nr_files);
|
||||
gf_proc_dump_write("max_read", "%" PRId64, GF_ATOMIC_GET(priv->read_value));
|
||||
gf_proc_dump_write("max_write", "%" PRId64,
|
||||
GF_ATOMIC_GET(priv->write_value));
|
||||
gf_proc_dump_write("nr_files", "%ld", GF_ATOMIC_GET(priv->nr_files));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -775,6 +776,9 @@ posix_init(xlator_t *this)
|
||||
}
|
||||
|
||||
LOCK_INIT(&_private->lock);
|
||||
GF_ATOMIC_INIT(_private->nr_files, 0);
|
||||
GF_ATOMIC_INIT(_private->read_value, 0);
|
||||
GF_ATOMIC_INIT(_private->write_value, 0);
|
||||
|
||||
_private->export_statfs = 1;
|
||||
tmp_data = dict_get(this->options, "export-statfs-size");
|
||||
|
@ -2210,11 +2210,7 @@ fill_stat:
|
||||
gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_FD_PATH_SETTING_FAILED,
|
||||
"failed to set the fd context path=%s fd=%p", real_path, fd);
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->nr_files++;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_INC(priv->nr_files);
|
||||
|
||||
op_ret = 0;
|
||||
|
||||
|
@ -1476,12 +1476,7 @@ posix_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
|
||||
gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_FD_PATH_SETTING_FAILED,
|
||||
"failed to set the fd context path=%s fd=%p", real_path, fd);
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->nr_files++;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
|
||||
GF_ATOMIC_INC(priv->nr_files);
|
||||
op_ret = 0;
|
||||
|
||||
out:
|
||||
@ -1590,11 +1585,7 @@ posix_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
|
||||
goto out;
|
||||
}
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->read_value += op_ret;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_ADD(priv->read_value, op_ret);
|
||||
|
||||
vec.iov_base = iobuf->ptr;
|
||||
vec.iov_len = op_ret;
|
||||
@ -1940,11 +1931,7 @@ posix_writev(call_frame_t *frame, xlator_t *this, fd_t *fd,
|
||||
}
|
||||
}
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->write_value += op_ret;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_ADD(priv->write_value, op_ret);
|
||||
|
||||
out:
|
||||
|
||||
@ -2208,11 +2195,7 @@ posix_copy_file_range(call_frame_t *frame, xlator_t *this, fd_t *fd_in,
|
||||
* this comment (or add comment to explain why it is not
|
||||
* needed).
|
||||
*/
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->write_value += op_ret;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
GF_ATOMIC_ADD(priv->write_value, op_ret);
|
||||
|
||||
out:
|
||||
|
||||
@ -2371,12 +2354,7 @@ posix_release(xlator_t *this, fd_t *fd)
|
||||
if (!priv)
|
||||
goto out;
|
||||
|
||||
LOCK(&priv->lock);
|
||||
{
|
||||
priv->nr_files--;
|
||||
}
|
||||
UNLOCK(&priv->lock);
|
||||
|
||||
GF_ATOMIC_DEC(priv->nr_files);
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
@ -152,9 +152,9 @@ struct posix_private {
|
||||
time_t last_landfill_check;
|
||||
int32_t janitor_sleep_duration;
|
||||
|
||||
int64_t read_value; /* Total read, from init */
|
||||
int64_t write_value; /* Total write, from init */
|
||||
int64_t nr_files;
|
||||
gf_atomic_t read_value; /* Total read, from init */
|
||||
gf_atomic_t write_value; /* Total write, from init */
|
||||
gf_atomic_t nr_files;
|
||||
/*
|
||||
In some cases, two exported volumes may reside on the same
|
||||
partition on the server. Sending statvfs info for both
|
||||
|
Loading…
x
Reference in New Issue
Block a user