marker: don't account destination linkto-file during internal migration

During a DHT re-balance operation, quota accounts for the destination.
Problem of accounting this destination file are:
1) Migration is an internal operation, 'quota list' shows more usage on the CLI
   and this will come to the normal numbers once the migration is complete
2) If the usage is close to the limit set, then we can get 'Disk Quota
   Exceeded' errors in the I/O path during file migration

Solution is we should not account of the usage on the destination file
during migration, at the end of the migration. We need to reduce size of
the source directory and accounting for the migrated dest file

We assume that there are sufficent disk space in the back-end. DHT
migrator should make sure that there are sufficient disk space before it
starts the migration process.

Change-Id: Ie3cfe3e4ab5241c2a127ba0edc599a053d30c3a0
BUG: 1260545
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: http://review.gluster.org/12113
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Reviewed-by: Dan Lambright <dlambrig@redhat.com>
Tested-by: Dan Lambright <dlambrig@redhat.com>
This commit is contained in:
vmallika 2015-09-07 12:43:07 +05:30 committed by Dan Lambright
parent 2ebfc3d0a6
commit ab667778ed
5 changed files with 111 additions and 47 deletions

View File

@ -0,0 +1,59 @@
#!/bin/bash
. $(dirname $0)/../../include.rc
. $(dirname $0)/../../volume.rc
cleanup;
QDD=$(dirname $0)/quota
# compile the test write program and run it
build_tester $(dirname $0)/../../basic/quota.c -o $QDD
TEST glusterd
TEST pidof glusterd;
TEST $CLI volume info;
TEST $CLI volume create $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}2;
TEST $CLI volume start $V0;
TEST $CLI volume quota $V0 enable;
TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0;
TEST $CLI volume quota $V0 limit-usage / 15MB
TEST $CLI volume quota $V0 hard-timeout 0
TEST $CLI volume quota $V0 soft-timeout 0
TEST $QDD $M0/f1 256 40
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quotausage "/"
if [ -f "$B0/${V0}1/f1" ]; then
HASHED="$B0/${V0}1"
OTHER="$B0/${V0}2"
else
HASHED="$B0/${V0}2"
OTHER="$B0/${V0}1"
fi
TEST $CLI volume remove-brick $V0 $H0:${HASHED} start
EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" remove_brick_status_completed_field "$V0" "$H0:${HASHED}";
#check consistency in mount point and also check that file is migrated to OTHER
TEST [ -f "$OTHER/f1" ];
TEST [ -f "$M0/f1" ];
#check that remove-brick status should not have any failed or skipped files
var=`$CLI volume remove-brick $V0 $H0:${HASHED} status | grep completed`
TEST [ `echo $var | awk '{print $5}'` = "0" ]
TEST [ `echo $var | awk '{print $6}'` = "0" ]
EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "10.0MB" quotausage "/"
rm -f $M0/f1
TEST $CLI volume stop $V0
TEST $CLI volume delete $V0
EXPECT "1" get_aux
rm -f $QDD
cleanup;

View File

