|
|
21ab4e |
From 2a397f0ca64505438edf96a15de901bb640cd871 Mon Sep 17 00:00:00 2001
|
|
|
21ab4e |
From: Sunil Kumar Acharya <sheggodu@redhat.com>
|
|
|
21ab4e |
Date: Wed, 17 May 2017 14:35:41 +0530
|
|
|
21ab4e |
Subject: [PATCH 467/473] cluster/ec: Implement FALLOCATE FOP for EC
|
|
|
21ab4e |
|
|
|
21ab4e |
FALLOCATE file operations is not implemented in the
|
|
|
21ab4e |
existing EC code. This change set implements it
|
|
|
21ab4e |
for EC.
|
|
|
21ab4e |
|
|
|
21ab4e |
>BUG: 1448293
|
|
|
21ab4e |
>Change-Id: Id9ed914db984c327c16878a5b2304a0ea461b623
|
|
|
21ab4e |
>Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
|
|
|
21ab4e |
>Reviewed-on: https://review.gluster.org/15200
|
|
|
21ab4e |
>Smoke: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
|
|
|
21ab4e |
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
|
|
|
21ab4e |
|
|
|
21ab4e |
BUG: 1447559
|
|
|
21ab4e |
Change-Id: Ibeaf1fc8d564e2bef602653894672812c68397fe
|
|
|
21ab4e |
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
|
|
|
21ab4e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/107051
|
|
|
21ab4e |
Reviewed-by: Ashish Pandey <aspandey@redhat.com>
|
|
|
21ab4e |
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
|
|
|
21ab4e |
---
|
|
|
21ab4e |
libglusterfs/src/compat.h | 8 ++
|
|
|
21ab4e |
tests/basic/ec/ec-fallocate.t | 72 +++++++++++
|
|
|
21ab4e |
tests/basic/ec/ec-rebalance.t | 60 ++++++++++
|
|
|
21ab4e |
xlators/cluster/ec/src/ec-fops.h | 4 +
|
|
|
21ab4e |
xlators/cluster/ec/src/ec-inode-write.c | 203 +++++++++++++++++++++++++++++++-
|
|
|
21ab4e |
xlators/cluster/ec/src/ec.c | 5 +-
|
|
|
21ab4e |
xlators/storage/posix/src/posix.c | 10 +-
|
|
|
21ab4e |
7 files changed, 354 insertions(+), 8 deletions(-)
|
|
|
21ab4e |
create mode 100644 tests/basic/ec/ec-fallocate.t
|
|
|
21ab4e |
create mode 100644 tests/basic/ec/ec-rebalance.t
|
|
|
21ab4e |
|
|
|
21ab4e |
diff --git a/libglusterfs/src/compat.h b/libglusterfs/src/compat.h
|
|
|
21ab4e |
index ea72202..2738657 100644
|
|
|
21ab4e |
--- a/libglusterfs/src/compat.h
|
|
|
21ab4e |
+++ b/libglusterfs/src/compat.h
|
|
|
21ab4e |
@@ -59,6 +59,12 @@
|
|
|
21ab4e |
#ifndef FALLOC_FL_ZERO_RANGE
|
|
|
21ab4e |
#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */
|
|
|
21ab4e |
#endif
|
|
|
21ab4e |
+#ifndef FALLOC_FL_COLLAPSE_RANGE
|
|
|
21ab4e |
+#define FALLOC_FL_COLLAPSE_RANGE 0x08 /* reduces the size */
|
|
|
21ab4e |
+#endif
|
|
|
21ab4e |
+#ifndef FALLOC_FL_INSERT_RANGE
|
|
|
21ab4e |
+#define FALLOC_FL_INSERT_RANGE 0x20 /* expands the size */
|
|
|
21ab4e |
+#endif
|
|
|
21ab4e |
|
|
|
21ab4e |
#ifndef HAVE_LLISTXATTR
|
|
|
21ab4e |
|
|
|
21ab4e |
@@ -177,6 +183,8 @@ enum {
|
|
|
21ab4e |
#define FALLOC_FL_KEEP_SIZE 0x01 /* default is extend size */
|
|
|
21ab4e |
#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
|
|
|
21ab4e |
#define FALLOC_FL_ZERO_RANGE 0x10 /* zeroes out range */
|
|
|
21ab4e |
+#define FALLOC_FL_INSERT_RANGE 0x20 /* Expands the size */
|
|
|
21ab4e |
+#define FALLOC_FL_COLLAPSE_RANGE 0x08 /* Reduces the size */
|
|
|
21ab4e |
|
|
|
21ab4e |
#ifndef _PATH_UMOUNT
|
|
|
21ab4e |
#define _PATH_UMOUNT "/sbin/umount"
|
|
|
21ab4e |
diff --git a/tests/basic/ec/ec-fallocate.t b/tests/basic/ec/ec-fallocate.t
|
|
|
21ab4e |
new file mode 100644
|
|
|
21ab4e |
index 0000000..1b827ee
|
|
|
21ab4e |
--- /dev/null
|
|
|
21ab4e |
+++ b/tests/basic/ec/ec-fallocate.t
|
|
|
21ab4e |
@@ -0,0 +1,72 @@
|
|
|
21ab4e |
+#!/bin/bash
|
|
|
21ab4e |
+#
|
|
|
21ab4e |
+# Run several commands to verify basic fallocate functionality. We verify that
|
|
|
21ab4e |
+# fallocate creates and allocates blocks to a file. We also verify that the keep
|
|
|
21ab4e |
+# size option does not modify the file size.
|
|
|
21ab4e |
+###
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+. $(dirname $0)/../../include.rc
|
|
|
21ab4e |
+. $(dirname $0)/../../volume.rc
|
|
|
21ab4e |
+. $(dirname $0)/../../fallocate.rc
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#cleate and start volume
|
|
|
21ab4e |
+TEST glusterd
|
|
|
21ab4e |
+TEST pidof glusterd
|
|
|
21ab4e |
+TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0..2}
|
|
|
21ab4e |
+TEST $CLI volume start $V0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#Mount the volume
|
|
|
21ab4e |
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
|
|
|
21ab4e |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# check for fallocate support before continuing the test
|
|
|
21ab4e |
+require_fallocate -l 1m -n $M0/file && rm -f $M0/file
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# fallocate a file and verify blocks are allocated
|
|
|
21ab4e |
+TEST fallocate -l 1m $M0/file
|
|
|
21ab4e |
+blksz=`stat -c %b $M0/file`
|
|
|
21ab4e |
+nblks=`stat -c %B $M0/file`
|
|
|
21ab4e |
+TEST [ $(($blksz * $nblks)) -eq 1048576 ]
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+TEST unlink $M0/file
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# truncate a file to a fixed size, fallocate and verify that the size does not
|
|
|
21ab4e |
+# change
|
|
|
21ab4e |
+TEST truncate -s 1M $M0/file
|
|
|
21ab4e |
+TEST fallocate -l 2m -n $M0/file
|
|
|
21ab4e |
+blksz=`stat -c %b $M0/file`
|
|
|
21ab4e |
+nblks=`stat -c %B $M0/file`
|
|
|
21ab4e |
+sz=`stat -c %s $M0/file`
|
|
|
21ab4e |
+TEST [ $sz -eq 1048576 ]
|
|
|
21ab4e |
+# Note that gluster currently incorporates a hack to limit the number of blocks
|
|
|
21ab4e |
+# reported as allocated to the file by the file size. We have allocated beyond the
|
|
|
21ab4e |
+# file size here. Just check for non-zero allocation to avoid setting a land mine
|
|
|
21ab4e |
+# for if/when that behavior might change.
|
|
|
21ab4e |
+TEST [ ! $(($blksz * $nblks)) -eq 0 ]
|
|
|
21ab4e |
+TEST unlink $M0/file
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# write some data, fallocate within and outside the range
|
|
|
21ab4e |
+# and check for data corruption.
|
|
|
21ab4e |
+TEST dd if=/dev/urandom of=$M0/file bs=1024k count=1
|
|
|
21ab4e |
+TEST cp $M0/file $M0/file.copy.pre
|
|
|
21ab4e |
+TEST fallocate -o 512k -l 128k $M0/file
|
|
|
21ab4e |
+TEST cp $M0/file $M0/file.copy.post
|
|
|
21ab4e |
+TEST cmp $M0/file.copy.pre $M0/file.copy.post
|
|
|
21ab4e |
+TEST fallocate -o 1000k -l 128k $M0/file
|
|
|
21ab4e |
+TEST cp $M0/file $M0/file.copy.post2
|
|
|
21ab4e |
+TEST ! cmp $M0/file.copy.pre $M0/file.copy.post2
|
|
|
21ab4e |
+TEST truncate -s 1M $M0/file.copy.post2
|
|
|
21ab4e |
+TEST cmp $M0/file.copy.pre $M0/file.copy.post2
|
|
|
21ab4e |
+TEST unlink $M0/file
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#Make sure offset/size are modified so that 3 blocks are allocated
|
|
|
21ab4e |
+TEST touch $M0/f1
|
|
|
21ab4e |
+TEST fallocate -o 1280 -l 1024 $M0/f1
|
|
|
21ab4e |
+EXPECT "^2304$" stat -c "%s" $M0/f1
|
|
|
21ab4e |
+EXPECT "^1536$" stat -c "%s" $B0/${V0}0/f1
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup;
|
|
|
21ab4e |
diff --git a/tests/basic/ec/ec-rebalance.t b/tests/basic/ec/ec-rebalance.t
|
|
|
21ab4e |
new file mode 100644
|
|
|
21ab4e |
index 0000000..b5c3072
|
|
|
21ab4e |
--- /dev/null
|
|
|
21ab4e |
+++ b/tests/basic/ec/ec-rebalance.t
|
|
|
21ab4e |
@@ -0,0 +1,60 @@
|
|
|
21ab4e |
+#!/bin/bash
|
|
|
21ab4e |
+#
|
|
|
21ab4e |
+# This will test the rebalance failure reported in 1447559
|
|
|
21ab4e |
+#
|
|
|
21ab4e |
+###
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+. $(dirname $0)/../../include.rc
|
|
|
21ab4e |
+. $(dirname $0)/../../volume.rc
|
|
|
21ab4e |
+. $(dirname $0)/../../fallocate.rc
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#cleate and start volume
|
|
|
21ab4e |
+TEST glusterd
|
|
|
21ab4e |
+TEST pidof glusterd
|
|
|
21ab4e |
+TEST $CLI volume create $V0 disperse 3 redundancy 1 $H0:$B0/${V0}{0..2}
|
|
|
21ab4e |
+TEST $CLI volume start $V0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#Mount the volume
|
|
|
21ab4e |
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
|
|
|
21ab4e |
+EXPECT_WITHIN $CHILD_UP_TIMEOUT "3" ec_child_up_count $V0 0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+# Create files
|
|
|
21ab4e |
+for i in {1..10}
|
|
|
21ab4e |
+do
|
|
|
21ab4e |
+ dd if=/dev/urandom of=$M0/file$i bs=1024k count=1
|
|
|
21ab4e |
+done
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+md5_1=$(md5sum $M0/file1 | awk '{print $1}')
|
|
|
21ab4e |
+md5_2=$(md5sum $M0/file2 | awk '{print $1}')
|
|
|
21ab4e |
+md5_3=$(md5sum $M0/file3 | awk '{print $1}')
|
|
|
21ab4e |
+md5_4=$(md5sum $M0/file4 | awk '{print $1}')
|
|
|
21ab4e |
+md5_5=$(md5sum $M0/file5 | awk '{print $1}')
|
|
|
21ab4e |
+md5_6=$(md5sum $M0/file6 | awk '{print $1}')
|
|
|
21ab4e |
+md5_7=$(md5sum $M0/file7 | awk '{print $1}')
|
|
|
21ab4e |
+md5_8=$(md5sum $M0/file8 | awk '{print $1}')
|
|
|
21ab4e |
+md5_9=$(md5sum $M0/file9 | awk '{print $1}')
|
|
|
21ab4e |
+md5_10=$(md5sum $M0/file10 | awk '{print $1}')
|
|
|
21ab4e |
+# Add brick
|
|
|
21ab4e |
+TEST $CLI volume add-brick $V0 $H0:$B0/${V0}{3..5}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#Trigger rebalance
|
|
|
21ab4e |
+TEST $CLI volume rebalance $V0 start force
|
|
|
21ab4e |
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field $V0
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+#Remount to avoid any caches
|
|
|
21ab4e |
+EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
|
|
|
21ab4e |
+TEST $GFS --volfile-id=/$V0 --volfile-server=$H0 $M0;
|
|
|
21ab4e |
+EXPECT "$md5_1" echo $(md5sum $M0/file1 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_2" echo $(md5sum $M0/file2 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_3" echo $(md5sum $M0/file3 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_4" echo $(md5sum $M0/file4 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_5" echo $(md5sum $M0/file5 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_6" echo $(md5sum $M0/file6 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_7" echo $(md5sum $M0/file7 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_8" echo $(md5sum $M0/file8 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_9" echo $(md5sum $M0/file9 | awk '{print $1}')
|
|
|
21ab4e |
+EXPECT "$md5_10" echo $(md5sum $M0/file10 | awk '{print $1}')
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+cleanup;
|
|
|
21ab4e |
diff --git a/xlators/cluster/ec/src/ec-fops.h b/xlators/cluster/ec/src/ec-fops.h
|
|
|
21ab4e |
index 053c6b4..9842f6a 100644
|
|
|
21ab4e |
--- a/xlators/cluster/ec/src/ec-fops.h
|
|
|
21ab4e |
+++ b/xlators/cluster/ec/src/ec-fops.h
|
|
|
21ab4e |
@@ -168,6 +168,10 @@ void ec_symlink(call_frame_t * frame, xlator_t * this, uintptr_t target,
|
|
|
21ab4e |
const char * linkname, loc_t * loc, mode_t umask,
|
|
|
21ab4e |
dict_t * xdata);
|
|
|
21ab4e |
|
|
|
21ab4e |
+void ec_fallocate(call_frame_t *frame, xlator_t *this, uintptr_t target,
|
|
|
21ab4e |
+ int32_t minimum, fop_fallocate_cbk_t func, void *data, fd_t *fd,
|
|
|
21ab4e |
+ int32_t mode, off_t offset, size_t len, dict_t *xdata);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
void ec_truncate(call_frame_t * frame, xlator_t * this, uintptr_t target,
|
|
|
21ab4e |
int32_t minimum, fop_truncate_cbk_t func, void *data,
|
|
|
21ab4e |
loc_t * loc, off_t offset, dict_t * xdata);
|
|
|
21ab4e |
diff --git a/xlators/cluster/ec/src/ec-inode-write.c b/xlators/cluster/ec/src/ec-inode-write.c
|
|
|
21ab4e |
index 92c6b8a..8b72373 100644
|
|
|
21ab4e |
--- a/xlators/cluster/ec/src/ec-inode-write.c
|
|
|
21ab4e |
+++ b/xlators/cluster/ec/src/ec-inode-write.c
|
|
|
21ab4e |
@@ -827,7 +827,208 @@ out:
|
|
|
21ab4e |
}
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
-/* FOP: truncate */
|
|
|
21ab4e |
+/*********************************************************************
|
|
|
21ab4e |
+ *
|
|
|
21ab4e |
+ * File Operation : fallocate
|
|
|
21ab4e |
+ *
|
|
|
21ab4e |
+ *********************************************************************/
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int32_t ec_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
21ab4e |
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
|
|
|
21ab4e |
+ struct iatt *postbuf, dict_t *xdata)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ return ec_inode_write_cbk (frame, this, cookie, op_ret, op_errno,
|
|
|
21ab4e |
+ prebuf, postbuf, xdata);
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+void ec_wind_fallocate(ec_t *ec, ec_fop_data_t *fop, int32_t idx)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ ec_trace("WIND", fop, "idx=%d", idx);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ STACK_WIND_COOKIE(fop->frame, ec_fallocate_cbk, (void *)(uintptr_t)idx,
|
|
|
21ab4e |
+ ec->xl_list[idx], ec->xl_list[idx]->fops->fallocate,
|
|
|
21ab4e |
+ fop->fd, fop->int32, fop->offset,
|
|
|
21ab4e |
+ fop->size, fop->xdata);
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+int32_t ec_manager_fallocate(ec_fop_data_t *fop, int32_t state)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ ec_cbk_data_t *cbk = NULL;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ switch (state) {
|
|
|
21ab4e |
+ case EC_STATE_INIT:
|
|
|
21ab4e |
+ if (fop->size == 0) {
|
|
|
21ab4e |
+ ec_fop_set_error(fop, EINVAL);
|
|
|
21ab4e |
+ return EC_STATE_REPORT;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ if (fop->int32 & (FALLOC_FL_COLLAPSE_RANGE
|
|
|
21ab4e |
+ |FALLOC_FL_INSERT_RANGE
|
|
|
21ab4e |
+ |FALLOC_FL_ZERO_RANGE
|
|
|
21ab4e |
+ |FALLOC_FL_PUNCH_HOLE)) {
|
|
|
21ab4e |
+ ec_fop_set_error(fop, ENOTSUP);
|
|
|
21ab4e |
+ return EC_STATE_REPORT;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ fop->user_size = fop->offset + fop->size;
|
|
|
21ab4e |
+ fop->head = ec_adjust_offset (fop->xl->private, &fop->offset, 1);
|
|
|
21ab4e |
+ fop->size = ec_adjust_size (fop->xl->private, fop->head + fop->size, 1);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* Fall through */
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case EC_STATE_LOCK:
|
|
|
21ab4e |
+ ec_lock_prepare_fd(fop, fop->fd,
|
|
|
21ab4e |
+ EC_UPDATE_DATA | EC_UPDATE_META |
|
|
|
21ab4e |
+ EC_QUERY_INFO);
|
|
|
21ab4e |
+ ec_lock(fop);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_DISPATCH;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case EC_STATE_DISPATCH:
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ ec_dispatch_all(fop);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_PREPARE_ANSWER;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case EC_STATE_PREPARE_ANSWER:
|
|
|
21ab4e |
+ cbk = ec_fop_prepare_answer(fop, _gf_false);
|
|
|
21ab4e |
+ if (cbk != NULL) {
|
|
|
21ab4e |
+ ec_iatt_rebuild(fop->xl->private, cbk->iatt, 2,
|
|
|
21ab4e |
+ cbk->count);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* This shouldn't fail because we have the inode locked. */
|
|
|
21ab4e |
+ GF_ASSERT(ec_get_inode_size(fop, fop->locks[0].lock->loc.inode,
|
|
|
21ab4e |
+ &cbk->iatt[0].ia_size));
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /*If mode has FALLOC_FL_KEEP_SIZE keep the size */
|
|
|
21ab4e |
+ if (fop->int32 & FALLOC_FL_KEEP_SIZE) {
|
|
|
21ab4e |
+ cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
|
|
|
21ab4e |
+ } else if (fop->user_size > cbk->iatt[0].ia_size) {
|
|
|
21ab4e |
+ cbk->iatt[1].ia_size = fop->user_size;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ /* This shouldn't fail because we have the inode
|
|
|
21ab4e |
+ * locked. */
|
|
|
21ab4e |
+ GF_ASSERT(ec_set_inode_size(fop,
|
|
|
21ab4e |
+ fop->locks[0].lock->loc.inode,
|
|
|
21ab4e |
+ cbk->iatt[1].ia_size));
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
+ cbk->iatt[1].ia_size = cbk->iatt[0].ia_size;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_REPORT;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case EC_STATE_REPORT:
|
|
|
21ab4e |
+ cbk = fop->answer;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ GF_ASSERT(cbk != NULL);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (fop->cbks.fallocate != NULL) {
|
|
|
21ab4e |
+ fop->cbks.fallocate(fop->req_frame, fop, fop->xl, cbk->op_ret,
|
|
|
21ab4e |
+ cbk->op_errno, &cbk->iatt[0], &cbk->iatt[1],
|
|
|
21ab4e |
+ cbk->xdata);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_LOCK_REUSE;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case -EC_STATE_INIT:
|
|
|
21ab4e |
+ case -EC_STATE_LOCK:
|
|
|
21ab4e |
+ case -EC_STATE_DISPATCH:
|
|
|
21ab4e |
+ case -EC_STATE_PREPARE_ANSWER:
|
|
|
21ab4e |
+ case -EC_STATE_REPORT:
|
|
|
21ab4e |
+ GF_ASSERT(fop->error != 0);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (fop->cbks.fallocate != NULL) {
|
|
|
21ab4e |
+ fop->cbks.fallocate(fop->req_frame, fop, fop->xl, -1,
|
|
|
21ab4e |
+ fop->error, NULL, NULL, NULL);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_LOCK_REUSE;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case -EC_STATE_LOCK_REUSE:
|
|
|
21ab4e |
+ case EC_STATE_LOCK_REUSE:
|
|
|
21ab4e |
+ ec_lock_reuse(fop);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_UNLOCK;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ case -EC_STATE_UNLOCK:
|
|
|
21ab4e |
+ case EC_STATE_UNLOCK:
|
|
|
21ab4e |
+ ec_unlock(fop);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_END;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ default:
|
|
|
21ab4e |
+ gf_msg (fop->xl->name, GF_LOG_ERROR, EINVAL,
|
|
|
21ab4e |
+ EC_MSG_UNHANDLED_STATE,
|
|
|
21ab4e |
+ "Unhandled state %d for %s",
|
|
|
21ab4e |
+ state, ec_fop_name(fop->id));
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ return EC_STATE_END;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+void ec_fallocate(call_frame_t *frame, xlator_t *this, uintptr_t target,
|
|
|
21ab4e |
+ int32_t minimum, fop_fallocate_cbk_t func, void *data, fd_t *fd,
|
|
|
21ab4e |
+ int32_t mode, off_t offset, size_t len, dict_t *xdata)
|
|
|
21ab4e |
+{
|
|
|
21ab4e |
+ ec_cbk_t callback = { .fallocate = func };
|
|
|
21ab4e |
+ ec_fop_data_t *fop = NULL;
|
|
|
21ab4e |
+ int32_t error = ENOMEM;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ gf_msg_trace ("ec", 0, "EC(FALLOCATE) %p", frame);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ VALIDATE_OR_GOTO(this, out);
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO(this->name, frame, out);
|
|
|
21ab4e |
+ GF_VALIDATE_OR_GOTO(this->name, this->private, out);
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ fop = ec_fop_data_allocate(frame, this, GF_FOP_FALLOCATE, 0, target,
|
|
|
21ab4e |
+ minimum, ec_wind_fallocate, ec_manager_fallocate,
|
|
|
21ab4e |
+ callback, data);
|
|
|
21ab4e |
+ if (fop == NULL) {
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ fop->use_fd = 1;
|
|
|
21ab4e |
+ fop->int32 = mode;
|
|
|
21ab4e |
+ fop->offset = offset;
|
|
|
21ab4e |
+ fop->size = len;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (fd != NULL) {
|
|
|
21ab4e |
+ fop->fd = fd_ref(fd);
|
|
|
21ab4e |
+ if (fop->fd == NULL) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ EC_MSG_FILE_DESC_REF_FAIL,
|
|
|
21ab4e |
+ "Failed to reference a "
|
|
|
21ab4e |
+ "file descriptor.");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ if (xdata != NULL) {
|
|
|
21ab4e |
+ fop->xdata = dict_ref(xdata);
|
|
|
21ab4e |
+ if (fop->xdata == NULL) {
|
|
|
21ab4e |
+ gf_msg (this->name, GF_LOG_ERROR, 0,
|
|
|
21ab4e |
+ EC_MSG_DICT_REF_FAIL,
|
|
|
21ab4e |
+ "Failed to reference a "
|
|
|
21ab4e |
+ "dictionary.");
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+ error = 0;
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+out:
|
|
|
21ab4e |
+ if (fop != NULL) {
|
|
|
21ab4e |
+ ec_manager(fop, error);
|
|
|
21ab4e |
+ } else {
|
|
|
21ab4e |
+ func(frame, NULL, this, -1, error, NULL, NULL, NULL);
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
+}
|
|
|
21ab4e |
+
|
|
|
21ab4e |
+/*********************************************************************
|
|
|
21ab4e |
+ *
|
|
|
21ab4e |
+ * File Operation : truncate
|
|
|
21ab4e |
+ *
|
|
|
21ab4e |
+ *********************************************************************/
|
|
|
21ab4e |
|
|
|
21ab4e |
int32_t ec_truncate_write(ec_fop_data_t * fop, uintptr_t mask)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
diff --git a/xlators/cluster/ec/src/ec.c b/xlators/cluster/ec/src/ec.c
|
|
|
21ab4e |
index f687050..bad5578 100644
|
|
|
21ab4e |
--- a/xlators/cluster/ec/src/ec.c
|
|
|
21ab4e |
+++ b/xlators/cluster/ec/src/ec.c
|
|
|
21ab4e |
@@ -734,10 +734,11 @@ int32_t ec_gf_fentrylk(call_frame_t * frame, xlator_t * this,
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
int32_t ec_gf_fallocate(call_frame_t * frame, xlator_t * this, fd_t * fd,
|
|
|
21ab4e |
- int32_t keep_size, off_t offset, size_t len,
|
|
|
21ab4e |
+ int32_t mode, off_t offset, size_t len,
|
|
|
21ab4e |
dict_t * xdata)
|
|
|
21ab4e |
{
|
|
|
21ab4e |
- default_fallocate_failure_cbk(frame, ENOTSUP);
|
|
|
21ab4e |
+ ec_fallocate(frame, this, -1, EC_MINIMUM_MIN, default_fallocate_cbk,
|
|
|
21ab4e |
+ NULL, fd, mode, offset, len, xdata);
|
|
|
21ab4e |
|
|
|
21ab4e |
return 0;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
index ed70782..afd0ff8 100644
|
|
|
21ab4e |
--- a/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
+++ b/xlators/storage/posix/src/posix.c
|
|
|
21ab4e |
@@ -696,11 +696,11 @@ posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
|
|
|
21ab4e |
goto out;
|
|
|
21ab4e |
}
|
|
|
21ab4e |
|
|
|
21ab4e |
- ret = sys_fallocate (pfd->fd, flags, offset, len);
|
|
|
21ab4e |
- if (ret == -1) {
|
|
|
21ab4e |
- ret = -errno;
|
|
|
21ab4e |
- goto out;
|
|
|
21ab4e |
- }
|
|
|
21ab4e |
+ ret = sys_fallocate (pfd->fd, flags, offset, len);
|
|
|
21ab4e |
+ if (ret == -1) {
|
|
|
21ab4e |
+ ret = -errno;
|
|
|
21ab4e |
+ goto out;
|
|
|
21ab4e |
+ }
|
|
|
21ab4e |
|
|
|
21ab4e |
ret = posix_fdstat (this, pfd->fd, statpost);
|
|
|
21ab4e |
if (ret == -1) {
|
|
|
21ab4e |
--
|
|
|
21ab4e |
1.8.3.1
|
|
|
21ab4e |
|