Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quota new design #16

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions cli/src/cli-rpc-ops.c
Expand Up @@ -2362,6 +2362,8 @@ gf_cli_print_limit_list (char *volname, char *limit_list,
char *size_str = NULL;
char path [PATH_MAX] = {0, };
char ret_str [1024] = {0, };
char hard_lim [1024] = {0, };
char soft_lim [1024] = {0, };
char value [1024] = {0, };
char mountdir [] = "/tmp/mntXXXXXX";
char abspath [PATH_MAX] = {0, };
Expand Down Expand Up @@ -2408,7 +2410,7 @@ gf_cli_print_limit_list (char *volname, char *limit_list,

i = 0;

cli_out ("\tpath\t\t limit_set\t size");
cli_out ("\tpath\t\t limit_set (soft/hard)\t\t size");
cli_out ("-----------------------------------------------------------"
"-----------------------");
while (i < len) {
Expand All @@ -2422,22 +2424,28 @@ gf_cli_print_limit_list (char *volname, char *limit_list,

colon_ptr = strrchr (path, ':');
*colon_ptr = '\0';
strcpy (value, ++colon_ptr);
strcpy (hard_lim, ++colon_ptr);

colon_ptr = strrchr (path, ':');
*colon_ptr = '\0';
strcpy (soft_lim, ++colon_ptr);

sprintf (value, "%s/%s", soft_lim, hard_lim);

snprintf (abspath, sizeof (abspath), "%s/%s", mountdir, path);

ret = sys_lgetxattr (abspath, "trusted.limit.list", (void *) ret_str, 4096);
if (ret < 0) {
cli_out ("%-20s %10s", path, value);
cli_out ("%-20s %25s", path, value);
} else {
sscanf (ret_str, "%"PRId64",%"PRId64, &size,
&limit_value);
size_str = gf_uint64_2human_readable ((uint64_t) size);
if (size_str == NULL) {
cli_out ("%-20s %10s %20"PRId64, path,
cli_out ("%-20s %25s %20"PRId64, path,
value, size);
} else {
cli_out ("%-20s %10s %20s", path,
cli_out ("%-20s %25s %20s", path,
value, size_str);
GF_FREE (size_str);
}
Expand Down
1 change: 0 additions & 1 deletion libglusterfs/src/xlator.c
Expand Up @@ -662,7 +662,6 @@ loc_copy (loc_t *dst, loc_t *src)

uuid_copy (dst->gfid, src->gfid);
uuid_copy (dst->pargfid, src->pargfid);
uuid_copy (dst->gfid, src->gfid);

if (src->inode)
dst->inode = inode_ref (src->inode);
Expand Down
12 changes: 9 additions & 3 deletions xlators/features/marker/src/marker-quota.c
Expand Up @@ -2245,7 +2245,7 @@ _mq_inode_remove_done (call_frame_t *frame, void *cookie, xlator_t *this,

frame->local = NULL;

if (local->hl_count > 1) {
if (local->ia_nlink > 1) {
GET_CONTRI_KEY (contri_key, local->contri->gfid, ret);

STACK_WIND (frame, mq_removexattr_cbk, FIRST_CHILD(this),
Expand Down Expand Up @@ -2375,16 +2375,21 @@ mq_reduce_parent_size_xattr (call_frame_t *frame, void *cookie, xlator_t *this,
}

int32_t
mq_reduce_parent_size (xlator_t *this, loc_t *loc, int64_t contri)
mq_reduce_parent_size (xlator_t *this, marker_local_t *local, int64_t contri)
{
int32_t ret = -1;
struct gf_flock lock = {0,};
call_frame_t *frame = NULL;
quota_local_t *local = NULL;
quota_inode_ctx_t *ctx = NULL;
inode_contribution_t *contribution = NULL;
loc_t *loc = NULL;
int32_t ia_nlink = 0;

GF_VALIDATE_OR_GOTO ("marker", this, out);
GF_VALIDATE_OR_GOTO ("marker", local, out);

ia_nlink = local->ia_nlink;
loc = &local->loc;
GF_VALIDATE_OR_GOTO ("marker", loc, out);

ret = mq_inode_ctx_get (loc->inode, this, &ctx);
Expand Down Expand Up @@ -2421,6 +2426,7 @@ mq_reduce_parent_size (xlator_t *this, loc_t *loc, int64_t contri)
goto out;

local->ctx = ctx;
local->ia_nlink = ia_nlink;
local->contri = contribution;

ret = mq_inode_loc_fill (NULL, loc->parent, &local->parent_loc);
Expand Down
3 changes: 0 additions & 3 deletions xlators/features/marker/src/marker-quota.h
Expand Up @@ -116,9 +116,6 @@ int32_t
mq_dirty_inode_readdir (call_frame_t *, void *, xlator_t *,
int32_t, int32_t, fd_t *, dict_t *);

int32_t
mq_reduce_parent_size (xlator_t *, loc_t *, int64_t);

int32_t
mq_rename_update_newpath (xlator_t *, loc_t *);

Expand Down
10 changes: 5 additions & 5 deletions xlators/features/marker/src/marker.c
Expand Up @@ -733,7 +733,7 @@ marker_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;

if (priv->feature_enabled & GF_QUOTA)
mq_reduce_parent_size (this, &local->loc, -1);
mq_reduce_parent_size (this, local, -1);

if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
Expand Down Expand Up @@ -800,8 +800,8 @@ marker_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,

priv = this->private;

if ((priv->feature_enabled & GF_QUOTA) && (local->ia_nlink == 1))
mq_reduce_parent_size (this, &local->loc, -1);
if (priv->feature_enabled & GF_QUOTA)
mq_reduce_parent_size (this, local, -1);

if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
Expand Down Expand Up @@ -989,10 +989,10 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this,
NULL, NULL, NULL, NULL);
}

mq_reduce_parent_size (this, &oplocal->loc, oplocal->contribution);
mq_reduce_parent_size (this, oplocal, oplocal->contribution);

if (local->loc.inode != NULL) {
mq_reduce_parent_size (this, &local->loc, local->contribution);
mq_reduce_parent_size (this, local, local->contribution);
}

newloc.inode = inode_ref (oplocal->loc.inode);
Expand Down
4 changes: 3 additions & 1 deletion xlators/features/marker/src/marker.h
Expand Up @@ -100,7 +100,6 @@ struct marker_local{
int64_t d_off;
int64_t sum;
int64_t size;
int32_t hl_count;
int32_t dentry_child_count;

fd_t *fd;
Expand Down Expand Up @@ -134,3 +133,6 @@ struct marker_conf{
typedef struct marker_conf marker_conf_t;

#endif

int32_t
mq_reduce_parent_size (xlator_t *, marker_local_t *, int64_t);
8 changes: 6 additions & 2 deletions xlators/features/quota/src/Makefile.am
@@ -1,17 +1,21 @@
xlator_LTLIBRARIES = quota.la
xlator_LTLIBRARIES = quota.la quota-client.la
xlatordir = $(libdir)/glusterfs/$(PACKAGE_VERSION)/xlator/features

quota_la_LDFLAGS = -module -avoid-version
quota_client_la_LDFLAGS = -module -avoid-version

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

quota_client_la_SOURCES = quota-client.c
quota_client_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la

noinst_HEADERS = quota-mem-types.h quota.h

AM_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src \
-I$(top_srcdir)/xlators/cluster/dht/src

AM_CFLAGS = -Wall $(GF_CFLAGS)

CLEANFILES =
CLEANFILES =