Skip to content

Commit 1575034

Browse files
committed
added BackupPC::XS::DirOps::refCountAllInodeMax() and bpc_path_refCountAllInodeMax() to
allow BackupPC_refCountAll to get the lagest inode as the backup tree is traversed. Also bumped version to 0.57.
1 parent e40a1d4 commit 1575034

File tree

7 files changed

+53
-6
lines changed

7 files changed

+53
-6
lines changed

BackupPC_XS.xs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,23 @@ refCountAll(path, compress, incr = 1, deltaInfo = NULL)
993993
OUTPUT:
994994
RETVAL
995995

996+
void
997+
refCountAllInodeMax(path, compress, incr = 1, deltaInfo = NULL)
998+
char *path;
999+
int compress;
1000+
int incr;
1001+
BackupPC::XS::DeltaRefCnt deltaInfo;
1002+
PREINIT:
1003+
int retVal;
1004+
unsigned int inodeMax = 0;
1005+
PPCODE:
1006+
{
1007+
retVal = bpc_path_refCountAllInodeMax(deltaInfo, path, compress, incr, &inodeMax);
1008+
EXTEND(SP, 2);
1009+
PUSHs(sv_2mortal(newSViv(retVal)));
1010+
PUSHs(sv_2mortal(newSViv(inodeMax)));
1011+
}
1012+
9961013
int
9971014
lockRangeFd(fd, offset, len, block)
9981015
int fd;

Changes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Revision history for Perl extension BackupPC-XS.
22

3+
0.57: Dec 2, 2017
4+
5+
- added BackupPC::XS::DirOps::refCountAllInodeMax() and bpc_path_refCountAllInodeMax() to allow
6+
BackupPC_refCountAll to get the lagest inode as the backup tree is traversed.
7+
38
0.56: Jun 11, 2017
49

510
- change to Makefile.PL to ensure that parallel builds (make -j N) work with BSD make

README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BackupPC-XS version 0.56
1+
BackupPC-XS version 0.57
22
========================
33

44
BackupPC::XS implements various BackupPC functions in a perl-callable

backuppc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ void bpc_logMsgCBSet(void (*cb)(int errFlag, char *mesg, size_t mesgLen));
256256
int bpc_path_create(char *path);
257257
int bpc_path_remove(bpc_deltaCount_info *deltaInfo, char *path, int compress);
258258
int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr);
259+
int bpc_path_refCountAllInodeMax(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr, unsigned int *inodeMax);
259260
int bpc_lockRangeFd(int fd, OFF_T offset, OFF_T len, int block);
260261
int bpc_unlockRangeFd(int fd, OFF_T offset, OFF_T len);
261262
int bpc_lockRangeFile(char *lockFile, OFF_T offset, OFF_T len, int block);
@@ -329,6 +330,7 @@ void bpc_attrib_dirInit(bpc_attrib_dir *dir, int compressLevel);
329330
void bpc_attrib_dirDestroy(bpc_attrib_dir *dir);
330331
ssize_t bpc_attrib_getEntries(bpc_attrib_dir *dir, char *entries, ssize_t entrySize);
331332
void bpc_attrib_dirRefCount(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr);
333+
void bpc_attrib_dirRefCountInodeMax(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr, unsigned int *inodeMax);
332334
void bpc_attrib_attribFilePath(char *path, char *dir, char *attribFileName);
333335
bpc_digest *bpc_attrib_dirDigestGet(bpc_attrib_dir *dir);
334336
uchar *bpc_attrib_buf2file(bpc_attrib_file *file, uchar *buf, uchar *bufEnd, int xattrNumEntries);

bpc_attrib.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ void bpc_attrib_dirDestroy(bpc_attrib_dir *dir)
396396
typedef struct {
397397
bpc_deltaCount_info *deltaInfo;
398398
int incr;
399+
unsigned int *inodeMax;
399400
} fileRefCnt_info;
400401

