Skip to content

Commit

Permalink
WT-2630 Rename pluggable filesystem methods to avoid reserved names. (#…
Browse files Browse the repository at this point in the history
…2730)

* WT-2630 Rename pluggable filesystem methods to avoid reserved names.

Use "fstr" consistently as the variable name and prefix for WT_FSTREAM.
  • Loading branch information
michaelcahill committed May 24, 2016
1 parent 2c16e4a commit cace8ac
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 227 deletions.
44 changes: 22 additions & 22 deletions examples/c/ex_file_system.c
Expand Up @@ -148,14 +148,14 @@ demo_file_system_create(WT_CONNECTION *conn, WT_CONFIG_ARG *config)
file_system = (WT_FILE_SYSTEM *)demo_fs;

/* Initialize the in-memory jump table. */
file_system->directory_list = demo_fs_directory_list;
file_system->directory_list_free = demo_fs_directory_list_free;
file_system->directory_sync = demo_fs_directory_sync;
file_system->exist = demo_fs_exist;
file_system->open_file = demo_fs_open;
file_system->remove = demo_fs_remove;
file_system->rename = demo_fs_rename;
file_system->size = demo_fs_size;
file_system->fs_directory_list = demo_fs_directory_list;
file_system->fs_directory_list_free = demo_fs_directory_list_free;
file_system->fs_directory_sync = demo_fs_directory_sync;
file_system->fs_exist = demo_fs_exist;
file_system->fs_open_file = demo_fs_open;
file_system->fs_remove = demo_fs_remove;
file_system->fs_rename = demo_fs_rename;
file_system->fs_size = demo_fs_size;
file_system->terminate = demo_fs_terminate;

