summaryrefslogtreecommitdiffstats
path: root/xlators/features/marker/src
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2015-09-07 12:43:07 +0530
committerDan Lambright <dlambrig@redhat.com>2015-09-22 04:59:53 -0700
commit7e1a00990324a5d7b1fa001bdea24a456fc1aa05 (patch)
treedd52d7b915ab6e1b5d71d20ce52558d08ccd7359 /xlators/features/marker/src
parent139732c40fda1424d95146d69328148775e61540 (diff)
marker: don't account destination linkto-file during internal migration
This is a backport of http://review.gluster.org/#/c/12113/ 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> Change-Id: I2254392ada61a40ce259003c6b5787ecf6dc6376 BUG: 1260919 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/12204 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Dan Lambright <dlambrig@redhat.com> Tested-by: Dan Lambright <dlambrig@redhat.com>
Diffstat (limited to 'xlators/features/marker/src')
-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 0ba30bb8eaf..167d2dcb59d 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -992,7 +992,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);
@@ -2913,11 +2913,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;
@@ -3017,20 +3026,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;
@@ -3048,27 +3058,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;
}
@@ -3189,7 +3199,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);
@@ -3209,7 +3219,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;
@@ -3448,14 +3458,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;
@@ -3479,7 +3490,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;
@@ -3487,13 +3498,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;
@@ -3501,7 +3512,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;
}
@@ -3665,7 +3676,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;
}
@@ -3762,14 +3773,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;
@@ -3806,7 +3817,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);
{
@@ -3825,7 +3836,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 */
@@ -3842,15 +3853,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;
@@ -4278,7 +4281,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 1f50c264810..334969e0998 100644
--- a/xlators/features/marker/src/marker-quota.h
+++ b/xlators/features/marker/src/marker-quota.h
@@ -132,13 +132,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 6265028a9df..66bdfbcaebd 100644
--- a/xlators/features/marker/src/marker.c
+++ b/xlators/features/marker/src/marker.c
@@ -620,7 +620,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);
@@ -695,7 +695,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);
@@ -766,7 +766,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);
@@ -989,7 +989,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);
}
@@ -1079,7 +1079,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);
@@ -1227,6 +1227,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,
@@ -1596,7 +1597,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);
@@ -1665,7 +1666,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);
@@ -1737,7 +1738,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)
@@ -1812,7 +1813,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)
@@ -1885,7 +1886,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);
@@ -1954,7 +1955,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);
@@ -2021,7 +2022,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 12a51bc1484..e6e19331d70 100644
--- a/xlators/features/marker/src/marker.h
+++ b/xlators/features/marker/src/marker.h
@@ -101,6 +101,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;