Skip to content

Commit

Permalink
* cleanup of glusterfs_ctx from fuse, now, whenever umount is called,…
Browse files Browse the repository at this point in the history
… raise (SIGTERM) will happen, and xlator->fini() is called for every xlator in the graph.

* gf_string2bytesize takes uint64_t instead of size_t, which is 32bit on 32bit machine, and hence fails to take more than 4GB as input.

* added quota translator. Currently is designed to sit atop the posix translator, and takes 'min-free-disk-limit' (in %), or 'disk-usage-limit' in (bytes) as options.
  • Loading branch information
amarts committed May 5, 2017
1 parent f147df8 commit 8dcde0c
Show file tree
Hide file tree
Showing 23 changed files with 1,037 additions and 111 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ AC_CONFIG_FILES([Makefile
xlators/features/trash/src/Makefile
xlators/features/filter/Makefile
xlators/features/filter/src/Makefile
xlators/features/quota/Makefile
xlators/features/quota/src/Makefile
xlators/encryption/Makefile
xlators/encryption/rot-13/Makefile
xlators/encryption/rot-13/src/Makefile
Expand Down
15 changes: 10 additions & 5 deletions glusterfs/src/glusterfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,9 @@ void
cleanup_and_exit (int signum)
{
glusterfs_ctx_t *ctx = NULL;

xlator_t *trav = NULL;
ctx = get_global_ctx_ptr ();

gf_log (progname, GF_LOG_WARNING, "shutting down");

if (ctx->pidfp) {
gf_unlockfd (fileno (ctx->pidfp));
fclose (ctx->pidfp);
Expand All @@ -545,8 +543,15 @@ cleanup_and_exit (int signum)
if (ctx->cmd_args.pid_file)
unlink (ctx->cmd_args.pid_file);

if (ctx->graph && ctx->cmd_args.mount_point)
((xlator_t *)ctx->graph)->fini (ctx->graph);
if (ctx->graph) {
trav = ctx->graph;
while (trav) {
trav->fini (trav);
trav = trav->next;
}
}

gf_log (progname, GF_LOG_WARNING, "shutting down");

exit (0);
}
Expand Down
8 changes: 4 additions & 4 deletions libglusterfs/src/common-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
typedef int32_t (*rw_op_t)(int32_t fd, char *buf, int32_t size);
typedef int32_t (*rwv_op_t)(int32_t fd, const struct iovec *buf, int32_t size);
static glusterfs_ctx_t *gf_global_ctx;
int64_t total_bytes_xferd;
int64_t total_bytes_rcvd;
uint64_t total_bytes_xferd;
uint64_t total_bytes_rcvd;

static int32_t
full_rw (int32_t fd, char *buf, int32_t size,
Expand Down Expand Up @@ -154,7 +154,7 @@ void
gf_print_bytes ()
{
gf_log ("glusterfs", GF_LOG_WARNING,
"Total data (in bytes): transfered (%"PRId64"), received (%"PRId64")",
"Total data (in bytes): transfered (%"PRIu64"), received (%"PRIu64")",
total_bytes_xferd, total_bytes_rcvd);
}

Expand Down Expand Up @@ -1222,7 +1222,7 @@ gf_string2uint64_base10 (const char *str, uint64_t *n)
}

int
gf_string2bytesize (const char *str, size_t *n)
gf_string2bytesize (const char *str, uint64_t *n)
{
uint64_t value = 0ULL;
char *tail = NULL;
Expand Down
6 changes: 3 additions & 3 deletions libglusterfs/src/common-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ void gf_print_bytes (void);
void gf_log_volume_specfile (FILE *specfp);
void gf_print_trace (int32_t signal);

extern int64_t total_bytes_xferd;
extern int64_t total_bytes_rcvd;
extern uint64_t total_bytes_xferd;
extern uint64_t total_bytes_rcvd;
extern char *gf_fop_list[GF_FOP_MAXVALUE];
extern char *gf_mop_list[GF_MOP_MAXVALUE];

Expand Down Expand Up @@ -277,7 +277,7 @@ int gf_string2uint16_base10 (const char *str, uint16_t *n);
int gf_string2uint32_base10 (const char *str, uint32_t *n);
int gf_string2uint64_base10 (const char *str, uint64_t *n);

int gf_string2bytesize (const char *str, size_t *n);
int gf_string2bytesize (const char *str, uint64_t *n);

int gf_string2boolean (const char *str, gf_boolean_t *b);
int gf_string2percent (const char *str, uint32_t *n);
Expand Down
2 changes: 1 addition & 1 deletion libglusterfs/src/revision.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define GLUSTERFS_REPOSITORY_REVISION "glusterfs--mainline--3.0--patch-378"
#define GLUSTERFS_REPOSITORY_REVISION "glusterfs--mainline--3.0--patch-379"
7 changes: 2 additions & 5 deletions libglusterfs/src/xlator.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ xlator_validate_given_options (xlator_t *xl)
data_pair_t *pairs = NULL;
int32_t index = 0;
int32_t valid = 0;
int64_t input_size = 0;
uint64_t input_size = 0;
long long inputll = 0;

if (!xl->std_options)
Expand Down Expand Up @@ -195,18 +195,15 @@ xlator_validate_given_options (xlator_t *xl)
break;
case GF_OPTION_TYPE_SIZET:
{
size_t tmp_size = 0;

/* Check the range */
if (gf_string2bytesize (pairs->value->data, &tmp_size) != 0) {
if (gf_string2bytesize (pairs->value->data, &input_size) != 0) {
gf_log (xl->name,
GF_LOG_ERROR,
"invalid number format \"%s\" in \"option %s\"",
pairs->value->data, pairs->key);
return -1;
}

input_size = (int64_t)tmp_size;
if (trav->min_value == -1) {
gf_log (xl->name, GF_LOG_DEBUG,
"no range check required for 'option %s %s'",
Expand Down
10 changes: 2 additions & 8 deletions scheduler/alu/src/alu.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,14 @@ alu_init (xlator_t *xl)
entry_fn = dict_get (xl->options, "alu.disk-usage.entry-threshold");
if (entry_fn)
{
size_t tmp_du = 0;

if (gf_string2bytesize (entry_fn->data, &tmp_du) != 0)
if (gf_string2bytesize (entry_fn->data, &alu_sched->entry_limit.disk_usage) != 0)
{
gf_log ("alu",
GF_LOG_ERROR,
"invalid number format \"%s\" of \"option alu.disk-usage.entry-threshold\"",
entry_fn->data);
return -1;
}
alu_sched->entry_limit.disk_usage = (uint64_t)tmp_du;
}
else
{
Expand All @@ -200,17 +197,14 @@ alu_init (xlator_t *xl)
exit_fn = dict_get (xl->options, "alu.disk-usage.exit-threshold");
if (exit_fn)
{
size_t tmp_du = 0;

if (gf_string2bytesize (exit_fn->data, &tmp_du) != 0)
if (gf_string2bytesize (exit_fn->data, &alu_sched->exit_limit.disk_usage) != 0)
{
gf_log ("alu",
GF_LOG_ERROR,
"invalid number format \"%s\" of \"option alu.disk-usage.exit-threshold\"",
exit_fn->data);
return -1;
}
alu_sched->exit_limit.disk_usage = (uint64_t)tmp_du;
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions xlators/cluster/stripe/src/stripe.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct stripe_local;
*/
struct stripe_private {
xlator_t **xl_array;
size_t block_size;
uint64_t block_size;
gf_lock_t lock;
uint8_t nodes_down;
int8_t first_child_down;
Expand Down Expand Up @@ -3080,7 +3080,7 @@ init (xlator_t *this)
}
}

gf_log (this->name, GF_LOG_DEBUG, "stripe block size %d", priv->block_size);
gf_log (this->name, GF_LOG_DEBUG, "stripe block size %"PRIu64"", priv->block_size);

/* notify related */
priv->nodes_down = priv->child_count;
Expand Down
2 changes: 1 addition & 1 deletion xlators/features/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

SUBDIRS = posix-locks trash path-convertor filter
SUBDIRS = posix-locks trash path-convertor filter quota

CLEANFILES =
3 changes: 3 additions & 0 deletions xlators/features/quota/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SUBDIRS = src

CLEANFILES =
13 changes: 13 additions & 0 deletions xlators/features/quota/src/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
xlator_LTLIBRARIES = quota.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features

quota_la_LDFLAGS = -module -avoidversion

quota_la_SOURCES = quota.c
quota_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la

AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
-I$(top_srcdir)/libglusterfs/src -shared -nostartfiles $(GF_CFLAGS)

CLEANFILES =

Loading

0 comments on commit 8dcde0c

Please sign in to comment.