summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
Diffstat (limited to 'rpc')
-rw-r--r--rpc/block_svc_routines.c6
-rw-r--r--rpc/glfs-operations.c57
-rw-r--r--rpc/rpcl/block.x1
3 files changed, 59 insertions, 5 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index 0c32293..f6f532b 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -3009,9 +3009,9 @@ block_create_cli_1_svc_st(blockCreateCli *blk, struct svc_req *rqstp)
GB_METAUPDATE_OR_GOTO(lock, glfs, blk->block_name, blk->volume,
errCode, errMsg, exist,
- "VOLUME: %s\nGBID: %s\nSIZE: %zu\n"
+ "VOLUME: %s\nGBID: %s\n"
"HA: %d\nENTRYCREATE: INPROGRESS\n",
- blk->volume, gbid, blk->size, blk->mpath);
+ blk->volume, gbid, blk->mpath);
if (glusterBlockCreateEntry(glfs, blk, gbid, &errCode, &errMsg)) {
LOG("mgmt", GB_LOG_ERROR, "%s volume: %s host: %s",
@@ -3020,7 +3020,7 @@ block_create_cli_1_svc_st(blockCreateCli *blk, struct svc_req *rqstp)
}
GB_METAUPDATE_OR_GOTO(lock, glfs, blk->block_name, blk->volume,
- errCode, errMsg, exist, "ENTRYCREATE: SUCCESS\n");
+ errCode, errMsg, exist, "SIZE: %zu\nENTRYCREATE: SUCCESS\n", blk->size);
GB_STRCPYSTATIC(cobj.volume, blk->volume);
GB_STRCPYSTATIC(cobj.block_name, blk->block_name);
diff --git a/rpc/glfs-operations.c b/rpc/glfs-operations.c
index 838d3c7..341a6e2 100644
--- a/rpc/glfs-operations.c
+++ b/rpc/glfs-operations.c
@@ -91,6 +91,7 @@ glusterBlockCreateEntry(struct glfs *glfs, blockCreateCli *blk, char *gbid,
int *errCode, char **errMsg)
{
struct glfs_fd *tgfd;
+ struct stat st;
char *tmp;
int ret;
@@ -112,6 +113,56 @@ glusterBlockCreateEntry(struct glfs *glfs, blockCreateCli *blk, char *gbid,
goto out;
}
+ if (strlen(blk->storage)) {
+ ret = glfs_stat(glfs, blk->storage, &st);
+ if (ret) {
+ *errCode = errno;
+ if (*errCode == ENOENT) {
+ LOG("mgmt", GB_LOG_ERROR,
+ "storage file '/block-store/%s' doesn't exist in volume %s",
+ blk->storage, blk->volume);
+ GB_ASPRINTF(errMsg,
+ "storage file '/block-store/%s' doesn't exist in volume %s\n",
+ blk->storage, blk->volume);
+ } else {
+ LOG("mgmt", GB_LOG_ERROR,
+ "glfs_stat failed on /block-store/%s in volume %s [%s]",
+ blk->storage, blk->volume, strerror(*errCode));
+ GB_ASPRINTF(errMsg,
+ "glfs_stat failed on /block-store/%s in volume %s [%s]",
+ blk->storage, blk->volume, strerror(*errCode));
+ }
+ goto out;
+ }
+ blk->size = st.st_size;
+
+ if (st.st_nlink == 1) {
+ ret = glfs_link(glfs, blk->storage, gbid);
+ if (ret) {
+ *errCode=errno;
+ LOG("mgmt", GB_LOG_ERROR,
+ "glfs_link(%s, %s) on volume %s for block %s failed [%s]",
+ blk->storage, gbid, blk->volume, blk->block_name, strerror(errno));
+ GB_ASPRINTF(errMsg,
+ "glfs_link(%s, %s) on volume %s for block %s failed [%s]",
+ blk->storage, gbid, strerror(errno));
+ goto out;
+ }
+ } else {
+ *errCode = EBUSY;
+ LOG("mgmt", GB_LOG_ERROR,
+ "storage file /block-store/%s is already in use in volume %s [%s]",
+ blk->storage, blk->volume, strerror(*errCode));
+ GB_ASPRINTF(errMsg,
+ "storage file /block-store/%s is already in use in volume %s [%s]\n"
+ "hint: delete the hardlink file, make sure file is not in use\n",
+ blk->storage, blk->volume, strerror(*errCode));
+ ret = -1;
+ goto out;
+ }
+ return 0;
+ }
+
tgfd = glfs_creat(glfs, gbid,
O_WRONLY | O_CREAT | O_EXCL | O_SYNC,
S_IRUSR | S_IWUSR);
@@ -163,8 +214,10 @@ unlink:
out:
if (ret) {
- GB_ASPRINTF (errMsg, "Not able to create storage for %s/%s [%s]",
- blk->volume, blk->block_name, strerror(*errCode));
+ if (!errMsg) {
+ GB_ASPRINTF (errMsg, "Not able to create storage for %s/%s [%s]",
+ blk->volume, blk->block_name, strerror(*errCode));
+ }
GB_ASPRINTF(&tmp, "%s/%s", GB_METADIR, blk->block_name);
diff --git a/rpc/rpcl/block.x b/rpc/rpcl/block.x
index 4ad0549..e3fcbd1 100644
--- a/rpc/rpcl/block.x
+++ b/rpc/rpcl/block.x
@@ -47,6 +47,7 @@ struct blockCreateCli {
u_int mpath; /* HA request count */
bool auth_mode;
bool prealloc;
+ char storage[255];
char block_name[255];
string block_hosts<>;
enum JsonResponseFormat json_resp;