bdev/aio: rename "fname" to "filename"

The construct_aio_bdev RPC still accepts "fname" for backwards
compatibility.

Change-Id: Ibf44f5f3667c6de4b827f7f3f8787aff0a6c4fc9
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/373834
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2017-08-10 15:47:45 -07:00 committed by Jim Harris
parent b44377f9e6
commit 6d5285bdfb
4 changed files with 23 additions and 13 deletions

View File

@ -62,10 +62,10 @@ bdev_aio_open(struct file_disk *disk)
{
int fd;
fd = open(disk->file, O_RDWR | O_DIRECT);
fd = open(disk->filename, O_RDWR | O_DIRECT);
if (fd < 0) {
/* Try without O_DIRECT for non-disk files */
fd = open(disk->file, O_RDWR);
fd = open(disk->filename, O_RDWR);
if (fd < 0) {
perror("open");
disk->fd = -1;
@ -331,12 +331,13 @@ static void aio_free_disk(struct file_disk *fdisk)
{
if (fdisk == NULL)
return;
free(fdisk->filename);
free(fdisk->disk.name);
free(fdisk);
}
struct spdk_bdev *
create_aio_disk(const char *name, const char *fname, uint32_t block_size)
create_aio_disk(const char *name, const char *filename, uint32_t block_size)
{
struct file_disk *fdisk;
uint32_t detected_block_size;
@ -348,9 +349,13 @@ create_aio_disk(const char *name, const char *fname, uint32_t block_size)
return NULL;
}
fdisk->file = fname;
fdisk->filename = strdup(filename);
if (!fdisk->filename) {
goto error_return;
}
if (bdev_aio_open(fdisk)) {
SPDK_ERRLOG("Unable to open file %s. fd: %d errno: %d\n", fname, fdisk->fd, errno);
SPDK_ERRLOG("Unable to open file %s. fd: %d errno: %d\n", filename, fdisk->fd, errno);
goto error_return;
}

View File

@ -56,10 +56,10 @@ struct bdev_aio_io_channel {
struct file_disk {
struct spdk_bdev disk;
const char *file;
char *filename;
int fd;
};
struct spdk_bdev *create_aio_disk(const char *name, const char *fname, uint32_t block_size);
struct spdk_bdev *create_aio_disk(const char *name, const char *filename, uint32_t block_size);
#endif // SPDK_BDEV_AIO_H

View File

@ -39,7 +39,7 @@
struct rpc_construct_aio {
char *name;
char *fname;
char *filename;
uint32_t block_size;
};
@ -47,12 +47,13 @@ static void
free_rpc_construct_aio(struct rpc_construct_aio *req)
{
free(req->name);
free(req->fname);
free(req->filename);
}
static const struct spdk_json_object_decoder rpc_construct_aio_decoders[] = {
{"name", offsetof(struct rpc_construct_aio, name), spdk_json_decode_string},
{"fname", offsetof(struct rpc_construct_aio, fname), spdk_json_decode_string},
{"fname", offsetof(struct rpc_construct_aio, filename), spdk_json_decode_string, true}, /* deprecated - use "filename" */
{"filename", offsetof(struct rpc_construct_aio, filename), spdk_json_decode_string, true},
{"block_size", offsetof(struct rpc_construct_aio, block_size), spdk_json_decode_uint32, true},
};
@ -71,7 +72,11 @@ spdk_rpc_construct_aio_bdev(struct spdk_jsonrpc_request *request,
goto invalid;
}
bdev = create_aio_disk(req.name, req.fname, req.block_size);
if (req.filename == NULL) {
goto invalid;
}
bdev = create_aio_disk(req.name, req.filename, req.block_size);
if (bdev == NULL) {
goto invalid;
}

View File

@ -188,7 +188,7 @@ p.set_defaults(func=construct_null_bdev)
def construct_aio_bdev(args):
params = {'name': args.name,
'fname': args.fname}
'filename': args.filename}
if args.block_size:
params['block_size'] = args.block_size
@ -196,7 +196,7 @@ def construct_aio_bdev(args):
print_array(jsonrpc_call('construct_aio_bdev', params))
p = subparsers.add_parser('construct_aio_bdev', help='Add a bdev with aio backend')
p.add_argument('fname', help='Path to device or file (ex: /dev/sda)')
p.add_argument('filename', help='Path to device or file (ex: /dev/sda)')
p.add_argument('name', help='Block device name')
p.add_argument('block_size', help='Block size for this bdev', type=int, default=argparse.SUPPRESS)
p.set_defaults(func=construct_aio_bdev)