适配DSS接口与错误码修改
This commit is contained in:
@ -953,12 +953,13 @@ static void dss_init(void)
|
||||
parse_vgname_args(instance_config.dss.vgname);
|
||||
|
||||
/* Check dss connect */
|
||||
if (!dss_exist_dir(instance_config.dss.vgdata)) {
|
||||
struct stat st;
|
||||
if (stat(instance_config.dss.vgdata, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
||||
elog(ERROR, "Could not connect dssserver, vgdata: \"%s\", socketpath: \"%s\", check and retry later.",
|
||||
instance_config.dss.vgdata, instance_config.dss.socketpath);
|
||||
}
|
||||
|
||||
if (strlen(instance_config.dss.vglog) && !dss_exist_dir(instance_config.dss.vglog)) {
|
||||
if (strlen(instance_config.dss.vglog) && (stat(instance_config.dss.vglog, &st) != 0 || !S_ISDIR(st.st_mode))) {
|
||||
elog(ERROR, "Could not connect dssserver, vglog: \"%s\", socketpath: \"%s\", check and retry later.",
|
||||
instance_config.dss.vglog, instance_config.dss.socketpath);
|
||||
}
|
||||
|
@ -490,7 +490,8 @@ static void SetGlobalDssParam(void)
|
||||
securec_check_c(rc, "\0", "\0");
|
||||
XLogSegmentSize = DSS_XLOG_SEG_SIZE;
|
||||
/* Check dss connect */
|
||||
if (!dss_exist_dir(g_datadir.dss_data)) {
|
||||
struct stat st;
|
||||
if (stat(g_datadir.dss_data, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
||||
fprintf(stderr, _("Could not connect dssserver, vgname: \"%s\", socketpath: \"%s\", \n"
|
||||
"please check that whether the dssserver is manually started and retry later.\n"),
|
||||
dss.vgname, dss.socketpath);
|
||||
|
3
src/common/backend/utils/cache/relmapper.cpp
vendored
3
src/common/backend/utils/cache/relmapper.cpp
vendored
@ -493,7 +493,8 @@ void RelationMapFinishBootstrap(void)
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name, RELMAPPER_FILENAME);
|
||||
securec_check_ss_c(rc, "\0", "\0");
|
||||
|
||||
if (dss_exist_file(map_file_name)) {
|
||||
struct stat st;
|
||||
if (stat(map_file_name, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2160,7 +2160,8 @@ void initDSSConf(void)
|
||||
}
|
||||
|
||||
// check whether dss connect is successful.
|
||||
if (!dss_exist_dir(g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name)) {
|
||||
struct stat st;
|
||||
if (stat(g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name, &st) != 0 || !S_ISDIR(st.st_mode)) {
|
||||
ereport(FATAL, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
|
||||
errmsg("Could not connect dssserver, vgname: \"%s\", socketpath: \"%s\"",
|
||||
g_instance.attr.attr_storage.dss_attr.ss_dss_vg_name,
|
||||
|
@ -167,7 +167,8 @@ void SSInitReformerControlPages(void)
|
||||
/*
|
||||
* If already exists control file, reformer page must have been initialized
|
||||
*/
|
||||
if (dss_exist_file(XLOG_CONTROL_FILE)) {
|
||||
struct stat st;
|
||||
if (stat(XLOG_CONTROL_FILE, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
SSReadControlFile(REFORM_CTRL_PAGE);
|
||||
if (g_instance.dms_cxt.SSReformerControl.list_stable != 0 ||
|
||||
g_instance.dms_cxt.SSReformerControl.primaryInstId == SS_MY_INST_ID) {
|
||||
@ -187,7 +188,7 @@ void SSInitReformerControlPages(void)
|
||||
* Initialize list_stable and primaryInstId
|
||||
* First node to initdb is chosen as primary for now, and for first-time cluster startup.
|
||||
*/
|
||||
Assert(!dss_exist_file(XLOG_CONTROL_FILE));
|
||||
Assert(stat(XLOG_CONTROL_FILE, &st) != 0 || !S_ISREG(st.st_mode));
|
||||
g_instance.dms_cxt.SSReformerControl.list_stable = 0;
|
||||
g_instance.dms_cxt.SSReformerControl.primaryInstId = SS_MY_INST_ID;
|
||||
g_instance.dms_cxt.SSReformerControl.recoveryInstId = INVALID_INSTANCEID;
|
||||
|
@ -104,9 +104,7 @@ int dss_device_init(const char *conn_path, bool enable_dss)
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_ftruncate", (void **)&device_op.dss_truncate));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_fwrite", (void **)&device_op.dss_write));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_pwrite", (void **)&device_op.dss_pwrite));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_fexist", (void **)&device_op.dss_exist));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_dmake", (void **)&device_op.dss_create_dir));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_dexist", (void **)&device_op.dss_exist_dir));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_dopen", (void **)&device_op.dss_open_dir));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_dread", (void **)&device_op.dss_read_dir));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_dclose", (void **)&device_op.dss_close_dir));
|
||||
@ -119,7 +117,6 @@ int dss_device_init(const char *conn_path, bool enable_dss)
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_get_error", (void **)&device_op.dss_get_error));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_symlink", (void **)&device_op.dss_link));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_unlink", (void **)&device_op.dss_unlink));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_islink", (void **)&device_op.dss_exist_link));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_readlink", (void **)&device_op.dss_read_link));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_stat", (void **)&device_op.dss_stat));
|
||||
SS_RETURN_IFERR(dss_load_symbol(device_op.handle, "dss_lstat", (void **)&device_op.dss_lstat));
|
||||
|
@ -93,15 +93,6 @@ void dss_set_errno(int *errcode)
|
||||
}
|
||||
}
|
||||
|
||||
bool dss_exist_file(const char *file_name)
|
||||
{
|
||||
bool result = false;
|
||||
if (g_dss_device_op.dss_exist(file_name, &result) != DSS_SUCCESS) {
|
||||
dss_set_errno(NULL);
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int dss_access_file(const char *file_name, int mode)
|
||||
{
|
||||
@ -118,16 +109,6 @@ int dss_create_dir(const char *name, mode_t mode)
|
||||
return GS_SUCCESS;
|
||||
}
|
||||
|
||||
bool dss_exist_dir(const char *name)
|
||||
{
|
||||
bool result = false;
|
||||
if (g_dss_device_op.dss_exist_dir(name, &result) != DSS_SUCCESS) {
|
||||
dss_set_errno(NULL);
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int dss_open_dir(const char *name, DIR **dir_handle)
|
||||
{
|
||||
DSS_DIR *dss_dir = NULL;
|
||||
@ -216,9 +197,10 @@ int dss_remove_file(const char *name)
|
||||
|
||||
int dss_open_file(const char *name, int flags, mode_t mode, int *handle)
|
||||
{
|
||||
if ((flags & O_CREAT) != 0 && !dss_exist_file(name)) {
|
||||
struct stat st;
|
||||
if ((flags & O_CREAT) != 0 && dss_stat_file(name, &st) != GS_SUCCESS) {
|
||||
// file not exists, create it first.
|
||||
if (g_dss_device_op.dss_create(name, flags) != DSS_SUCCESS) {
|
||||
if (errno == ERR_DSS_FILE_NOT_EXIST && g_dss_device_op.dss_create(name, flags) != DSS_SUCCESS) {
|
||||
dss_set_errno(NULL);
|
||||
return GS_ERROR;
|
||||
}
|
||||
@ -508,16 +490,6 @@ int dss_unlink_target(const char *name)
|
||||
return GS_SUCCESS;
|
||||
}
|
||||
|
||||
bool dss_exist_link(const char *name)
|
||||
{
|
||||
bool result = false;
|
||||
if (g_dss_device_op.dss_exist_link(name, &result) != DSS_SUCCESS) {
|
||||
dss_set_errno(NULL);
|
||||
return false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ssize_t dss_read_link(const char *path, char *buf, size_t buf_size)
|
||||
{
|
||||
ssize_t result = (ssize_t)g_dss_device_op.dss_read_link(path, buf, buf_size);
|
||||
@ -696,9 +668,11 @@ int dss_set_server_status_wrapper()
|
||||
|
||||
int dss_remove_dev(const char *name)
|
||||
{
|
||||
if (dss_exist_file(name)) {
|
||||
struct stat st;
|
||||
int ret = lstat(name, &st);
|
||||
if (ret == 0 && S_ISREG(st.st_mode)) {
|
||||
return dss_remove_file(name);
|
||||
} else if (dss_exist_link(name)) {
|
||||
} else if (ret == 0 && S_ISLNK(st.st_mode)) {
|
||||
return dss_unlink_target(name);
|
||||
} else {
|
||||
return GS_SUCCESS;
|
||||
|
@ -2635,7 +2635,8 @@ static bool CheckExistReplslotPath(char *path)
|
||||
errno_t rc = strcat_s(path_for_check, MAXPGPATH, suffix);
|
||||
securec_check_ss(rc, "\0", "\0");
|
||||
}
|
||||
if (dss_exist_dir(path_for_check)) {
|
||||
struct stat st;
|
||||
if (stat(path_for_check, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,8 @@
|
||||
|
||||
void WriteSSDoradoCtlInfoFile()
|
||||
{
|
||||
Assert(dss_exist_file(SS_DORADO_CTRL_FILE));
|
||||
struct stat st;
|
||||
Assert(stat(SS_DORADO_CTRL_FILE, &st) == 0 && S_ISREG(st.st_mode));
|
||||
Assert(g_instance.xlog_cxt.ssReplicationXLogCtl != NULL);
|
||||
ShareStorageXLogCtl *ctlInfo = g_instance.xlog_cxt.ssReplicationXLogCtl;
|
||||
errno_t errorno = EOK;
|
||||
@ -65,7 +66,8 @@ void WriteSSDoradoCtlInfoFile()
|
||||
|
||||
void ReadSSDoradoCtlInfoFile()
|
||||
{
|
||||
Assert(dss_exist_file(SS_DORADO_CTRL_FILE));
|
||||
struct stat st;
|
||||
Assert(stat(SS_DORADO_CTRL_FILE, &st) == 0 && S_ISREG(st.st_mode));
|
||||
Assert(g_instance.xlog_cxt.ssReplicationXLogCtl != NULL);
|
||||
ShareStorageXLogCtl *ctlInfo = g_instance.xlog_cxt.ssReplicationXLogCtl;
|
||||
errno_t errorno = EOK;
|
||||
@ -105,7 +107,8 @@ void ReadSSDoradoCtlInfoFile()
|
||||
|
||||
void InitSSDoradoCtlInfoFile()
|
||||
{
|
||||
if (dss_exist_file(SS_DORADO_CTRL_FILE)) {
|
||||
struct stat st;
|
||||
if (stat(SS_DORADO_CTRL_FILE, &st) == 0 && S_ISREG(st.st_mode)) {
|
||||
ReadSSDoradoCtlInfoFile();
|
||||
ereport(LOG, (errcode_for_file_access(), errmsg("[InitSSDoradoCtlInfoFile] Dorado ctl info file already exists.")));
|
||||
return;
|
||||
@ -117,7 +120,7 @@ void InitSSDoradoCtlInfoFile()
|
||||
int fd = -1;
|
||||
char buffer[SS_DORADO_CTL_INFO_SIZE] __attribute__((__aligned__(ALIGNOF_BUFFER))); /* need to be aligned */
|
||||
errno_t errorno = EOK;
|
||||
Assert(!dss_exist_file(SS_DORADO_CTRL_FILE));
|
||||
Assert(stat(SS_DORADO_CTRL_FILE, &st) !=0 || !S_ISREG(st.st_mode));
|
||||
|
||||
/* create SS_DORADO_CTRL_FILE first time */
|
||||
fd = BasicOpenFile(SS_DORADO_CTRL_FILE, O_RDWR | O_CREAT | O_EXCL | PG_BINARY, S_IRUSR | S_IWUSR);
|
||||
|
@ -44,9 +44,7 @@ typedef int (*dss_trucate_device)(int handle, long keep_size);
|
||||
typedef int (*dss_create_device)(const char *name, int flags);
|
||||
typedef int (*dss_remove_device)(const char *name);
|
||||
typedef int (*dss_close_device)(int handle);
|
||||
typedef int (*dss_exist_device)(const char *name, bool *result);
|
||||
typedef int (*dss_create_device_dir)(const char *name);
|
||||
typedef int (*dss_exist_device_dir)(const char *name, bool *result);
|
||||
typedef dss_dir_handle (*dss_open_device_dir)(const char *name);
|
||||
typedef int (*dss_read_device_dir)(dss_dir_handle dir, dss_dirent_t *item, dss_dir_item_t *result);
|
||||
typedef int (*dss_close_device_dir)(dss_dir_handle dir);
|
||||
@ -56,7 +54,6 @@ typedef int (*dss_check_device_size)(int size);
|
||||
typedef int (*dss_align_device_size)(int size);
|
||||
typedef int (*dss_link_device)(const char *oldpath, const char *newpath);
|
||||
typedef int (*dss_unlink_device)(const char *path);
|
||||
typedef int (*dss_exist_device_link)(const char *path, bool *result);
|
||||
typedef int (*dss_device_name)(int handle, char *fname, size_t fname_size);
|
||||
typedef int (*dss_read_device_link)(const char *path, char *buf, int bufsize);
|
||||
typedef int (*dss_stat_device)(const char *path, dss_stat_info_t item);
|
||||
@ -88,9 +85,7 @@ typedef struct st_dss_device_op_t {
|
||||
dss_seek_device dss_seek;
|
||||
dss_trucate_device dss_truncate;
|
||||
dss_close_device dss_close;
|
||||
dss_exist_device dss_exist;
|
||||
dss_create_device_dir dss_create_dir;
|
||||
dss_exist_device_dir dss_exist_dir;
|
||||
dss_rename_device dss_rename;
|
||||
dss_check_device_size dss_check_size;
|
||||
dss_align_device_size dss_align_size;
|
||||
@ -103,7 +98,6 @@ typedef struct st_dss_device_op_t {
|
||||
dss_remove_device_dir dss_remove_dir;
|
||||
dss_link_device dss_link;
|
||||
dss_unlink_device dss_unlink;
|
||||
dss_exist_device_link dss_exist_link;
|
||||
dss_read_device_link dss_read_link;
|
||||
dss_stat_device dss_stat;
|
||||
dss_lstat_device dss_lstat;
|
||||
|
@ -34,10 +34,8 @@
|
||||
|
||||
void dss_device_register(dss_device_op_t *dss_device_op, bool enable_dss);
|
||||
void dss_set_errno(int *errcode);
|
||||
bool dss_exist_file(const char *file_name);
|
||||
int dss_access_file(const char *file_name, int mode);
|
||||
int dss_create_dir(const char *name, mode_t mode);
|
||||
bool dss_exist_dir(const char *name);
|
||||
int dss_open_dir(const char *name, DIR **dir_handle);
|
||||
int dss_read_dir(DIR *dir_handle, struct dirent **result);
|
||||
int dss_close_dir(DIR *dir_handle);
|
||||
@ -66,7 +64,6 @@ off_t dss_get_file_size(const char *fname);
|
||||
int dss_fallocate_file(int handle, int mode, off_t offset, off_t len);
|
||||
int dss_link(const char *src, const char *dst);
|
||||
int dss_unlink_target(const char *name);
|
||||
bool dss_exist_link(const char *name);
|
||||
ssize_t dss_read_link(const char *path, char *buf, size_t buf_size);
|
||||
int dss_setvbuf(FILE *stream, char *buf, int mode, size_t size);
|
||||
int dss_feof(FILE *stream);
|
||||
|
@ -166,10 +166,10 @@ static inline int fallocate_dev(int fd, int mode, off_t offset, off_t len)
|
||||
static inline int access_dev(const char *pathname, int mode)
|
||||
{
|
||||
if (is_dss_file(pathname)) {
|
||||
if (!dss_exist_file(pathname) && !dss_exist_dir(pathname)) {
|
||||
if (dss_access_file(pathname, mode) != GS_SUCCESS) {
|
||||
return -1;
|
||||
}
|
||||
return dss_access_file(pathname, mode);
|
||||
return 0;
|
||||
} else {
|
||||
return access(pathname, mode);
|
||||
}
|
||||
@ -215,7 +215,8 @@ static inline int symlink_dev(const char *target, const char *linkpath)
|
||||
static inline ssize_t readlink_dev(const char *pathname, char *buf, size_t bufsiz)
|
||||
{
|
||||
if (is_dss_file(pathname)) {
|
||||
if (!dss_exist_link(pathname)) {
|
||||
struct stat st;
|
||||
if (dss_lstat_file(pathname, &st) != GS_SUCCESS || !S_ISLNK(st.st_mode)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -249,11 +250,13 @@ static inline int unlink_dev(const char *pathname)
|
||||
static inline int lstat_dev(const char * pathname, struct stat * statbuf)
|
||||
{
|
||||
if (is_dss_file(pathname)) {
|
||||
if (!dss_exist_file(pathname) && !dss_exist_dir(pathname)) {
|
||||
errno = ENOENT;
|
||||
if (dss_lstat_file(pathname, statbuf) != GS_SUCCESS) {
|
||||
if (errno == ERR_DSS_FILE_NOT_EXIST) {
|
||||
errno = ENOENT;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return dss_lstat_file(pathname, statbuf);
|
||||
return GS_SUCCESS;
|
||||
} else {
|
||||
return lstat(pathname, statbuf);
|
||||
}
|
||||
@ -262,11 +265,13 @@ static inline int lstat_dev(const char * pathname, struct stat * statbuf)
|
||||
static inline int stat_dev(const char *pathname, struct stat *statbuf)
|
||||
{
|
||||
if (is_dss_file(pathname)) {
|
||||
if (!dss_exist_file(pathname) && !dss_exist_dir(pathname)) {
|
||||
errno = ENOENT;
|
||||
if (dss_stat_file(pathname, statbuf) != GS_SUCCESS) {
|
||||
if (errno == ERR_DSS_FILE_NOT_EXIST) {
|
||||
errno = ENOENT;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return dss_stat_file(pathname, statbuf);
|
||||
return GS_SUCCESS;
|
||||
} else {
|
||||
return stat(pathname, statbuf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user