if ((ret = conn->set_file_system(conn, file_system, NULL)) != 0) {
Expand Down Expand Up @@ -236,20 +236,20 @@ demo_fs_open(WT_FILE_SYSTEM *file_system, WT_SESSION *session,
* the functionality.
*/
file_handle->close = demo_file_close;
file_handle->fadvise = NULL;
file_handle->fallocate = NULL;
file_handle->fallocate_nolock = NULL;
file_handle->lock = demo_file_lock;
file_handle->map = NULL;
file_handle->map_discard = NULL;
file_handle->map_preload = NULL;
file_handle->unmap = NULL;
file_handle->read = demo_file_read;
file_handle->size = demo_file_size;
file_handle->sync = demo_file_sync;
file_handle->sync_nowait = demo_file_sync_nowait;
file_handle->truncate = demo_file_truncate;
file_handle->write = demo_file_write;
file_handle->fh_advise = NULL;
file_handle->fh_allocate = NULL;
file_handle->fh_allocate_nolock = NULL;
file_handle->fh_lock = demo_file_lock;
file_handle->fh_map = NULL;
file_handle->fh_map_discard = NULL;
file_handle->fh_map_preload = NULL;
file_handle->fh_unmap = NULL;
file_handle->fh_read = demo_file_read;
file_handle->fh_size = demo_file_size;
file_handle->fh_sync = demo_file_sync;
file_handle->fh_sync_nowait = demo_file_sync_nowait;
file_handle->fh_truncate = demo_file_truncate;
file_handle->fh_write = demo_file_write;

TAILQ_INSERT_HEAD(&demo_fs->fileq, demo_fh, q);
++demo_fs->opened_unique_file_count;
Expand Down
6 changes: 3 additions & 3 deletions src/block/block_map.c
Expand Up @@ -46,15 +46,15 @@ __wt_block_map(WT_SESSION_IMPL *session, WT_BLOCK *block,
* There may be no underlying functionality.
*/
handle = block->fh->handle;
if (handle->map == NULL)
if (handle->fh_map == NULL)
return (0);

/*
* Map the file into memory.
* Ignore not-supported errors, we'll read the file through the cache
* if map fails.
*/
ret = handle->map(handle,
ret = handle->fh_map(handle,
(WT_SESSION *)session, mapped_regionp, lengthp, mapped_cookiep);
if (ret == ENOTSUP) {
*(void **)mapped_regionp = NULL;
Expand All @@ -76,6 +76,6 @@ __wt_block_unmap(WT_SESSION_IMPL *session,

/* Unmap the file from memory. */
handle = block->fh->handle;
return (handle->unmap(handle,
return (handle->fh_unmap(handle,
(WT_SESSION *)session, mapped_region, length, mapped_cookie));
}
2 changes: 1 addition & 1 deletion src/block/block_mgr.c
Expand Up @@ -311,7 +311,7 @@ __bm_map_discard(WT_BM *bm, WT_SESSION_IMPL *session, void *map, size_t len)
WT_FILE_HANDLE *handle;

handle = bm->block->fh->handle;
return (handle->map_discard(
return (handle->fh_map_discard(
handle, (WT_SESSION *)session, map, len, bm->mapped_cookie));
}

Expand Down
12 changes: 6 additions & 6 deletions src/block/block_read.c
Expand Up @@ -35,11 +35,11 @@ __wt_bm_preload(

handle = block->fh->handle;
mapped = bm->map != NULL && offset + size <= (wt_off_t)bm->maplen;
if (mapped && handle->map_preload != NULL)
ret = handle->map_preload(handle, (WT_SESSION *)session,
if (mapped && handle->fh_map_preload != NULL)
ret = handle->fh_map_preload(handle, (WT_SESSION *)session,
(uint8_t *)bm->map + offset, size, bm->mapped_cookie);
if (!mapped && handle->fadvise != NULL)
ret = handle->fadvise(handle, (WT_SESSION *)session,
if (!mapped && handle->fh_advise != NULL)
ret = handle->fh_advise(handle, (WT_SESSION *)session,
(wt_off_t)offset, (wt_off_t)size, WT_FILE_HANDLE_WILLNEED);
if (ret != EBUSY && ret != ENOTSUP)
return (ret);
Expand Down Expand Up @@ -78,10 +78,10 @@ __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session,
*/
handle = block->fh->handle;
mapped = bm->map != NULL && offset + size <= (wt_off_t)bm->maplen;
if (mapped && handle->map_preload != NULL) {
if (mapped && handle->fh_map_preload != NULL) {
buf->data = (uint8_t *)bm->map + offset;
buf->size = size;
ret = handle->map_preload(handle, (WT_SESSION *)session,
ret = handle->fh_map_preload(handle, (WT_SESSION *)session,
buf->data, buf->size,bm->mapped_cookie);

WT_STAT_FAST_CONN_INCR(session, block_map_read);
Expand Down
9 changes: 5 additions & 4 deletions src/block/block_write.c
Expand Up @@ -52,7 +52,7 @@ __wt_block_discard(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t added_size)

/* The file may not support this call. */
handle = block->fh->handle;
if (handle->fadvise == NULL)
if (handle->fh_advise == NULL)
return (0);

/* The call may not be configured. */
Expand All @@ -67,7 +67,7 @@ __wt_block_discard(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t added_size)
return (0);

block->os_cache = 0;
ret = handle->fadvise(handle, (WT_SESSION *)session,
ret = handle->fh_advise(handle, (WT_SESSION *)session,
(wt_off_t)0, (wt_off_t)0, WT_FILE_HANDLE_DONTNEED);
return (ret == EBUSY || ret == ENOTSUP ? 0 : ret);
}
Expand Down Expand Up @@ -128,15 +128,16 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block,
* and remember that ftruncate requires locking.
*/
handle = fh->handle;
if (handle->fallocate != NULL || handle->fallocate_nolock != NULL) {
if (handle->fh_allocate != NULL ||
handle->fh_allocate_nolock != NULL) {
/*
* Release any locally acquired lock if not needed to extend the
* file, extending the file may require updating on-disk file's
* metadata, which can be slow. (It may be a bad idea to
* configure for file extension on systems that require locking
* over the extend call.)
*/
if (handle->fallocate_nolock != NULL && *release_lockp) {
if (handle->fh_allocate_nolock != NULL && *release_lockp) {
*release_lockp = locked = false;
__wt_spin_unlock(session, &block->live_lock);
}
Expand Down
14 changes: 7 additions & 7 deletions src/conn/conn_api.c
Expand Up @@ -1919,16 +1919,16 @@ __conn_chk_file_system(WT_SESSION_IMPL *session, bool readonly)
WT_RET_MSG(session, EINVAL, \
"a WT_FILE_SYSTEM.%s method must be configured", #name)

WT_CONN_SET_FILE_SYSTEM_REQ(directory_list);
WT_CONN_SET_FILE_SYSTEM_REQ(directory_list_free);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_directory_list);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_directory_list_free);
/* not required: directory_sync */
WT_CONN_SET_FILE_SYSTEM_REQ(exist);
WT_CONN_SET_FILE_SYSTEM_REQ(open_file);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_exist);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_open_file);
if (!readonly) {
WT_CONN_SET_FILE_SYSTEM_REQ(remove);
WT_CONN_SET_FILE_SYSTEM_REQ(rename);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_remove);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_rename);
}
WT_CONN_SET_FILE_SYSTEM_REQ(size);
WT_CONN_SET_FILE_SYSTEM_REQ(fs_size);

return (0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/extern.h
Expand Up @@ -730,7 +730,7 @@ extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, b
extern int __wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp);
extern int __wt_errno(void);
extern int __wt_filename(WT_SESSION_IMPL *session, const char *name, char **path);
extern int __wt_fopen(WT_SESSION_IMPL *session, const char *name, uint32_t open_flags, uint32_t flags, WT_FSTREAM **fsp);
extern int __wt_fopen(WT_SESSION_IMPL *session, const char *name, uint32_t open_flags, uint32_t flags, WT_FSTREAM **fstrp);
extern int __wt_get_vm_pagesize(void);
extern int __wt_getenv(WT_SESSION_IMPL *session, const char *variable, const char **envp);
extern int __wt_getlasterror(void);
Expand Down
7 changes: 4 additions & 3 deletions src/include/os.h
Expand Up @@ -141,7 +141,8 @@ struct __wt_fstream {
uint32_t flags;

int (*close)(WT_SESSION_IMPL *, WT_FSTREAM *);
int (*flush)(WT_SESSION_IMPL *, WT_FSTREAM *);
int (*getline)(WT_SESSION_IMPL *, WT_FSTREAM *, WT_ITEM *);
int (*printf)(WT_SESSION_IMPL *, WT_FSTREAM *, const char *, va_list);
int (*fstr_flush)(WT_SESSION_IMPL *, WT_FSTREAM *);
int (*fstr_getline)(WT_SESSION_IMPL *, WT_FSTREAM *, WT_ITEM *);
int (*fstr_printf)(
WT_SESSION_IMPL *, WT_FSTREAM *, const char *, va_list);
};
29 changes: 15 additions & 14 deletions src/include/os_fhandle.i
Expand Up @@ -22,11 +22,11 @@ __wt_fsync(WT_SESSION_IMPL *session, WT_FH *fh, bool block)

handle = fh->handle;
if (block)
return (handle->sync == NULL ? 0 :
handle->sync(handle, (WT_SESSION *)session));
return (handle->fh_sync == NULL ? 0 :
handle->fh_sync(handle, (WT_SESSION *)session));
else
return (handle->sync_nowait == NULL ? 0 :
handle->sync_nowait(handle, (WT_SESSION *)session));
return (handle->fh_sync_nowait == NULL ? 0 :
handle->fh_sync_nowait(handle, (WT_SESSION *)session));
}

/*
Expand Down Expand Up @@ -55,14 +55,14 @@ __wt_fallocate(
* flavor, that failed, and we have to fallback to the locking flavor.
*/
handle = fh->handle;
if (handle->fallocate_nolock != NULL) {
if ((ret = handle->fallocate_nolock(
if (handle->fh_allocate_nolock != NULL) {
if ((ret = handle->fh_allocate_nolock(
handle, (WT_SESSION *)session, offset, len)) == 0)
return (0);
WT_RET_ERROR_OK(ret, ENOTSUP);
}
if (handle->fallocate != NULL)
return (handle->fallocate(
if (handle->fh_allocate != NULL)
return (handle->fh_allocate(
handle, (WT_SESSION *)session, offset, len));
return (ENOTSUP);
}
Expand All @@ -80,8 +80,8 @@ __wt_file_lock(WT_SESSION_IMPL * session, WT_FH *fh, bool lock)
"%s: handle-lock: %s", fh->handle->name, lock ? "lock" : "unlock"));

handle = fh->handle;
return (handle->lock == NULL ? 0 :
handle->lock(handle, (WT_SESSION*)session, lock));
return (handle->fh_lock == NULL ? 0 :
handle->fh_lock(handle, (WT_SESSION*)session, lock));
}

/*
Expand All @@ -98,7 +98,7 @@ __wt_read(

WT_STAT_FAST_CONN_INCR(session, read_io);

return (fh->handle->read(
return (fh->handle->fh_read(
fh->handle, (WT_SESSION *)session, offset, len, buf));
}

Expand All @@ -112,7 +112,7 @@ __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep)
WT_RET(__wt_verbose(
session, WT_VERB_HANDLEOPS, "%s: handle-size", fh->handle->name));

return (fh->handle->size(fh->handle, (WT_SESSION *)session, sizep));
return (fh->handle->fh_size(fh->handle, (WT_SESSION *)session, sizep));
}

/*
Expand All @@ -128,7 +128,8 @@ __wt_ftruncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t len)
"%s: handle-truncate: %" PRIuMAX,
fh->handle->name, (uintmax_t)len));

return (fh->handle->truncate(fh->handle, (WT_SESSION *)session, len));
return (fh->handle->fh_truncate(
fh->handle, (WT_SESSION *)session, len));
}

/*
Expand All @@ -149,6 +150,6 @@ __wt_write(WT_SESSION_IMPL *session,

WT_STAT_FAST_CONN_INCR(session, write_io);

return (fh->handle->write(
return (fh->handle->fh_write(
fh->handle, (WT_SESSION *)session, offset, len, buf));
}
17 changes: 9 additions & 8 deletions src/include/os_fs.i
Expand Up @@ -30,7 +30,7 @@ __wt_fs_directory_list(WT_SESSION_IMPL *session,

file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->directory_list(
ret = file_system->fs_directory_list(
file_system, wt_session, path, prefix, dirlistp, countp);

__wt_free(session, path);
Expand All @@ -52,7 +52,7 @@ __wt_fs_directory_list_free(
if (*dirlistp != NULL) {
file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->directory_list_free(
ret = file_system->fs_directory_list_free(
file_system, wt_session, *dirlistp, count);
}

Expand Down Expand Up @@ -88,7 +88,7 @@ __wt_fs_directory_sync(WT_SESSION_IMPL *session, const char *name)
* needed.
*/
file_system = S2C(session)->file_system;
if (file_system->directory_sync == NULL)
if (file_system->fs_directory_sync == NULL)
return (0);

copy = NULL;
Expand All @@ -109,7 +109,7 @@ __wt_fs_directory_sync(WT_SESSION_IMPL *session, const char *name)
}

wt_session = (WT_SESSION *)session;
ret = file_system->directory_sync(file_system, wt_session, name);
ret = file_system->fs_directory_sync(file_system, wt_session, name);

__wt_free(session, copy);
return (ret);
Expand All @@ -133,7 +133,7 @@ __wt_fs_exist(WT_SESSION_IMPL *session, const char *name, bool *existp)

file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->exist(file_system, wt_session, path, existp);
ret = file_system->fs_exist(file_system, wt_session, path, existp);

__wt_free(session, path);
return (ret);
Expand Down Expand Up @@ -169,7 +169,7 @@ __wt_fs_remove(WT_SESSION_IMPL *session, const char *name)

file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->remove(file_system, wt_session, path);
ret = file_system->fs_remove(file_system, wt_session, path);

__wt_free(session, path);
return (ret);
Expand Down Expand Up @@ -211,7 +211,8 @@ __wt_fs_rename(WT_SESSION_IMPL *session, const char *from, const char *to)

file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->rename(file_system, wt_session, from_path, to_path);
ret = file_system->fs_rename(
file_system, wt_session, from_path, to_path);

err: __wt_free(session, from_path);
__wt_free(session, to_path);
Expand All @@ -236,7 +237,7 @@ __wt_fs_size(WT_SESSION_IMPL *session, const char *name, wt_off_t *sizep)

file_system = S2C(session)->file_system;
wt_session = (WT_SESSION *)session;
ret = file_system->size(file_system, wt_session, path, sizep);
ret = file_system->fs_size(file_system, wt_session, path, sizep);

__wt_free(session, path);
return (ret);
Expand Down

0 comments on commit cace8ac

Please sign in to comment.