|
|
14f8ab |
From 17a9ce965ef2fec9ee5c8e4b76981bb7cbcf1352 Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: mohit84 <moagrawa@redhat.com>
|
|
|
14f8ab |
Date: Mon, 9 Nov 2020 17:15:42 +0530
|
|
|
14f8ab |
Subject: [PATCH 506/511] posix: Attach a posix_spawn_disk_thread with
|
|
|
14f8ab |
glusterfs_ctx (#1595)
|
|
|
14f8ab |
|
|
|
14f8ab |
Currently posix xlator spawns posix_disk_space_threads per brick and in
|
|
|
14f8ab |
case of brick_mux environment while glusterd attached bricks at maximum
|
|
|
14f8ab |
level(250) with a single brick process in that case 250 threads are
|
|
|
14f8ab |
spawned for all bricks and brick process memory size also increased.
|
|
|
14f8ab |
|
|
|
14f8ab |
Solution: Attach a posix_disk_space thread with glusterfs_ctx to
|
|
|
14f8ab |
spawn a thread per process basis instead of spawning a per brick
|
|
|
14f8ab |
|
|
|
14f8ab |
> Fixes: #1482
|
|
|
14f8ab |
> Change-Id: I8dd88f252a950495b71742e2a7588bd5bb019ec7
|
|
|
14f8ab |
> Cherry-picked from commit 3f93be77e1acf5baacafa97a320e91e6879d1c0e
|
|
|
14f8ab |
> Reviewed on upstream link https://github.com/gluster/glusterfs/issues/1482
|
|
|
14f8ab |
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
Change-Id: I8dd88f252a950495b71742e2a7588bd5bb019ec7
|
|
|
14f8ab |
Bug: 1898776
|
|
|
14f8ab |
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/220366
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
glusterfsd/src/glusterfsd.c | 4 +
|
|
|
14f8ab |
libglusterfs/src/glusterfs/glusterfs.h | 6 ++
|
|
|
14f8ab |
xlators/storage/posix/src/posix-common.c | 68 +++++++++++--
|
|
|
14f8ab |
xlators/storage/posix/src/posix-handle.h | 3 +-
|
|
|
14f8ab |
xlators/storage/posix/src/posix-helpers.c | 131 ++++++++++++++-----------
|
|
|
14f8ab |
xlators/storage/posix/src/posix-inode-fd-ops.c | 3 +-
|
|
|
14f8ab |
xlators/storage/posix/src/posix-mem-types.h | 1 +
|
|
|
14f8ab |
xlators/storage/posix/src/posix.h | 12 ++-
|
|
|
14f8ab |
8 files changed, 160 insertions(+), 68 deletions(-)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
|
|
|
14f8ab |
index 955bf1d..ac25255 100644
|
|
|
14f8ab |
--- a/glusterfsd/src/glusterfsd.c
|
|
|
14f8ab |
+++ b/glusterfsd/src/glusterfsd.c
|
|
|
14f8ab |
@@ -1840,9 +1840,13 @@ glusterfs_ctx_defaults_init(glusterfs_ctx_t *ctx)
|
|
|
14f8ab |
INIT_LIST_HEAD(&cmd_args->xlator_options);
|
|
|
14f8ab |
INIT_LIST_HEAD(&cmd_args->volfile_servers);
|
|
|
14f8ab |
ctx->pxl_count = 0;
|
|
|
14f8ab |
+ ctx->diskxl_count = 0;
|
|
|
14f8ab |
pthread_mutex_init(&ctx->fd_lock, NULL);
|
|
|
14f8ab |
pthread_cond_init(&ctx->fd_cond, NULL);
|
|
|
14f8ab |
INIT_LIST_HEAD(&ctx->janitor_fds);
|
|
|
14f8ab |
+ pthread_mutex_init(&ctx->xl_lock, NULL);
|
|
|
14f8ab |
+ pthread_cond_init(&ctx->xl_cond, NULL);
|
|
|
14f8ab |
+ INIT_LIST_HEAD(&ctx->diskth_xl);
|
|
|
14f8ab |
|
|
|
14f8ab |
lim.rlim_cur = RLIM_INFINITY;
|
|
|
14f8ab |
lim.rlim_max = RLIM_INFINITY;
|
|
|
14f8ab |
diff --git a/libglusterfs/src/glusterfs/glusterfs.h b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
index bf6a987..d3400bf 100644
|
|
|
14f8ab |
--- a/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
+++ b/libglusterfs/src/glusterfs/glusterfs.h
|
|
|
14f8ab |
@@ -740,7 +740,13 @@ struct _glusterfs_ctx {
|
|
|
14f8ab |
pthread_t janitor;
|
|
|
14f8ab |
/* The variable is use to save total posix xlator count */
|
|
|
14f8ab |
uint32_t pxl_count;
|
|
|
14f8ab |
+ uint32_t diskxl_count;
|
|
|
14f8ab |
|
|
|
14f8ab |
+ /* List of posix xlator use by disk thread*/
|
|
|
14f8ab |
+ struct list_head diskth_xl;
|
|
|
14f8ab |
+ pthread_mutex_t xl_lock;
|
|
|
14f8ab |
+ pthread_cond_t xl_cond;
|
|
|
14f8ab |
+ pthread_t disk_space_check;
|
|
|
14f8ab |
char volume_id[GF_UUID_BUF_SIZE]; /* Used only in protocol/client */
|
|
|
14f8ab |
};
|
|
|
14f8ab |
typedef struct _glusterfs_ctx glusterfs_ctx_t;
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix-common.c b/xlators/storage/posix/src/posix-common.c
|
|
|
14f8ab |
index e5c6e62..2c9030b 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix-common.c
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix-common.c
|
|
|
14f8ab |
@@ -138,6 +138,36 @@ posix_inode(xlator_t *this)
|
|
|
14f8ab |
return 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+static void
|
|
|
14f8ab |
+delete_posix_diskxl(xlator_t *this)
|
|
|
14f8ab |
+{
|
|
|
14f8ab |
+ struct posix_private *priv = this->private;
|
|
|
14f8ab |
+ struct posix_diskxl *pxl = priv->pxl;
|
|
|
14f8ab |
+ glusterfs_ctx_t *ctx = this->ctx;
|
|
|
14f8ab |
+ uint32_t count = 1;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (pxl) {
|
|
|
14f8ab |
+ pthread_mutex_lock(&ctx->xl_lock);
|
|
|
14f8ab |
+ {
|
|
|
14f8ab |
+ pxl->detach_notify = _gf_true;
|
|
|
14f8ab |
+ while (pxl->is_use)
|
|
|
14f8ab |
+ pthread_cond_wait(&pxl->cond, &ctx->xl_lock);
|
|
|
14f8ab |
+ list_del_init(&pxl->list);
|
|
|
14f8ab |
+ priv->pxl = NULL;
|
|
|
14f8ab |
+ count = --ctx->diskxl_count;
|
|
|
14f8ab |
+ if (count == 0)
|
|
|
14f8ab |
+ pthread_cond_signal(&ctx->xl_cond);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
+ pthread_cond_destroy(&pxl->cond);
|
|
|
14f8ab |
+ GF_FREE(pxl);
|
|
|
14f8ab |
+ if (count == 0) {
|
|
|
14f8ab |
+ pthread_join(ctx->disk_space_check, NULL);
|
|
|
14f8ab |
+ ctx->disk_space_check = 0;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
/**
|
|
|
14f8ab |
* notify - when parent sends PARENT_UP, send CHILD_UP event from here
|
|
|
14f8ab |
*/
|
|
|
14f8ab |
@@ -194,6 +224,8 @@ posix_notify(xlator_t *this, int32_t event, void *data, ...)
|
|
|
14f8ab |
}
|
|
|
14f8ab |
pthread_mutex_unlock(&ctx->fd_lock);
|
|
|
14f8ab |
|
|
|
14f8ab |
+ delete_posix_diskxl(this);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
gf_log(this->name, GF_LOG_INFO, "Sending CHILD_DOWN for brick %s",
|
|
|
14f8ab |
victim->name);
|
|
|
14f8ab |
default_notify(this->parents->xlator, GF_EVENT_CHILD_DOWN, data);
|
|
|
14f8ab |
@@ -318,6 +350,7 @@ posix_reconfigure(xlator_t *this, dict_t *options)
|
|
|
14f8ab |
int32_t force_directory_mode = -1;
|
|
|
14f8ab |
int32_t create_mask = -1;
|
|
|
14f8ab |
int32_t create_directory_mask = -1;
|
|
|
14f8ab |
+ double old_disk_reserve = 0.0;
|
|
|
14f8ab |
|
|
|
14f8ab |
priv = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -383,6 +416,7 @@ posix_reconfigure(xlator_t *this, dict_t *options)
|
|
|
14f8ab |
" fallback to <hostname>:<export>");
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+ old_disk_reserve = priv->disk_reserve;
|
|
|
14f8ab |
GF_OPTION_RECONF("reserve", priv->disk_reserve, options, percent_or_size,
|
|
|
14f8ab |
out);
|
|
|
14f8ab |
/* option can be any one of percent or bytes */
|
|
|
14f8ab |
@@ -390,11 +424,19 @@ posix_reconfigure(xlator_t *this, dict_t *options)
|
|
|
14f8ab |
if (priv->disk_reserve < 100.0)
|
|
|
14f8ab |
priv->disk_unit = 'p';
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (priv->disk_reserve) {
|
|
|
14f8ab |
+ /* Delete a pxl object from a list of disk_reserve while something
|
|
|
14f8ab |
+ is changed for reserve option during graph reconfigure
|
|
|
14f8ab |
+ */
|
|
|
14f8ab |
+ if (old_disk_reserve != priv->disk_reserve) {
|
|
|
14f8ab |
+ delete_posix_diskxl(this);
|
|
|
14f8ab |
+ old_disk_reserve = 0;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (!old_disk_reserve && priv->disk_reserve) {
|
|
|
14f8ab |
ret = posix_spawn_disk_space_check_thread(this);
|
|
|
14f8ab |
if (ret) {
|
|
|
14f8ab |
gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_DISK_SPACE_CHECK_FAILED,
|
|
|
14f8ab |
- "Getting disk space check from thread failed");
|
|
|
14f8ab |
+ "Getting disk space check from thread failed ");
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
}
|
|
|
14f8ab |
@@ -1008,13 +1050,13 @@ posix_init(xlator_t *this)
|
|
|
14f8ab |
" fallback to <hostname>:<export>");
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- _private->disk_space_check_active = _gf_false;
|
|
|
14f8ab |
_private->disk_space_full = 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
GF_OPTION_INIT("reserve", _private->disk_reserve, percent_or_size, out);
|
|
|
14f8ab |
|
|
|
14f8ab |
/* option can be any one of percent or bytes */
|
|
|
14f8ab |
_private->disk_unit = 0;
|
|
|
14f8ab |
+ pthread_cond_init(&_private->fd_cond, NULL);
|
|
|
14f8ab |
if (_private->disk_reserve < 100.0)
|
|
|
14f8ab |
_private->disk_unit = 'p';
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -1162,12 +1204,6 @@ posix_fini(xlator_t *this)
|
|
|
14f8ab |
priv->health_check = 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
- if (priv->disk_space_check) {
|
|
|
14f8ab |
- priv->disk_space_check_active = _gf_false;
|
|
|
14f8ab |
- (void)gf_thread_cleanup_xint(priv->disk_space_check);
|
|
|
14f8ab |
- priv->disk_space_check = 0;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
-
|
|
|
14f8ab |
if (priv->janitor) {
|
|
|
14f8ab |
/*TODO: Make sure the synctask is also complete */
|
|
|
14f8ab |
ret = gf_tw_del_timer(this->ctx->tw->timer_wheel, priv->janitor);
|
|
|
14f8ab |
@@ -1192,10 +1228,24 @@ posix_fini(xlator_t *this)
|
|
|
14f8ab |
pthread_join(ctx->janitor, NULL);
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
+ pthread_mutex_lock(&ctx->xl_lock);
|
|
|
14f8ab |
+ {
|
|
|
14f8ab |
+ count = --ctx->diskxl_count;
|
|
|
14f8ab |
+ if (count == 0)
|
|
|
14f8ab |
+ pthread_cond_signal(&ctx->xl_cond);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if (count == 0) {
|
|
|
14f8ab |
+ pthread_join(ctx->disk_space_check, NULL);
|
|
|
14f8ab |
+ ctx->disk_space_check = 0;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
if (priv->fsyncer) {
|
|
|
14f8ab |
(void)gf_thread_cleanup_xint(priv->fsyncer);
|
|
|
14f8ab |
priv->fsyncer = 0;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
+
|
|
|
14f8ab |
/*unlock brick dir*/
|
|
|
14f8ab |
if (priv->mount_lock)
|
|
|
14f8ab |
(void)sys_closedir(priv->mount_lock);
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix-handle.h b/xlators/storage/posix/src/posix-handle.h
|
|
|
14f8ab |
index c4d7cb1..8e4c719 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix-handle.h
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix-handle.h
|
|
|
14f8ab |
@@ -206,5 +206,6 @@ int
|
|
|
14f8ab |
posix_check_internal_writes(xlator_t *this, fd_t *fd, int sysfd, dict_t *xdata);
|
|
|
14f8ab |
|
|
|
14f8ab |
void
|
|
|
14f8ab |
-posix_disk_space_check(xlator_t *this);
|
|
|
14f8ab |
+posix_disk_space_check(struct posix_private* priv);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
#endif /* !_POSIX_HANDLE_H */
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
|
|
|
14f8ab |
index ceac52a..110d383 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix-helpers.c
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix-helpers.c
|
|
|
14f8ab |
@@ -2284,9 +2284,8 @@ unlock:
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
void
|
|
|
14f8ab |
-posix_disk_space_check(xlator_t *this)
|
|
|
14f8ab |
+posix_disk_space_check(struct posix_private *priv)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- struct posix_private *priv = NULL;
|
|
|
14f8ab |
char *subvol_path = NULL;
|
|
|
14f8ab |
int op_ret = 0;
|
|
|
14f8ab |
double size = 0;
|
|
|
14f8ab |
@@ -2295,16 +2294,14 @@ posix_disk_space_check(xlator_t *this)
|
|
|
14f8ab |
double totsz = 0;
|
|
|
14f8ab |
double freesz = 0;
|
|
|
14f8ab |
|
|
|
14f8ab |
- GF_VALIDATE_OR_GOTO(this->name, this, out);
|
|
|
14f8ab |
- priv = this->private;
|
|
|
14f8ab |
- GF_VALIDATE_OR_GOTO(this->name, priv, out);
|
|
|
14f8ab |
+ GF_VALIDATE_OR_GOTO("posix-helpers", priv, out);
|
|
|
14f8ab |
|
|
|
14f8ab |
subvol_path = priv->base_path;
|
|
|
14f8ab |
|
|
|
14f8ab |
op_ret = sys_statvfs(subvol_path, &buf;;
|
|
|
14f8ab |
|
|
|
14f8ab |
if (op_ret == -1) {
|
|
|
14f8ab |
- gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_STATVFS_FAILED,
|
|
|
14f8ab |
+ gf_msg("posix-disk", GF_LOG_ERROR, errno, P_MSG_STATVFS_FAILED,
|
|
|
14f8ab |
"statvfs failed on %s", subvol_path);
|
|
|
14f8ab |
goto out;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
@@ -2328,78 +2325,102 @@ out:
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
static void *
|
|
|
14f8ab |
-posix_disk_space_check_thread_proc(void *data)
|
|
|
14f8ab |
+posix_ctx_disk_thread_proc(void *data)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- xlator_t *this = NULL;
|
|
|
14f8ab |
struct posix_private *priv = NULL;
|
|
|
14f8ab |
+ glusterfs_ctx_t *ctx = NULL;
|
|
|
14f8ab |
uint32_t interval = 0;
|
|
|
14f8ab |
- int ret = -1;
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- this = data;
|
|
|
14f8ab |
- priv = this->private;
|
|
|
14f8ab |
+ struct posix_diskxl *pthis = NULL;
|
|
|
14f8ab |
+ xlator_t *this = NULL;
|
|
|
14f8ab |
+ struct timespec sleep_till = {
|
|
|
14f8ab |
+ 0,
|
|
|
14f8ab |
+ };
|
|
|
14f8ab |
|
|
|
14f8ab |
+ ctx = data;
|
|
|
14f8ab |
interval = 5;
|
|
|
14f8ab |
- gf_msg_debug(this->name, 0,
|
|
|
14f8ab |
- "disk-space thread started, "
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ gf_msg_debug("glusterfs_ctx", 0,
|
|
|
14f8ab |
+ "Ctx disk-space thread started, "
|
|
|
14f8ab |
"interval = %d seconds",
|
|
|
14f8ab |
interval);
|
|
|
14f8ab |
- while (1) {
|
|
|
14f8ab |
- /* aborting sleep() is a request to exit this thread, sleep()
|
|
|
14f8ab |
- * will normally not return when cancelled */
|
|
|
14f8ab |
- ret = sleep(interval);
|
|
|
14f8ab |
- if (ret > 0)
|
|
|
14f8ab |
- break;
|
|
|
14f8ab |
- /* prevent thread errors while doing the health-check(s) */
|
|
|
14f8ab |
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
|
|
14f8ab |
-
|
|
|
14f8ab |
- /* Do the disk-check.*/
|
|
|
14f8ab |
- posix_disk_space_check(this);
|
|
|
14f8ab |
- if (!priv->disk_space_check_active)
|
|
|
14f8ab |
- goto out;
|
|
|
14f8ab |
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
|
|
|
14f8ab |
-out:
|
|
|
14f8ab |
- gf_msg_debug(this->name, 0, "disk space check thread exiting");
|
|
|
14f8ab |
- LOCK(&priv->lock);
|
|
|
14f8ab |
+ pthread_mutex_lock(&ctx->xl_lock);
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- priv->disk_space_check_active = _gf_false;
|
|
|
14f8ab |
+ while (ctx->diskxl_count > 0) {
|
|
|
14f8ab |
+ list_for_each_entry(pthis, &ctx->diskth_xl, list)
|
|
|
14f8ab |
+ {
|
|
|
14f8ab |
+ pthis->is_use = _gf_true;
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ THIS = this = pthis->xl;
|
|
|
14f8ab |
+ priv = this->private;
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ posix_disk_space_check(priv);
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ pthread_mutex_lock(&ctx->xl_lock);
|
|
|
14f8ab |
+ pthis->is_use = _gf_false;
|
|
|
14f8ab |
+ /* Send a signal to posix_notify function */
|
|
|
14f8ab |
+ if (pthis->detach_notify)
|
|
|
14f8ab |
+ pthread_cond_signal(&pthis->cond);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ timespec_now_realtime(&sleep_till);
|
|
|
14f8ab |
+ sleep_till.tv_sec += 5;
|
|
|
14f8ab |
+ (void)pthread_cond_timedwait(&ctx->xl_cond, &ctx->xl_lock,
|
|
|
14f8ab |
+ &sleep_till);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
}
|
|
|
14f8ab |
- UNLOCK(&priv->lock);
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
|
|
|
14f8ab |
return NULL;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
int
|
|
|
14f8ab |
-posix_spawn_disk_space_check_thread(xlator_t *xl)
|
|
|
14f8ab |
+posix_spawn_disk_space_check_thread(xlator_t *this)
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- struct posix_private *priv = NULL;
|
|
|
14f8ab |
- int ret = -1;
|
|
|
14f8ab |
+ int ret = 0;
|
|
|
14f8ab |
+ glusterfs_ctx_t *ctx = this->ctx;
|
|
|
14f8ab |
+ struct posix_diskxl *pxl = NULL;
|
|
|
14f8ab |
+ struct posix_private *priv = this->private;
|
|
|
14f8ab |
|
|
|
14f8ab |
- priv = xl->private;
|
|
|
14f8ab |
+ pxl = GF_CALLOC(1, sizeof(struct posix_diskxl), gf_posix_mt_diskxl_t);
|
|
|
14f8ab |
+ if (!pxl) {
|
|
|
14f8ab |
+ ret = -ENOMEM;
|
|
|
14f8ab |
+ gf_log(this->name, GF_LOG_ERROR,
|
|
|
14f8ab |
+ "Calloc is failed to allocate "
|
|
|
14f8ab |
+ "memory for diskxl object");
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ pthread_cond_init(&pxl->cond, NULL);
|
|
|
14f8ab |
|
|
|
14f8ab |
- LOCK(&priv->lock);
|
|
|
14f8ab |
+ pthread_mutex_lock(&ctx->xl_lock);
|
|
|
14f8ab |
{
|
|
|
14f8ab |
- /* cancel the running thread */
|
|
|
14f8ab |
- if (priv->disk_space_check_active == _gf_true) {
|
|
|
14f8ab |
- pthread_cancel(priv->disk_space_check);
|
|
|
14f8ab |
- priv->disk_space_check_active = _gf_false;
|
|
|
14f8ab |
- }
|
|
|
14f8ab |
+ if (ctx->diskxl_count++ == 0) {
|
|
|
14f8ab |
+ ret = gf_thread_create(&ctx->disk_space_check, NULL,
|
|
|
14f8ab |
+ posix_ctx_disk_thread_proc, ctx,
|
|
|
14f8ab |
+ "posixctxres");
|
|
|
14f8ab |
|
|
|
14f8ab |
- ret = gf_thread_create(&priv->disk_space_check, NULL,
|
|
|
14f8ab |
- posix_disk_space_check_thread_proc, xl,
|
|
|
14f8ab |
- "posix_reserve");
|
|
|
14f8ab |
- if (ret) {
|
|
|
14f8ab |
- priv->disk_space_check_active = _gf_false;
|
|
|
14f8ab |
- gf_msg(xl->name, GF_LOG_ERROR, errno, P_MSG_DISK_SPACE_CHECK_FAILED,
|
|
|
14f8ab |
- "unable to setup disk space check thread");
|
|
|
14f8ab |
- goto unlock;
|
|
|
14f8ab |
+ if (ret) {
|
|
|
14f8ab |
+ gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_THREAD_FAILED,
|
|
|
14f8ab |
+ "spawning disk space check thread failed");
|
|
|
14f8ab |
+ ctx->diskxl_count--;
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
+ goto out;
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
}
|
|
|
14f8ab |
+ pxl->xl = this;
|
|
|
14f8ab |
+ priv->pxl = (void *)pxl;
|
|
|
14f8ab |
+ list_add_tail(&pxl->list, &ctx->diskth_xl);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
+ pthread_mutex_unlock(&ctx->xl_lock);
|
|
|
14f8ab |
|
|
|
14f8ab |
- priv->disk_space_check_active = _gf_true;
|
|
|
14f8ab |
+out:
|
|
|
14f8ab |
+ if (ret) {
|
|
|
14f8ab |
+ if (pxl) {
|
|
|
14f8ab |
+ pthread_cond_destroy(&pxl->cond);
|
|
|
14f8ab |
+ GF_FREE(pxl);
|
|
|
14f8ab |
+ }
|
|
|
14f8ab |
}
|
|
|
14f8ab |
-unlock:
|
|
|
14f8ab |
- UNLOCK(&priv->lock);
|
|
|
14f8ab |
return ret;
|
|
|
14f8ab |
}
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
14f8ab |
index 1d37aed..761e018 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
|
|
|
14f8ab |
@@ -37,6 +37,7 @@
|
|
|
14f8ab |
#include <fcntl.h>
|
|
|
14f8ab |
#endif /* HAVE_LINKAT */
|
|
|
14f8ab |
|
|
|
14f8ab |
+#include "posix-handle.h"
|
|
|
14f8ab |
#include <glusterfs/glusterfs.h>
|
|
|
14f8ab |
#include <glusterfs/checksum.h>
|
|
|
14f8ab |
#include <glusterfs/dict.h>
|
|
|
14f8ab |
@@ -713,7 +714,7 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
|
|
|
14f8ab |
option behaviour
|
|
|
14f8ab |
*/
|
|
|
14f8ab |
if (priv->disk_reserve)
|
|
|
14f8ab |
- posix_disk_space_check(this);
|
|
|
14f8ab |
+ posix_disk_space_check(priv);
|
|
|
14f8ab |
|
|
|
14f8ab |
DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, ret, ret, unlock);
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix-mem-types.h b/xlators/storage/posix/src/posix-mem-types.h
|
|
|
14f8ab |
index 2253f38..bb4c56d 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix-mem-types.h
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix-mem-types.h
|
|
|
14f8ab |
@@ -20,6 +20,7 @@ enum gf_posix_mem_types_ {
|
|
|
14f8ab |
gf_posix_mt_paiocb,
|
|
|
14f8ab |
gf_posix_mt_inode_ctx_t,
|
|
|
14f8ab |
gf_posix_mt_mdata_attr,
|
|
|
14f8ab |
+ gf_posix_mt_diskxl_t,
|
|
|
14f8ab |
gf_posix_mt_end
|
|
|
14f8ab |
};
|
|
|
14f8ab |
#endif
|
|
|
14f8ab |
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
|
|
|
14f8ab |
index 07f367b..4be979c 100644
|
|
|
14f8ab |
--- a/xlators/storage/posix/src/posix.h
|
|
|
14f8ab |
+++ b/xlators/storage/posix/src/posix.h
|
|
|
14f8ab |
@@ -36,7 +36,6 @@
|
|
|
14f8ab |
#include <glusterfs/compat.h>
|
|
|
14f8ab |
#include <glusterfs/timer.h>
|
|
|
14f8ab |
#include "posix-mem-types.h"
|
|
|
14f8ab |
-#include "posix-handle.h"
|
|
|
14f8ab |
#include <glusterfs/call-stub.h>
|
|
|
14f8ab |
|
|
|
14f8ab |
#ifdef HAVE_LIBAIO
|
|
|
14f8ab |
@@ -138,6 +137,14 @@ struct posix_fd {
|
|
|
14f8ab |
char _pad[4]; /* manual padding */
|
|
|
14f8ab |
};
|
|
|
14f8ab |
|
|
|
14f8ab |
+struct posix_diskxl {
|
|
|
14f8ab |
+ pthread_cond_t cond;
|
|
|
14f8ab |
+ struct list_head list;
|
|
|
14f8ab |
+ xlator_t *xl;
|
|
|
14f8ab |
+ gf_boolean_t detach_notify;
|
|
|
14f8ab |
+ gf_boolean_t is_use;
|
|
|
14f8ab |
+};
|
|
|
14f8ab |
+
|
|
|
14f8ab |
struct posix_private {
|
|
|
14f8ab |
char *base_path;
|
|
|
14f8ab |
int32_t base_path_length;
|
|
|
14f8ab |
@@ -207,6 +214,7 @@ struct posix_private {
|
|
|
14f8ab |
pthread_mutex_t janitor_mutex;
|
|
|
14f8ab |
pthread_cond_t janitor_cond;
|
|
|
14f8ab |
pthread_cond_t fd_cond;
|
|
|
14f8ab |
+ pthread_cond_t disk_cond;
|
|
|
14f8ab |
int fsync_queue_count;
|
|
|
14f8ab |
|
|
|
14f8ab |
enum {
|
|
|
14f8ab |
@@ -233,7 +241,6 @@ struct posix_private {
|
|
|
14f8ab |
char disk_unit;
|
|
|
14f8ab |
uint32_t disk_space_full;
|
|
|
14f8ab |
pthread_t disk_space_check;
|
|
|
14f8ab |
- gf_boolean_t disk_space_check_active;
|
|
|
14f8ab |
|
|
|
14f8ab |
#ifdef GF_DARWIN_HOST_OS
|
|
|
14f8ab |
enum {
|
|
|
14f8ab |
@@ -263,6 +270,7 @@ struct posix_private {
|
|
|
14f8ab |
gf_boolean_t ctime;
|
|
|
14f8ab |
gf_boolean_t janitor_task_stop;
|
|
|
14f8ab |
uint32_t rel_fdcount;
|
|
|
14f8ab |
+ void *pxl;
|
|
|
14f8ab |
};
|
|
|
14f8ab |
|
|
|
14f8ab |
typedef struct {
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|