401402
static void bpc_attrib_fileRefCount(bpc_attrib_file *file, fileRefCnt_info *info)
@@ -406,18 +407,22 @@ static void bpc_attrib_fileRefCount(bpc_attrib_file *file, fileRefCnt_info *info
406407
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_fileRefCount: file %s digest %s delta %d\n", file->name, hexStr, info->incr);
407408
bpc_poolRefDeltaUpdate(info->deltaInfo, file->compress, &file->digest, info->incr);
408409
}
410+
if ( info->inodeMax && file->inode > *info->inodeMax ) {
411+
*info->inodeMax = file->inode;
412+
}
409413
}
410414

411415
/*
412416
* call refDeltaUpdate with incr (typically +/-1) for every entry in the directory,
413417
* as well as the dir itself.
414418
*/
415-
void bpc_attrib_dirRefCount(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr)
419+
void bpc_attrib_dirRefCountInodeMax(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr, unsigned int *inodeMax)
416420
{
417421
fileRefCnt_info info;
418422

419423
info.deltaInfo = deltaInfo;
420424
info.incr = incr;
425+
info.inodeMax = inodeMax;
421426
bpc_hashtable_iterate(&dir->filesHT, (void*)bpc_attrib_fileRefCount, &info);
422427
if ( dir->digest.len > 0 ) {
423428
char hexStr[BPC_DIGEST_LEN_MAX * 2 + 1];
@@ -429,6 +434,15 @@ void bpc_attrib_dirRefCount(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir,
429434
}
430435
}
431436

437+
/*
438+
* call refDeltaUpdate with incr (typically +/-1) for every entry in the directory,
439+
* as well as the dir itself.
440+
*/
441+
void bpc_attrib_dirRefCount(bpc_deltaCount_info *deltaInfo, bpc_attrib_dir *dir, int incr)
442+
{
443+
bpc_attrib_dirRefCountInodeMax(deltaInfo, dir, incr, NULL);
444+
}
445+
432446
typedef struct {
433447
char *entries;
434448
ssize_t entryIdx;

bpc_dirOps.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ int bpc_path_remove(bpc_deltaCount_info *deltaInfo, char *path, int compress)
164164
* Reference count all the files below the directory path, based on the attrib
165165
* files in and below path.
166166
*/
167-
int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr)
167+
int bpc_path_refCountAllInodeMax(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr, unsigned int *inodeMax)
168168
{
169169
char filePath[BPC_MAXPATHLEN];
170170
STRUCT_STAT st;
@@ -217,7 +217,7 @@ int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compres
217217
errorCnt++;
218218
} else {
219219
if ( BPC_LogLevel >= 9 ) bpc_logMsgf("bpc_path_refCountAll: adjusting ref counts from attrib file %s\n", filePath);
220-
bpc_attrib_dirRefCount(deltaInfo, &dir, incr);
220+
bpc_attrib_dirRefCountInodeMax(deltaInfo, &dir, incr, inodeMax);
221221
}
222222
bpc_attrib_dirDestroy(&dir);
223223
}
@@ -230,13 +230,22 @@ int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compres
230230
if ( dirList ) {
231231
for ( dirListP = dirList ; dirListP < dirList + dirListLen ; dirListP += strlen(dirListP) + 1 ) {
232232
snprintf(filePath, sizeof(filePath), "%s/%s", path, dirListP);
233-
errorCnt += bpc_path_refCountAll(deltaInfo, filePath, compress, incr);
233+
errorCnt += bpc_path_refCountAllInodeMax(deltaInfo, filePath, compress, incr, inodeMax);
234234
}
235235
free(dirList);
236236
}
237237
return errorCnt;
238238
}
239239

240+
/*
241+
* Reference count all the files below the directory path, based on the attrib
242+
* files in and below path.
243+
*/
244+
int bpc_path_refCountAll(bpc_deltaCount_info *deltaInfo, char *path, int compress, int incr)
245+
{
246+
return bpc_path_refCountAllInodeMax(deltaInfo, path, compress, incr, NULL);
247+
}
248+
240249
/*
241250
* Add an exclusive lock to the byte range in the given file.
242251
* Blocks until the lock becomes available.

lib/BackupPC/XS.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ my @FILE_TYPES = qw(
5555
'all' => [ @EXPORT_OK ],
5656
);
5757

58-
our $VERSION = '0.56';
58+
our $VERSION = '0.57';
5959

6060
require XSLoader;
6161
XSLoader::load('BackupPC::XS', $VERSION);

0 commit comments

Comments
 (0)