From 111bf9e34debd34857f8b7e79fcf096365cde32e Mon Sep 17 00:00:00 2001 From: "A.J. Beamon" Date: Fri, 30 Sep 2022 16:05:47 -0700 Subject: [PATCH] Add macros for literal string ref versions of __FUNCTION__ and __FILE__ --- fdbclient/DatabaseBackupAgent.actor.cpp | 10 +- fdbclient/FileBackupAgent.actor.cpp | 96 +++++++++---------- .../include/fdbclient/BackupAgent.actor.h | 82 +++++++--------- fdbclient/include/fdbclient/TaskBucket.h | 2 +- fdbrpc/FlowTests.actor.cpp | 2 +- fdbserver/RestoreCommon.actor.cpp | 28 +++--- flow/include/flow/Arena.h | 2 + 7 files changed, 103 insertions(+), 119 deletions(-) diff --git a/fdbclient/DatabaseBackupAgent.actor.cpp b/fdbclient/DatabaseBackupAgent.actor.cpp index 45fe3ea24e..548f03c46c 100644 --- a/fdbclient/DatabaseBackupAgent.actor.cpp +++ b/fdbclient/DatabaseBackupAgent.actor.cpp @@ -79,9 +79,9 @@ public: DRConfig(Reference task) : DRConfig(BinaryReader::fromStringRef(task->params[BackupAgentBase::keyConfigLogUid], Unversioned())) {} - KeyBackedBinaryValue rangeBytesWritten() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue rangeBytesWritten() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedBinaryValue logBytesWritten() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue logBytesWritten() { return configSpace.pack(__FUNCTION__sr); } void clear(Reference tr) { tr->clear(configSpace.range()); } @@ -136,7 +136,7 @@ struct BackupRangeTaskFunc : TaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam bytesWritten() { return LiteralStringRef(__FUNCTION__); } + static TaskParam bytesWritten() { return __FUNCTION__sr; } } Params; static const Key keyAddBackupRangeTasks; @@ -704,7 +704,7 @@ struct CopyLogRangeTaskFunc : TaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam bytesWritten() { return LiteralStringRef(__FUNCTION__); } + static TaskParam bytesWritten() { return __FUNCTION__sr; } } Params; static const Key keyNextBeginVersion; @@ -1455,7 +1455,7 @@ struct OldCopyLogRangeTaskFunc : TaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam bytesWritten() { return LiteralStringRef(__FUNCTION__); } + static TaskParam bytesWritten() { return __FUNCTION__sr; } } Params; static const Key keyNextBeginVersion; diff --git a/fdbclient/FileBackupAgent.actor.cpp b/fdbclient/FileBackupAgent.actor.cpp index 6c5d131ee4..438401c405 100644 --- a/fdbclient/FileBackupAgent.actor.cpp +++ b/fdbclient/FileBackupAgent.actor.cpp @@ -157,41 +157,37 @@ public: RestoreConfig(UID uid = UID()) : KeyBackedConfig(fileRestorePrefixRange.begin, uid) {} RestoreConfig(Reference task) : KeyBackedConfig(fileRestorePrefixRange.begin, task) {} - KeyBackedProperty stateEnum() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty stateEnum() { return configSpace.pack(__FUNCTION__sr); } Future stateText(Reference tr) { return map(stateEnum().getD(tr), [](ERestoreState s) -> StringRef { return FileBackupAgent::restoreStateText(s); }); } - KeyBackedProperty addPrefix() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty removePrefix() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty onlyApplyMutationLogs() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty inconsistentSnapshotOnly() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty addPrefix() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty removePrefix() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty onlyApplyMutationLogs() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty inconsistentSnapshotOnly() { return configSpace.pack(__FUNCTION__sr); } // XXX: Remove restoreRange() once it is safe to remove. It has been changed to restoreRanges - KeyBackedProperty restoreRange() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty> restoreRanges() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } - KeyBackedProperty batchFuture() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty beginVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty restoreVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } - KeyBackedProperty firstConsistentVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty restoreRange() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty> restoreRanges() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty batchFuture() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty beginVersion() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty restoreVersion() { return configSpace.pack(__FUNCTION__sr); } + KeyBackedProperty firstConsistentVersion() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty> sourceContainer() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty> sourceContainer() { return configSpace.pack(__FUNCTION__sr); } // Get the source container as a bare URL, without creating a container instance KeyBackedProperty sourceContainerURL() { return configSpace.pack("sourceContainer"_sr); } // Total bytes written by all log and range restore tasks. - KeyBackedBinaryValue bytesWritten() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue bytesWritten() { return configSpace.pack(__FUNCTION__sr); } // File blocks that have had tasks created for them by the Dispatch task - KeyBackedBinaryValue filesBlocksDispatched() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue filesBlocksDispatched() { return configSpace.pack(__FUNCTION__sr); } // File blocks whose tasks have finished - KeyBackedBinaryValue fileBlocksFinished() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue fileBlocksFinished() { return configSpace.pack(__FUNCTION__sr); } // Total number of files in the fileMap - KeyBackedBinaryValue fileCount() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue fileCount() { return configSpace.pack(__FUNCTION__sr); } // Total number of file blocks in the fileMap - KeyBackedBinaryValue fileBlockCount() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue fileBlockCount() { return configSpace.pack(__FUNCTION__sr); } Future> getRestoreRangesOrDefault(Reference tr) { return getRestoreRangesOrDefault_impl(this, tr); @@ -234,7 +230,7 @@ public: }; typedef KeyBackedSet FileSetT; - FileSetT fileSet() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + FileSetT fileSet() { return configSpace.pack(__FUNCTION__sr); } Future isRunnable(Reference tr) { return map(stateEnum().getD(tr), [](ERestoreState s) -> bool { @@ -1531,9 +1527,9 @@ struct BackupRangeTaskFunc : BackupTaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam beginKey() { return LiteralStringRef(__FUNCTION__); } - static TaskParam endKey() { return LiteralStringRef(__FUNCTION__); } - static TaskParam addBackupRangeTasks() { return LiteralStringRef(__FUNCTION__); } + static TaskParam beginKey() { return __FUNCTION__sr; } + static TaskParam endKey() { return __FUNCTION__sr; } + static TaskParam addBackupRangeTasks() { return __FUNCTION__sr; } } Params; std::string toString(Reference task) const override { @@ -1897,11 +1893,11 @@ struct BackupSnapshotDispatchTask : BackupTaskFuncBase { static struct { // Set by Execute, used by Finish - static TaskParam shardsBehind() { return LiteralStringRef(__FUNCTION__); } + static TaskParam shardsBehind() { return __FUNCTION__sr; } // Set by Execute, used by Finish - static TaskParam snapshotFinished() { return LiteralStringRef(__FUNCTION__); } + static TaskParam snapshotFinished() { return __FUNCTION__sr; } // Set by Execute, used by Finish - static TaskParam nextDispatchVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam nextDispatchVersion() { return __FUNCTION__sr; } } Params; StringRef getName() const override { return name; }; @@ -2469,10 +2465,10 @@ struct BackupLogRangeTaskFunc : BackupTaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam addBackupLogRangeTasks() { return LiteralStringRef(__FUNCTION__); } - static TaskParam fileSize() { return LiteralStringRef(__FUNCTION__); } - static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } - static TaskParam endVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam addBackupLogRangeTasks() { return __FUNCTION__sr; } + static TaskParam fileSize() { return __FUNCTION__sr; } + static TaskParam beginVersion() { return __FUNCTION__sr; } + static TaskParam endVersion() { return __FUNCTION__sr; } } Params; StringRef getName() const override { return name; }; @@ -2710,9 +2706,9 @@ struct EraseLogRangeTaskFunc : BackupTaskFuncBase { StringRef getName() const override { return name; }; static struct { - static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } - static TaskParam endVersion() { return LiteralStringRef(__FUNCTION__); } - static TaskParam destUidValue() { return LiteralStringRef(__FUNCTION__); } + static TaskParam beginVersion() { return __FUNCTION__sr; } + static TaskParam endVersion() { return __FUNCTION__sr; } + static TaskParam destUidValue() { return __FUNCTION__sr; } } Params; ACTOR static Future addTask(Reference tr, @@ -2784,8 +2780,8 @@ struct BackupLogsDispatchTask : BackupTaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam prevBeginVersion() { return LiteralStringRef(__FUNCTION__); } - static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam prevBeginVersion() { return __FUNCTION__sr; } + static TaskParam beginVersion() { return __FUNCTION__sr; } } Params; ACTOR static Future _finish(Reference tr, @@ -3013,7 +3009,7 @@ struct BackupSnapshotManifest : BackupTaskFuncBase { static StringRef name; static constexpr uint32_t version = 1; static struct { - static TaskParam endVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam endVersion() { return __FUNCTION__sr; } } Params; ACTOR static Future _execute(Database cx, @@ -3212,7 +3208,7 @@ struct StartFullBackupTaskFunc : BackupTaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam beginVersion() { return __FUNCTION__sr; } } Params; ACTOR static Future _execute(Database cx, @@ -3455,9 +3451,9 @@ REGISTER_TASKFUNC(RestoreCompleteTaskFunc); struct RestoreFileTaskFuncBase : RestoreTaskFuncBase { struct InputParams { - static TaskParam inputFile() { return LiteralStringRef(__FUNCTION__); } - static TaskParam readOffset() { return LiteralStringRef(__FUNCTION__); } - static TaskParam readLen() { return LiteralStringRef(__FUNCTION__); } + static TaskParam inputFile() { return __FUNCTION__sr; } + static TaskParam readOffset() { return __FUNCTION__sr; } + static TaskParam readLen() { return __FUNCTION__sr; } } Params; std::string toString(Reference task) const override { @@ -3472,8 +3468,8 @@ struct RestoreRangeTaskFunc : RestoreFileTaskFuncBase { static struct : InputParams { // The range of data that the (possibly empty) data represented, which is set if it intersects the target // restore range - static TaskParam originalFileRange() { return LiteralStringRef(__FUNCTION__); } - static TaskParam> originalFileRanges() { return LiteralStringRef(__FUNCTION__); } + static TaskParam originalFileRange() { return __FUNCTION__sr; } + static TaskParam> originalFileRanges() { return __FUNCTION__sr; } static std::vector getOriginalFileRanges(Reference task) { if (originalFileRanges().exists(task)) { @@ -4069,11 +4065,11 @@ struct RestoreDispatchTaskFunc : RestoreTaskFuncBase { StringRef getName() const override { return name; }; static struct { - static TaskParam beginVersion() { return LiteralStringRef(__FUNCTION__); } - static TaskParam beginFile() { return LiteralStringRef(__FUNCTION__); } - static TaskParam beginBlock() { return LiteralStringRef(__FUNCTION__); } - static TaskParam batchSize() { return LiteralStringRef(__FUNCTION__); } - static TaskParam remainingInBatch() { return LiteralStringRef(__FUNCTION__); } + static TaskParam beginVersion() { return __FUNCTION__sr; } + static TaskParam beginFile() { return __FUNCTION__sr; } + static TaskParam beginBlock() { return __FUNCTION__sr; } + static TaskParam batchSize() { return __FUNCTION__sr; } + static TaskParam remainingInBatch() { return __FUNCTION__sr; } } Params; ACTOR static Future _finish(Reference tr, @@ -4542,7 +4538,7 @@ struct StartFullRestoreTaskFunc : RestoreTaskFuncBase { static constexpr uint32_t version = 1; static struct { - static TaskParam firstVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam firstVersion() { return __FUNCTION__sr; } } Params; // Find all files needed for the restore and save them in the RestoreConfig for the task. diff --git a/fdbclient/include/fdbclient/BackupAgent.actor.h b/fdbclient/include/fdbclient/BackupAgent.actor.h index d7621e02bb..314f151fd0 100644 --- a/fdbclient/include/fdbclient/BackupAgent.actor.h +++ b/fdbclient/include/fdbclient/BackupAgent.actor.h @@ -143,7 +143,7 @@ public: futureBucket = std::move(r.futureBucket); } - KeyBackedProperty lastBackupTimestamp() { return config.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty lastBackupTimestamp() { return config.pack(__FUNCTION__sr); } Future run(Database cx, double pollDelay, int maxConcurrentTasks) { return taskBucket->run(cx, futureBucket, std::make_shared(pollDelay), maxConcurrentTasks); @@ -633,7 +633,7 @@ static inline Future> getAllBackupTags(Reference uid() { return LiteralStringRef(__FUNCTION__); } + static TaskParam uid() { return __FUNCTION__sr; } } TaskParams; KeyBackedConfig(StringRef prefix, UID uid = UID()) @@ -666,7 +666,7 @@ public: }); } - KeyBackedProperty tag() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty tag() { return configSpace.pack(__FUNCTION__sr); } UID getUid() { return uid; } @@ -675,12 +675,10 @@ public: void clear(Reference tr) { tr->clear(configSpace.range()); } // lastError is a pair of error message and timestamp expressed as an int64_t - KeyBackedProperty> lastError() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty> lastError() { return configSpace.pack(__FUNCTION__sr); } KeyBackedMap> lastErrorPerType() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // Updates the error per type map and the last error property @@ -769,47 +767,41 @@ public: // Map of range end boundaries to info about the backup file written for that range. typedef KeyBackedMap RangeFileMapT; - RangeFileMapT snapshotRangeFileMap() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + RangeFileMapT snapshotRangeFileMap() { return configSpace.pack(__FUNCTION__sr); } // Number of kv range files that were both committed to persistent storage AND inserted into // the snapshotRangeFileMap. Note that since insertions could replace 1 or more existing // map entries this is not necessarily the number of entries currently in the map. // This value exists to help with sizing of kv range folders for BackupContainers that // require it. - KeyBackedBinaryValue snapshotRangeFileCount() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue snapshotRangeFileCount() { return configSpace.pack(__FUNCTION__sr); } // Coalesced set of ranges already dispatched for writing. typedef KeyBackedMap RangeDispatchMapT; - RangeDispatchMapT snapshotRangeDispatchMap() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + RangeDispatchMapT snapshotRangeDispatchMap() { return configSpace.pack(__FUNCTION__sr); } // Interval to use for the first (initial) snapshot. - KeyBackedProperty initialSnapshotIntervalSeconds() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty initialSnapshotIntervalSeconds() { return configSpace.pack(__FUNCTION__sr); } // Interval to use for determining the target end version for new snapshots - KeyBackedProperty snapshotIntervalSeconds() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotIntervalSeconds() { return configSpace.pack(__FUNCTION__sr); } // When the current snapshot began - KeyBackedProperty snapshotBeginVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotBeginVersion() { return configSpace.pack(__FUNCTION__sr); } // When the current snapshot is desired to end. // This can be changed at runtime to speed up or slow down a snapshot - KeyBackedProperty snapshotTargetEndVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotTargetEndVersion() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty snapshotBatchSize() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotBatchSize() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty snapshotBatchFuture() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotBatchFuture() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty snapshotBatchDispatchDoneKey() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty snapshotBatchDispatchDoneKey() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty snapshotDispatchLastShardsBehind() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty snapshotDispatchLastShardsBehind() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty snapshotDispatchLastVersion() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty snapshotDispatchLastVersion() { return configSpace.pack(__FUNCTION__sr); } Future initNewSnapshot(Reference tr, int64_t intervalSeconds = -1) { BackupConfig& copy = *this; // Capture this by value instead of this ptr @@ -843,56 +835,50 @@ public: }); } - KeyBackedBinaryValue rangeBytesWritten() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue rangeBytesWritten() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedBinaryValue logBytesWritten() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedBinaryValue logBytesWritten() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty stateEnum() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty stateEnum() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty> backupContainer() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty> backupContainer() { return configSpace.pack(__FUNCTION__sr); } // Set to true when all backup workers for saving mutation logs have been started. - KeyBackedProperty allWorkerStarted() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty allWorkerStarted() { return configSpace.pack(__FUNCTION__sr); } // Each backup worker adds its (epoch, tag.id) to this property. KeyBackedProperty>> startedBackupWorkers() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // Set to true if backup worker is enabled. - KeyBackedProperty backupWorkerEnabled() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty backupWorkerEnabled() { return configSpace.pack(__FUNCTION__sr); } // Set to true if partitioned log is enabled (only useful if backup worker is also enabled). - KeyBackedProperty partitionedLogEnabled() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty partitionedLogEnabled() { return configSpace.pack(__FUNCTION__sr); } // Set to true if only requesting incremental backup without base snapshot. - KeyBackedProperty incrementalBackupOnly() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty incrementalBackupOnly() { return configSpace.pack(__FUNCTION__sr); } // Latest version for which all prior versions have saved by backup workers. - KeyBackedProperty latestBackupWorkerSavedVersion() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty latestBackupWorkerSavedVersion() { return configSpace.pack(__FUNCTION__sr); } // Stop differntial logging if already started or don't start after completing KV ranges - KeyBackedProperty stopWhenDone() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty stopWhenDone() { return configSpace.pack(__FUNCTION__sr); } // Enable snapshot backup file encryption - KeyBackedProperty enableSnapshotBackupEncryption() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); - } + KeyBackedProperty enableSnapshotBackupEncryption() { return configSpace.pack(__FUNCTION__sr); } // Latest version for which all prior versions have had their log copy tasks completed - KeyBackedProperty latestLogEndVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty latestLogEndVersion() { return configSpace.pack(__FUNCTION__sr); } // The end version of the last complete snapshot - KeyBackedProperty latestSnapshotEndVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty latestSnapshotEndVersion() { return configSpace.pack(__FUNCTION__sr); } // The end version of the first complete snapshot - KeyBackedProperty firstSnapshotEndVersion() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty firstSnapshotEndVersion() { return configSpace.pack(__FUNCTION__sr); } - KeyBackedProperty destUidValue() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty destUidValue() { return configSpace.pack(__FUNCTION__sr); } Future> getLatestRestorableVersion(Reference tr) { tr->setOption(FDBTransactionOptions::READ_SYSTEM_KEYS); @@ -923,7 +909,7 @@ public: }); } - KeyBackedProperty> backupRanges() { return configSpace.pack(LiteralStringRef(__FUNCTION__)); } + KeyBackedProperty> backupRanges() { return configSpace.pack(__FUNCTION__sr); } void startMutationLogs(Reference tr, KeyRangeRef backupRange, Key destUidValue) { Key mutationLogsDestKey = destUidValue.withPrefix(backupLogKeys.begin); diff --git a/fdbclient/include/fdbclient/TaskBucket.h b/fdbclient/include/fdbclient/TaskBucket.h index b7e6091d0f..408fcef749 100644 --- a/fdbclient/include/fdbclient/TaskBucket.h +++ b/fdbclient/include/fdbclient/TaskBucket.h @@ -115,7 +115,7 @@ public: }; struct ReservedTaskParams { - static TaskParam scheduledVersion() { return LiteralStringRef(__FUNCTION__); } + static TaskParam scheduledVersion() { return __FUNCTION__sr; } }; class FutureBucket; diff --git a/fdbrpc/FlowTests.actor.cpp b/fdbrpc/FlowTests.actor.cpp index e53f7dd5e5..fc59fca6df 100644 --- a/fdbrpc/FlowTests.actor.cpp +++ b/fdbrpc/FlowTests.actor.cpp @@ -48,7 +48,7 @@ TEST_CASE("/flow/actorcompiler/lineNumbers") { } break; } - ASSERT(LiteralStringRef(__FILE__).endsWith("FlowTests.actor.cpp"_sr)); + ASSERT(__FILE__sr.endsWith("FlowTests.actor.cpp"_sr)); return Void(); } diff --git a/fdbserver/RestoreCommon.actor.cpp b/fdbserver/RestoreCommon.actor.cpp index d87e416f70..54dfc0769b 100644 --- a/fdbserver/RestoreCommon.actor.cpp +++ b/fdbserver/RestoreCommon.actor.cpp @@ -38,33 +38,33 @@ // RestoreCommon.actor.cpp KeyBackedProperty RestoreConfigFR::stateEnum() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } Future RestoreConfigFR::stateText(Reference tr) { return map(stateEnum().getD(tr), [](ERestoreState s) -> StringRef { return FileBackupAgent::restoreStateText(s); }); } KeyBackedProperty RestoreConfigFR::addPrefix() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } KeyBackedProperty RestoreConfigFR::removePrefix() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // XXX: Remove restoreRange() once it is safe to remove. It has been changed to restoreRanges KeyBackedProperty RestoreConfigFR::restoreRange() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } KeyBackedProperty> RestoreConfigFR::restoreRanges() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } KeyBackedProperty RestoreConfigFR::batchFuture() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } KeyBackedProperty RestoreConfigFR::restoreVersion() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } KeyBackedProperty> RestoreConfigFR::sourceContainer() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // Get the source container as a bare URL, without creating a container instance KeyBackedProperty RestoreConfigFR::sourceContainerURL() { @@ -73,23 +73,23 @@ KeyBackedProperty RestoreConfigFR::sourceContainerURL() { // Total bytes written by all log and range restore tasks. KeyBackedBinaryValue RestoreConfigFR::bytesWritten() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // File blocks that have had tasks created for them by the Dispatch task KeyBackedBinaryValue RestoreConfigFR::filesBlocksDispatched() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // File blocks whose tasks have finished KeyBackedBinaryValue RestoreConfigFR::fileBlocksFinished() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // Total number of files in the fileMap KeyBackedBinaryValue RestoreConfigFR::fileCount() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } // Total number of file blocks in the fileMap KeyBackedBinaryValue RestoreConfigFR::fileBlockCount() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } Future> RestoreConfigFR::getRestoreRangesOrDefault(Reference tr) { @@ -108,7 +108,7 @@ ACTOR Future> RestoreConfigFR::getRestoreRangesOrDefault_i } KeyBackedSet RestoreConfigFR::fileSet() { - return configSpace.pack(LiteralStringRef(__FUNCTION__)); + return configSpace.pack(__FUNCTION__sr); } Future RestoreConfigFR::isRunnable(Reference tr) { diff --git a/flow/include/flow/Arena.h b/flow/include/flow/Arena.h index 0c632e8bbd..7976f04c84 100644 --- a/flow/include/flow/Arena.h +++ b/flow/include/flow/Arena.h @@ -740,6 +740,8 @@ StringRef LiteralStringRefHelper(const char* str) { } } // namespace literal_string_ref #define LiteralStringRef(str) literal_string_ref::LiteralStringRefHelper(str) +#define __FILE__sr StringRef(reinterpret_cast(__FILE__), sizeof(__FILE__)) +#define __FUNCTION__sr StringRef(reinterpret_cast(__FUNCTION__), sizeof(__FUNCTION__)) template <> struct fmt::formatter : formatter {