summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2017-06-23 13:10:56 +0530
committerAtin Mukherjee <amukherj@redhat.com>2017-07-24 15:34:34 +0000
commitfebf5ed4848ad705a34413353559482417c61467 (patch)
tree081447d6844b0bb16622c6bfce9fbb680ad42549 /xlators/storage
parent0b3fec6924cad5c9f38941550ab4106972efa5cc (diff)
posix: option to handle the shared bricks for statvfs()
Currently 'storage/posix' xlator has an option called option `export-statfs-size no`, which exports zero as values for few fields in `struct statvfs`. In a case of backend brick shared between multiple brick processes, the values of these variables should be `field_value / number-of-bricks-at-node`. This way, even the issue of 'min-free-disk' etc at different layers would also be handled properly when the statfs() sys call is made. Fixes #241 Change-Id: I2e320e1fdcc819ab9173277ef3498201432c275f Signed-off-by: Amar Tumballi <amarts@redhat.com> Reviewed-on: https://review.gluster.org/17618 CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c34
-rw-r--r--xlators/storage/posix/src/posix.h3
2 files changed, 36 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index dc8a129cacb..92a2f3772cb 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3641,6 +3641,7 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
int32_t op_errno = 0;
struct statvfs buf = {0, };
struct posix_private * priv = NULL;
+ int shared_by = 1;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -3665,6 +3666,16 @@ posix_statfs (call_frame_t *frame, xlator_t *this,
goto out;
}
+ shared_by = priv->shared_brick_count;
+ if (shared_by > 1) {
+ buf.f_blocks /= shared_by;
+ buf.f_bfree /= shared_by;
+ buf.f_bavail /= shared_by;
+ buf.f_files /= shared_by;
+ buf.f_ffree /= shared_by;
+ buf.f_favail /= shared_by;
+ }
+
if (!priv->export_statfs) {
buf.f_blocks = 0;
buf.f_bfree = 0;
@@ -6971,7 +6982,7 @@ int
reconfigure (xlator_t *this, dict_t *options)
{
int ret = -1;
-struct posix_private *priv = NULL;
+ struct posix_private *priv = NULL;
int32_t uid = -1;
int32_t gid = -1;
char *batch_fsync_mode_str = NULL;
@@ -7039,6 +7050,9 @@ struct posix_private *priv = NULL;
options, uint32, out);
posix_spawn_health_check_thread (this);
+ GF_OPTION_RECONF ("shared-brick-count", priv->shared_brick_count,
+ options, int32, out);
+
ret = 0;
out:
return ret;
@@ -7573,6 +7587,17 @@ init (xlator_t *this)
}
}
#endif
+ _private->shared_brick_count = 1;
+ ret = dict_get_int32 (this->options, "shared-brick-count",
+ &_private->shared_brick_count);
+ if (ret == -1) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ P_MSG_INVALID_OPTION_VAL,
+ "'shared-brick-count' takes only integer "
+ "values");
+ goto out;
+ }
+
this->private = (void *)_private;
op_ret = posix_handle_init (this);
@@ -7863,5 +7888,12 @@ struct volume_options options[] = {
"\t- Strip: Will strip the user namespace before setting. The raw filesystem will work in OS X.\n"
},
#endif
+ { .key = {"shared-brick-count"},
+ .type = GF_OPTION_TYPE_INT,
+ .default_value = "1",
+ .description = "Number of bricks sharing the same backend export."
+ " Useful for displaying the proper usable size through statvfs() "
+ "call (df command)",
+ },
{ .key = {NULL} }
};
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 480566a5340..81158266111 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -176,6 +176,9 @@ struct posix_private {
} xattr_user_namespace;
#endif
+ /* Option to handle the cases of multiple bricks exported from
+ same backend. Very much usable in brick-splitting feature. */
+ int32_t shared_brick_count;
};
typedef struct {