From febf5ed4848ad705a34413353559482417c61467 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Fri, 23 Jun 2017 13:10:56 +0530 Subject: 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 Reviewed-on: https://review.gluster.org/17618 CentOS-regression: Gluster Build System Smoke: Gluster Build System Reviewed-by: Jeff Darcy Reviewed-by: Atin Mukherjee --- xlators/storage/posix/src/posix.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'xlators/storage/posix/src/posix.c') 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} } }; -- cgit