Skip to content

Commit 15b457d

Browse files
committed
small cfs fixes
1 parent 6d4c966 commit 15b457d

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

src/backup.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,6 @@ parse_backup_filelist_filenames(parray *files, const char *root)
19681968
int sscanf_result;
19691969

19701970
relative = GetRelativePath(file->path, root);
1971-
file->is_cfs = false;
19721971
filename[0] = '\0';
19731972

19741973
elog(VERBOSE, "-----------------------------------------------------: %s", relative);
@@ -2042,7 +2041,7 @@ parse_backup_filelist_filenames(parray *files, const char *root)
20422041
/* Found file in pg_tblspc/tblsOid/TABLESPACE_VERSION_DIRECTORY
20432042
Legal only in case of 'pg_compression'
20442043
*/
2045-
if (strcmp(relative + strlen(relative) - strlen("pg_compression"), "pg_compression") == 0)
2044+
if (strcmp(file->name, "pg_compression") == 0)
20462045
{
20472046
elog(VERBOSE, "Found pg_compression file in TABLESPACE_VERSION_DIRECTORY, filepath %s", relative);
20482047
/*Set every datafile in tablespace as is_cfs */
@@ -2186,29 +2185,39 @@ set_cfs_datafiles(parray *files, const char *root, char *relative, size_t i)
21862185
{
21872186
int len;
21882187
size_t p;
2188+
pgFile *prev_file;
21892189
char *cfs_tblspc_path;
2190+
char *relative_prev_file;
21902191

21912192
cfs_tblspc_path = strdup(relative);
21922193
len = strlen("/pg_compression");
21932194
cfs_tblspc_path[strlen(cfs_tblspc_path) - len] = 0;
21942195
elog(VERBOSE, "CFS DIRECTORY %s, pg_compression path: %s", cfs_tblspc_path, relative);
21952196

2196-
for (p = i; p != 0; p--)
2197+
for (p = i; p >= 0; p--)
21972198
{
2198-
char *relative_prev_file;
2199-
pgFile *prev_file = (pgFile *) parray_get(files, p);
2199+
prev_file = (pgFile *) parray_get(files, p);
22002200
relative_prev_file = GetRelativePath(prev_file->path, root);
2201-
//elog(VERBOSE, "P: %d, CHECKING file %s", p, relative_prev_file);
2201+
2202+
//elog(VERBOSE, "P: %lu, Checking file in cfs tablespace %s", p, relative_prev_file);
2203+
elog(VERBOSE, "Checking file in cfs tablespace %s", relative_prev_file);
2204+
22022205
if (strstr(relative_prev_file, cfs_tblspc_path) != NULL)
22032206
{
22042207
if (S_ISREG(prev_file->mode) && prev_file->is_datafile)
22052208
{
2206-
elog(VERBOSE, "Setting as 'is_cfs' file %s, fork %s",
2207-
relative_prev_file, prev_file->forkName);
2209+
elog(VERBOSE, "Setting 'is_cfs' on file %s, name %s",
2210+
relative_prev_file, prev_file->name);
22082211
prev_file->is_cfs = true;
22092212
}
22102213
}
2214+
else
2215+
{
2216+
elog(VERBOSE, "Breaking on %s", relative_prev_file);
2217+
break;
2218+
}
22112219
}
2220+
free(cfs_tblspc_path);
22122221
}
22132222

22142223

src/data.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -317,13 +317,10 @@ backup_data_file(const char *from_root, const char *to_root,
317317
file->path, strerror(errno));
318318
}
319319

320-
if (!file->is_cfs)
320+
if (file->size % BLCKSZ != 0)
321321
{
322-
if (file->size % BLCKSZ != 0)
323-
{
324-
fclose(in);
325-
elog(ERROR, "File: %s, invalid file size %lu", file->path, file->size);
326-
}
322+
fclose(in);
323+
elog(ERROR, "File: %s, invalid file size %lu", file->path, file->size);
327324
}
328325

329326
/*

src/dir.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,20 @@ dir_list_file_internal(parray *files, const char *root, bool exclude,
393393
if (file_name == NULL)
394394
file_name = file->path;
395395
else
396+
{
396397
file_name++;
398+
file->name = file_name;
399+
}
397400

398401
/* Check if we need to exclude file by name */
399402
for (i = 0; pgdata_exclude_files[i]; i++)
400-
if (strcmp(file_name, pgdata_exclude_files[i]) == 0)
403+
if (strcmp(file->name, pgdata_exclude_files[i]) == 0)
404+
{
401405
/* Skip */
406+
elog(VERBOSE, "Excluding file: %s", file->name);
402407
return;
408+
}
403409
}
404-
405410
parray_append(files, file);
406411
}
407412

@@ -463,7 +468,10 @@ dir_list_file_internal(parray *files, const char *root, bool exclude,
463468
if (dirname == NULL)
464469
dirname = file->path;
465470
else
471+
{
466472
dirname++;
473+
file->name = dirname;
474+
}
467475

468476
/*
469477
* If the item in the exclude list starts with '/', compare to the
@@ -472,6 +480,7 @@ dir_list_file_internal(parray *files, const char *root, bool exclude,
472480
*/
473481
for (i = 0; exclude && pgdata_exclude_dir[i]; i++)
474482
{
483+
/* Full-path exclude*/
475484
if (pgdata_exclude_dir[i][0] == '/')
476485
{
477486
if (strcmp(file->path, pgdata_exclude_dir[i]) == 0)
@@ -480,14 +489,17 @@ dir_list_file_internal(parray *files, const char *root, bool exclude,
480489
break;
481490
}
482491
}
483-
else if (strcmp(dirname, pgdata_exclude_dir[i]) == 0)
492+
else if (strcmp(file->name, pgdata_exclude_dir[i]) == 0)
484493
{
485494
skip = true;
486495
break;
487496
}
488497
}
489498
if (skip)
499+
{
500+
elog(VERBOSE, "Excluding directory content: %s", file->name);
490501
break;
502+
}
491503
}
492504

493505
/* open directory and list contents */

src/pg_probackup.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ typedef enum CompressAlg
8080
/* Information about single file (or dir) in backup */
8181
typedef struct pgFile
8282
{
83+
char *name; /* file or directory name */
8384
mode_t mode; /* protection (file type and permission) */
8485
size_t size; /* size of the file */
8586
size_t read_size; /* size of the portion read (if only some pages are
@@ -90,7 +91,7 @@ typedef struct pgFile
9091
pg_crc32 crc; /* CRC value of the file, regular file only */
9192
char *linked; /* path of the linked file */
9293
bool is_datafile; /* true if the file is PostgreSQL data file */
93-
char *path; /* path of the file */
94+
char *path; /* absolute path of the file */
9495
Oid tblspcOid; /* tblspcOid extracted from path, if applicable */
9596
Oid dbOid; /* dbOid extracted from path, if applicable */
9697
Oid relOid; /* relOid extracted from path, if applicable */

0 commit comments

Comments
 (0)