bdev_aio: Remove use of perror() for open/close failure

All SPDK libraries should use the spdk/log.h family of functions
for logging.

Change-Id: I4c12388433f8c57291cea9f30566438a9d78e3d1
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/391683
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Shuhei Matsumoto 2017-12-15 11:25:23 +09:00 committed by Jim Harris
parent 1bcc289ef7
commit a79a69d226

View File

@ -42,6 +42,7 @@
#include "spdk/io_channel.h" #include "spdk/io_channel.h"
#include "spdk/json.h" #include "spdk/json.h"
#include "spdk/util.h" #include "spdk/util.h"
#include "spdk/string.h"
#include "spdk_internal/log.h" #include "spdk_internal/log.h"
@ -65,13 +66,16 @@ static int
bdev_aio_open(struct file_disk *disk) bdev_aio_open(struct file_disk *disk)
{ {
int fd; int fd;
char buf[64];
fd = open(disk->filename, O_RDWR | O_DIRECT); fd = open(disk->filename, O_RDWR | O_DIRECT);
if (fd < 0) { if (fd < 0) {
/* Try without O_DIRECT for non-disk files */ /* Try without O_DIRECT for non-disk files */
fd = open(disk->filename, O_RDWR); fd = open(disk->filename, O_RDWR);
if (fd < 0) { if (fd < 0) {
perror("open"); spdk_strerror_r(errno, buf, sizeof(buf));
SPDK_ERRLOG("open() failed (file:%s), errno %d: %s\n",
disk->filename, errno, buf);
disk->fd = -1; disk->fd = -1;
return -1; return -1;
} }
@ -86,6 +90,7 @@ static int
bdev_aio_close(struct file_disk *disk) bdev_aio_close(struct file_disk *disk)
{ {
int rc; int rc;
char buf[64];
if (disk->fd == -1) { if (disk->fd == -1) {
return 0; return 0;
@ -93,7 +98,9 @@ bdev_aio_close(struct file_disk *disk)
rc = close(disk->fd); rc = close(disk->fd);
if (rc < 0) { if (rc < 0) {
perror("close"); spdk_strerror_r(errno, buf, sizeof(buf));
SPDK_ERRLOG("close() failed (fd=%d), errno %d: %s\n",
disk->fd, errno, buf);
return -1; return -1;
} }