@ -991,7 +991,7 @@ mq_inode_creation_done (call_frame_t *frame, void *cookie, xlator_t *this,
local = frame->local;
if (local != NULL) {
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, NULL);
}
QUOTA_STACK_DESTROY (frame, this);
@ -2914,11 +2914,20 @@ mq_synctask (xlator_t *this, synctask_fn_t task, gf_boolean_t spawn, loc_t *loc)
int32_t
mq_prevalidate_txn (xlator_t *this, loc_t *origin_loc, loc_t *loc,
quota_inode_ctx_t **ctx)
quota_inode_ctx_t **ctx, struct iatt *buf)
{
int32_t ret = -1;
quota_inode_ctx_t *ctxtmp = NULL;
if (buf) {
if (buf->ia_type == IA_IFREG && IS_DHT_LINKFILE_MODE(buf))
goto out;
if (buf->ia_type != IA_IFREG && buf->ia_type != IA_IFLNK &&
buf->ia_type != IA_IFDIR)
goto out;
}
if (origin_loc == NULL || origin_loc->inode == NULL ||
gf_uuid_is_null(origin_loc->inode->gfid))
goto out;
@ -3018,20 +3027,21 @@ out:
mq_set_ctx_create_status (ctx, _gf_false);
if (need_txn)
ret = mq_initiate_quota_blocking_txn (this, loc);
ret = mq_initiate_quota_blocking_txn (this, loc, NULL);
return ret;
}
static int
_mq_create_xattrs_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn)
_mq_create_xattrs_txn (xlator_t *this, loc_t *origin_loc, struct iatt *buf,
gf_boolean_t spawn)
{
int32_t ret = -1;
quota_inode_ctx_t *ctx = NULL;
gf_boolean_t status = _gf_true;
loc_t loc = {0, };
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx);
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx, buf);
if (ret < 0)
goto out;
@ -3049,27 +3059,27 @@ out:
}
int
mq_create_xattrs_txn (xlator_t *this, loc_t *loc)
mq_create_xattrs_txn (xlator_t *this, loc_t *loc, struct iatt *buf)
{
int32_t ret = -1;
GF_VALIDATE_OR_GOTO ("marker", loc, out);
GF_VALIDATE_OR_GOTO ("marker", loc->inode, out);
ret = _mq_create_xattrs_txn (this, loc, _gf_true);
ret = _mq_create_xattrs_txn (this, loc, buf, _gf_true);
out:
return ret;
}
int
mq_create_xattrs_blocking_txn (xlator_t *this, loc_t *loc)
mq_create_xattrs_blocking_txn (xlator_t *this, loc_t *loc, struct iatt *buf)
{
int32_t ret = -1;
GF_VALIDATE_OR_GOTO ("marker", loc, out);
GF_VALIDATE_OR_GOTO ("marker", loc->inode, out);
ret = _mq_create_xattrs_txn (this, loc, _gf_false);
ret = _mq_create_xattrs_txn (this, loc, buf, _gf_false);
out:
return ret;
}
@ -3190,7 +3200,7 @@ out:
ret = mq_lock (this, &parent_loc, F_UNLCK);
if (ret >= 0)
ret = mq_initiate_quota_blocking_txn (this, &parent_loc);
ret = mq_initiate_quota_blocking_txn (this, &parent_loc, NULL);
loc_wipe (&parent_loc);
@ -3210,7 +3220,7 @@ mq_reduce_parent_size_txn (xlator_t *this, loc_t *origin_loc,
GF_VALIDATE_OR_GOTO ("marker", this, out);
GF_VALIDATE_OR_GOTO ("marker", origin_loc, out);
ret = mq_prevalidate_txn (this, origin_loc, &loc, NULL);
ret = mq_prevalidate_txn (this, origin_loc, &loc, NULL, NULL);
if (ret < 0)
goto out;
@ -3449,14 +3459,15 @@ out:
}
int
_mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, gf_boolean_t spawn)
_mq_initiate_quota_txn (xlator_t *this, loc_t *origin_loc, struct iatt *buf,
gf_boolean_t spawn)
{
int32_t ret = -1;
quota_inode_ctx_t *ctx = NULL;
gf_boolean_t status = _gf_true;
loc_t loc = {0,};
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx);
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx, buf);
if (ret < 0)
goto out;
@ -3480,7 +3491,7 @@ out:
}
int
mq_initiate_quota_txn (xlator_t *this, loc_t *loc)
mq_initiate_quota_txn (xlator_t *this, loc_t *loc, struct iatt *buf)
{
int32_t ret = -1;
@ -3488,13 +3499,13 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc)
GF_VALIDATE_OR_GOTO ("marker", loc, out);
GF_VALIDATE_OR_GOTO ("marker", loc->inode, out);
ret = _mq_initiate_quota_txn (this, loc, _gf_true);
ret = _mq_initiate_quota_txn (this, loc, buf, _gf_true);
out:
return ret;
}
int
mq_initiate_quota_blocking_txn (xlator_t *this, loc_t *loc)
mq_initiate_quota_blocking_txn (xlator_t *this, loc_t *loc, struct iatt *buf)
{
int32_t ret = -1;
@ -3502,7 +3513,7 @@ mq_initiate_quota_blocking_txn (xlator_t *this, loc_t *loc)
GF_VALIDATE_OR_GOTO ("marker", loc, out);
GF_VALIDATE_OR_GOTO ("marker", loc->inode, out);
ret = _mq_initiate_quota_txn (this, loc, _gf_false);
ret = _mq_initiate_quota_txn (this, loc, buf, _gf_false);
out:
return ret;
}
@ -3667,7 +3678,7 @@ out:
loc_wipe(&child_loc);
if (updated)
mq_initiate_quota_blocking_txn (this, loc);
mq_initiate_quota_blocking_txn (this, loc, NULL);
return ret;
}
@ -3764,14 +3775,14 @@ mq_inspect_directory_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
if (!loc_is_root(loc) &&
!quota_meta_is_null (&delta))
mq_initiate_quota_txn (this, loc);
mq_initiate_quota_txn (this, loc, NULL);
ret = 0;
goto out;
create_xattr:
if (ret < 0)
ret = mq_create_xattrs_txn (this, loc);
ret = mq_create_xattrs_txn (this, loc, NULL);
out:
return ret;
@ -3808,7 +3819,7 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
ret = _quota_dict_get_meta (this, dict, contri_key, &contri,
IA_IFREG, _gf_true);
if (ret < 0) {
ret = mq_create_xattrs_txn (this, loc);
ret = mq_create_xattrs_txn (this, loc, NULL);
} else {
LOCK (&contribution->lock);
{
@ -3827,7 +3838,7 @@ mq_inspect_file_xattr (xlator_t *this, quota_inode_ctx_t *ctx,
mq_compute_delta (&delta, &size, &contri);
if (!quota_meta_is_null (&delta))
mq_initiate_quota_txn (this, loc);
mq_initiate_quota_txn (this, loc, NULL);
}
/* TODO: revist this code when fixing hardlinks */
@ -3844,15 +3855,7 @@ mq_xattr_state (xlator_t *this, loc_t *origin_loc, dict_t *dict,
loc_t loc = {0, };
inode_contribution_t *contribution = NULL;
if (((buf.ia_type == IA_IFREG) && !dht_is_linkfile (&buf, dict))
|| (buf.ia_type == IA_IFLNK) || (buf.ia_type == IA_IFDIR)) {
/* do healing only for these type of files */
} else {
ret = 0;
goto out;
}
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx);
ret = mq_prevalidate_txn (this, origin_loc, &loc, &ctx, &buf);
if (ret < 0)
goto out;
@ -4282,7 +4285,7 @@ mq_rename_update_newpath (xlator_t *this, loc_t *loc)
goto out;
}
mq_initiate_quota_txn (this, loc);
mq_initiate_quota_txn (this, loc, NULL);
out:
if (contribution)

View File

@ -127,13 +127,13 @@ int32_t
mq_set_inode_xattr (xlator_t *, loc_t *);
int
mq_initiate_quota_txn (xlator_t *, loc_t *);
mq_initiate_quota_txn (xlator_t *, loc_t *, struct iatt *);
int
mq_initiate_quota_blocking_txn (xlator_t *, loc_t *);
mq_initiate_quota_blocking_txn (xlator_t *, loc_t *, struct iatt *);
int
mq_create_xattrs_txn (xlator_t *this, loc_t *loc);
mq_create_xattrs_txn (xlator_t *this, loc_t *loc, struct iatt *buf);
int32_t
mq_dirty_inode_readdir (call_frame_t *, void *, xlator_t *,

View File

@ -617,7 +617,7 @@ marker_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_create_xattrs_txn (this, &local->loc);
mq_create_xattrs_txn (this, &local->loc, NULL);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -692,7 +692,7 @@ marker_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_create_xattrs_txn (this, &local->loc);
mq_create_xattrs_txn (this, &local->loc, buf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -763,7 +763,7 @@ marker_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -986,7 +986,7 @@ marker_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (priv->feature_enabled & GF_QUOTA) {
if (!local->skip_txn)
mq_create_xattrs_txn (this, &local->loc);
mq_create_xattrs_txn (this, &local->loc, buf);
}
@ -1076,7 +1076,7 @@ marker_rename_done (call_frame_t *frame, void *cookie, xlator_t *this,
newloc.name++;
newloc.parent = inode_ref (local->loc.parent);
mq_create_xattrs_txn (this, &newloc);
mq_create_xattrs_txn (this, &newloc, &local->buf);
loc_wipe (&newloc);
@ -1224,6 +1224,7 @@ marker_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto quota_err;
}
local->buf = *buf;
stub = fop_rename_cbk_stub (frame, default_rename_cbk, op_ret,
op_errno, buf, preoldparent,
postoldparent, prenewparent,
@ -1593,7 +1594,7 @@ marker_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -1662,7 +1663,7 @@ marker_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -1734,7 +1735,7 @@ marker_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA) {
mq_create_xattrs_txn (this, &local->loc);
mq_create_xattrs_txn (this, &local->loc, buf);
}
if (priv->feature_enabled & GF_XTIME)
@ -1809,7 +1810,7 @@ marker_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if ((priv->feature_enabled & GF_QUOTA) && (S_ISREG (local->mode))) {
mq_create_xattrs_txn (this, &local->loc);
mq_create_xattrs_txn (this, &local->loc, buf);
}
if (priv->feature_enabled & GF_XTIME)
@ -1882,7 +1883,7 @@ marker_fallocate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -1951,7 +1952,7 @@ marker_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);
@ -2018,7 +2019,7 @@ marker_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
priv = this->private;
if (priv->feature_enabled & GF_QUOTA)
mq_initiate_quota_txn (this, &local->loc);
mq_initiate_quota_txn (this, &local->loc, postbuf);
if (priv->feature_enabled & GF_XTIME)
marker_xtime_update_marks (this, local);

View File

@ -96,6 +96,7 @@ struct marker_local{
gid_t gid;
int32_t ref;
int32_t ia_nlink;
struct iatt buf;
gf_lock_t lock;
mode_t mode;
int32_t err;