summaryrefslogtreecommitdiffstats
path: root/rpc/glfs-operations.c
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-12 11:59:13 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-06-22 16:30:46 +0530
commit94c79620db4451bf804d6ab631c9ca59759dbc21 (patch)
treeee5c0e9430fb30812753ac1911bd8b5c163cb5fd /rpc/glfs-operations.c
parent8bb5dd787e84f719940230adb24642653fcaec77 (diff)
block: add support to prealloc = full | no option
currently we allocate sparse files for block backends in the gluster volume, with 'prealloc = full' option introduced by this patch we should be able to fully preallocate the backend block file. Change-Id: Ibf32df5f978f732a3fd248693170463da6d08268 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Diffstat (limited to 'rpc/glfs-operations.c')
-rw-r--r--rpc/glfs-operations.c45
1 files changed, 24 insertions, 21 deletions
diff --git a/rpc/glfs-operations.c b/rpc/glfs-operations.c
index 72de38f..db02620 100644
--- a/rpc/glfs-operations.c
+++ b/rpc/glfs-operations.c
@@ -126,37 +126,40 @@ glusterBlockCreateEntry(struct glfs *glfs, blockCreateCli *blk, char *gbid,
if (ret) {
*errCode = errno;
LOG("gfapi", GB_LOG_ERROR,
- "glfs_ftruncate(%s): on volume %s for block %s"
+ "glfs_ftruncate(%s): on volume %s for block %s "
"of size %zu failed[%s]", gbid, blk->volume, blk->block_name,
blk->size, strerror(errno));
-
- if (tgfd && glfs_close(tgfd) != 0) {
- LOG("gfapi", GB_LOG_ERROR,
- "glfs_close(%s): on volume %s for block %s failed[%s]",
- gbid, blk->volume, blk->block_name, strerror(errno));
- }
-
- ret = glfs_unlink(glfs, gbid);
- if (ret && errno != ENOENT) {
- LOG("gfapi", GB_LOG_ERROR,
- "glfs_unlink(%s) on volume %s for block %s failed[%s]",
- gbid, blk->volume, blk->block_name, strerror(errno));
- }
-
- ret = -1;
- goto out;
+ goto unlink;
}
- if (tgfd && glfs_close(tgfd) != 0) {
+ if (blk->prealloc && glfs_zerofill(tgfd, 0, blk->size)) {
*errCode = errno;
LOG("gfapi", GB_LOG_ERROR,
- "glfs_close(%s): on volume %s for block %s failed[%s]",
- gbid, blk->volume, blk->block_name, strerror(errno));
+ "glfs_zerofill(%s): on volume %s for block %s "
+ "of size %zu failed[%s]", gbid, blk->volume, blk->block_name,
+ blk->size, strerror(errno));
ret = -1;
- goto out;
+ goto unlink;
}
}
+
+unlink:
+ if (tgfd && glfs_close(tgfd) != 0) {
+ *errCode = errno;
+ LOG("gfapi", GB_LOG_ERROR,
+ "glfs_close(%s): on volume %s for block %s failed[%s]",
+ gbid, blk->volume, blk->block_name, strerror(errno));
+ ret = -1;
+ }
+
+ if (ret && glfs_unlink(glfs, gbid) && errno != ENOENT) {
+ *errCode = errno;
+ LOG("gfapi", GB_LOG_ERROR,
+ "glfs_unlink(%s) on volume %s for block %s failed[%s]",
+ gbid, blk->volume, blk->block_name, strerror(errno));
+ }
+
out:
if (ret) {
GB_ASPRINTF (errMsg, "Not able to create metadata for %s/%s[%s]", blk->volume,