45 #include <sys/param.h> 46 #include <sys/types.h> 49 #if defined (SERVER_MODE) 55 #include <sys/statfs.h> 59 #include <sys/statvfs.h> 88 #if defined (SERVER_MODE) 99 #if defined(SERVER_MODE) 104 #if !defined (CS_MODE) 113 #if defined (SERVER_MODE) 115 #endif // SERVER_MODE 116 #if defined (SERVER_MODE) 118 #endif // SERVER_MODE 119 #if defined (SERVER_MODE) 121 #endif // SERVER_MODE 131 #define MSGCAT_FILEIO_STARTS 1 132 #define MSGCAT_FILEIO_BKUP_NEEDED 2 133 #define MSGCAT_FILEIO_BKUP_HDR 3 134 #define MSGCAT_FILEIO_BKUP_HDR_MAGICID 4 135 #define MSGCAT_FILEIO_BKUP_HDR_RELEASES 5 136 #define MSGCAT_FILEIO_BKUP_HDR_DBINFO 6 137 #define MSGCAT_FILEIO_BKUP_HDR_LEVEL 7 138 #define MSGCAT_FILEIO_BKUP_HDR_TIME 8 139 #define MSGCAT_FILEIO_BKUP_FILE 9 140 #define MSGCAT_FILEIO_REST_RELO_NEEDED 10 141 #define MSGCAT_FILEIO_REST_RELO_OPTIONS 11 142 #define MSGCAT_FILEIO_NEWLOCATION 12 143 #define MSGCAT_FILEIO_INPUT_RANGE_ERROR 13 144 #define MSGCAT_FILEIO_INCORRECT_BKVOLUME 14 145 #define MSGCAT_FILEIO_LEVEL_MISMATCH 15 146 #define MSGCAT_FILEIO_MAGIC_MISMATCH 16 147 #define MSGCAT_FILEIO_DB_MISMATCH 17 148 #define MSGCAT_FILEIO_UNIT_NUM_MISMATCH 18 149 #define MSGCAT_FILEIO_BACKUP_TIME_MISMATCH 19 150 #define MSGCAT_FILEIO_BACKUP_VINF_ERROR 20 151 #define MSGCAT_FILEIO_BACKUP_LABEL_INFO 21 152 #define MSGCAT_FILEIO_BKUP_HDR_LX_LSA 22 153 #define MSGCAT_FILEIO_RESTORE_FIND_REASON 23 154 #define MSGCAT_FILEIO_BKUP_FIND_REASON 24 155 #define MSGCAT_FILEIO_BKUP_PREV_BKVOL 25 156 #define MSGCAT_FILEIO_BKUP_NEXT_BKVOL 26 157 #define MSGCAT_FILEIO_BKUP_HDR_BKUP_PAGESIZE 27 158 #define MSGCAT_FILEIO_BKUP_HDR_ZIP_INFO 28 159 #define MSGCAT_FILEIO_BKUP_HDR_INC_ACTIVELOG 29 162 #define FILEIO_USER_NAME_SIZE L_cuserid 164 #define FILEIO_USER_NAME_SIZE 9 168 #define GETPID() GetCurrentProcessId() 170 #define GETPID() getpid() 173 #define FILEIO_DISK_FORMAT_MODE (O_RDWR | O_CREAT) 174 #define FILEIO_DISK_PROTECTION_MODE 0600 175 #define FILEIO_MAX_WAIT_DBTXT 300 176 #define FILEIO_FULL_LEVEL_EXP 32 183 #define GET_NEXT_1K_SIZE(s) (((((s) - 1) / 1024) + 1) * 1024) 184 #define FILEIO_BACKUP_HEADER_IO_SIZE GET_NEXT_1K_SIZE(sizeof(FILEIO_BACKUP_HEADER)) 185 #define FILEIO_GET_FILE_SIZE(pagesize, npages) \ 186 (((off_t)(pagesize)) * ((off_t)(npages))) 188 #define FILEIO_BACKUP_NO_ZIP_HEADER_VERSION 1 189 #define FILEIO_BACKUP_CURRENT_HEADER_VERSION 2 190 #define FILEIO_CHECK_FOR_INTERRUPT_INTERVAL 100 192 #define FILEIO_PAGE_SIZE_FULL_LEVEL (IO_PAGESIZE * FILEIO_FULL_LEVEL_EXP) 193 #define FILEIO_BACKUP_PAGE_OVERHEAD \ 194 (offsetof(FILEIO_BACKUP_PAGE, iopage) + sizeof(PAGEID)) 195 #define FILEIO_BACKUP_DBVOLS_IO_PAGE_SIZE \ 196 (IO_PAGESIZE + FILEIO_BACKUP_PAGE_OVERHEAD) 197 #define FILEIO_BACKUP_DBVOLS_IO_PAGE_SIZE_FULL_LEVEL \ 198 (FILEIO_PAGE_SIZE_FULL_LEVEL + FILEIO_BACKUP_PAGE_OVERHEAD) 200 #define FILEIO_RESTORE_DBVOLS_IO_PAGE_SIZE(sess) \ 201 ((sess)->bkup.bkuphdr->bkpagesize + FILEIO_BACKUP_PAGE_OVERHEAD) 203 #define FILEIO_DBVOLS_IO_PAGE_SIZE(backup_header_p) \ 204 ((backup_header_p)->bkpagesize + FILEIO_BACKUP_PAGE_OVERHEAD) 206 #define FILEIO_BACKUP_FILE_HEADER_PAGE_SIZE \ 207 (sizeof(FILEIO_BACKUP_FILE_HEADER) + offsetof(FILEIO_BACKUP_PAGE, iopage)) 210 #define FILEIO_SET_BACKUP_PAGE_ID_COPY(area, pageid, psize) \ 211 *(PAGEID *)(((char *)(area)) + \ 212 (offsetof(FILEIO_BACKUP_PAGE, iopage) + psize)) = pageid 215 #define FILEIO_SET_BACKUP_PAGE_ID(area, pageid, psize) \ 217 ((FILEIO_BACKUP_PAGE *)(area))->iopageid = pageid; \ 219 FILEIO_SET_BACKUP_PAGE_ID_COPY(area, pageid, psize); \ 223 #define FILEIO_GET_BACKUP_PAGE_ID(area) (((FILEIO_BACKUP_PAGE *)(area))->iopageid) 231 #define FILEIO_CHECK_RESTORE_PAGE_ID(area, pagesz) \ 232 (((FILEIO_BACKUP_PAGE *)(area))->iopageid == \ 233 *(PAGEID *)(((char *)(area)) + offsetof(FILEIO_BACKUP_PAGE, iopage) + pagesz)) 237 #define FILEIO_BACKUP_MINIMUM_NUM_PAGES \ 238 CEIL_PTVDIV((FILEIO_BACKUP_HEADER_IO_SIZE + \ 239 (FILEIO_BACKUP_DBVOLS_IO_PAGE_SIZE) * 4), IO_PAGESIZE) 240 #define FILEIO_BACKUP_MINIMUM_NUM_PAGES_FULL_LEVEL \ 241 CEIL_PTVDIV((FILEIO_BACKUP_HEADER_IO_SIZE + \ 242 (FILEIO_BACKUP_DBVOLS_IO_PAGE_SIZE_FULL_LEVEL) * 4), IO_PAGESIZE) 244 #define FILEIO_CHECK_AND_INITIALIZE_VOLUME_HEADER_CACHE(rtn) \ 246 if (fileio_Vol_info_header.volinfo == NULL \ 247 && fileio_initialize_volume_info_cache () < 0) \ 252 #define FILEIO_BACKUP_START_PAGE_ID (-2) 253 #define FILEIO_BACKUP_END_PAGE_ID (-3) 254 #define FILEIO_BACKUP_FILE_START_PAGE_ID (-4) 255 #define FILEIO_BACKUP_FILE_END_PAGE_ID (-5) 256 #define FILEIO_BACKUP_VOL_CONT_PAGE_ID (-6) 258 #define FILEIO_END_OF_FILE (1) 261 #define FILEIO_MIN_FLUSH_PAGES_PER_SEC (41943040 / IO_PAGESIZE) 274 #define FILEIO_PAGE_FLUSH_GROW_RATE 0.5 276 #define FILEIO_PAGE_FLUSH_DROP_RATE 0.1 279 #define fileio_lock_file_write(fd, offset, whence, len) \ 280 fileio_lock_region(fd, F_TLOCK, offset, len) 281 #define fileio_lock_file_writew(fd, offset, whence, len) \ 282 fileio_lock_region(fd, F_LOCK, offset, len) 283 #define fileio_lock_file_read(fd, offset, whence, len) \ 284 fileio_lock_region(fd, F_TLOCK, offset, len) 285 #define fileio_lock_file_readw(fd, offset, whence, len) \ 286 fileio_lock_region(fd, F_LOCK, offset, len) 287 #define fileio_unlock_file(fd, offset, whence, len) \ 288 fileio_lock_region(fd, F_ULOCK, offset, len) 290 #define fileio_lock_file_read(fd, offset, whence, len) \ 291 fileio_lock_region(fd, F_SETLK, F_RDLCK, offset, whence, len) 292 #define fileio_lock_file_readw(fd, offset, whence, len) \ 293 fileio_lock_region(fd, F_SETLKW, F_RDLCK, offset, whence, len) 294 #define fileio_lock_file_write(fd, offset, whence, len) \ 295 fileio_lock_region(fd, F_SETLK, F_WRLCK, offset, whence, len) 296 #define fileio_lock_file_writew(fd, offset, whence, len) \ 297 fileio_lock_region(fd, F_SETLKW, F_WRLCK, offset, whence, len) 298 #define fileio_unlock_file(fd, offset, whence, len) \ 299 fileio_lock_region(fd, F_SETLK, F_UNLCK, offset, whence, len) 302 #define FILEIO_VOLINFO_INCREMENT 32 304 #if !defined(SERVER_MODE) 305 #define pthread_mutex_init(a, b) 306 #define pthread_mutex_destroy(a) 307 #define pthread_mutex_lock(a) 0 308 #define pthread_mutex_unlock(a) 346 char bkvol_name[PATH_MAX];
365 #if defined(SERVER_MODE) && defined(WINDOWS) 366 pthread_mutex_t sysvol_mutex;
374 #if defined(SERVER_MODE) 375 pthread_mutex_t
mutex;
387 #if defined(SERVER_MODE) && defined(WINDOWS) 388 pthread_mutex_t vol_mutex;
404 #if defined(SERVER_MODE) 405 pthread_mutex_t
mutex;
422 #if defined(SERVER_MODE) 423 PTHREAD_MUTEX_INITIALIZER,
428 #if defined(SERVER_MODE) && defined(WINDOWS) 429 PTHREAD_MUTEX_INITIALIZER,
435 #if defined(SERVER_MODE) 436 PTHREAD_MUTEX_INITIALIZER,
446 #if !defined(HAVE_ATOMIC_BUILTINS) 455 #if defined(CUBRID_DEBUG) 462 static int io_Bkuptrace_debug = -1;
465 #if defined(SERVER_MODE) && defined(WINDOWS) 466 static pthread_mutex_t *fileio_get_volume_mutex (
THREAD_ENTRY * thread_p,
int vdes);
471 bool dolock,
bool dosync);
473 VOLID volid,
bool dolock,
bool dosync,
int atleast_pages);
513 #if !defined (WINDOWS) 518 #if !defined(WINDOWS) 533 const char *restore_verbose_file_path,
bool newvolpath);
548 bool first_time,
bool authenticate, INT64 match_bkupcreation);
567 #if !defined(WINDOWS) 570 static int fileio_lock_region (
int fd,
int cmd,
int type, off_t offset,
int whence, off_t len);
573 #if defined(SERVER_MODE) 592 int flushed_page_count;
594 #if defined(HAVE_ATOMIC_BUILTINS) 603 return flushed_page_count;
609 #if !defined(SERVER_MODE) 614 int flushed_page_count;
623 if (thread_p ==
NULL)
660 #if !defined(SERVER_MODE) 689 fc_Token_bucket = tb;
704 #if !defined(SERVER_MODE) 710 if (fc_Token_bucket ==
NULL)
716 fc_Token_bucket =
NULL;
733 #if !defined(SERVER_MODE) 740 bool log_cs_own =
false;
742 PERF_UTIME_TRACKER time_tracker = PERF_UTIME_TRACKER_INITIALIZER;
757 while (nreq > 0 && retry_count < 10)
763 if (log_cs_own ==
true)
788 if (log_cs_own ==
true)
794 PERF_UTIME_TRACKER_START (thread_p, &time_tracker);
821 #if !defined(SERVER_MODE) 859 *token_gen = gen_tokens;
883 #if !defined (SERVER_MODE) 958 fileio_final_volinfo_cache (
void)
961 #if defined(WINDOWS) && defined(SERVER_MODE) 969 #if defined(WINDOWS) && defined(SERVER_MODE) 970 vf = fileio_Vol_info_header.
volinfo[
i];
973 if (vf[j].vol_mutex !=
NULL)
995 if (vol_info_p ==
NULL)
1007 vol_info_p[
i].
vlabel[0] =
'\0';
1008 #if defined(WINDOWS) 1013 header_p->
volinfo[idx] = vol_info_p;
1031 int from_idx, to_idx;
1046 for (; from_idx <= to_idx; from_idx++)
1076 int from_idx, to_idx;
1091 for (; from_idx >= to_idx; from_idx--)
1123 tmp_time = (time_t) (*clock_p);
1124 t = ctime_r (&tmp_time, buffer_p);
1126 p = strchr (t,
'\n');
1143 #if defined(WINDOWS) 1146 h_process = OpenProcess (PROCESS_QUERY_INFORMATION,
FALSE, pid);
1147 if (h_process ==
NULL)
1153 CloseHandle (h_process);
1157 if (kill (pid, 0) == -1)
1168 #if !defined(WINDOWS) 1179 fileio_lock (
const char *db_full_name_p,
const char *vol_label_p,
int vol_fd,
bool dowait)
1182 char name_info_lock[PATH_MAX];
1188 long long tmp_lock_time;
1193 int total_num_loops = 0;
1196 char io_timeval[
CTIME_MAX], format_string[32];
1203 #if defined(CUBRID_DEBUG) 1213 if (fstat (vol_fd, &stbuf) != -1)
1215 if ((stbuf.st_mode & S_ISGID) != 0 && (stbuf.st_mode & S_IRWXG) != S_IXGRP)
1222 if (vol_label_p ==
NULL)
1247 lockf_errno = errno;
1251 fp = fopen (name_info_lock,
"r");
1256 total_num_loops += 3;
1257 fp = fopen (name_info_lock,
"r");
1258 if (fp ==
NULL && num_loops <= 3)
1271 if (fp ==
NULL || fscanf (fp, format_string, user, &pid, host, &tmp_lock_time) != 4)
1273 strcpy (user,
"???");
1274 strcpy (host,
"???");
1280 lock_time = tmp_lock_time;
1291 (lock_time == 0) ?
"???" : io_timeval);
1298 cuserid ((
char *) login_name);
1306 if (dowait !=
false)
1317 && total_num_loops < max_num_loops)
1326 total_num_loops += 3;
1329 if (total_num_loops < max_num_loops)
1344 #if defined(CUBRID_DEBUG) 1346 "io_lock: WARNING ignoring a run away lock on volume = %s\n. lockd deamon may not be" 1347 " working right.\n UNIX error = %s", vol_label_p, strerror (lockf_errno));
1352 fp = fopen (name_info_lock,
"w");
1357 strcpy (host,
"???");
1362 strcpy (login_name,
"???");
1365 (void) fprintf (fp,
"%s %d %s %ld", login_name, (
int)
GETPID (),
host, time (
NULL));
1399 long long tmp_lock_time;
1405 char io_timeval[64], format_string[32];
1407 #if defined(CUBRID_DEBUG) 1417 if (fstat (vol_fd, &stbuf) != -1)
1419 if ((stbuf.st_mode & S_ISGID) != 0 && (stbuf.st_mode & S_IRWXG) != S_IXGRP)
1426 if (lock_path_p ==
NULL)
1446 lockf_errno = errno;
1450 fp = fopen (lock_path_p,
"r");
1455 fp = fopen (lock_path_p,
"r");
1456 if (fp ==
NULL && num_loops <= 3)
1463 if (fp ==
NULL || fscanf (fp, format_string, last_deleted_arv_num, user, &pid, host, &tmp_lock_time) != 5)
1465 strcpy (user,
"???");
1466 strcpy (host,
"???");
1469 *last_deleted_arv_num = -1;
1473 lock_time = tmp_lock_time;
1480 #if defined(CUBRID_DEBUG) 1482 "io_lock: WARNING ignoring a run away lock on volume = %s\n. lockd deamon may not be" 1483 " working right.\n UNIX error = %s", lock_path_p, strerror (lockf_errno));
1486 memset (io_timeval, 0,
sizeof (io_timeval));
1489 (lock_time == 0) ?
"???" : io_timeval);
1494 fp = fdopen (vol_fd,
"w+");
1497 if (fscanf (fp, format_string, last_deleted_arv_num, user, &pid, host, &tmp_lock_time) != 5)
1499 *last_deleted_arv_num = -1;
1502 fseek (fp, 0, SEEK_SET);
1506 strcpy (host,
"???");
1511 strcpy (login_name,
"???");
1514 if (*last_deleted_arv_num < 0)
1516 *last_deleted_arv_num = -1;
1519 (void) fprintf (fp,
"%-10d %s %d %s %ld", *last_deleted_arv_num, login_name, (
int)
GETPID (),
host, time (
NULL));
1553 char lock_dir[PATH_MAX], lock_path[PATH_MAX];
1555 char format_string[PATH_MAX];
1558 if (snprintf (lock_path,
sizeof (lock_path) - 1,
"%s/%s", lock_dir, db_name) < 0)
1565 if (access (lock_dir, F_OK) < 0)
1568 if (mkdir (lock_dir, 0777) < 0 && errno == ENOENT)
1570 char pdir[PATH_MAX];
1572 if (
cub_dirname_r (lock_dir, pdir, PATH_MAX) > 0 && access (pdir, F_OK) < 0)
1579 if (access (lock_dir, F_OK) < 0)
1581 if (mkdir (lock_dir, 0777) < 0)
1592 fd =
fileio_open (lock_path, O_RDWR | O_CREAT, 0644);
1602 fp = fopen (lock_path,
"r");
1605 fseek (fp, (off_t) 0, SEEK_SET);
1607 r = fscanf (fp, format_string, &pid, tmp_db_name, tmp_log_path);
1612 if (strcmp (db_name, tmp_db_name) || strcmp (log_path, tmp_log_path))
1642 fp = fopen (lock_path,
"w+");
1645 fseek (fp, (off_t) 0, SEEK_SET);
1648 fprintf (fp,
"%-10d %s %s", pid, db_name, log_path);
1697 char lock_dir[PATH_MAX], lock_path[PATH_MAX];
1700 if (snprintf (lock_path,
sizeof (lock_path) - 1,
"%s/%s", lock_dir, db_name) < 0)
1706 if (access (lock_dir, F_OK) < 0)
1721 fp = fopen (lock_path,
"w+");
1730 fseek (fp, (off_t) 0, SEEK_END);
1731 end_offset = ftell (fp);
1732 fseek (fp, (off_t) 0, SEEK_SET);
1736 fprintf (fp,
"%*s", (
int) end_offset,
" ");
1779 char format_string[32];
1781 fp = fopen (name_info_lock_p,
"r");
1785 if (fscanf (fp, format_string, user, &pid, host) != 3)
1787 strcpy (user,
"???");
1788 strcpy (host,
"???");
1797 && strcmp (host, host2) == 0)
1799 (void)
remove (name_info_lock_p);
1823 char name_info_lock[PATH_MAX];
1827 if (vol_label_p ==
NULL)
1832 strcpy (name_info_lock, vol_label_p);
1847 (void)
remove (name_info_lock);
1868 bool skip_flush =
false;
1869 #if defined (SERVER_MODE) 1870 int count_of_page_for_a_sleep = 10;
1871 INT64 allowed_millis_for_a_sleep = 0;
1872 INT64 previous_elapsed_millis;
1873 INT64 time_to_sleep;
1878 INT64 page_count_per_sec;
1881 #if defined (SERVER_MODE) 1882 if (kbytes_to_be_written_per_sec > 0)
1886 if (page_count_per_sec < count_of_page_for_a_sleep)
1888 page_count_per_sec = count_of_page_for_a_sleep;
1890 allowed_millis_for_a_sleep = count_of_page_for_a_sleep * 1000 / page_count_per_sec;
1896 #if !defined (CS_MODE) 1900 for (page_id = start_pageid; page_id < npages + start_pageid; page_id++)
1902 #if !defined(CS_MODE) 1913 #if !defined(NDEBUG) 1926 #if defined (SERVER_MODE) 1927 if (kbytes_to_be_written_per_sec > 0 && (page_id + 1) % count_of_page_for_a_sleep == 0)
1932 previous_elapsed_millis = (tv_diff.tv_sec * 1000LL) + (tv_diff.tv_usec / 1000LL);
1935 time_to_sleep = allowed_millis_for_a_sleep - previous_elapsed_millis;
1936 if (time_to_sleep > 0)
1963 #if defined(WINDOWS) 1964 vol_fd = open (vol_label_p, flags | _O_BINARY, mode);
1966 vol_fd = open (vol_label_p, flags, mode);
1971 #if !defined(WINDOWS) 1978 high_vol_fd = fcntl (vol_fd, F_DUPFD, range);
1979 if (high_vol_fd != -1)
1982 vol_fd = high_vol_fd;
1995 #if !defined(WINDOWS) 2008 if (stat (vol_label_p, &buf) < 0)
2018 mode &= ~(S_IEXEC >> 3);
2022 if (chmod (vol_label_p, mode) < 0)
2080 #if !defined(WINDOWS) 2087 if (close (vol_fd) != 0)
2105 bool is_do_lock,
bool is_do_sync)
2110 #if defined(WINDOWS) 2116 #if !defined(CS_MODE) 2125 #if defined(WINDOWS) 2126 sh_flag = is_do_lock ? _SH_DENYWR : _SH_DENYNO;
2131 if (sh_flag == _SH_DENYRW && errno != ENOENT)
2144 o_sync = (is_do_sync !=
false) ? O_SYNC : 0;
2147 if (is_do_lock !=
false)
2149 tmp_vol_desc =
fileio_open (vol_label_p, O_RDWR | o_sync, 0);
2153 lockf_type =
fileio_lock (db_full_name_p, vol_label_p, tmp_vol_desc,
false);
2183 #if !defined(WINDOWS) 2184 if (is_do_lock ==
true)
2186 lockf_type =
fileio_lock (db_full_name_p, vol_label_p, vol_fd,
false);
2200 #if !defined(CS_MODE) 2201 if (
fileio_cache (vol_id, vol_label_p, vol_fd, lockf_type) != vol_fd)
2237 bool is_do_lock,
bool is_do_sync,
int atleast_npages)
2242 if (stat (vol_label_p, &stbuf) != -1)
2244 #if !defined(WINDOWS) 2247 if (S_ISFIFO (stbuf.st_mode))
2250 struct timeval to = { 0, 100000 };
2254 vdes =
fileio_open (vol_label_p, O_WRONLY | O_NONBLOCK, 0200);
2265 #if !defined(CS_MODE) 2280 if (atleast_npages > 0 && S_ISREG (stbuf.st_mode))
2283 if (num_free < atleast_npages)
2286 (
long long) ((
IO_PAGESIZE / 1024) * atleast_npages), num_free,
2293 return (
fileio_create (thread_p, db_full_name_p, vol_label_p, vol_id, is_do_lock, is_do_sync));
2315 DKNPAGES npages,
bool is_sweep_clean,
bool is_do_lock,
bool is_do_sync,
size_t page_size,
2316 int kbytes_to_be_written_per_sec,
bool reuse_file)
2322 #if !defined(WINDOWS) 2325 bool is_raw_device =
false;
2337 #if !defined(WINDOWS) 2338 if (lstat (vol_label_p, &buf) != 0)
2343 if (!S_ISLNK (buf.st_mode))
2349 if (stat (vol_label_p, &buf) != 0)
2354 is_raw_device = S_ISCHR (buf.st_mode);
2358 is_raw_device =
false;
2378 if (npages > max_npages || (offset < npages && npages > 1))
2380 if (offset < npages)
2386 if (max_npages >= 0)
2400 malloc_io_page_p = (
FILEIO_PAGE *) malloc (page_size);
2401 if (malloc_io_page_p ==
NULL)
2407 memset ((
char *) malloc_io_page_p, 0, page_size);
2410 vol_fd =
fileio_create (thread_p, db_full_name_p, vol_label_p, vol_id, is_do_lock, is_do_sync);
2435 if ((is_sweep_clean ==
true 2437 || (is_sweep_clean ==
false 2441 && (is_sweep_clean ==
false 2443 kbytes_to_be_written_per_sec) == malloc_io_page_p)))
2457 (offset / 1024), max_npages, (
long long) ((page_size / 1024) * max_npages));
2463 #if defined(WINDOWS) 2477 #if !defined (CS_MODE) 2515 const char *vol_label_p;
2520 size_t current_size;
2523 size_t desired_extend_size;
2524 size_t max_extend_size;
2525 #if defined(WINDOWS) && defined(SERVER_MODE) 2527 pthread_mutex_t *io_mutex;
2528 static pthread_mutex_t io_mutex_instance = PTHREAD_MUTEX_INITIALIZER;
2533 assert (size_npages > 0);
2551 #if defined(WINDOWS) && defined(SERVER_MODE) 2552 io_mutex = fileio_get_volume_mutex (thread_p, vol_fd);
2553 if (io_mutex ==
NULL)
2555 io_mutex = &io_mutex_instance;
2567 current_size = lseek (vol_fd, 0, SEEK_END);
2568 #if defined(WINDOWS) && defined(SERVER_MODE) 2577 if (new_size <= current_size)
2584 vol_id, current_size, new_size);
2590 max_size = ((size_t)
VOL_MAX_NPAGES (IO_PAGESIZE)) * IO_PAGESIZE;
2591 new_size = MIN (new_size, max_size);
2594 desired_extend_size = new_size - current_size;
2595 max_extend_size = ((size_t) max_npages) *
IO_PAGESIZE;
2597 if (max_extend_size < desired_extend_size)
2599 const size_t ONE_KILO = 1024;
2603 desired_extend_size / IO_PAGESIZE, new_size / ONE_KILO, max_npages,
2609 if (io_page_p ==
NULL)
2616 memset (io_page_p, 0, IO_PAGESIZE);
2619 start_pageid = (
PAGEID) (current_size / IO_PAGESIZE);
2620 last_pageid = ((
PAGEID) (new_size / IO_PAGESIZE) - 1);
2636 IO_PAGESIZE, -1) ==
NULL)
2661 #if defined(ENABLE_UNUSED_FUNCTION) 2672 const char *vol_label_p;
2674 bool is_retry =
true;
2684 if (npages_to_resize <= 0)
2691 while (is_retry ==
true)
2694 if (ftruncate (vol_fd, length))
2708 return npages_to_resize;
2738 #if defined (EnableThreadMonitoring) 2742 #if !defined(CS_MODE) 2744 char vlabel_p[PATH_MAX];
2751 strcpy (vlabel_p, vol_label_p);
2752 vol_label_p = vlabel_p;
2757 #if defined (EnableThreadMonitoring) 2764 if (new_label_p ==
NULL)
2766 (void)
remove (vol_label_p);
2776 #if defined (EnableThreadMonitoring) 2810 VOLID to_vol_id,
bool is_reset_recovery_info)
2827 fileio_format (thread_p,
NULL, to_vol_label_p, to_vol_id, npages,
false,
false,
false,
IO_PAGESIZE, 0,
false);
2836 if (malloc_io_page_p ==
NULL)
2842 if (is_reset_recovery_info ==
false)
2845 for (page_id = 0; page_id < npages; page_id++)
2857 for (page_id = 0; page_id < npages; page_id++)
2885 if (malloc_io_page_p !=
NULL)
2909 bool skip_flush =
false;
2912 if (malloc_io_page_p ==
NULL)
2918 for (page_id = 0; page_id < npages; page_id++)
2960 #if defined(WINDOWS) 2964 #if !defined(CS_MODE) 2975 sh_flags = lock_wait > 0 ? _SH_DENYWR : _SH_DENYNO;
2977 vol_fd = _sopen (vol_label_p, _O_RDWR | _O_BINARY, sh_flags, 0600);
2980 if (sh_flags == _SH_DENYWR && errno != ENOENT)
2992 #if !defined(CS_MODE) 3008 struct stat stat_buf;
3009 time_t last_modification_time = 0;
3010 off_t last_size = 0;
3012 #if !defined(CS_MODE) 3023 o_sync = (is_do_sync !=
false) ? O_SYNC : 0;
3027 vol_fd =
fileio_open (vol_label_p, O_RDWR | o_sync, 0600);
3034 is_do_wait = (lock_wait > 1) ?
true :
false;
3037 if (fstat (vol_fd, &stat_buf) != 0)
3042 last_modification_time = stat_buf.st_mtime;
3043 last_size = stat_buf.st_size;
3046 #if _POSIX_C_SOURCE >= 200112L 3049 int advise_flag = 0;
3054 advise_flag = POSIX_FADV_NORMAL;
3057 advise_flag = POSIX_FADV_SEQUENTIAL;
3060 advise_flag = POSIX_FADV_RANDOM;
3063 advise_flag = POSIX_FADV_NOREUSE;
3066 advise_flag = POSIX_FADV_WILLNEED;
3069 advise_flag = POSIX_FADV_DONTNEED;
3073 if (posix_fadvise (vol_fd, 0, amount, advise_flag) != 0)
3084 lockf_type =
fileio_lock (db_full_name_p, vol_label_p, vol_fd, is_do_wait);
3091 else if (lockf_type ==
FILEIO_LOCKF && is_do_wait ==
true)
3094 if (fstat (vol_fd, &stat_buf) != 0)
3100 if (last_modification_time != stat_buf.st_mtime || last_size != stat_buf.st_size)
3109 #if !defined(CS_MODE) 3111 if (
fileio_cache (vol_id, vol_label_p, vol_fd, lockf_type) != vol_fd)
3137 #if !defined(WINDOWS) 3150 #if !defined(WINDOWS) 3172 #if !defined (WINDOWS) 3222 for (sys_vol_info_p = &fileio_Sys_vol_info_header.
anchor;
3225 if ((*apply_function) (thread_p, sys_vol_info_p, arg) ==
true)
3228 return sys_vol_info_p;
3249 for (j = 0; j <= max_j; j++)
3251 vol_info_p = &header_p->
volinfo[
i][j];
3252 if ((*apply_function) (thread_p, vol_info_p, arg) ==
true)
3275 for (j = max_j; j >= 0; j--)
3277 vol_info_p = &header_p->
volinfo[
i][j];
3278 if ((*apply_function) (thread_p, vol_info_p, arg) ==
true)
3291 int i, j, min_j, num_temp_vols;
3306 vol_info_p = &header_p->
volinfo[
i][j];
3307 if ((*apply_function) (thread_p, vol_info_p, arg) ==
true)
3320 int i, j, min_j, num_temp_vols;
3334 vol_info_p = &header_p->
volinfo[
i][j];
3335 if ((*apply_function) (thread_p, vol_info_p, arg) ==
true)
3352 #if !defined(WINDOWS) 3362 #if defined(WINDOWS) && defined(SERVER_MODE) 3379 int i, num_perm_vols, num_temp_vols;
3387 for (sys_vol_info_p = &sys_header_p->
anchor; sys_vol_info_p !=
NULL;)
3394 #if !defined(WINDOWS) 3404 tmp_sys_vol_info_p = sys_vol_info_p;
3405 sys_vol_info_p = sys_vol_info_p->
next;
3406 if (tmp_sys_vol_info_p != &sys_header_p->
anchor)
3408 #if defined(SERVER_MODE) && defined(WINDOWS) 3468 int i, j, max_j, min_j, num_temp_vols;
3477 for (j = 0; j <= max_j; j++)
3479 vol_info_p = &header_p->
volinfo[
i][j];
3482 if (((*fun) (thread_p, vol_info_p->
volid, args)) ==
false)
3499 vol_info_p = &header_p->
volinfo[
i][j];
3502 if (((*fun) (thread_p, vol_info_p->
volid, args)) ==
false)
3520 return (vol_info_p->
vdes == arg->
vdes);
3558 for (sys_vol_info_p = &fileio_Sys_vol_info_header.
anchor;
3561 if ((*apply_function) (thread_p, sys_vol_info_p, arg) ==
true)
3563 return sys_vol_info_p;
3574 return (sys_vol_info_p->
vdes == arg->
vdes);
3599 char *log_block_string, *dest_ptr;
3600 const size_t size = length * 4;
3603 dest_ptr = log_block_string = (
char *) malloc (size);
3604 if (log_block_string ==
NULL)
3609 for (i = 0, line_no = 0; i < length; i++, src_data++)
3613 dest_ptr += sprintf (dest_ptr,
"\n%05d: ", line_no++);
3616 dest_ptr += sprintf (dest_ptr,
"%02X ", (
unsigned char) (*src_data));
3619 dest_ptr += sprintf (dest_ptr,
"\n");
3621 assert ((
size_t) (dest_ptr - log_block_string) < size);
3628 #if !defined (WINDOWS) 3641 static bool init =
false;
3642 const int mod_factor = 25000;
3643 const int block_size = 4096;
3645 ssize_t r, written_nbytes;
3647 bool fi_partial_write1_on, fi_partial_write2_on;
3651 srand ((
unsigned int) time (
NULL));
3658 if ((fi_partial_write1_on || fi_partial_write2_on) && ((rand () % mod_factor) == 0))
3661 count_blocks = count / block_size;
3663 for (
int i = 0;
i < count_blocks;
i++)
3665 if (fi_partial_write1_on)
3667 unit_offset =
i * block_size;
3672 unit_offset = ((count_blocks - 1) -
i) * block_size;
3675 r = pwrite (fd, ((
char *) buf) + unit_offset, block_size, offset + unit_offset);
3676 written_nbytes += r;
3677 if (r != block_size)
3679 return written_nbytes;
3683 if ((rand () % count_blocks - 1) == 0)
3689 sprintf (msg,
"fault injected to write a page to offset (%ld) of '%s'\n", offset,
3690 vlabel ? vlabel :
"unknown volume");
3697 #if !defined(NDEBUG) 3702 #if defined (SERVER_MODE) || defined (SA_MODE) 3708 bool is_page_corrupted;
3739 return written_nbytes;
3742 return pwrite (fd, buf, count, offset);
3746 #if defined(HPUX) && !defined(IA64) 3760 pread (
int fd,
void *buf,
size_t nbytes, off_t offset)
3763 const struct aiocb *list[1];
3767 io.aio_offset = offset;
3771 io.aio_sigevent.sigev_notify = SIGEV_NONE;
3773 err = aio_read (&io);
3781 err = aio_suspend (list, 1,
NULL);
3787 return aio_return (&io);
3799 pwrite (
int fd,
const void *buf,
size_t nbytes, off_t offset)
3802 const struct aiocb *list[1];
3806 io.aio_offset = offset;
3810 io.aio_sigevent.sigev_notify = SIGEV_NONE;
3812 err = aio_write (&io);
3820 err = aio_suspend (list, 1,
NULL);
3826 return aio_return (&io);
3828 #elif defined(WINDOWS) && defined(SERVER_MODE) 3834 static pthread_mutex_t *
3835 fileio_get_volume_mutex (
THREAD_ENTRY * thread_p,
int vdes)
3850 return &volinfo->vol_mutex;
3857 return &volinfo->vol_mutex;
3868 return &sys_volinfo->sysvol_mutex;
3887 #if !defined (SERVER_MODE) 3889 if (lseek (vol_fd, offset, SEEK_SET) != offset)
3895 return read (vol_fd, io_page_p, count);
3896 #elif defined (WINDOWS) 3900 pthread_mutex_t *io_mutex;
3901 static pthread_mutex_t io_mutex_instance = PTHREAD_MUTEX_INITIALIZER;
3903 io_mutex = fileio_get_volume_mutex (thread_p, vol_fd);
3904 if (io_mutex ==
NULL)
3906 io_mutex = &io_mutex_instance;
3917 if (lseek (vol_fd, offset, SEEK_SET) != offset)
3924 nbytes = read (vol_fd, io_page_p, (
unsigned int) count);
3933 return pread (vol_fd, io_page_p, count, offset);
3952 #if defined (EnableThreadMonitoring) 3958 bool is_retry =
true;
3960 #if defined (EnableThreadMonitoring) 3967 while (is_retry ==
true)
3971 nbytes =
fileio_os_read (thread_p, vol_fd, io_page_p, page_size, offset);
3972 if (nbytes != (ssize_t) page_size)
3995 #if defined (EnableThreadMonitoring) 4027 #if !defined (CS_MODE) 4028 bool skip_flush =
false;
4053 error_code =
dwb_add_page (thread_p, io_page_p, &vpid, &p_dwb_slot);
4058 else if (p_dwb_slot !=
NULL)
4071 return fileio_write (thread_p, vol_fd, io_page_p, page_id, page_size, write_mode);
4089 #if !defined (SERVER_MODE) 4090 if (lseek (vol_fd, offset, SEEK_SET) != offset)
4096 return write (vol_fd, io_page_p, count);
4097 #elif defined (WINDOWS) 4100 pthread_mutex_t *io_mutex;
4101 static pthread_mutex_t io_mutex_instance = PTHREAD_MUTEX_INITIALIZER;
4103 io_mutex = fileio_get_volume_mutex (thread_p, vol_fd);
4104 if (io_mutex ==
NULL)
4106 io_mutex = &io_mutex_instance;
4116 if (lseek (vol_fd, offset, SEEK_SET) != offset)
4123 nbytes = write (vol_fd, io_page_p, (
unsigned int) count);
4128 #elif defined (NDEBUG) 4130 return pwrite (vol_fd, io_page_p, count, offset);
4153 #if defined (EnableThreadMonitoring) 4157 ssize_t nbytes_written;
4159 bool is_retry =
true;
4161 #if defined (EnableThreadMonitoring) 4168 while (is_retry ==
true)
4172 nbytes_written =
fileio_os_write (thread_p, vol_fd, io_page_p, page_size, offset);
4173 if (nbytes_written != (ssize_t) page_size)
4179 else if (errno == ENOSPC)
4184 #if defined (SERVER_MODE) && !defined (WINDOWS) 4185 syslog (LOG_ALERT,
"[CUBRID] %s () at %s:%d %m", __func__, __FILE__, __LINE__);
4198 #if defined (EnableThreadMonitoring) 4230 #if defined (EnableThreadMonitoring) 4235 ssize_t nbytes_read;
4236 size_t nbytes_to_be_read;
4241 nbytes_to_be_read = ((size_t) page_size) * ((size_t) num_pages);
4243 #if defined (EnableThreadMonitoring) 4250 while (nbytes_to_be_read > 0)
4252 nbytes_read =
fileio_os_read (thread_p, vol_fd, io_pages_p, nbytes_to_be_read, offset);
4253 if (nbytes_read <= 0)
4255 if (nbytes_read == 0)
4265 #if !defined(WINDOWS) 4278 offset += nbytes_read;
4279 io_pages_p += nbytes_read;
4280 nbytes_to_be_read -= nbytes_read;
4283 #if defined (EnableThreadMonitoring) 4317 #if defined (EnableThreadMonitoring) 4322 ssize_t nbytes_written;
4323 size_t nbytes_to_be_written;
4328 nbytes_to_be_written = ((size_t) page_size) * ((size_t) num_pages);
4330 #if defined (EnableThreadMonitoring) 4337 while (nbytes_to_be_written > 0)
4339 nbytes_written =
fileio_os_write (thread_p, vol_fd, io_pages_p, nbytes_to_be_written, offset);
4340 if (nbytes_written <= 0)
4342 if (nbytes_written == 0)
4352 #if !defined(WINDOWS) 4365 offset += nbytes_written;
4366 io_pages_p += nbytes_written;
4367 nbytes_to_be_written -= nbytes_written;
4370 #if defined (EnableThreadMonitoring) 4418 #if !defined (CS_MODE) 4422 for (i = 0; i < npages; i++)
4424 if (
fileio_write (thread_p, vol_fd, io_page_array[i], start_page_id + i, page_size, write_mode) ==
NULL)
4430 return io_page_array[0];
4444 bool all_sync =
false;
4445 #if defined (EnableThreadMonitoring) 4449 #if defined (SERVER_MODE) 4450 static pthread_mutex_t inc_cnt_mutex = PTHREAD_MUTEX_INITIALIZER;
4453 static int inc_cnt = 0;
4457 #if defined (SERVER_MODE) 4466 #if defined (SERVER_MODE) 4471 #if defined (SERVER_MODE) 4476 #if defined (EnableThreadMonitoring) 4483 #if !defined (CS_MODE) 4491 if (ret ==
NO_ERROR && all_sync ==
false)
4493 ret = fsync (vol_fd);
4496 #if defined (EnableThreadMonitoring) 4512 #if defined (EnableThreadMonitoring) 4621 bool all_sync =
false;
4623 #if defined (SERVER_MODE) || defined (SA_MODE) 4624 PERF_UTIME_TRACKER time_track;
4626 PERF_UTIME_TRACKER_START (thread_p, &time_track);
4639 #if !defined (CS_MODE) 4645 if (success ==
NO_ERROR && all_sync ==
false)
4658 #if defined (SERVER_MODE) || defined (SA_MODE) 4665 #if defined(ENABLE_UNUSED_FUNCTION) 4680 fileio_read_user_area (
THREAD_ENTRY * thread_p,
int vol_fd,
PAGEID page_id, off_t start_offset,
size_t nbytes,
4684 bool is_retry =
true;
4686 #if defined(WINDOWS) && defined(SERVER_MODE) 4687 pthread_mutex_t io_mutex;
4693 if (io_page_p ==
NULL)
4702 while (is_retry ==
true)
4706 #if !defined(SERVER_MODE) 4708 if (lseek (vol_fd, offset, SEEK_SET) != offset)
4710 if (io_page_p !=
NULL)
4722 #elif defined(WINDOWS) 4723 io_mutex = fileio_get_volume_mutex (thread_p, vol_fd);
4732 if (lseek (vol_fd, offset, SEEK_SET) != offset)
4741 actual_nread = read (vol_fd, io_page_p,
IO_PAGESIZE);
4758 if (io_page_p !=
NULL)
4770 memcpy (area_p, io_page_p->
page + start_offset, nbytes);
4772 if (io_page_p !=
NULL)
4795 fileio_write_user_area (
THREAD_ENTRY * thread_p,
int vol_fd,
PAGEID page_id, off_t start_offset,
int nbytes,
4799 bool is_retry =
true;
4802 struct stat stat_buf;
4803 #if defined(WINDOWS) && defined(SERVER_MODE) 4804 int actual_nwrite,
rv;
4805 pthread_mutex_t io_mutex;
4808 if (fstat (vol_fd, &stat_buf) != 0)
4815 #if defined(WINDOWS) 4820 offset += start_offset;
4824 if (S_ISREG (stat_buf.st_mode))
4830 offset += start_offset;
4835 else if (S_ISCHR (stat_buf.st_mode))
4847 if (io_page_p ==
NULL)
4854 memcpy (io_page_p->
page, area_p, nbytes);
4856 write_p = (
void *) io_page_p;
4867 while (is_retry ==
true)
4871 nbytes_written =
fileio_os_write (thread_p, vol_fd, write_p, nbytes, offset);
4872 if (nbytes_written != nbytes)
4878 else if (errno == ENOSPC)
4893 if (io_page_p !=
NULL)
4903 if (io_page_p !=
NULL)
4922 offset = lseek (vol_fd, 0L, SEEK_END);
4939 #if defined(WINDOWS) 4943 INT64 npages_of_partition = -1;
4944 #if defined(SOLARIS) 4950 #if defined(SOLARIS) 4951 if (statvfs (path_p, &buf) == -1)
4953 if (statfs ((
char *) path_p, &buf) == -1)
4955 if (statfs (path_p, &buf) == -1)
4966 (void)
remove (path_p);
4975 const size_t f_avail_size = buf.f_bsize * buf.f_bavail;
4976 npages_of_partition = f_avail_size /
page_size;
4977 if (npages_of_partition < 0 || npages_of_partition > INT_MAX)
4979 npages_of_partition = INT_MAX;
4983 if (npages_of_partition < 0)
4989 assert (npages_of_partition <= INT_MAX);
4991 return (
int) npages_of_partition;
5005 #if defined(WINDOWS) 5009 INT64 nsectors_of_partition = -1;
5010 #if defined(SOLARIS) 5016 #if defined(SOLARIS) 5017 if (statvfs (path_p, &buf) == -1)
5019 if (statfs ((
char *) path_p, &buf) == -1)
5021 if (statfs (path_p, &buf) == -1)
5032 (void)
remove (path_p);
5041 const size_t f_avail_size = buf.f_bsize * buf.f_bavail;
5043 if (nsectors_of_partition < 0 || nsectors_of_partition > INT_MAX)
5045 nsectors_of_partition = INT_MAX;
5049 if (nsectors_of_partition < 0)
5055 assert (nsectors_of_partition <= INT_MAX);
5057 return (
DKNSECTS) nsectors_of_partition;
5072 #if defined(CUBRID_DEBUG) 5098 #if !defined(CS_MODE) 5111 if (errno == ENOENT)
5144 if (stat (vol_label_p, &stbuf) != -1 && S_ISREG (stbuf.st_mode))
5158 tmp_name_p = name_p - (*max_name_size_p - check_size + 1);
5161 vol_fd =
fileio_open (new_guess_path_p, O_RDONLY, 0);
5165 if (vol_fd ==
NULL_VOLDES && errno == ENAMETOOLONG)
5167 *max_name_size_p = check_size + 1;
5168 name_p = tmp_name_p;
5175 (void)
remove (new_guess_path_p);
5197 tmp_name_p = name_p - (*max_name_size_p - check_size + 1);
5200 if (stat (new_guess_path_p, &buf[1]) == 0 && buf[0].st_ino == buf[1].st_ino)
5202 *max_name_size_p = check_size + 1;
5203 name_p = tmp_name_p;
5229 static char last_guess_path[PATH_MAX] = {
'\0' };
5230 static int max_name_size = -1;
5231 char new_guess_path[PATH_MAX];
5233 int check256, check14;
5234 bool is_remove =
false;
5240 *file_name_max_p = NAME_MAX;
5241 *path_name_max_p = PATH_MAX;
5243 if (*file_name_max_p > *path_name_max_p)
5245 *file_name_max_p = *path_name_max_p;
5251 name_p = strrchr (new_guess_path,
'/');
5252 #if defined(WINDOWS) 5254 char *tmp_name = strrchr (new_guess_path,
'\\');
5255 if (name_p < tmp_name)
5266 name_p = new_guess_path;
5269 if (max_name_size != -1 && strcmp (last_guess_path, new_guess_path) == 0)
5271 return *file_name_max_p = max_name_size;
5274 for (max_name_size = 1, i = (
int)
strlen (new_guess_path) + 1;
5275 max_name_size < *file_name_max_p && i < *path_name_max_p; max_name_size++, i++)
5286 while (max_name_size > 1)
5288 vol_fd =
fileio_open (new_guess_path, O_RDONLY, 0);
5305 if (errno != ENAMETOOLONG)
5315 if (max_name_size > 257 && check256 == 1)
5320 else if (max_name_size > 15 && check14 == 1)
5330 strncpy (last_guess_path, new_guess_path, PATH_MAX);
5335 if (stat (new_guess_path, &buf[0]) == -1)
5353 for (; max_name_size > 1; max_name_size--)
5356 if ((success = stat (new_guess_path, &buf[1])) == 0 && buf[0].st_ino == buf[1].st_ino)
5364 if (max_name_size > 257 && check256 == 1)
5370 else if (max_name_size > 15 && check14 == 1)
5382 else if (errno == ENOENT)
5394 if (is_remove ==
true)
5396 (void)
remove (last_guess_path);
5399 name_p = strrchr (last_guess_path,
'/');
5400 #if defined(WINDOWS) 5402 char *tmp_name = strrchr (last_guess_path,
'\\');
5403 if (name_p < tmp_name)
5415 max_name_size = max_name_size + 2;
5417 return *file_name_max_p = max_name_size;
5420 if (is_remove ==
true)
5422 (void)
remove (last_guess_path);
5426 *path_name_max_p = -1;
5427 *file_name_max_p = -1;
5461 char new_path[PATH_MAX];
5468 path_p = given_path_p;
5470 *file_name_max_p = pathconf ((
char *) path_p, _PC_NAME_MAX);
5471 *path_name_max_p = pathconf ((
char *) path_p, _PC_PATH_MAX);
5473 if ((*file_name_max_p < 0 || *path_name_max_p < 0) && (errno == ENOENT || errno == EINVAL))
5482 if (stat (path_p, &stbuf) != -1 && ((stbuf.st_mode & S_IFMT) != S_IFDIR))
5486 name_p = strrchr (new_path,
'/');
5487 #if defined(WINDOWS) 5489 char *tmp_name = strrchr (new_path,
'\\');
5490 if (name_p < tmp_name)
5500 *file_name_max_p = pathconf ((
char *) path_p, _PC_NAME_MAX);
5501 *path_name_max_p = pathconf ((
char *) path_p, _PC_PATH_MAX);
5503 path_p = given_path_p;
5507 if (*file_name_max_p < 0 || *path_name_max_p < 0)
5514 if (*file_name_max_p < 0 || *file_name_max_p > NAME_MAX)
5516 *file_name_max_p = NAME_MAX;
5519 if (*path_name_max_p < 0 || *path_name_max_p > PATH_MAX)
5521 *path_name_max_p = PATH_MAX;
5524 return *file_name_max_p;
5535 const char *no_path_name_p;
5538 #if defined(WINDOWS) 5540 const char *nn_tmp = strrchr (full_name_p,
'/');
5541 if (no_path_name_p < nn_tmp)
5543 no_path_name_p = nn_tmp;
5547 if (no_path_name_p ==
NULL)
5549 no_path_name_p = full_name_p;
5556 return no_path_name_p;
5574 assert (base_p >= full_name_p);
5576 if (base_p == full_name_p)
5579 if (getcwd (path_p, PATH_MAX) ==
NULL)
5587 path_size = (size_t) (base_p - full_name_p - 1);
5588 if (path_size > PATH_MAX)
5590 path_size = PATH_MAX;
5592 memcpy (path_p, full_name_p, path_size);
5593 path_p[path_size] =
'\0';
5656 sprintf (vol_ext_full_name_p,
"%s%s%s%s%03d", ext_path_p,
FILEIO_PATH_SEPARATOR (ext_path_p), ext_name_p,
5674 sprintf (vol_ext_full_name_p,
"%s%s%s", ext_path_p,
FILEIO_PATH_SEPARATOR (ext_path_p), ext_name_p);
5727 const char *base_log_name)
5732 sprintf (temp_log_name,
"%s_%03d_tmp", base_log_name, level);
5735 sprintf (temp_log_name,
"%s_%03d_tmp", base_log_name, level);
5738 sprintf (temp_log_name,
"%s_%03d_tmp", base_log_name, level);
5761 sprintf (log_archive_name_p,
"%s%s%s%s%03d", log_path_p,
FILEIO_PATH_SEPARATOR (log_path_p), db_name_p,
5779 sprintf (log_archive_name_p,
"%s%s%s%s.removed", log_path_p,
FILEIO_PATH_SEPARATOR (log_path_p), db_name_p,
5795 const char *fmt_string_p;
5797 fmt_string_p =
"%s%s%s%s";
5799 snprintf (log_archive_temp_name_p, PATH_MAX - 1, fmt_string_p, log_path_p,
FILEIO_PATH_SEPARATOR (log_path_p),
5835 sprintf (backup_volinfo_name_p,
"%s%s%s%s", backup_info_path_p,
FILEIO_PATH_SEPARATOR (backup_info_path_p), db_name_p,
5858 sprintf (backup_name_p,
"%s%c%s%s%dv%03d", backup_path_p,
PATH_SEPARATOR, no_path_vol_name_p,
5919 #ifdef UNSTABLE_TDE_FOR_REPLICATION_LOG 5931 fileio_make_ha_sock_name (
char *sock_path_p,
const char *base_path_p,
const char *sock_name_p)
5948 bool is_permanent_volume;
5967 is_permanent_volume =
true;
5979 is_permanent_volume =
false;
5982 vol_info_p = &fileio_Vol_info_header.
volinfo[
i][j];
5983 vol_info_p->
volid = vol_id;
5984 vol_info_p->
vdes = vol_fd;
5986 strncpy (vol_info_p->
vlabel, vol_label_p, PATH_MAX);
5989 if (is_permanent_volume)
6018 if (sys_vol_info_p ==
NULL)
6026 sys_vol_info_p->
volid = vol_id;
6027 sys_vol_info_p->
vdes = vol_fd;
6031 fileio_Sys_vol_info_header.
anchor.
next = sys_vol_info_p;
6032 fileio_Sys_vol_info_header.
num_vols++;
6033 #if defined(WINDOWS) 6040 sys_vol_info_p = &fileio_Sys_vol_info_header.
anchor;
6041 sys_vol_info_p->
volid = vol_id;
6042 sys_vol_info_p->
vdes = vol_fd;
6046 #if defined(WINDOWS) 6049 fileio_Sys_vol_info_header.
num_vols++;
6069 int vol_id, prev_vol;
6075 for ((sys_vol_info_p = &fileio_Sys_vol_info_header.
anchor, prev_sys_vol_info_p =
NULL);
6077 prev_sys_vol_info_p = sys_vol_info_p, sys_vol_info_p = sys_vol_info_p->
next)
6079 if (sys_vol_info_p->
vdes == vol_fd)
6081 if (prev_sys_vol_info_p ==
NULL)
6086 sys_vol_info_p = fileio_Sys_vol_info_header.
anchor.
next;
6090 strncpy (fileio_Sys_vol_info_header.
anchor.
vlabel, sys_vol_info_p->
vlabel, PATH_MAX);
6092 #if defined(SERVER_MODE) && defined(WINDOWS) 6104 #if defined(SERVER_MODE) && defined(WINDOWS) 6111 prev_sys_vol_info_p->
next = sys_vol_info_p->
next;
6112 #if defined(SERVER_MODE) && defined(WINDOWS) 6117 fileio_Sys_vol_info_header.
num_vols--;
6127 vol_id = vol_info_p->
volid;
6140 vol_info_p->
vlabel[0] =
'\0';
6141 #if defined(SERVER_MODE) && defined(WINDOWS) 6151 vol_id = vol_info_p->
volid;
6167 vol_info_p->
vlabel[0] =
'\0';
6168 #if defined(SERVER_MODE) && defined(WINDOWS) 6186 char *vol_label_p =
NULL;
6215 vol_info_p = &fileio_Vol_info_header.
volinfo[
i][j];
6216 vol_label_p = (
char *) vol_info_p->
vlabel;
6226 vol_label_p = (
char *) sys_vol_info_p->
vlabel;
6234 char *ret =
strdup (vol_label_p);
6282 vol_id = sys_vol_info_p->
volid;
6293 return vol_info_p->
volid;
6300 return vol_info_p->
volid;
6333 vol_id = sys_vol_info_p->
volid;
6344 return vol_info_p->
volid;
6351 return vol_info_p->
volid;
6427 return vol_info_p->
volid;
6451 return vol_info_p->
volid;
6475 return vol_info_p->
volid;
6519 vol_info_p = &fileio_Vol_info_header.
volinfo[
i][j];
6520 vol_fd = vol_info_p->
vdes;
6529 vol_fd = sys_vol_info_p->
vdes;
6558 vol_fd = sys_vol_info_p->
vdes;
6569 return vol_info_p->
vdes;
6576 return vol_info_p->
vdes;
6630 int vol_size, max_buf_size;
6639 while (max_buf_size > buf_size)
6641 if (vol_size % max_buf_size < buf_size)
6645 max_buf_size -= buf_size;
6657 #if defined(SERVER_MODE) 6663 queue_p = &thread_info_p->
io_queue;
6665 #if defined(SERVER_MODE) 6673 rv = pthread_cond_init (&thread_info_p->rcv,
NULL);
6680 rv = pthread_cond_init (&thread_info_p->wcv,
NULL);
6688 num_cpus = fileio_os_sysconf ();
6696 thread_info_p->
num_threads = MIN (num_threads, num_cpus * 2);
6702 #if defined(CUBRID_DEBUG) 6731 int num_threads,
int sleep_msecs)
6735 const char *db_nopath_name_p;
6739 const char *verbose_fp_mode;
6758 while (stat (backup_destination_p, &stbuf) == -1)
6775 if (S_ISDIR (stbuf.st_mode))
6787 else if (S_ISREG (stbuf.st_mode))
6802 #if defined(WINDOWS) 6805 buf_size = stbuf.st_blksize;
6811 fileio_determine_backup_buffer_size (session_p, buf_size);
6818 "Backup block buffer size %ld must be less " 6819 "than backup volume size %ld, resetting buffer size to %d\n", session_p->
bkup.
iosize,
6824 #if defined(CUBRID_DEBUG) 6826 fprintf (stdout,
"NATURAL BUFFER SIZE %ld (%d IO buffer blocks)\n", session_p->
bkup.
iosize,
6891 #if defined(CUBRID_DEBUG) 6892 fprintf (stdout,
"fileio_initialize_backup: %d\t%d,\t%d\n",
6903 if (verbose_file_path && *verbose_file_path)
6907 verbose_fp_mode =
"w";
6911 verbose_fp_mode =
"a";
6914 session_p->
verbose_fp = fopen (verbose_file_path, verbose_fp_mode);
6968 #if defined(SERVER_MODE) 6980 #if defined(SERVER_MODE) 6987 rv = pthread_cond_destroy (&tp->rcv);
6993 rv = pthread_cond_destroy (&tp->wcv);
7000 while (qp->
size > 0)
7006 for (node = qp->
free_list; node; node = node_next)
7008 node_next = node->
next;
7081 if (does_unformat_bk)
7188 backup_header_p->
db_creation = *db_creation_time_p;
7191 backup_header_p->
level = backup_level;
7197 if (all_levels_info_p)
7257 const char *first_bkvol_name;
7264 if (first_bkvol_name ==
NULL)
7270 if (strncmp (first_bkvol_name, session_p->
bkup.
vlabel, PATH_MAX) == 0)
7273 lseek (session_p->
bkup.
vdes, 0, SEEK_SET);
7286 nbytes = write (vdes, (
char *) &end_time,
sizeof (INT64));
7287 if (nbytes !=
sizeof (INT64))
7312 memcpy (write_to, (
char *) &end_time,
sizeof (INT64));
7339 char *msg_area =
NULL;
7343 end_time = (INT64) time (
NULL);
7357 nbytes +=
sizeof (INT64);
7367 #if defined(CUBRID_DEBUG) 7368 fprintf (stdout,
"io_backup_end: iosize = %ld, count = %ld, voltotalio = %ld : EOF JUNK\n",
7378 memset (session_p->
bkup.
ptr,
'\0', nbytes);
7408 #if defined(SERVER_MODE) && !defined(WINDOWS) 7450 const char *vol_name_p;
7452 level = start_level;
7470 if (vol_name_p ==
NULL)
7499 int zip_info_size, buf_size;
7529 assert (size <= LZ4_MAX_INPUT_SIZE);
7530 buf_size = LZ4_compressBound (size);
7531 zip_info_size = offsetof (
FILEIO_ZIP_INFO, zip_page) +
sizeof (int) + buf_size;
7598 #if defined(SERVER_MODE) 7610 queue_p->
tail = node_p;
7614 queue_p->
head = node_p;
7634 node = queue_p->
head;
7637 if (node == queue_p->
tail)
7665 if (!node_p || !node_p->
zip_info || !backup_header_p)
7680 if (local_buf_len <= 0)
7687 #if defined(CUBRID_DEBUG) 7689 "internal error - compression failed: node->pageid = %d, node->nread = %d, " 7690 "buf_len = %d, buf_size = %d\n",
7696 assert (local_buf_len < node_p->zip_info->buf_size);
7698 if ((ssize_t) local_buf_len < node_p->nread)
7701 zip_page->
buf_len = local_buf_len;
7748 if (!session_p || !node_p || !backup_header_p)
7797 #if defined(SERVER_MODE) 7805 bool need_unlock =
false;
7809 if (thread_p ==
NULL)
7812 if (thread_p ==
NULL)
7825 queue_p = &thread_info_p->
io_queue;
7828 thread_p->tran_index = thread_info_p->
tran_index;
7829 #if defined(CUBRID_DEBUG) 7830 fprintf (stdout,
"start io_backup_volume_read, session = %p\n", session_p);
7839 pthread_cond_wait (&thread_info_p->rcv, &thread_info_p->mtx);
7854 pthread_cond_signal (&thread_info_p->wcv);
7857 pthread_cond_wait (&thread_info_p->rcv, &thread_info_p->mtx);
7875 pthread_cond_signal (&thread_info_p->wcv);
7898 if (node_p->
nread == -1)
7904 else if (node_p->
nread == 0)
7916 #if defined(CUBRID_DEBUG) 7917 fprintf (stdout,
"io_backup_volume_read interrupt\n");
7934 (void) fileio_append_queue (queue_p, node_p);
7943 #if defined(CUBRID_DEBUG) 7944 fprintf (stdout,
"read_thread from_npages = %d, pageid = %d\n", thread_info_p->
from_npages,
7954 #if defined(CUBRID_DEBUG) 7955 fprintf (stdout,
"fileio_read_backup_volume: %d\t%d,\t%d\n",
7965 need_unlock =
false;
7974 #if defined(CUBRID_DEBUG) 7975 fprintf (stdout,
"end io_backup_volume_read\n");
7990 pthread_cond_signal (&thread_info_p->wcv);
8018 bool need_unlock =
false;
8028 queue_p = &thread_info_p->
io_queue;
8029 #if defined(CUBRID_DEBUG) 8030 fprintf (stdout,
"start io_backup_volume_write\n");
8038 pthread_cond_wait (&thread_info_p->wcv, &thread_info_p->mtx);
8065 #if defined(CUBRID_DEBUG) 8066 fprintf (stdout,
"write_thread node->pageid = %d, node->nread = %d\n", node_p->
pageid, node_p->
nread);
8097 pthread_cond_broadcast (&thread_info_p->rcv);
8100 #if defined(CUBRID_DEBUG) 8101 fprintf (stdout,
"end io_backup_volume_write\n");
8105 return thread_info_p->
io_type;
8111 switch (thread_info_p->
errid)
8132 pthread_cond_broadcast (&thread_info_p->rcv);
8133 pthread_cond_wait (&thread_info_p->wcv, &thread_info_p->mtx);
8142 fileio_read_backup_volume (&thread_ref, back_session);
8149 int check_ratio,
int check_npages,
FILEIO_QUEUE * queue_p)
8156 thread_info_p->
pageid = 0;
8169 auto exec_f = std::bind (fileio_read_backup_volume_execute, std::placeholders::_1, session_p);
8175 (void) fileio_write_backup_volume (thread_p, session_p);
8186 #if !defined(CS_MODE) 8216 VOLID from_vol_id,
PAGEID last_page,
bool is_only_updated_pages)
8218 struct stat from_stbuf;
8219 int from_npages, npages;
8223 int check_ratio = 0;
8224 int check_npages = 0;
8231 bool is_need_vol_closed;
8233 #if (defined(WINDOWS) || !defined(SERVER_MODE)) 8234 off_t saved_act_log_fp = (off_t) - 1;
8249 is_need_vol_closed =
false;
8253 #if (defined(WINDOWS) || !defined(SERVER_MODE)) 8257 saved_act_log_fp = lseek (session_p->
dbfile.
vdes, (off_t) 0, SEEK_CUR);
8259 if (saved_act_log_fp == (off_t) - 1)
8265 if (lseek (session_p->
dbfile.
vdes, (off_t) 0, SEEK_SET) == (off_t) - 1)
8282 is_need_vol_closed =
true;
8285 if (fstat (session_p->
dbfile.
vdes, &from_stbuf) == -1)
8291 if (S_ISREG (from_stbuf.st_mode))
8311 if (last_page >= 0 && last_page < npages)
8334 #if defined(CUBRID_DEBUG) 8337 if (io_Bkuptrace_debug > 0)
8342 fprintf (stdout,
"\n");
8350 check_npages = (int) (((
float) from_npages / 25.0) * check_ratio);
8354 queue_p = &thread_info_p->
io_queue;
8360 #if defined(SERVER_MODE) 8361 if (fileio_start_backup_thread (thread_p, session_p, thread_info_p, from_npages, is_only_updated_pages,
8362 check_ratio, check_npages, queue_p) !=
NO_ERROR)
8375 for (page_id = 0; page_id < from_npages; page_id++)
8395 node_p->
pageid = page_id;
8398 if (node_p->
nread == -1)
8402 else if (node_p->
nread == 0)
8424 #if defined(CUBRID_DEBUG) 8425 fprintf (stdout,
"fileio_backup_volume: %d\t%d,\t%d\n", ((
FILEIO_BACKUP_PAGE *) (node_p->
area))->iopageid,
8445 if (session_p->
verbose_fp && from_npages >= 25 && page_id >= check_npages)
8449 check_npages = (int) (((
float) from_npages / 25.0) * check_ratio);
8471 #if defined(CUBRID_DEBUG) 8494 #if defined(CUBRID_DEBUG) 8495 fprintf (stdout,
"volume EOF : bkpagesize = %d, voltotalio = %ld\n", backup_header_p->
bkpagesize,
8499 if (is_need_vol_closed ==
true)
8503 #if (defined(WINDOWS) || !defined(SERVER_MODE)) 8509 lseek (session_p->
dbfile.
vdes, saved_act_log_fp, SEEK_SET);
8520 if (from_npages < 25)
8522 fprintf (session_p->
verbose_fp,
"######################### | done\n");
8526 while (check_ratio <= 25)
8531 fprintf (session_p->
verbose_fp,
" | done\n");
8538 if (is_need_vol_closed ==
true)
8542 #if (defined(WINDOWS) || !defined(SERVER_MODE)) 8548 lseek (session_p->
dbfile.
vdes, saved_act_log_fp, SEEK_SET);
8582 bool is_interactive_need_new =
false;
8583 bool is_force_new_bkvol =
false;
8593 #if defined(CUBRID_DEBUG) 8594 fprintf (stdout,
"io_backup_flush: bkup.count = %ld, voltotalio = %ld\n", session_p->
bkup.
count,
8609 is_interactive_need_new =
false;
8610 is_force_new_bkvol =
false;
8626 is_force_new_bkvol =
true;
8631 nbytes = write (session_p->
bkup.
vdes, buffer_p, count);
8636 is_interactive_need_new =
true;
8647 #if !defined(WINDOWS) 8653 is_force_new_bkvol =
true;
8659 is_interactive_need_new =
true;
8673 count -= (int) nbytes;
8678 if (is_interactive_need_new || is_force_new_bkvol
8682 #if defined(CUBRID_DEBUG) 8683 fprintf (stdout,
"open a new backup volume\n");
8697 goto restart_newvol;
8726 #if defined(WINDOWS) 8737 #if defined(CUBRID_DEBUG) 8744 while (nread < io_page_size)
8747 #if !defined(SERVER_MODE) 8748 nbytes = read (session_p->
dbfile.
vdes, buffer_p, io_page_size - nread);
8749 #elif defined(WINDOWS) 8750 nbytes = read (session_p->
dbfile.
vdes, buffer_p, io_page_size - nread);
8753 pread (session_p->
dbfile.
vdes, buffer_p, io_page_size - nread,
8765 else if (nbytes == 0)
8769 #if defined(CUBRID_DEBUG) 8770 fprintf (stdout,
"io_backup_read: io_pagesize = %d, nread = %d, voltotalio = %d : ADD FILLER\n",
8778 memset (buffer_p,
'\0', io_page_size - nread);
8779 nread = io_page_size;
8787 #if defined(SERVER_MODE) 8811 if (sleep_msecs > 0)
8813 sleep_msecs = (int) (((
double) sleep_msecs) / (
ONE_M / io_page_size));
8815 if (sleep_msecs > 0)
8840 while (to_write_nbytes > 0)
8849 if (nbytes > to_write_nbytes)
8851 nbytes = to_write_nbytes;
8854 memcpy (session_p->
bkup.
ptr, buffer_p, nbytes);
8858 to_write_nbytes -=
nbytes;
8897 nbytes = write (session_p->
bkup.
vdes, buffer_p, count);
8900 if (errno == EINTR || errno == EAGAIN)
8905 if (errno == ENOSPC)
8946 const char *restore_verbose_file_path,
bool is_new_vol_path)
8948 char orig_name[PATH_MAX];
8950 strcpy (orig_name, backup_source_p);
8955 fprintf (stdout,
"%s\n",
er_msg ());
8957 strcpy (backup_source_p, orig_name);
8971 restore_verbose_file_path, 0 , 0 ));
8998 #if defined(WINDOWS) 9004 const char *next_vol_p;
9005 bool is_end_of_backup =
false;
9006 bool is_need_next_vol =
false;
9010 while (to_read_nbytes > 0 && is_end_of_backup ==
false)
9020 is_need_next_vol =
false;
9035 is_end_of_backup =
true;
9040 is_need_next_vol =
true;
9052 #if !defined(WINDOWS) 9055 is_need_next_vol =
true;
9068 if (is_need_next_vol)
9074 if (next_vol_p ==
NULL)
9100 if (next_vol_p !=
NULL)
9102 strncpy (session_p->
bkup.
name, next_vol_p, PATH_MAX - 1);
9114 strncpy (session_p->
bkup.
name, next_vol_p, PATH_MAX - 1);
9137 goto restart_newvol;
9156 if (nbytes > to_read_nbytes)
9158 nbytes = to_read_nbytes;
9160 memcpy (buffer_p, session_p->
bkup.
ptr, nbytes);
9162 to_read_nbytes -=
nbytes;
9167 if (to_read_nbytes > 0 && !is_end_of_backup)
9200 buffer_p = (
char *) backup_header_p;
9201 while (to_read_nbytes > 0)
9203 nbytes = read (session_p->
bkup.
vdes, buffer_p, to_read_nbytes);
9217 else if (nbytes == 0)
9224 to_read_nbytes -=
nbytes;
9237 if (to_read_nbytes > 0)
9265 INT64 match_db_creation_time,
PGLENGTH * db_io_page_size_p,
float *db_compatibility_p,
9267 INT64 match_backup_creation_time,
const char *restore_verbose_file_path,
bool is_new_vol_path)
9273 restore_verbose_file_path, is_new_vol_path) ==
NULL)
9280 match_backup_creation_time);
9281 if (temp_session_p !=
NULL)
9287 return (temp_session_p);
9293 char *header_message_p =
NULL;
9294 char *remote_message_p =
NULL;
9303 if (
asprintf (&remote_message_p,
"%s%s", header_message_p, error_message_p) < 0)
9306 free (header_message_p);
9312 free (header_message_p);
9313 free (remote_message_p);
9337 INT64 match_backup_creation_time)
9343 bool is_original_header =
true;
9344 char *error_message_p =
NULL;
9346 const char *db_nopath_name_p;
9347 char copy_name[PATH_MAX];
9348 char orig_name[PATH_MAX];
9351 int search_loop_count = 0;
9354 memset (io_timeval, 0,
sizeof (io_timeval));
9362 is_need_retry =
false;
9368 exists = stat (session_p->
bkup.
vlabel, &stbuf) != -1;
9377 if (search_loop_count == 0)
9387 fprintf (stdout,
"%s\n",
er_msg ());
9390 strcpy (session_p->
bkup.
name, orig_name);
9401 search_loop_count++;
9408 is_need_retry =
true;
9447 free (error_message_p);
9451 free (error_message_p);
9452 is_need_retry =
true;
9470 if (is_authenticate)
9477 if (level != backup_header_p->
level)
9489 free (error_message_p);
9493 free (error_message_p);
9494 is_need_retry =
true;
9499 if (match_backup_creation_time != 0
9500 && difftime ((time_t) match_backup_creation_time, (time_t) backup_header_p->
start_time))
9502 char save_time1[64];
9504 fileio_ctime (&match_backup_creation_time, io_timeval);
9505 strcpy (save_time1, io_timeval);
9510 session_p->
bkup.
vlabel, save_time1, io_timeval) < 0)
9518 free (error_message_p);
9522 free (error_message_p);
9523 is_need_retry =
true;
9528 if (unit_num != backup_header_p->
unit_num)
9540 free (error_message_p);
9544 free (error_message_p);
9545 is_need_retry =
true;
9551 if (backup_header_p->
iopageid != expect_page_id)
9563 free (error_message_p);
9566 free (error_message_p);
9567 is_need_retry =
true;
9572 if (strcmp (backup_header_p->
db_fullname, db_full_name_p) != 0
9573 || (db_creation_time > 0 && difftime ((time_t) db_creation_time, (time_t) backup_header_p->
db_creation)))
9577 char save_time1[64];
9578 char save_time2[64];
9581 strcpy (save_time1, io_timeval);
9584 strcpy (save_time2, io_timeval);
9603 free (error_message_p);
9607 free (error_message_p);
9608 is_need_retry =
true;
9616 is_original_header =
false;
9632 while (is_need_retry);
9656 int io_pagesize, size;
9711 float db_compatibility;
9713 INT64 db_creation_time = 0;
9714 char file_name[PATH_MAX];
9718 if (
fileio_start_restore (thread_p, db_full_name_p, backup_source_p, db_creation_time, &db_iopagesize,
9719 &db_compatibility, session_p, level,
false, 0,
NULL, is_new_vol_path) ==
NULL)
9743 (
void) ctime_r (&tmp_time, time_val);
9751 tmp_time = (time_t) backup_header_p->
start_time;
9752 (
void) ctime_r (&tmp_time, time_val);
9768 (
void) ctime_r (&tmp_time, time_val);
9786 fprintf (stdout,
"\n");
9820 strncpy (file_name, file_header_p->
vlabel, PATH_MAX);
9829 fprintf (stdout,
"\n");
9847 const char *user_backuppath,
int try_level,
char *from_volbackup)
9849 FILE *backup_volinfo_fp =
NULL;
9850 const char *nopath_name;
9851 const char *volnameptr;
9854 char format_string[64];
9857 sprintf (format_string,
"%%%ds", PATH_MAX - 1);
9862 while ((stat (from_volbackup, &stbuf) == -1) || (backup_volinfo_fp = fopen (from_volbackup,
"r")) ==
NULL)
9868 if (user_backuppath !=
NULL)
9881 if (scanf (
"%d", &retry) != 1)
9896 if (scanf (format_string, from_volbackup) != 1)
9915 if (backup_volinfo_fp !=
NULL)
9922 if (volnameptr !=
NULL)
9924 strcpy (from_volbackup, volnameptr);
9934 fclose (backup_volinfo_fp);
9938 fclose (backup_volinfo_fp);
9941 if (user_backuppath !=
NULL)
9943 strncpy (from_volbackup, user_backuppath, PATH_MAX - 1);
9965 char file_path[PATH_MAX];
10013 strncpy (file_name_p, file_header_p->
vlabel, PATH_MAX);
10040 if (malloc_io_pgptr ==
NULL)
10043 if (malloc_io_pgptr ==
NULL)
10048 memset ((
char *) malloc_io_pgptr, 0,
IO_PAGESIZE);
10052 while (*next_page_id_p < stop_page_id)
10065 *next_page_id_p += 1;
10068 if (malloc_io_pgptr !=
NULL)
10096 queue_p = &thread_info_p->
io_queue;
10107 goto exit_on_error;
10120 goto exit_on_error;
10135 goto exit_on_error;
10145 #if defined(CUBRID_DEBUG) 10146 fprintf (stdout,
"io_restore_volume_decompress_read: block size error - data corrupted\n");
10148 goto exit_on_error;
10150 else if (zip_page->
buf_len < nbytes)
10164 goto exit_on_error;
10169 LZ4_decompress_safe ((
const char *) zip_page->
buf, (
char *) session_p->
dbfile.
area, zip_page->
buf_len,
10171 if (unzip_len < 0 || unzip_len != nbytes)
10175 #if defined(CUBRID_DEBUG) 10176 fprintf (stdout,
"io_restore_volume_decompress_read: compressed data violation\n");
10178 goto exit_on_error;
10189 goto exit_on_error;
10201 goto exit_on_error;
10222 #if !defined(CS_MODE) 10237 bool is_remember_pages)
10239 int next_page_id = 0;
10240 INT64 total_nbytes = 0;
10242 int from_npages, npages;
10244 int check_ratio = 0, check_npages = 0;
10249 bool incremental_includes_volume_header =
false;
10260 #if defined(CUBRID_DEBUG) 10261 if (io_Bkuptrace_debug > 0)
10266 fprintf (stdout,
"\n");
10274 check_npages = (int) (((
float) npages / 25.0) * check_ratio);
10287 IO_PAGESIZE, 0,
false);
10301 bitmap = (is_remember_pages) ? page_bitmap :
NULL;
10338 #if defined(CUBRID_DEBUG) 10339 fprintf (stdout,
"fileio_restore_volume: %d\t%d,\t%d\n",
10368 incremental_includes_volume_header =
true;
10373 for (i = 0; i < unit && next_page_id < npages; i++)
10384 if (session_p->
verbose_fp && npages >= 25 && next_page_id >= check_npages)
10388 check_npages = (int) (((
float) npages / 25.0) * check_ratio);
10398 #if defined(CUBRID_DEBUG) 10399 if (io_Bkuptrace_debug >= 2 && bitmap)
10402 (void) fprintf (stdout,
"\n\n");
10430 prev_vdes =
fileio_mount (thread_p,
NULL, prev_vol_label_p, prev_volid,
false,
false);
10448 strncpy (prev_vol_label_p, to_vol_label_p, PATH_MAX);
10458 if (next_page_id < 25)
10460 fprintf (session_p->
verbose_fp,
"######################### | done\n");
10464 while (check_ratio <= 25)
10469 fprintf (session_p->
verbose_fp,
" | done\n");
10512 #if !defined (CS_MODE) 10516 if (page_bitmap ==
NULL)
10526 #if !defined(NDEBUG) 10579 #if defined(CUBRID_DEBUG) 10580 fprintf (stdout,
"fileio_skip_restore_volume: %d\t%d,\t%d\n",
10627 char *fail_prompt_p =
NULL;
10628 char *reprompt_p =
NULL;
10629 char *full_message_p =
NULL;
10648 ||
asprintf (&full_message_p,
"%s%s%s%s%s", ptr1, ptr2, ptr3, ptr4, ptr1) < 0)
10671 strcpy (to_vol_name_p, &new_vol_name[1]);
10701 free (fail_prompt_p);
10709 if (full_message_p)
10711 free (full_message_p);
10722 static const char *
10728 return (
"FULL LEVEL");
10731 return (
"INCREMENTAL LEVEL 1");
10734 return (
"INCREMENTAL LEVEL 2");
10737 return (
"UNKNOWN");
10749 switch (zip_method)
10764 return (
"UNKNOWN");
10782 return (
"ZIP LEVEL 1");
10785 return (
"UNKNOWN");
10805 const char *db_nopath_name_p =
NULL;
10806 char copy_name[PATH_MAX];
10807 char orig_name[PATH_MAX];
10808 char *message_area_p =
NULL;
10823 is_new_user =
true;
10844 free (message_area_p);
10859 strcpy (copy_name, orig_name);
10866 strcpy (copy_name, session_p->
bkup.
name);
10871 strcpy (copy_name, session_p->
bkup.
name);
10872 strcpy (orig_name, session_p->
bkup.
name);
10897 strcpy (session_p->
bkup.
name, copy_name);
10916 free (message_area_p);
10920 is_new_user =
true;
10922 strcpy (copy_name, orig_name);
10958 char real_path_buf[PATH_MAX];
10961 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
10969 if (node_p ==
NULL)
10974 if (stat (name_p, &stbuf) != -1)
10976 if (S_ISREG (stbuf.st_mode))
10979 if (realpath (name_p, real_path_buf) !=
NULL)
10981 name_p = real_path_buf;
10986 strncpy (node_p->
bkvol_name, name_p, PATH_MAX - 1);
10990 if ((*data_p).anchors[level] ==
NULL)
10993 (*data_p).anchors[level] = node_p;
10998 back_p = (*data_p).anchors[level];
11006 back_p = back_p->
link;
11015 back_p->
link = node_p;
11036 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11044 for (node_p = (*data_p).anchors[level]; node_p !=
NULL; node_p = node_p->
link)
11069 char vol_name[PATH_MAX];
11071 char format_string[32];
11085 sprintf (format_string,
"%%d %%d %%%ds", PATH_MAX - 1);
11086 while ((n = fscanf (fp, format_string, &tmp, &unit_num, vol_name)) > 0)
11123 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11124 for (node_p = (*data_p).anchors[level]; node_p !=
NULL; node_p = node_p->
link)
11147 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11148 if ((*data_p).initialized)
11151 (*data_p).initialized =
false;
11168 #if defined(CUBRID_DEBUG) 11169 const char *env_value;
11172 if (io_Bkuptrace_debug < 0)
11176 io_Bkuptrace_debug = (env_value ==
NULL ? 0 : atoi (env_value));
11180 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11181 if (!(*data_p).initialized)
11184 memset ((*data_p).anchors, 0, sizeof ((*data_p).anchors));
11185 (*data_p).initialized =
true;
11202 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11203 if (!(*data_p).initialized)
11209 if ((*data_p).free !=
NULL)
11211 temp_entry_p = (*data_p).free;
11212 (*data_p).free = temp_entry_p->
link;
11219 if (temp_entry_p !=
NULL)
11229 return temp_entry_p;
11251 data_p = &(fileio_Backup_vol_info_data[which_bkvinf]);
11260 while ((*data_p).anchors[i] !=
NULL)
11262 next_p = (*data_p).anchors[
i]->
link;
11270 (*data_p).anchors[
i]->link = (*data_p).free;
11271 (*data_p).free = (*data_p).anchors[
i];
11273 (*data_p).anchors[
i] = next_p;
11280 while ((*data_p).free)
11282 next_p = (*data_p).free->
link;
11284 (*data_p).free = next_p;
11305 char *response_p,
const char *failure_prompt_p,
int range_low,
int range_high,
11306 const char *secondary_prompt_p,
int reprompt_value)
11308 #if defined(SERVER_MODE) 11309 char *remote_data_p =
NULL;
11310 char *remote_answer_p =
NULL;
11317 secondary_prompt_p, reprompt_value) !=
NO_ERROR)
11340 if (response_p && data_size > 0)
11344 if (remote_answer_p !=
NULL)
11346 memcpy (response_p, remote_answer_p,
intl_mbs_len (remote_answer_p) + 1);
11356 char *user_response_p = new_vol_name;
11357 const char *display_string_p;
11358 char line_buf[PATH_MAX * 2];
11359 int pr_status, pr_len;
11362 bool is_retry_in =
true;
11364 char format_string[32];
11369 display_string_p = prompt_p;
11370 memset (new_vol_name, 0,
sizeof (new_vol_name));
11374 while (is_retry_in)
11377 fprintf (stdout, display_string_p);
11381 is_retry_in =
false;
11386 if ((fgets (line_buf, PATH_MAX, stdin) !=
NULL)
11387 && ((rc = sscanf (line_buf, format_string, user_response_p)) > 0))
11395 result =
parse_int (&x, user_response_p, 10);
11396 if (result != 0 || x < range_low || x > range_high)
11398 fprintf (stdout, failure_prompt_p);
11399 is_retry_in =
true;
11409 if (
char_tolower (*user_response_p) ==
'y' || *user_response_p ==
'1' 11414 strcpy (user_response_p,
"1");
11420 strcpy (user_response_p,
"0");
11432 result =
parse_int (&x, user_response_p, 10);
11433 if (result != 0 || x < range_low || x > range_high)
11435 fprintf (stdout, failure_prompt_p);
11436 is_retry_in =
true;
11438 else if (x == reprompt_value)
11441 display_string_p = secondary_prompt_p;
11442 is_retry_in =
true;
11464 is_retry_in =
true;
11486 memcpy (response_p, new_vol_name,
sizeof (new_vol_name));
11490 return (pr_status);
11494 #if !defined(WINDOWS) 11510 if (symlink (src_p, dest_p) == -1)
11534 lock.l_type = type;
11535 lock.l_start = offset;
11536 lock.l_whence = whence;
11538 return fcntl (fd, cmd, &lock);
11542 #if defined(SERVER_MODE) 11548 fileio_os_sysconf (
void)
11552 #if defined(_SC_NPROCESSORS_ONLN) 11553 nprocs = sysconf (_SC_NPROCESSORS_ONLN);
11554 #elif defined(_SC_NPROC_ONLN) 11555 nprocs = sysconf (_SC_NPROC_ONLN);
11556 #elif defined(_SC_CRAY_NCPU) 11557 nprocs = sysconf (_SC_CRAY_NCPU);
11558 #elif defined(WINDOWS) 11560 SYSTEM_INFO sysinfo;
11562 GetSystemInfo (&sysinfo);
11563 nprocs = sysinfo.dwNumberOfProcessors;
11568 return (nprocs > 1) ? (int) nprocs : 1;
11618 int page_bitmap_size;
11621 if (page_bitmap ==
NULL)
11630 page_bitmap->
vol_id = vol_id;
11631 page_bitmap->
size = page_bitmap_size;
11632 page_bitmap->
bitmap = (
unsigned char *) malloc (page_bitmap_size);
11640 memset (page_bitmap->
bitmap, 0x0, page_bitmap_size);
11642 return page_bitmap;
11657 if (page_bitmap_list->
head ==
NULL)
11664 page_bitmap = page_bitmap_list->
head;
11666 while (page_bitmap !=
NULL)
11668 if (page_bitmap->
vol_id == vol_id)
11670 return page_bitmap;
11672 page_bitmap = page_bitmap->
next;
11687 #if !defined(NDEBUG) 11694 #if !defined(NDEBUG) 11696 bitmap = page_bitmap_list->
head;
11697 while (bitmap !=
NULL)
11700 bitmap = bitmap->
next;
11704 if (page_bitmap_list->
head ==
NULL)
11708 page_bitmap_list->
head = page_bitmap;
11709 page_bitmap_list->
tail = page_bitmap;
11715 page_bitmap_list->
tail->
next = page_bitmap;
11716 page_bitmap_list->
tail = page_bitmap;
11733 page_bitmap = page_bitmap_list->
head;
11735 while (page_bitmap !=
NULL)
11737 page_bitmap_next = page_bitmap->
next;
11739 page_bitmap->
vol_id = 0;
11740 page_bitmap->
size = 0;
11744 page_bitmap = page_bitmap_next;
11760 assert ((page_bitmap->
size - 1) >= (page_id / 8));
11762 page_bitmap->
bitmap[page_id / 8] |= 1 << (page_id % 8);
11777 assert ((page_bitmap->
size - 1) >= (page_id / 8));
11779 is_set = page_bitmap->
bitmap[page_id / 8] & (1 << (page_id % 8)) ?
true :
false;
11797 if (out_fp ==
NULL)
11802 fprintf (out_fp,
"BITMAP_ID = %d, BITMAP_SIZE = %d\n", page_bitmap->
vol_id, page_bitmap->
size);
11804 for (i = 0; i < page_bitmap->
size; i++)
11808 fprintf (out_fp,
"%#08X: ", i);
11812 fprintf (out_fp,
"%02X ", page_bitmap->
bitmap[i]);
11815 if ((i % 32) == 31)
11817 fprintf (out_fp,
"\n");
11820 fprintf (out_fp,
"\n");
11844 bool is_formatted =
false;
11847 if (ref_page ==
NULL)
11856 if (memcmp (io_page, ref_page,
IO_PAGESIZE) == 0)
11858 is_formatted =
true;
11862 return is_formatted;
#define MSGCAT_FILEIO_BKUP_PREV_BKVOL
FILEIO_BACKUP_SESSION * fileio_start_backup(THREAD_ENTRY *thread_p, const char *db_full_name_p, INT64 *db_creation_time_p, FILEIO_BACKUP_LEVEL backup_level, LOG_LSA *backup_start_lsa_p, LOG_LSA *backup_checkpoint_lsa_p, FILEIO_BACKUP_RECORD_INFO *all_levels_info_p, FILEIO_BACKUP_SESSION *session_p, FILEIO_ZIP_METHOD zip_method, FILEIO_ZIP_LEVEL zip_level)
void * fileio_writev(THREAD_ENTRY *thread_p, int vol_fd, void **io_page_array, PAGEID start_page_id, DKNPAGES npages, size_t page_size)
void fileio_make_volume_ext_name(char *vol_ext_full_name_p, const char *ext_path_p, const char *ext_name_p, VOLID vol_id)
#define ER_IO_DISMOUNT_FAIL
#define ER_IO_LZ4_DECOMPRESS_FAIL
FILEIO_ZIP_INFO * zip_info
int os_rename_file(const char *src_path, const char *dest_path)
static FILEIO_RELOCATION_VOLUME fileio_find_restore_volume(THREAD_ENTRY *thread_p, const char *dbname, char *to_volname, int unit_num, FILEIO_BACKUP_LEVEL level, int reason)
static int fileio_synchronize_bg_archive_volume(THREAD_ENTRY *thread_p)
#define FILEIO_MAX_SUFFIX_LENGTH
#define ER_FAILED_ASSERTION
const VOLID LOG_DBLOG_INFO_VOLID
#define FILEIO_MAX_WAIT_DBTXT
cubthread::entry * thread_get_thread_entry_info(void)
void fileio_unformat_and_rename(THREAD_ENTRY *thread_p, const char *vol_label_p, const char *new_label_p)
int intl_mbs_len(const char *mbs)
pthread_mutex_t token_mutex
static char * fileio_check_file_exist(char *name_p, char *new_guess_path_p, int check_size, int *max_name_size_p)
static int fileio_cache(VOLID volid, const char *vlabel, int vdes, FILEIO_LOCKF_TYPE lockf_type)
static int fileio_get_next_backup_volume(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, bool user_new)
static int fileio_initialize_volume_info_cache(void)
#define MSGCAT_FILEIO_DB_MISMATCH
#define FILEIO_VOLLOCK_SUFFIX
void * fileio_write_or_add_to_dwb(THREAD_ENTRY *thread_p, int vol_fd, FILEIO_PAGE *io_page_p, PAGEID page_id, size_t page_size)
bool LOG_CS_OWN(THREAD_ENTRY *thread_p)
float rel_disk_compatible(void)
#define ER_IO_LZ4_COMPRESS_FAIL
const char * fileio_get_zip_level_string(FILEIO_ZIP_LEVEL zip_level)
static int fileio_decompress_restore_volume(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, int nbytes)
FILEIO_LOCKF_TYPE lockf_type
#define ER_IO_CANNOT_GET_PERMISSION
FILEIO_BACKUP_INFO_ENTRY * link
static int fileio_get_lock(int fd, const char *vlabel)
static int fileio_write_backup_header(FILEIO_BACKUP_SESSION *session)
#define FILEIO_SUFFIX_TMP_LOGARCHIVE
static FILEIO_SYSTEM_VOLUME_INFO * fileio_find_system_volume(THREAD_ENTRY *thread_p, SYS_VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
#define MSGCAT_FILEIO_BKUP_HDR_LEVEL
void LSA_COPY(log_lsa *plsa1, const log_lsa *plsa2)
int fileio_reset_volume(THREAD_ENTRY *thread_p, int vol_fd, const char *vlabel, DKNPAGES npages, const LOG_LSA *reset_lsa_p)
const char * fileio_get_zip_method_string(FILEIO_ZIP_METHOD zip_method)
static bool fileio_is_volume_id_equal(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
#define FILEIO_FIRST_BACKUP_VOL_INFO
#define FILEIO_CHECK_RESTORE_PAGE_ID(area, pagesz)
#define FILEIO_GET_FILE_SIZE(pagesize, npages)
void * fileio_read(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, PAGEID page_id, size_t page_size)
static int fileio_increase_flushed_page_count(int npages)
int parse_int(int *ret_p, const char *str_p, int base)
int fileio_get_next_restore_file(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p, char *file_name_p, VOLID *vol_id_p)
FILEIO_REMOTE_PROMPT_TYPE
#define ER_NET_DATA_TRUNCATED
void fileio_dismount_without_fsync(THREAD_ENTRY *thread_p, int vol_fd)
static FILEIO_VOLUME_INFO * fileio_reverse_traverse_temporary_volume(THREAD_ENTRY *thread_p, VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
#define ER_IO_FORMAT_OUT_OF_SPACE
#define FILEIO_DISK_PROTECTION_MODE
static bool fileio_page_bitmap_is_set(FILEIO_RESTORE_PAGE_BITMAP *page_bitmap, int page_id)
static FILEIO_BACKUP_SESSION * fileio_continue_restore(THREAD_ENTRY *thread_p, const char *db_fullname, INT64 db_creation, FILEIO_BACKUP_SESSION *session, bool first_time, bool authenticate, INT64 match_bkupcreation)
#define FILEIO_DISK_FORMAT_MODE
void fileio_make_keys_name_given_path(char *keys_name_p, const char *keys_path_p, const char *db_name_p)
VOLID fileio_find_volume_id_with_label(THREAD_ENTRY *thread_p, const char *vol_label_p)
VOLID fileio_find_next_perm_volume(THREAD_ENTRY *thread_p, VOLID volid)
#define ER_IO_GET_LOCK_FAIL
int fileio_finish_restore(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p)
bool dwb_is_created(void)
FILEIO_BACKUP_SESSION * fileio_start_restore(THREAD_ENTRY *thread_p, const char *db_full_name_p, char *backup_source_p, INT64 match_db_creation_time, PGLENGTH *db_io_page_size_p, float *db_compatibility_p, FILEIO_BACKUP_SESSION *session_p, FILEIO_BACKUP_LEVEL level, bool is_authenticate, INT64 match_backup_creation_time, const char *restore_verbose_file_path, bool is_new_vol_path)
int fileio_skip_restore_volume(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p)
static FILEIO_LOCKF_TYPE fileio_get_lockf_type(int vdes)
bool fileio_is_volume_exist_and_file(const char *vol_label_p)
#define MSGCAT_FILEIO_RESTORE_FIND_REASON
FILEIO_LOCKF_TYPE fileio_lock_la_log_path(const char *db_full_name_p, const char *lock_path_p, int vol_fd, int *last_deleted_arv_num)
void fileio_unformat(THREAD_ENTRY *thread_p, const char *vol_label_p)
#define MSGCAT_FILEIO_LEVEL_MISMATCH
#define FILEIO_VOLINFO_INCREMENT
int fileio_restore_volume(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p, char *to_vol_label_p, char *verbose_to_vol_label_p, char *prev_vol_label_p, FILEIO_RESTORE_PAGE_BITMAP *page_bitmap, bool is_remember_pages)
int disk_set_link(THREAD_ENTRY *thread_p, INT16 volid, INT16 next_volid, const char *next_volext_fullname, bool logchange, DISK_FLUSH_TYPE flush)
static ssize_t fileio_read_backup(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, int pageid)
#define ER_IO_CANNOT_OPEN_VERBOSE_FILE
#define fileio_unlock_file(fd, offset, whence, len)
VOLID fileio_find_previous_temp_volume(THREAD_ENTRY *thread_p, VOLID volid)
#define MSGCAT_FILEIO_BKUP_FIND_REASON
STATIC_INLINE void fileio_init_lsa_of_page(FILEIO_PAGE *io_page, PGLENGTH page_size)
#define ASSERT_ERROR_AND_SET(error_code)
static bool fileio_is_system_volume_descriptor_equal(THREAD_ENTRY *thread_p, FILEIO_SYSTEM_VOLUME_INFO *sys_vol_info_p, APPLY_ARG *arg)
void thread_sleep(double millisec)
#define assert_release(e)
#define MSGCAT_LOG_BACKUPINFO_NEEDED
#define ER_CSS_PTHREAD_COND_DESTROY
#define FILEIO_CHECK_FOR_INTERRUPT_INTERVAL
#define ER_IO_RESTORE_READ_ERROR
static int fileio_make_error_message(THREAD_ENTRY *thread_p, char *error_message_p)
#define pthread_mutex_unlock(a)
void fileio_flush_control_finalize(void)
#define ER_IO_CANNOT_CHANGE_PERMISSION
#define ER_CSS_PTHREAD_MUTEX_LOCK
#define ER_IO_MOUNT_LOCKED
const VOLID LOG_DBLOG_ACTIVE_VOLID
static int fileio_flush_control_get_token(THREAD_ENTRY *thread_p, int ntoken)
static FLUSH_STATS fc_Stats
static TOKEN_BUCKET * fc_Token_bucket
#define FILEIO_BACKUP_MINIMUM_NUM_PAGES_FULL_LEVEL
void fileio_make_log_archive_temp_name(char *log_archive_temp_name_p, const char *log_path_p, const char *db_name_p)
struct timeval TSCTIMEVAL
static int fileio_initialize_backup_thread(FILEIO_BACKUP_SESSION *session_p, int num_threads)
bool fileio_is_volume_exist(const char *vol_label_p)
void tsc_elapsed_time_usec(TSCTIMEVAL *tv, TSC_TICKS end_tick, TSC_TICKS start_tick)
const VOLID LOG_MAX_DBVOLID
char * or_unpack_string_nocopy(char *ptr, char **string)
void fileio_remove_all_backup(THREAD_ENTRY *thread_p, int start_level)
static ssize_t fileio_os_write(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, size_t count, off_t offset)
static bool fileio_dismount_volume(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *ignore_arg)
#define FILEIO_BACKUP_NO_ZIP_HEADER_VERSION
#define FILEIO_CHECK_AND_INITIALIZE_VOLUME_HEADER_CACHE(rtn)
#define ER_IO_FORMAT_BAD_NPAGES
#define MSGCAT_FILEIO_MAGIC_MISMATCH
bool fileio_is_temp_volume(THREAD_ENTRY *thread_p, VOLID volid)
int pgbuf_flush_control_from_dirty_ratio(void)
STATIC_INLINE void fileio_reset_page_lsa(FILEIO_PAGE *io_page, PGLENGTH page_size)
DKNSECTS fileio_get_number_of_partition_free_sectors(const char *path_p)
const VOLID LOG_DBLOG_BKUPINFO_VOLID
#define MSGCAT_FILEIO_BKUP_HDR_LX_LSA
bool logtb_get_check_interrupt(THREAD_ENTRY *thread_p)
#define FILEIO_BACKUP_FILE_HEADER_PAGE_SIZE
FILEIO_RESTORE_PAGE_BITMAP * head
int fileio_clear_backup_info_level(int level, bool is_dealloc, int which_bkvinf)
#define FILEIO_SUFFIX_LOGINFO
bool LSA_LT(const log_lsa *plsa1, const log_lsa *plsa2)
#define MSGCAT_FILEIO_BACKUP_VINF_ERROR
#define er_log_debug(...)
FILEIO_BACKUP_INFO_ENTRY * free
#define ER_BO_CANNOT_CREATE_LINK
char * getuserid(char *string, int size)
const VOLID LOG_DBCOPY_VOLID
static int fileio_read_restore_header(FILEIO_BACKUP_SESSION *session)
static VOLID fileio_get_volume_id(int vdes)
char * fileio_get_volume_label_by_fd(int vol_fd, bool is_peek)
static FILEIO_LOCKF_TYPE fileio_lock(const char *db_fullname, const char *vlabel, int vdes, bool dowait)
void fileio_make_temp_log_files_from_backup(char *temp_log_name, VOLID to_volid, FILEIO_BACKUP_LEVEL level, const char *base_log_name)
FILEIO_BACKUP_HEADER * bkuphdr
#define FILEIO_PAGE_FLUSH_GROW_RATE
char * fileio_get_directory_path(char *path_p, const char *full_name_p)
static void fileio_make_volume_lock_name(char *vol_lockname, const char *vol_fullname)
const char * fileio_rename(VOLID vol_id, const char *old_label_p, const char *new_label_p)
#define FILEIO_BACKUP_VOL_CONT_PAGE_ID
#define FILEIO_INITIAL_BACKUP_UNITS
int fileio_mount(THREAD_ENTRY *thread_p, const char *db_full_name_p, const char *vol_label_p, VOLID vol_id, int lock_wait, bool is_do_sync)
#define ER_LOG_DBBACKUP_FAIL
void * fileio_read_pages(THREAD_ENTRY *thread_p, int vol_fd, char *io_pages_p, PAGEID page_id, int num_pages, size_t page_size)
int fileio_read_backup_info_entries(FILE *fp, int which_bkvinf)
#define FILEIO_USER_NAME_SIZE
#define MSGCAT_FILEIO_INCORRECT_BKVOLUME
void fileio_page_bitmap_list_init(FILEIO_RESTORE_PAGE_BITMAP_LIST *page_bitmap_list)
#define MSGCAT_FILEIO_BACKUP_LABEL_INFO
struct fileio_node * next
#define ER_IO_WRITE_OUT_OF_SPACE
FILEIO_BACKUP_PAGE * area
#define ER_BO_CANNOT_CREATE_VOL
int fileio_symlink(const char *src_p, const char *dest_p, int overwrite)
#define FILEIO_BACKUP_START_PAGE_ID
static int fileio_initialize_backup_info(int which_bkvinf)
static int fileio_flush_control_get_desired_rate(TOKEN_BUCKET *tb)
#define MSGCAT_FILEIO_BKUP_HDR_BKUP_PAGESIZE
UINT64 prm_get_bigint_value(PARAM_ID prm_id)
int disk_set_creation(THREAD_ENTRY *thread_p, INT16 volid, const char *new_vol_fullname, const INT64 *new_dbcreation, const LOG_LSA *new_chkptlsa, bool logchange, DISK_FLUSH_TYPE flush)
void fileio_page_bitmap_list_add(FILEIO_RESTORE_PAGE_BITMAP_LIST *page_bitmap_list, FILEIO_RESTORE_PAGE_BITMAP *page_bitmap)
#define ER_IO_FORMAT_FAIL
#define VPID_SET(vpid_ptr, volid_value, pageid_value)
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int fileio_find_volume_descriptor_with_label(const char *vol_label_p)
static void fileio_check_lockby_file(char *name_info_lock_p)
void css_push_external_task(CSS_CONN_ENTRY *conn, cubthread::entry_task *task)
int fileio_get_volume_max_suffix(void)
#define ER_IO_RELEASE_LOCK_FAIL
static bool fileio_is_terminated_process(int pid)
char * fileio_get_volume_label(VOLID vol_id, bool is_peek)
static ssize_t fileio_os_read(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, size_t count, off_t offset)
static bool fileio_is_volume_label_equal(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
const VOLID LOG_DBLOG_ARCHIVE_VOLID
int fileio_add_volume_to_backup_info(const char *name_p, FILEIO_BACKUP_LEVEL level, int unit_num, int which_bkvinf)
const char * fileio_get_base_file_name(const char *full_name_p)
static char * fileio_ctime(INT64 *clock, char *buf)
const VOLID LOG_DBFIRST_VOLID
#define FILEIO_BACKUP_HEADER_IO_SIZE
#define FILEIO_VOLEXT_PREFIX
int prm_get_integer_value(PARAM_ID prm_id)
#define FILEIO_BACKUP_MINIMUM_NUM_PAGES
void fileio_make_volume_temp_name(char *vol_tmp_full_name_p, const char *tmp_path_p, const char *tmp_name_p, VOLID vol_id)
#define MSGCAT_FILEIO_BKUP_HDR_TIME
std::chrono::high_resolution_clock clock
void fileio_close(int vol_fd)
#define CUBRID_MAGIC_MAX_LENGTH
#define ER_OUT_OF_VIRTUAL_MEMORY
int fileio_get_number_of_partition_free_pages(const char *path_p, size_t page_size)
void fileio_page_bitmap_list_destroy(FILEIO_RESTORE_PAGE_BITMAP_LIST *page_bitmap_list)
void fileio_abort_backup(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p, bool does_unformat_bk)
#define MSGCAT_FILEIO_BKUP_FILE
static char * fileio_check_file_is_same(char *name_p, char *new_guess_path_p, int check_size, int *max_name_size_p, struct stat *buf)
#define MSGCAT_FILEIO_REST_RELO_NEEDED
#define FILEIO_SUFFIX_BACKUP_VOLINFO
#define DB_MAX_IDENTIFIER_LENGTH
static int fileio_write_backup(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, ssize_t towrite_nbytes)
FILEIO_RESTORE_PAGE_BITMAP * fileio_page_bitmap_list_find(FILEIO_RESTORE_PAGE_BITMAP_LIST *page_bitmap_list, int vol_id)
#define CUBRID_MAGIC_DATABASE_BACKUP
#define CUBRID_MAGIC_DATABASE_BACKUP_OLD
static enum scanner_mode mode
#define FILEIO_RESTORE_DBVOLS_IO_PAGE_SIZE(sess)
static void fileio_unlock(const char *vlabel, int vdes, FILEIO_LOCKF_TYPE lockf_type)
#define MSGCAT_FILEIO_NEWLOCATION
bool pgbuf_is_log_check_for_interrupts(THREAD_ENTRY *thread_p)
#define pthread_mutex_lock(a)
static void fileio_write_backup_end_time_to_last_page(FILEIO_BACKUP_SESSION *session_p, INT64 end_time)
static FILEIO_VOLUME_INFO * fileio_traverse_permanent_volume(THREAD_ENTRY *thread_p, VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
unsigned int num_log_pages
#define MSGCAT_FILEIO_BACKUP_TIME_MISMATCH
int asprintf(char **ptr, const char *format,...)
static FILEIO_NODE * fileio_delete_queue_head(FILEIO_QUEUE *qp)
int cub_dirname_r(const char *path, char *pathbuf, size_t buflen)
void fileio_dismount(THREAD_ENTRY *thread_p, int vol_fd)
bool rel_is_log_compatible(const char *writer_rel_str, const char *reader_rel_str)
static int fileio_Flushed_page_count
const char * rel_name(void)
static pthread_mutex_t fileio_Flushed_page_counter_mutex
int fileio_synchronize_all(THREAD_ENTRY *thread_p, bool is_include)
#define MSGCAT_FILEIO_BKUP_NEXT_BKVOL
void logpb_debug_check_log_page(THREAD_ENTRY *thread_p, void *log_pgptr_ptr)
FILEIO_BACKUP_SESSION * fileio_finish_backup(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p)
void fileio_dismount_all(THREAD_ENTRY *thread_p)
bool(* VOLINFO_APPLY_FN)(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
#define FILEIO_SUFFIX_KEYS
#define pthread_mutex_destroy(a)
#define FILEIO_VOLTMP_PREFIX
#define FILEIO_VOLINFO_SUFFIX
FILEIO_RESTORE_PAGE_BITMAP * tail
#define strncpy_bufsize(buf, str)
static int fileio_flush_backup(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session)
#define FILEIO_BACKUP_PAGE_OVERHEAD
const char * er_msg(void)
static int fileio_compress_backup_node(FILEIO_NODE *node, FILEIO_BACKUP_HEADER *backup_hdr)
void fileio_make_removed_log_archive_name(char *log_archive_name_p, const char *log_path_p, const char *db_name_p)
static FILEIO_SYSTEM_VOLUME_HEADER fileio_Sys_vol_info_header
union fileio_apply_function_arg APPLY_ARG
void tsc_getticks(TSC_TICKS *tck)
STATIC_INLINE void fileio_set_page_lsa(FILEIO_PAGE *io_page, const LOG_LSA *lsa, PGLENGTH page_size)
int xio_send_user_prompt_to_client(THREAD_ENTRY *thread_p, FILEIO_REMOTE_PROMPT_TYPE prompt_id, const char *prompt, const char *failure_prompt, int range_low, int range_high, const char *secondary_prompt, int reprompt_value)
#define FILEIO_MAX_USER_RESPONSE_SIZE
char current_path[PATH_MAX]
DKNPAGES xdisk_get_total_numpages(THREAD_ENTRY *thread_p, VOLID volid)
bool LSA_ISNULL(const log_lsa *lsa_ptr)
int util_compare_filepath(const char *file1, const char *file2)
static FILEIO_VOLUME_INFO * fileio_reverse_traverse_permanent_volume(THREAD_ENTRY *thread_p, VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
void fileio_finalize_backup_info(int which_bkvinf)
#define FILEIO_SET_BACKUP_PAGE_ID(area, pageid, psize)
static int fileio_release_lock(int fd)
static void fileio_finalize_backup_thread(FILEIO_BACKUP_SESSION *session_p, FILEIO_ZIP_METHOD zip_method)
int fileio_set_permission(const char *vol_label_p)
static int fileio_write_backup_node(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, FILEIO_NODE *node, FILEIO_BACKUP_HEADER *backup_hdr)
#define VOL_MAX_NPAGES(page_size)
static int fileio_write_backup_end_time_to_header(FILEIO_BACKUP_SESSION *session_p, INT64 end_time)
#define FILEIO_BACKUP_FILE_END_PAGE_ID
char * or_unpack_int(char *ptr, int *number)
FILEIO_BACKUP_LEVEL level
#define FILEIO_BACKUP_FILE_START_PAGE_ID
#define db_private_free(thrd, ptr)
pthread_cond_t waiter_cond
#define db_private_alloc(thrd, size)
CSS_CONN_ENTRY * css_get_current_conn_entry(void)
#define FILEIO_PAGE_FLUSH_DROP_RATE
#define CEIL_PTVDIV(dividend, divisor)
const VOLID LOG_DBDWB_VOLID
void er_set_with_oserror(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
int count(int &result, const cub_regex_object ®, const std::string &src, const int position, const INTL_CODESET codeset)
void fileio_make_keys_name(char *keys_name_p, const char *db_full_name_p)
#define MSGCAT_CATALOG_CUBRID
static int fileio_read_restore(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session, int toread_nbytes)
void fileio_make_log_active_name(char *log_active_name_p, const char *log_path_p, const char *db_name_p)
#define ER_CSS_PTHREAD_MUTEX_DESTROY
#define MSGCAT_FILEIO_INPUT_RANGE_ERROR
void fileio_make_log_info_name(char *log_info_name_p, const char *log_path_p, const char *db_name_p)
FILEIO_LOCKF_TYPE lockf_type
#define ER_MNT_WAITING_THREAD
#define ER_IO_RESTORE_PAGEID_OUTOF_BOUNDS
#define FILEIO_SET_BACKUP_PAGE_ID_COPY(area, pageid, psize)
void fileio_make_log_archive_name(char *log_archive_name_p, const char *log_path_p, const char *db_name_p, int archive_number)
static bool fileio_is_system_volume_id_equal(THREAD_ENTRY *thread_p, FILEIO_SYSTEM_VOLUME_INFO *sys_vol_info_p, APPLY_ARG *arg)
void fileio_abort_restore(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p)
int xs_receive_data_from_client(THREAD_ENTRY *thread_p, char **area, int *datasize)
const char * envvar_get(const char *name)
static int fileio_allocate_and_initialize_volume_info(FILEIO_VOLUME_HEADER *header_p, int idx)
bool LOG_CS_OWN_WRITE_MODE(THREAD_ENTRY *thread_p)
static void error(const char *msg)
bool fileio_is_permanent_volume_descriptor(THREAD_ENTRY *thread_p, int vol_fd)
static FILEIO_BACKUP_SESSION * fileio_initialize_restore(THREAD_ENTRY *thread_p, const char *db_fullname, char *backup_src, FILEIO_BACKUP_SESSION *session, FILEIO_BACKUP_LEVEL level, const char *restore_verbose_file_path, bool newvolpath)
#define FILEIO_SUFFIX_LOGARCHIVE
#define ER_IO_NOT_A_BACKUP_OF_GIVEN_DATABASE
void * fileio_write(THREAD_ENTRY *thread_p, int vol_fd, void *io_page_p, PAGEID page_id, size_t page_size, FILEIO_WRITE_MODE write_mode)
FILEIO_BACKUP_DB_BUFFER dbfile
#define FILEIO_BACKUP_CURRENT_HEADER_VERSION
static int fileio_fill_hole_during_restore(THREAD_ENTRY *thread_p, int *next_pageid, int stop_pageid, FILEIO_BACKUP_SESSION *session, FILEIO_RESTORE_PAGE_BITMAP *page_bitmap)
#define FI_TEST(th, code, state)
STATIC_INLINE void perfmon_inc_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid) __attribute__((ALWAYS_INLINE))
FILEIO_RESTORE_PAGE_BITMAP * fileio_page_bitmap_create(int vol_id, int total_pages)
static bool fileio_is_volume_id_lt(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
unsigned int db_on_server
int fileio_get_max_name(const char *given_path_p, long int *file_name_max_p, long int *path_name_max_p)
#define ER_BO_DIRECTORY_DOESNOT_EXIST
#define LOG_FIND_THREAD_TRAN_INDEX(thrd)
#define FILEIO_BACKUP_END_PAGE_ID
int fileio_request_user_response(THREAD_ENTRY *thread_p, FILEIO_REMOTE_PROMPT_TYPE prompt_id, const char *prompt_p, char *response_p, const char *failure_prompt_p, int range_low, int range_high, const char *secondary_prompt_p, int reprompt_value)
#define fileio_lock_file_write(fd, offset, whence, len)
static FILEIO_VOLUME_INFO * fileio_traverse_temporary_volume(THREAD_ENTRY *thread_p, VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
#define ER_LOG_BKUP_INCOMPATIBLE
FILEIO_LOCKF_TYPE fileio_unlock_la_dbname(int *lockf_vdes, char *db_name, bool clear_owner)
int fileio_expand_to(THREAD_ENTRY *thread_p, VOLID vol_id, DKNPAGES size_npages, DB_VOLTYPE voltype)
void er_print_callstack(const char *file_name, const int line_no, const char *fmt,...)
bool(* SYS_VOLINFO_APPLY_FN)(THREAD_ENTRY *thread_p, FILEIO_SYSTEM_VOLUME_INFO *sys_vol_info_p, APPLY_ARG *arg)
const char * fileio_get_backup_info_volume_name(FILEIO_BACKUP_LEVEL level, int unit_num, int which_bkvinf)
#define ER_LOG_CANNOT_ACCESS_BACKUP
static int fileio_expand_permanent_volume_info(FILEIO_VOLUME_HEADER *header, int volid)
char * envvar_vardir_file(char *path, size_t size, const char *filename)
int fileio_synchronize(THREAD_ENTRY *thread_p, int vol_fd, const char *vlabel, FILEIO_SYNC_OPTION sync_dwb)
int fileio_list_restore(THREAD_ENTRY *thread_p, const char *db_full_name_p, char *backup_source_p, FILEIO_BACKUP_LEVEL level, bool is_new_vol_path)
DKNPAGES fileio_get_number_of_volume_pages(int vol_fd, size_t page_size)
#define DISK_VOLHEADER_PAGE
int fileio_get_backup_volume(THREAD_ENTRY *thread_p, const char *db_fullname, const char *logpath, const char *user_backuppath, int try_level, char *from_volbackup)
#define pthread_mutex_init(a, b)
#define FILEIO_MIN_FLUSH_PAGES_PER_SEC
static int fileio_min_temporary_volumes(int index, int num_temp_volums, int num_volinfo_array)
static int fileio_get_primitive_way_max(const char *path, long int *filename_max, long int *pathname_max)
static int fileio_create(THREAD_ENTRY *thread_p, const char *db_fullname, const char *vlabel, VOLID volid, bool dolock, bool dosync)
static FILEIO_SYSTEM_VOLUME_INFO * fileio_traverse_system_volume(THREAD_ENTRY *thread_p, SYS_VOLINFO_APPLY_FN apply_function, APPLY_ARG *arg)
#define MSGCAT_FILEIO_REST_RELO_OPTIONS
#define free_and_init(ptr)
#define LOG_ISRESTARTED()
static void fileio_decache(THREAD_ENTRY *thread_p, int vdes)
VOLID fileio_find_previous_perm_volume(THREAD_ENTRY *thread_p, VOLID volid)
#define ER_IO_NOT_A_BACKUP
char bkvol_name[PATH_MAX]
void LSA_SET_NULL(log_lsa *lsa_ptr)
#define ER_IO_BKUP_DATABASE_VOLUME_OR_FILE_EXPECTED
#define FILEIO_SECOND_BACKUP_VOL_INFO
int fileio_write_backup_info_entries(FILE *fp, int which_bkvinf)
#define FI_INSERTED(code)
void fileio_make_dwb_name(char *dwb_name_p, const char *dwb_path_p, const char *db_name_p)
static TOKEN_BUCKET fc_Token_bucket_s
int fileio_backup_volume(THREAD_ENTRY *thread_p, FILEIO_BACKUP_SESSION *session_p, const char *from_vol_label_p, VOLID from_vol_id, PAGEID last_page, bool is_only_updated_pages)
const VOLID LOG_DBLOG_BG_ARCHIVE_VOLID
static void * fileio_write_restore(THREAD_ENTRY *thread_p, FILEIO_RESTORE_PAGE_BITMAP *page_bitmap, int vdes, void *io_pgptr, VOLID vol_id, PAGEID page_id, FILEIO_BACKUP_LEVEL level)
FILEIO_LOCKF_TYPE fileio_lock_la_dbname(int *lockf_vdes, char *db_name, char *log_path)
void fileio_make_volume_ext_given_name(char *vol_ext_full_name_p, const char *ext_path_p, const char *ext_name_p)
#define MSGCAT_FILEIO_BKUP_HDR_DBINFO
static bool fileio_is_volume_descriptor_equal(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
FILEIO_THREAD_INFO read_thread_info
#define FILEIO_GET_BACKUP_PAGE_ID(area)
bool prm_get_bool_value(PARAM_ID prm_id)
#define ER_CSS_PTHREAD_MUTEX_UNLOCK
#define MSGCAT_FILEIO_BKUP_HDR_INC_ACTIVELOG
int intl_mbs_casecmp(const char *mbs1, const char *mbs2)
#define MSGCAT_LOG_NEWLOCATION
void fileio_page_hexa_dump(const char *src_data, int length)
static void fileio_page_bitmap_dump(FILE *out_fp, const FILEIO_RESTORE_PAGE_BITMAP *page_bitmap)
static void fileio_read_backup_end_time_from_last_page(FILEIO_BACKUP_SESSION *session_p)
FILEIO_BACKUP_SESSION * fileio_initialize_backup(const char *db_full_name_p, const char *backup_destination_p, FILEIO_BACKUP_SESSION *session_p, FILEIO_BACKUP_LEVEL level, const char *verbose_file_path, int num_threads, int sleep_msecs)
int fileio_format(THREAD_ENTRY *thread_p, const char *db_full_name_p, const char *vol_label_p, VOLID vol_id, DKNPAGES npages, bool is_sweep_clean, bool is_do_lock, bool is_do_sync, size_t page_size, int kbytes_to_be_written_per_sec, bool reuse_file)
static int fileio_expand_temporary_volume_info(FILEIO_VOLUME_HEADER *header, int volid)
struct fileio_node * prev
int dwb_flush_force(THREAD_ENTRY *thread_p, bool *all_sync)
char loc_db_fullname[PATH_MAX]
char * msgcat_message(int cat_id, int set_id, int msg_id)
static ssize_t pwrite_with_injected_fault(THREAD_ENTRY *thread_p, int fd, const void *buf, size_t count, off_t offset)
void fileio_make_backup_volume_info_name(char *backup_volinfo_name_p, const char *backup_info_path_p, const char *db_name_p)
#define MSGCAT_FILEIO_BKUP_HDR
static const char * fileio_get_backup_level_string(FILEIO_BACKUP_LEVEL level)
static FILEIO_NODE * fileio_allocate_node(FILEIO_QUEUE *qp, FILEIO_BACKUP_HEADER *backup_hdr)
FILEIO_BACKUP_PAGE * area
void fileio_make_backup_name(char *backup_name_p, const char *no_path_vol_name_p, const char *backup_path_p, FILEIO_BACKUP_LEVEL level, int unit_num)
static int fileio_create_backup_volume(THREAD_ENTRY *thread_p, const char *db_fullname, const char *vlabel, VOLID volid, bool dolock, bool dosync, int atleast_pages)
static bool fileio_synchronize_volume(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
void * fileio_initialize_pages(THREAD_ENTRY *thread_p, int vol_fd, FILEIO_PAGE *io_page_p, DKNPAGES start_pageid, DKNPAGES npages, size_t page_size, int kbytes_to_be_written_per_sec)
void * fileio_write_pages(THREAD_ENTRY *thread_p, int vol_fd, char *io_pages_p, PAGEID page_id, int num_pages, size_t page_size, FILEIO_WRITE_MODE write_mode)
#define FILEIO_SUFFIX_LOGACTIVE
void fileio_initialize_res(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page, PGLENGTH page_size)
STATIC_INLINE void perfmon_add_stat(THREAD_ENTRY *thread_p, PERF_STAT_ID psid, UINT64 amount) __attribute__((ALWAYS_INLINE))
char * strdup(const char *str)
#define FILEIO_PATH_SEPARATOR(path)
STATIC_INLINE int fileio_is_page_sane(FILEIO_PAGE *io_page, PGLENGTH page_size)
FILEIO_BACKUP_BUFFER bkup
static void fileio_compensate_flush(THREAD_ENTRY *thread_p, int fd, int npage)
static bool fileio_synchronize_sys_volume(THREAD_ENTRY *thread_p, FILEIO_SYSTEM_VOLUME_INFO *vol_sys_info_p, APPLY_ARG *arg)
int fileio_copy_volume(THREAD_ENTRY *thread_p, int from_vol_desc, DKNPAGES npages, const char *to_vol_label_p, VOLID to_vol_id, bool is_reset_recovery_info)
static bool fileio_is_volume_id_gt(THREAD_ENTRY *thread_p, FILEIO_VOLUME_INFO *vol_info_p, APPLY_ARG *arg)
FILEIO_SYSTEM_VOLUME_INFO * next
#define ER_IO_EXPAND_OUT_OF_SPACE
#define ER_LOG_RECOVER_ON_OLD_RELEASE
#define FILEIO_SUFFIX_DWB
static FILEIO_BACKUP_INFO_QUEUE fileio_Backup_vol_info_data[2]
static int fileio_lock_region(int fd, int cmd, int type, off_t offset, int whence, off_t len)
#define CUB_MAXHOSTNAMELEN
const char * rel_release_string(void)
#define ER_CSS_PTHREAD_MUTEX_INIT
#define FILEIO_DBVOLS_IO_PAGE_SIZE(backup_header_p)
#define MSGCAT_FILEIO_UNIT_NUM_MISMATCH
int dwb_add_page(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page_p, VPID *vpid, DWB_SLOT **p_dwb_slot)
static FILEIO_NODE * fileio_free_node(FILEIO_QUEUE *qp, FILEIO_NODE *node)
static FILEIO_VOLUME_HEADER fileio_Vol_info_header
static bool fileio_is_system_volume_label_equal(THREAD_ENTRY *thread_p, FILEIO_SYSTEM_VOLUME_INFO *sys_vol_info_p, APPLY_ARG *arg)
static int fileio_max_permanent_volumes(int index, int num_permanent_volums)
#define MSGCAT_FILEIO_BKUP_HDR_RELEASES
#define FILEIO_BACKUP_NUM_THREADS_AUTO
#define MONITOR_WAITING_THREAD(elapsed)
int fileio_flush_control_initialize(void)
static FILEIO_BACKUP_INFO_ENTRY * fileio_allocate_backup_info(int which_bkvinf)
int fileio_open(const char *vol_label_p, int flags, int mode)
#define ER_CSS_PTHREAD_COND_INIT
int fileio_page_check_corruption(THREAD_ENTRY *thread_p, FILEIO_PAGE *io_page, bool *is_page_corrupted)
void fileio_make_volume_info_name(char *vol_info_name_p, const char *db_full_name_p)
bool fileio_is_formatted_page(THREAD_ENTRY *thread_p, const char *io_page)
#define MSGCAT_LOG_STARTS
#define FILEIO_SUFFIX_BACKUP
#define GETHOSTNAME(p, l)
FILEIO_RESTORE_PAGE_BITMAP * next
#define fileio_lock_file_read(fd, offset, whence, len)
static void fileio_page_bitmap_set(FILEIO_RESTORE_PAGE_BITMAP *page_bitmap, int page_id)
#define ER_IO_RENAME_FAIL
bool fileio_map_mounted(THREAD_ENTRY *thread_p, bool(*fun)(THREAD_ENTRY *thread_p, VOLID vol_id, void *args), void *args)
#define MSGCAT_FILEIO_BKUP_HDR_ZIP_INFO
#define MSGCAT_FILEIO_STARTS
#define FILEIO_FULL_LEVEL_EXP
int fileio_get_volume_descriptor(VOLID vol_id)
int fileio_flush_control_add_tokens(THREAD_ENTRY *thread_p, INT64 diff_usec, int *token_gen, int *token_consumed)