summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-09-07 12:43:07 +0530
committerDan Lambright <dlambrig@redhat.com>2015-09-22 03:55:29 -0700
commitab667778ed7c5016d32090b98b69b3ef0c528788 (patch)
tree259419887395e4c1d34fe92d8bf69709219b6b2d /xlators/features/marker
parent2ebfc3d0a61ab88bc0e4bad07157f69f618ad54f (diff)
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>
Diffstat (limited to 'xlators/features/marker')
-rw-r--r--xlators/features/marker/src/marker-quota.c67
-rw-r--r--xlators/features/marker/src/marker-quota.h6
-rw-r--r--xlators/features/marker/src/marker.c25
-rw-r--r--xlators/features/marker/src/marker.h1
4 files changed, 52 insertions, 47 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index 2049dd01f6a..44fb45919ab 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -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)
diff --git a/xlators/features/marker/src/marker-quota.h b/xlators/features/marker/src/marker-quota.h
index 9491d5e12bd..0b6c6f02fee 100644
--- a/xlators/features/marker/src/marker-quota.h
+++ b/xlators/features/marker/src/marker-quota.h
@@ -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 *,
diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c
index 401feb9a4d0..096b749310d 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -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);
diff --git a/xlators/features/marker/src/marker.h b/xlators/features/marker/src/marker.h
index 228fd6fa5d8..650acd84d1b 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -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;