summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorMohit Agrawal <moagrawa@redhat.com>2017-07-15 17:55:14 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-10-30 15:53:46 +0000
commita320f2021ee4dcab85483dbe10d85e797bd6b3b4 (patch)
tree4b9c2993b72dd388c33e5e40578ea9000e7f8494 /xlators
parentae9b006f23b1408ff548348440369d056becdc1d (diff)
posix: Ignore disk space reserve check for internal FOPS
Problem: Currently disk space reserve check is applicable for internal FOP also it needs to be ignore for internal FOP. Solution: Update the DISK_SPACE_CHECK_AND_GOTO macro at posix component. Macro will call only while key "GLUSTERFS_INTERNAL_FOP_KEY" exists in xdata. BUG: 1506083 Change-Id: I2b0840bbf4fa14bc247855b024ca136773d68d16 Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/storage/posix/src/posix-aio.c2
-rw-r--r--xlators/storage/posix/src/posix-helpers.c12
-rw-r--r--xlators/storage/posix/src/posix-messages.h2
-rw-r--r--xlators/storage/posix/src/posix.c48
-rw-r--r--xlators/storage/posix/src/posix.h8
5 files changed, 36 insertions, 36 deletions
diff --git a/xlators/storage/posix/src/posix-aio.c b/xlators/storage/posix/src/posix-aio.c
index 2adafeb07b8..47460bc77b4 100644
--- a/xlators/storage/posix/src/posix-aio.c
+++ b/xlators/storage/posix/src/posix-aio.c
@@ -330,7 +330,7 @@ posix_aio_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
VALIDATE_OR_GOTO (fd, err);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_errno, op_errno, err);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_errno, op_errno, err);
ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index 826441f1dd7..77affc45ae0 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1990,10 +1990,10 @@ posix_disk_space_check (xlator_t *this)
GF_VALIDATE_OR_GOTO (this->name, this, out);
priv = this->private;
- GF_VALIDATE_OR_GOTO ("posix-helpers", priv, out);
+ GF_VALIDATE_OR_GOTO (this->name, priv, out);
subvol_path = priv->base_path;
- percent = priv->disk_threshhold;
+ percent = priv->disk_reserve;
op_ret = sys_statvfs (subvol_path, &buf);
@@ -2073,9 +2073,9 @@ posix_spawn_disk_space_check_thread (xlator_t *xl)
priv->disk_space_check_active = _gf_false;
}
- ret = gf_thread_create (&priv->disk_space_check, NULL,
- posix_disk_space_check_thread_proc,
- xl, "posix_reserve");
+ ret = gf_thread_create_detached (&priv->disk_space_check,
+ posix_disk_space_check_thread_proc,
+ xl, "posix_reserve");
if (ret < 0) {
priv->disk_space_check_active = _gf_false;
gf_msg (xl->name, GF_LOG_ERROR, errno,
@@ -2084,8 +2084,6 @@ posix_spawn_disk_space_check_thread (xlator_t *xl)
goto unlock;
}
- /* run the thread detached, resources will be freed on exit */
- pthread_detach (priv->disk_space_check);
priv->disk_space_check_active = _gf_true;
}
unlock:
diff --git a/xlators/storage/posix/src/posix-messages.h b/xlators/storage/posix/src/posix-messages.h
index 20cf1f0109b..fbae4d8d83a 100644
--- a/xlators/storage/posix/src/posix-messages.h
+++ b/xlators/storage/posix/src/posix-messages.h
@@ -45,7 +45,7 @@
*/
#define POSIX_COMP_BASE GLFS_MSGID_COMP_POSIX
-#define GLFS_NUM_MESSAGES 111
+#define GLFS_NUM_MESSAGES 112
#define GLFS_MSGID_END (POSIX_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x POSIX_COMP_BASE, "Invalid: Start of messages"
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 117a58ce96c..5a285bcd7e7 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -806,7 +806,7 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
VALIDATE_OR_GOTO (fd, out);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, ret, ret, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, ret, ret, out);
ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
@@ -853,6 +853,8 @@ out:
locked = _gf_false;
}
SET_TO_OLD_FS_ID ();
+ if (ret == ENOSPC)
+ ret = -ENOSPC;
return ret;
}
@@ -1108,17 +1110,18 @@ posix_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
struct iatt statpost = {0,};
struct posix_private *priv = NULL;
int op_ret = -1;
- int op_errno = -1;
+ int op_errno = -EINVAL;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
ret = posix_do_zerofill (frame, this, fd, offset, len,
&statpre, &statpost, xdata);
if (ret < 0) {
+ op_ret = -1;
op_errno = -ret;
goto out;
}
@@ -1396,13 +1399,12 @@ posix_mknod (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv, out);
GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno,
out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
-
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL);
gid = frame->root->gid;
SET_FS_ID (frame->root->uid, gid);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
if (!real_path || !par_path) {
op_ret = -1;
@@ -1617,7 +1619,7 @@ posix_mkdir (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv, out);
GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno,
out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, NULL);
if (!real_path || !par_path) {
@@ -2444,7 +2446,7 @@ posix_symlink (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv, out);
GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno,
out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf);
@@ -2603,7 +2605,7 @@ posix_rename (call_frame_t *frame, xlator_t *this,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
SET_FS_ID (frame->root->uid, frame->root->gid);
MAKE_ENTRY_HANDLE (real_oldpath, par_oldpath, this, oldloc, NULL);
@@ -2886,7 +2888,7 @@ posix_link (call_frame_t *frame, xlator_t *this,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
SET_FS_ID (frame->root->uid, frame->root->gid);
MAKE_INODE_HANDLE (real_oldpath, this, oldloc, &stbuf);
@@ -3096,7 +3098,7 @@ posix_create (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv, out);
GFID_NULL_CHECK_AND_GOTO (frame, this, loc, xdata, op_ret, op_errno,
out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
MAKE_ENTRY_HANDLE (real_path, par_path, this, loc, &stbuf);
@@ -3285,7 +3287,7 @@ posix_open (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (priv, out);
if (flags & O_CREAT)
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
MAKE_INODE_HANDLE (real_path, this, loc, &stbuf);
if (!real_path) {
@@ -3610,7 +3612,7 @@ posix_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
priv = this->private;
VALIDATE_OR_GOTO (priv, out);
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
@@ -3775,7 +3777,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
goto out;
}
- percent = priv->disk_threshhold;
+ percent = priv->disk_reserve;
buf.f_bfree = (buf.f_bfree - ((buf.f_blocks * percent) / 100));
shared_by = priv->shared_brick_count;
@@ -4051,7 +4053,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (dict, out);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
MAKE_INODE_HANDLE (real_path, this, loc, NULL);
if (!real_path) {
@@ -5417,7 +5419,7 @@ posix_fsetxattr (call_frame_t *frame, xlator_t *this,
VALIDATE_OR_GOTO (dict, out);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
if (ret < 0) {
@@ -6090,8 +6092,7 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
VALIDATE_OR_GOTO (this, out);
priv = this->private;
- DISK_SPACE_CHECK_AND_GOTO (frame, priv, op_ret, op_errno, out);
-
+ DISK_SPACE_CHECK_AND_GOTO (frame, priv, xdata, op_ret, op_errno, out);
if (fd) {
op_ret = posix_fd_ctx_get (fd, this, &pfd, &op_errno);
@@ -7214,9 +7215,9 @@ reconfigure (xlator_t *this, dict_t *options)
" fallback to <hostname>:<export>");
}
- GF_OPTION_RECONF ("reserve", priv->disk_threshhold,
+ GF_OPTION_RECONF ("reserve", priv->disk_reserve,
options, uint32, out);
- if (priv->disk_threshhold)
+ if (priv->disk_reserve)
posix_spawn_disk_space_check_thread (this);
GF_OPTION_RECONF ("health-check-interval", priv->health_check_interval,
@@ -7820,8 +7821,8 @@ init (xlator_t *this)
_private->disk_space_check_active = _gf_false;
_private->disk_space_full = 0;
GF_OPTION_INIT ("reserve",
- _private->disk_threshhold, uint32, out);
- if (_private->disk_threshhold)
+ _private->disk_reserve, uint32, out);
+ if (_private->disk_reserve)
posix_spawn_disk_space_check_thread (this);
_private->health_check_active = _gf_false;
@@ -8032,9 +8033,8 @@ struct volume_options options[] = {
.min = 0,
.default_value = "1",
.validate = GF_OPT_VALIDATE_MIN,
- .description = "Value in percentage in integer form required "
- "to set reserve disk, "
- "set to 0 to disable"
+ .description = "Percentage of disk space to be reserved."
+ " Set to 0 to disable"
},
{ .key = {"batch-fsync-mode"},
.type = GF_OPTION_TYPE_STR,
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 4ba676fb7c0..b63643d970b 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -63,8 +63,9 @@
#define GF_UNLINK_TRUE 0x0000000000000001
#define GF_UNLINK_FALSE 0x0000000000000000
-#define DISK_SPACE_CHECK_AND_GOTO(frame, priv, op_ret, op_errno, out) do { \
- if (frame->root->pid >= 0 && priv->disk_space_full) { \
+#define DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, op_ret, op_errno, out) do { \
+ if (frame->root->pid >= 0 && priv->disk_space_full && \
+ !dict_get (xdata, GLUSTERFS_INTERNAL_FOP_KEY)) { \
op_ret = -1; \
op_errno = ENOSPC; \
gf_msg_debug ("posix", ENOSPC, \
@@ -74,6 +75,7 @@
} \
} while (0)
+
#define GFID_NULL_CHECK_AND_GOTO(frame, this, loc, xattr_req, op_ret, \
op_errno, out) \
do { \
@@ -209,7 +211,7 @@ struct posix_private {
pthread_t health_check;
gf_boolean_t health_check_active;
- uint32_t disk_threshhold;
+ uint32_t disk_reserve;
uint32_t disk_space_full;
pthread_t disk_space_check;
gf_boolean_t disk_space_check_active;