summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2019-07-29 14:08:37 +0530
committerPranith Kumar K <pkarampu@redhat.com>2019-07-30 06:45:33 +0530
commit065b10beaae8ea7390c2e3059044313aef8a5fea (patch)
treecb989cfe1fc594376dd93f287bbc31d44d214293
parentd7001336c38bb9516645bbc0fd07a8c7f1f8b3f8 (diff)
cluster/ec: Fix reopen flags to avoid misbehavior
Problem: when a file needs to be re-opened O_APPEND and O_EXCL flags are not filtered in EC. - O_APPEND should be filtered because EC doesn't send O_APPEND below EC for open to make sure writes happen on the individual fragments instead of at the end of the file. - O_EXCL should be filtered because shd could have created the file so even when file exists open should succeed - O_CREAT should be filtered because open happens with gfid as parameter. So open fop will create just the gfid which will lead to problems. Fix: Filter out these two flags in reopen. Change-Id: Ia280470fcb5188a09caa07bf665a2a94bce23bc4 Fixes: bz#1733935 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
-rw-r--r--xlators/cluster/ec/src/ec-common.c4
-rw-r--r--xlators/cluster/ec/src/ec-inode-write.c7
2 files changed, 8 insertions, 3 deletions
diff --git a/xlators/cluster/ec/src/ec-common.c b/xlators/cluster/ec/src/ec-common.c
index f55c3c59651..1c829a09e1f 100644
--- a/xlators/cluster/ec/src/ec-common.c
+++ b/xlators/cluster/ec/src/ec-common.c
@@ -101,6 +101,7 @@ ec_fix_open(ec_fop_data_t *fop, uintptr_t mask)
{
uintptr_t need_open = 0;
int ret = 0;
+ int32_t flags = 0;
loc_t loc = {
0,
};
@@ -121,6 +122,7 @@ ec_fix_open(ec_fop_data_t *fop, uintptr_t mask)
goto out;
}
+ flags = fop->fd->flags & (~(O_TRUNC | O_APPEND | O_CREAT | O_EXCL));
if (IA_IFDIR == fop->fd->inode->ia_type) {
ec_opendir(fop->frame, fop->xl, need_open,
EC_MINIMUM_ONE | EC_FOP_NO_PROPAGATE_ERROR, NULL, NULL,
@@ -128,7 +130,7 @@ ec_fix_open(ec_fop_data_t *fop, uintptr_t mask)
} else {
ec_open(fop->frame, fop->xl, need_open,
EC_MINIMUM_ONE | EC_FOP_NO_PROPAGATE_ERROR, NULL, NULL, &loc,
- fop->fd->flags & (~O_TRUNC), fop->fd, NULL);
+ flags, fop->fd, NULL);
}
out:
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
index ec1c5b5d85c..49cb8c147e4 100644
--- a/xlators/cluster/ec/src/ec-inode-write.c
+++ b/xlators/cluster/ec/src/ec-inode-write.c
@@ -1981,10 +1981,13 @@ ec_get_lock_good_mask(inode_t *inode, xlator_t *xl)
LOCK(&inode->lock);
{
ictx = __ec_inode_get(inode, xl);
- lock = ictx->inode_lock;
+ if (ictx)
+ lock = ictx->inode_lock;
}
UNLOCK(&inode->lock);
- return lock->good_mask;
+ if (lock)
+ return lock->good_mask;
+ return 0;
}
void