summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/bugs/quota/bug-1260545.t59
-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
5 files changed, 111 insertions, 47 deletions
diff --git a/tests/bugs/quota/bug-1260545.t b/tests/bugs/quota/bug-1260545.t
new file mode 100644
index 00000000000..7cd137dda61
--- /dev/null
+++ b/tests/bugs/quota/bug-1260545.t
@@ -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;
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;