Beispiel #1
0
/*
 * __wt_exclusive_handle_operation --
 *	Get exclusive access to a file and apply a function.
 */
int
__wt_exclusive_handle_operation(WT_SESSION_IMPL *session,
   const char *uri,
   int (*file_func)(WT_SESSION_IMPL *, const char *[]),
   const char *cfg[], uint32_t open_flags)
{
	WT_DECL_RET;

	/*
	 * If the operation requires exclusive access, close
	 * any open file handles, including checkpoints.
	 */
	if (FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE)) {
		WT_WITH_HANDLE_LIST_WRITE_LOCK(session,
		    ret = __wt_conn_dhandle_close_all(
		    session, uri, false, false));
		WT_RET(ret);
	}

	WT_RET(__wt_session_get_btree_ckpt(session, uri, cfg, open_flags));
	WT_SAVE_DHANDLE(session, ret = file_func(session, cfg));
	WT_TRET(__wt_session_release_dhandle(session));

	return (ret);
}
Beispiel #2
0
/*
 * __drop_file --
 *	Drop a file.
 */
static int
__drop_file(
    WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[])
{
	WT_CONFIG_ITEM cval;
	WT_DECL_RET;
	const char *filename;
	bool remove_files;

	WT_RET(__wt_config_gets(session, cfg, "remove_files", &cval));
	remove_files = cval.val != 0;

	filename = uri;
	WT_PREFIX_SKIP_REQUIRED(session, filename, "file:");

	WT_RET(__wt_schema_backup_check(session, filename));
	/* Close all btree handles associated with this file. */
	WT_WITH_HANDLE_LIST_WRITE_LOCK(session,
	    ret = __wt_conn_dhandle_close_all(session, uri, true, force));
	WT_RET(ret);

	/* Remove the metadata entry (ignore missing items). */
	WT_TRET(__wt_metadata_remove(session, uri));
	if (!remove_files)
		return (ret);

	/*
	 * Schedule the remove of the underlying physical file when the drop
	 * completes.
	 */
	WT_TRET(__wt_meta_track_drop(session, filename));

	return (ret);
}