From 4856534e767c9640011b88068b95e972c16213ab Mon Sep 17 00:00:00 2001 From: "John A. Chandy" Date: Sat, 9 Feb 2013 11:08:21 -0500 Subject: [PATCH] added support for SG_IO ioctl async scsi commands (using read and write) do not work when you have multiple processes, since one process's command response can get read by another response. The ioctl forces a blocking read after the write. --- osd-initiator/device.c | 130 +++++++++++++-------- osd-initiator/sync.c | 253 ++++++++++------------------------------- 2 files changed, 139 insertions(+), 244 deletions(-) diff --git a/osd-initiator/device.c b/osd-initiator/device.c index 348ecc6..216147a 100644 --- a/osd-initiator/device.c +++ b/osd-initiator/device.c @@ -24,69 +24,69 @@ #include "osd-util/osd-util.h" #include #include +#include #include "command.h" #include "device.h" -int osd_submit_command(int fd, struct osd_command *command) +static void +osd_submit_command_setup(struct osd_command *command, struct sg_io_v4 *sg) { - int ret; - struct sg_io_v4 sg; + memset(sg, 0, sizeof(*sg)); - memset(&sg, 0, sizeof(sg)); - sg.guard = 'Q'; - sg.request_len = command->cdb_len; - sg.request = (uint64_t) (uintptr_t) command->cdb; - sg.max_response_len = sizeof(command->sense); - sg.response = (uint64_t) (uintptr_t) command->sense; + sg->guard = 'Q'; + sg->request_len = command->cdb_len; + sg->request = (uint64_t) (uintptr_t) command->cdb; + sg->max_response_len = sizeof(command->sense); + sg->response = (uint64_t) (uintptr_t) command->sense; if (command->outlen) { #ifdef KERNEL_SUPPORTS_BSG_IOVEC - sg.dout_xfer_len = command->outlen; - sg.dout_xferp = (uint64_t) (uintptr_t) command->outdata; - sg.dout_iovec_count = command->iov_outlen; + sg->dout_xfer_len = command->outlen; + sg->dout_xferp = (uint64_t) (uintptr_t) command->outdata; + sg->dout_iovec_count = command->iov_outlen; #else // The kernel doesn't support BSG iovecs mainly because // of a problem going from 32-bit user iovecs to a 64-bit kernel // So, just copy the iovecs into a new buffer and use that sg_iovec_t *iov = (sg_iovec_t *)(uintptr_t)command->outdata; if (command->iov_outlen == 0) { - sg.dout_xfer_len = command->outlen; - sg.dout_xferp = (uint64_t) (uintptr_t) command->outdata; + sg->dout_xfer_len = command->outlen; + sg->dout_xferp = (uint64_t) (uintptr_t) command->outdata; } else if (command->iov_outlen == 1) { - sg.dout_xfer_len = iov->iov_len; - sg.dout_xferp = (uint64_t) (uintptr_t) iov->iov_base; + sg->dout_xfer_len = iov->iov_len; + sg->dout_xferp = (uint64_t) (uintptr_t) iov->iov_base; } else { int i; uint8_t *buff = Malloc(command->outlen); - sg.dout_xferp = (uint64_t) (uintptr_t) buff; + sg->dout_xferp = (uint64_t) (uintptr_t) buff; for (i=0; iiov_outlen; i++) { memcpy(buff, iov[i].iov_base, iov[i].iov_len); buff += iov[i].iov_len; } - sg.dout_xfer_len = command->outlen; + sg->dout_xfer_len = command->outlen; } - sg.dout_iovec_count = 0; + sg->dout_iovec_count = 0; #endif } if (command->inlen_alloc) { #ifdef KERNEL_SUPPORTS_BSG_IOVEC - sg.din_xfer_len = command->inlen_alloc; - sg.din_xferp = (uint64_t) (uintptr_t) command->indata; - sg.din_iovec_count = command->iov_inlen; + sg->din_xfer_len = command->inlen_alloc; + sg->din_xferp = (uint64_t) (uintptr_t) command->indata; + sg->din_iovec_count = command->iov_inlen; #else if (command->iov_inlen == 0) { - sg.din_xfer_len = command->inlen_alloc; - sg.din_xferp = (uint64_t) (uintptr_t) command->indata; - sg.din_iovec_count = command->iov_inlen; + sg->din_xfer_len = command->inlen_alloc; + sg->din_xferp = (uint64_t) (uintptr_t) command->indata; + sg->din_iovec_count = command->iov_inlen; } else if (command->iov_inlen == 1) { sg_iovec_t *iov = (sg_iovec_t *)command->indata; - sg.din_xfer_len = iov->iov_len; - sg.din_xferp = (uint64_t) (uintptr_t) iov->iov_base; + sg->din_xfer_len = iov->iov_len; + sg->din_xferp = (uint64_t) (uintptr_t) iov->iov_base; } else { - sg.din_xfer_len = command->inlen_alloc; - sg.din_xferp = (uint64_t) (uintptr_t) (uint8_t*) Malloc(command->inlen_alloc); + sg->din_xfer_len = command->inlen_alloc; + sg->din_xferp = (uint64_t) (uintptr_t) (uint8_t*) Malloc(command->inlen_alloc); } - sg.din_iovec_count = 0; + sg->din_iovec_count = 0; #endif } @@ -94,14 +94,31 @@ int osd_submit_command(int fd, struct osd_command *command) * Allow 30 sec for entire command. Some can be * slow, especially with debugging messages on. */ - sg.timeout = 30000; - sg.usr_ptr = (uint64_t) (uintptr_t) command; - ret = write(fd, &sg, sizeof(sg)); + sg->timeout = 30000; + sg->usr_ptr = (uint64_t) (uintptr_t) command; +} + +static void +osd_submit_command_cleanup(struct osd_command *command, struct sg_io_v4 *sg) +{ #ifndef KERNEL_SUPPORTS_BSG_IOVEC if (command->outlen && command->iov_outlen > 1) { - free((void *) (uintptr_t) sg.dout_xferp); + free((void *) (uintptr_t) sg->dout_xferp); } #endif +} + +int osd_submit_command(int fd, struct osd_command *command) +{ + struct sg_io_v4 sg; + int ret; + + osd_submit_command_setup(command, &sg); + + ret = write(fd, &sg, sizeof(sg)); + + osd_submit_command_cleanup(command, &sg); + if (ret < 0) { osd_error_errno("%s: write", __func__); return -errno; @@ -114,6 +131,8 @@ int osd_submit_command(int fd, struct osd_command *command) return 0; } +static void copy_sg_to_command(struct sg_io_v4 *sg, struct osd_command *command); + int osd_wait_response(int fd, struct osd_command **out_command) { struct sg_io_v4 sg; @@ -132,28 +151,32 @@ int osd_wait_response(int fd, struct osd_command **out_command) } command = (void *)(uintptr_t) sg.usr_ptr; + copy_sg_to_command(&sg, command); + + *out_command = command; + + return 0;} + +static void copy_sg_to_command(struct sg_io_v4 *sg, struct osd_command *command) +{ if (command->inlen_alloc) - command->inlen = command->inlen_alloc - sg.din_resid; - command->status = sg.device_status; - command->sense_len = sg.response_len; + command->inlen = command->inlen_alloc - sg->din_resid; + command->status = sg->device_status; + command->sense_len = sg->response_len; #ifndef KERNEL_SUPPORTS_BSG_IOVEC // copy from buffer to iovecs if (command->inlen_alloc && command->iov_inlen > 1) { sg_iovec_t *iov = (sg_iovec_t *) command->indata; - uint8_t *buff = (uint8_t *) (uintptr_t) sg.din_xferp; + uint8_t *buff = (uint8_t *) (uintptr_t) sg->din_xferp; int i; for (i=0; iiov_inlen; i++) { memcpy(iov[i].iov_base, buff, iov[i].iov_len); buff += iov[i].iov_len; } - free((void *) (uintptr_t) sg.din_xferp); + free((void *) (uintptr_t) sg->din_xferp); } #endif - - *out_command = command; - - return 0; } /* @@ -178,17 +201,26 @@ int osd_wait_this_response(int fd, struct osd_command *command) int osd_submit_and_wait(int fd, struct osd_command *command) { int ret; + struct sg_io_v4 sg; - ret = osd_submit_command(fd, command); - if (ret) { - osd_error("%s: submit failed", __func__); - return ret; + osd_submit_command_setup(command, &sg); + sg.flags = BSG_FLAG_Q_AT_TAIL; + + ret = ioctl(fd, SG_IO, &sg); + + osd_submit_command_cleanup(command, &sg); + + if ((struct osd_command *)(uintptr_t)sg.usr_ptr != command) { + osd_error("%s: wrong command returned", __func__); + ret = -EIO; } - ret = osd_wait_this_response(fd, command); + copy_sg_to_command(&sg, command); + if (ret) { - osd_error("%s: wait_response failed", __func__); + osd_error("%s: submit failed", __func__); return ret; } + return 0; } diff --git a/osd-initiator/sync.c b/osd-initiator/sync.c index 83e732d..f1e8f61 100644 --- a/osd-initiator/sync.c +++ b/osd-initiator/sync.c @@ -54,6 +54,36 @@ static int check_response(int ret, struct osd_command *command, return 0; } +static int submit_command(int fd, struct osd_command *command, + uint8_t *buf __attribute__((unused))) +{ + int ret; + + /* async does not work when you have multiple processes, since + one process's command response may get read by another process + */ + int use_async = 0; + + osd_debug("....submitting command"); + if (use_async) { + osd_debug("....submitting command"); + ret = osd_submit_command(fd, command); + if (ret) { + osd_error("%s: submit_and_wait failed", __func__); + return ret; + } + + osd_debug("....retrieving response"); + ret = osd_wait_this_response(fd, command); + } else { + ret = osd_submit_and_wait(fd, command); + osd_debug("....retrieving response"); + } + check_response(ret, &command, buf); + + return ret; +} + int inquiry(int fd) { const int INQUIRY_RSP_LEN = 80; @@ -71,14 +101,7 @@ int inquiry(int fd) command.indata = inquiry_rsp; command.inlen_alloc = sizeof(inquiry_rsp); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - if (ret) - osd_error("%s: osd_submit_command failed: %d", __func__, ret); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, inquiry_rsp); + submit_command(fd, &command, inquiry_rsp); #ifndef NDEBUG osd_hexdump(inquiry_rsp, command.inlen); @@ -90,7 +113,6 @@ int inquiry(int fd) int query(int fd, uint64_t pid, uint64_t cid, const uint8_t *query) { - int ret; uint8_t buf[100] = ""; struct osd_command command; @@ -112,13 +134,7 @@ int query(int fd, uint64_t pid, uint64_t cid, const uint8_t *query) command.indata = buf; command.inlen_alloc = sizeof(buf); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, buf); + submit_command(fd, &command, buf); return 0; } @@ -126,7 +142,6 @@ int query(int fd, uint64_t pid, uint64_t cid, const uint8_t *query) int create_osd(int fd, uint64_t pid, uint64_t requested_oid, uint16_t num_user_objects) { - int ret; struct osd_command command; osd_debug("****** CREATE OBJECT ******"); @@ -137,20 +152,13 @@ int create_osd(int fd, uint64_t pid, uint64_t requested_oid, osd_debug("....creating command"); osd_command_set_create(&command, pid, requested_oid, num_user_objects); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int create_partition(int fd, uint64_t requested_pid) { - int ret; struct osd_command command; osd_debug("****** CREATE PARTITION ******"); @@ -159,20 +167,13 @@ int create_partition(int fd, uint64_t requested_pid) osd_debug("....creating command"); osd_command_set_create_partition(&command, requested_pid); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int create_collection(int fd, uint64_t pid, uint64_t requested_cid) { - int ret; struct osd_command command; osd_debug("****** CREATE COLLECTION ******"); @@ -181,20 +182,13 @@ int create_collection(int fd, uint64_t pid, uint64_t requested_cid) osd_debug("....creating command"); osd_command_set_create_collection(&command, pid, requested_cid); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int remove_osd(int fd, uint64_t pid, uint64_t requested_oid) { - int ret; struct osd_command command; osd_debug("****** REMOVE OBJECT ******"); @@ -203,20 +197,13 @@ int remove_osd(int fd, uint64_t pid, uint64_t requested_oid) osd_debug("....creating command"); osd_command_set_remove(&command, pid, requested_oid); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int remove_partition(int fd, uint64_t pid) { - int ret; struct osd_command command; osd_debug("****** REMOVE PARTITION ******"); @@ -225,20 +212,13 @@ int remove_partition(int fd, uint64_t pid) osd_debug("....creating command"); osd_command_set_remove_partition(&command, pid); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int remove_collection(int fd, uint64_t pid, uint64_t cid, int force) { - int ret; struct osd_command command; osd_debug("****** REMOVE COLLECTION ******"); @@ -247,20 +227,13 @@ int remove_collection(int fd, uint64_t pid, uint64_t cid, int force) osd_debug("....creating command"); osd_command_set_remove_collection(&command, pid, cid, force); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int remove_member_objects(int fd, uint64_t pid, uint64_t cid) { - int ret; struct osd_command command; osd_debug("****** REMOVE MEMBER OBJECTS ******"); @@ -269,13 +242,7 @@ int remove_member_objects(int fd, uint64_t pid, uint64_t cid) osd_debug("....creating command"); osd_command_set_remove_member_objects(&command, pid, cid); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -283,7 +250,6 @@ int remove_member_objects(int fd, uint64_t pid, uint64_t cid) int create_and_write_osd(int fd, uint64_t pid, uint64_t requested_oid, const uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** CREATE / WRITE ******"); @@ -303,13 +269,7 @@ int create_and_write_osd(int fd, uint64_t pid, uint64_t requested_oid, command.outdata = buf; command.outlen = len; - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -317,7 +277,6 @@ int create_and_write_osd(int fd, uint64_t pid, uint64_t requested_oid, int create_and_write_sgl_osd(int fd, uint64_t pid, uint64_t requested_oid, const uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** CREATE / WRITE SGL ******"); @@ -337,11 +296,7 @@ int create_and_write_sgl_osd(int fd, uint64_t pid, uint64_t requested_oid, command.outdata = buf; command.outlen = len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -349,7 +304,6 @@ int create_and_write_sgl_osd(int fd, uint64_t pid, uint64_t requested_oid, int create_and_write_vec_osd(int fd, uint64_t pid, uint64_t requested_oid, const uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** CREATE / WRITE VEC ******"); @@ -369,11 +323,7 @@ int create_and_write_vec_osd(int fd, uint64_t pid, uint64_t requested_oid, command.outdata = buf; command.outlen = len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -405,11 +355,8 @@ int write_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, osd_command_attr_build(&command, &attr, 1); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); if (command.status != 0) return 1; @@ -459,11 +406,7 @@ int write_sgl_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, osd_command_attr_build(&command, &attr, 1); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); ret = osd_command_attr_resolve(&command); if (ret) { @@ -509,11 +452,7 @@ int write_vec_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, osd_command_attr_build(&command, &attr, 1); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); ret = osd_command_attr_resolve(&command); if (ret) { @@ -531,7 +470,6 @@ int write_vec_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, int append_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, uint64_t len) { - int ret; struct osd_command command; osd_debug("****** APPEND ******"); @@ -549,13 +487,7 @@ int append_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, command.outdata = buf; command.outlen = len; - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -563,7 +495,6 @@ int append_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, int append_sgl_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, uint64_t len) { - int ret; struct osd_command command; osd_debug("****** APPEND ******"); @@ -582,11 +513,7 @@ int append_sgl_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, command.outdata = buf; command.outlen = len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -594,7 +521,6 @@ int append_sgl_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, int append_vec_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, uint64_t len) { - int ret; struct osd_command command; osd_debug("****** APPEND ******"); @@ -613,11 +539,7 @@ int append_vec_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, command.outdata = buf; command.outlen = len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -625,7 +547,6 @@ int append_vec_osd(int fd, uint64_t pid, uint64_t oid, const uint8_t *buf, int read_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** READ ******"); @@ -638,13 +559,7 @@ int read_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *buf, uint64_t len, command.indata = buf; command.inlen_alloc = len; - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, buf); + submit_command(fd, &command, buf); return 0; } @@ -652,7 +567,6 @@ int read_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *buf, uint64_t len, int read_sgl_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *ddt_buf, uint64_t ddt_len, uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** READ ******"); @@ -669,11 +583,7 @@ int read_sgl_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *ddt_buf, command.outdata = ddt_buf; command.outlen = ddt_len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, buf); + submit_command(fd, &command, buf); return 0; } @@ -681,7 +591,6 @@ int read_sgl_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *ddt_buf, int read_vec_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *ddt_buf, uint64_t ddt_len, uint8_t *buf, uint64_t len, uint64_t offset) { - int ret; struct osd_command command; osd_debug("****** READ ******"); @@ -698,11 +607,7 @@ int read_vec_osd(int fd, uint64_t pid, uint64_t oid, uint8_t *ddt_buf, command.outdata = ddt_buf; command.outlen = ddt_len; - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, buf); + submit_command(fd, &command, buf); return 0; } @@ -733,20 +638,13 @@ int format_osd(int fd, int capacity) osd_debug("....creating command"); osd_command_set_format_osd(&command, capacity); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int flush_osd(int fd, int flush_scope) { - int ret; struct osd_command command; osd_debug("****** FLUSH OSD ******"); @@ -754,20 +652,13 @@ int flush_osd(int fd, int flush_scope) osd_debug("....creating command"); osd_command_set_flush_osd(&command, flush_scope); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int flush_partition(int fd, uint64_t pid, int flush_scope) { - int ret; struct osd_command command; osd_debug("****** FLUSH PARTITION ******"); @@ -776,20 +667,13 @@ int flush_partition(int fd, uint64_t pid, int flush_scope) osd_debug("....creating command"); osd_command_set_flush_partition(&command, pid, flush_scope); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int flush_collection(int fd, uint64_t pid, uint64_t cid, int flush_scope) { - int ret; struct osd_command command; osd_debug("****** FLUSH COLLECTION ******"); @@ -798,20 +682,13 @@ int flush_collection(int fd, uint64_t pid, uint64_t cid, int flush_scope) osd_debug("....creating command"); osd_command_set_flush_collection(&command, pid, cid, flush_scope); - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } int flush_object(int fd, uint64_t pid, uint64_t oid, uint64_t len, uint64_t offset, int flush_scope) { - int ret; struct osd_command command; osd_debug("****** FLUSH OBJECT ******"); @@ -819,11 +696,7 @@ int flush_object(int fd, uint64_t pid, uint64_t oid, uint64_t len, uint64_t offs osd_command_set_flush(&command, pid, oid, len, offset, flush_scope); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); - - ret = osd_wait_this_response(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, NULL); return 0; } @@ -927,7 +800,6 @@ int list(int fd, uint64_t pid, uint32_t list_id, uint64_t initial_oid, * It is 24 bytes larger than alloc_len for header information in the * returned data. */ - int ret; uint64_t buf_len = alloc_len + 24; uint8_t buf[buf_len]; memset(buf, 0, buf_len); @@ -961,12 +833,8 @@ int list(int fd, uint64_t pid, uint32_t list_id, uint64_t initial_oid, command.indata = buf; command.inlen_alloc = buf_len; - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, &command); - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); osd_command_list_resolve(&command); return 0; @@ -985,7 +853,6 @@ int list_collection(int fd, uint64_t pid, uint64_t cid, uint32_t list_id, * It is 24 bytes larger than alloc_len for header information in the * returned data. */ - int ret; uint64_t buf_len = alloc_len + 24; uint8_t buf[buf_len]; memset(buf, 0, buf_len); @@ -1021,12 +888,8 @@ int list_collection(int fd, uint64_t pid, uint64_t cid, uint32_t list_id, command.indata = buf; command.inlen_alloc = buf_len; - osd_debug("....submitting command"); - ret = osd_submit_command(fd, &command); - check_response(ret, &command, NULL); + submit_command(fd, &command, &command); - osd_debug("....retrieving response"); - ret = osd_wait_this_response(fd, &command); osd_command_list_collection_resolve(&command); return 0;