1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-09 00:45:49 +02:00

Simplify storage driver info and list functions.

The storage driver requires two list functions to be implemented, list and infoList. But the former is a subset of the latter so implementing both in every driver is wasteful. The reason both exist is that in Posix it is cheaper to get a list of names than it is to stat files to get size, time, etc. In S3 these operations are equivalent.

Introduce storageInfoLevelType to determine the amount of information required by the caller. That way Posix can work efficiently and all drivers can return only the data required which saves some bandwidth. The storageList() and storageInfoList() functions remain in the storage interface since they are useful -- the only change is simplifying the drivers with no external impact.

Note that since list() accepted an expression infoList() must now do so. Checking the expression is optional for the driver but can be used to limit results or save IO costs.

Similarly, exists() and pathExists() are just specialized forms of info() so adapt them to call info() instead.
This commit is contained in:
David Steele
2020-04-06 16:09:18 -04:00
parent 7679f8f886
commit 5e55d58850
19 changed files with 522 additions and 758 deletions

View File

@ -29,29 +29,18 @@ stress testing as needed.
/***********************************************************************************************************************************
Dummy functions and interface for constructing test drivers
***********************************************************************************************************************************/
static bool
storageTestDummyExists(THIS_VOID, const String *file, StorageInterfaceExistsParam param)
{
(void)thisVoid; (void)file; (void)param; return false;
}
static StorageInfo
storageTestDummyInfo(THIS_VOID, const String *file, StorageInterfaceInfoParam param)
storageTestDummyInfo(THIS_VOID, const String *file, StorageInfoLevel level, StorageInterfaceInfoParam param)
{
(void)thisVoid; (void)file; (void)param; return (StorageInfo){.exists = false};
(void)thisVoid; (void)file; (void)level; (void)param; return (StorageInfo){.exists = false};
}
static bool
storageTestDummyInfoList(
THIS_VOID, const String *path, StorageInfoListCallback callback, void *callbackData, StorageInterfaceInfoListParam param)
THIS_VOID, const String *path, StorageInfoLevel level, StorageInfoListCallback callback, void *callbackData,
StorageInterfaceInfoListParam param)
{
(void)thisVoid; (void)path; (void)callback; (void)callbackData; (void)param; return false;
}
static StringList *
storageTestDummyList(THIS_VOID, const String *path, StorageInterfaceListParam param)
{
(void)thisVoid; (void)path; (void)param; return NULL;
(void)thisVoid; (void)path; (void)level; (void)callback; (void)callbackData; (void)param; return false;
}
static StorageRead *
@ -80,10 +69,8 @@ storageTestDummyRemove(THIS_VOID, const String *file, StorageInterfaceRemovePara
static const StorageInterface storageInterfaceTestDummy =
{
.exists = storageTestDummyExists,
.info = storageTestDummyInfo,
.infoList = storageTestDummyInfoList,
.list = storageTestDummyList,
.newRead = storageTestDummyNewRead,
.newWrite = storageTestDummyNewWrite,
.pathRemove = storageTestDummyPathRemove,
@ -114,10 +101,11 @@ typedef struct
static bool
storageTestPerfInfoList(
THIS_VOID, const String *path, StorageInfoListCallback callback, void *callbackData, StorageInterfaceInfoListParam param)
THIS_VOID, const String *path, StorageInfoLevel level, StorageInfoListCallback callback, void *callbackData,
StorageInterfaceInfoListParam param)
{
THIS(StorageTestPerfInfoList);
(void)path; (void)param;
(void)path; (void)level; (void)param;
MEM_CONTEXT_TEMP_BEGIN()
{