summaryrefslogtreecommitdiff
path: root/includes/filebackend/FileBackendStore.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/filebackend/FileBackendStore.php')
-rw-r--r--includes/filebackend/FileBackendStore.php87
1 files changed, 40 insertions, 47 deletions
diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php
index 495ac3c0..25e87d43 100644
--- a/includes/filebackend/FileBackendStore.php
+++ b/includes/filebackend/FileBackendStore.php
@@ -118,7 +118,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function createInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( strlen( $params['content'] ) > $this->maxFileSizeInternal() ) {
$status = Status::newFatal( 'backend-fail-maxsize',
$params['dst'], $this->maxFileSizeInternal() );
@@ -159,7 +159,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function storeInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( filesize( $params['src'] ) > $this->maxFileSizeInternal() ) {
$status = Status::newFatal( 'backend-fail-maxsize',
$params['dst'], $this->maxFileSizeInternal() );
@@ -201,7 +201,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function copyInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doCopyInternal( $params );
$this->clearCache( array( $params['dst'] ) );
if ( !isset( $params['dstExists'] ) || $params['dstExists'] ) {
@@ -233,7 +233,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function deleteInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doDeleteInternal( $params );
$this->clearCache( array( $params['src'] ) );
$this->deleteFileCache( $params['src'] ); // persistent cache
@@ -267,7 +267,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function moveInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = $this->doMoveInternal( $params );
$this->clearCache( array( $params['src'], $params['dst'] ) );
$this->deleteFileCache( $params['src'] ); // persistent cache
@@ -313,7 +313,7 @@ abstract class FileBackendStore extends FileBackend {
* @return Status
*/
final public function describeInternal( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
if ( count( $params['headers'] ) ) {
$status = $this->doDescribeInternal( $params );
$this->clearCache( array( $params['src'] ) );
@@ -346,7 +346,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function concatenate( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Try to lock the source files for the scope of this function
@@ -439,7 +439,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doPrepare( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -474,7 +474,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doSecure( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -509,7 +509,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doPublish( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
list( $fullCont, $dir, $shard ) = $this->resolveStoragePath( $params['dir'] );
@@ -544,7 +544,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doClean( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Recursive: first delete all empty subdirs recursively
@@ -600,21 +600,21 @@ abstract class FileBackendStore extends FileBackend {
}
final public function fileExists( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return ( $stat === null ) ? null : (bool)$stat; // null => failure
}
final public function getFileTimestamp( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return $stat ? $stat['mtime'] : false;
}
final public function getFileSize( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$stat = $this->getFileStat( $params );
return $stat ? $stat['size'] : false;
@@ -625,9 +625,9 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$latest = !empty( $params['latest'] ); // use latest data?
- if ( !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
+ if ( !$latest && !$this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
$this->primeFileCache( array( $path ) ); // check persistent cache
}
if ( $this->cheapCache->has( $path, 'stat', self::CACHE_TTL ) ) {
@@ -644,9 +644,7 @@ abstract class FileBackendStore extends FileBackend {
}
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$stat = $this->doGetFileStat( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
if ( is_array( $stat ) ) { // file exists
// Strongly consistent backends can automatically set "latest"
$stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest;
@@ -679,7 +677,7 @@ abstract class FileBackendStore extends FileBackend {
abstract protected function doGetFileStat( array $params );
public function getFileContentsMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
$contents = $this->doGetFileContentsMulti( $params );
@@ -708,7 +706,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$latest = !empty( $params['latest'] ); // use latest data?
if ( $this->cheapCache->has( $path, 'xattr', self::CACHE_TTL ) ) {
$stat = $this->cheapCache->get( $path, 'xattr' );
@@ -718,12 +716,8 @@ abstract class FileBackendStore extends FileBackend {
return $stat['map'];
}
}
- wfProfileIn( __METHOD__ . '-miss' );
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$fields = $this->doGetFileXAttributes( $params );
$fields = is_array( $fields ) ? self::normalizeXAttributes( $fields ) : false;
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
- wfProfileOut( __METHOD__ . '-miss' );
$this->cheapCache->set( $path, 'xattr', array( 'map' => $fields, 'latest' => $latest ) );
return $fields;
@@ -742,7 +736,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $path === null ) {
return false; // invalid storage path
}
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$latest = !empty( $params['latest'] ); // use latest data?
if ( $this->cheapCache->has( $path, 'sha1', self::CACHE_TTL ) ) {
$stat = $this->cheapCache->get( $path, 'sha1' );
@@ -752,9 +746,7 @@ abstract class FileBackendStore extends FileBackend {
return $stat['hash'];
}
}
- wfProfileIn( __METHOD__ . '-miss-' . $this->name );
$hash = $this->doGetFileSha1Base36( $params );
- wfProfileOut( __METHOD__ . '-miss-' . $this->name );
$this->cheapCache->set( $path, 'sha1', array( 'hash' => $hash, 'latest' => $latest ) );
return $hash;
@@ -775,7 +767,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getFileProps( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$fsFile = $this->getLocalReference( $params );
$props = $fsFile ? $fsFile->getProps() : FSFile::placeholderProps();
@@ -783,7 +775,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getLocalReferenceMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
@@ -826,7 +818,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function getLocalCopyMulti( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$params = $this->setConcurrencyFlags( $params );
$tmpFiles = $this->doGetLocalCopyMulti( $params );
@@ -851,7 +843,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function streamFile( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
$info = $this->getFileStat( $params );
@@ -865,9 +857,7 @@ abstract class FileBackendStore extends FileBackend {
if ( $res == StreamFile::NOT_MODIFIED ) {
// do nothing; client cache is up to date
} elseif ( $res == StreamFile::READY_STREAM ) {
- wfProfileIn( __METHOD__ . '-send-' . $this->name );
$status = $this->doStreamFile( $params );
- wfProfileOut( __METHOD__ . '-send-' . $this->name );
if ( !$status->isOK() ) {
// Per bug 41113, nasty things can happen if bad cache entries get
// stuck in cache. It's also possible that this error can come up
@@ -1071,7 +1061,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doOperationsInternal( array $ops, array $opts ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Fix up custom header name/value pairs...
@@ -1137,7 +1127,7 @@ abstract class FileBackendStore extends FileBackend {
}
final protected function doQuickOperationsInternal( array $ops ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$status = Status::newGood();
// Fix up custom header name/value pairs...
@@ -1198,13 +1188,13 @@ abstract class FileBackendStore extends FileBackend {
* The resulting Status object fields will correspond
* to the order in which the handles where given.
*
- * @param array $fileOpHandles
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
* @throws FileBackendError
- * @internal param array $handles List of FileBackendStoreOpHandle objects
* @return array Map of Status objects
*/
final public function executeOpHandlesInternal( array $fileOpHandles ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
foreach ( $fileOpHandles as $fileOpHandle ) {
if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
@@ -1223,9 +1213,11 @@ abstract class FileBackendStore extends FileBackend {
/**
* @see FileBackendStore::executeOpHandlesInternal()
- * @param array $fileOpHandles
+ *
+ * @param FileBackendStoreOpHandle[] $fileOpHandles
+ *
* @throws FileBackendError
- * @return array List of corresponding Status objects
+ * @return Status[] List of corresponding Status objects
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
if ( count( $fileOpHandles ) ) {
@@ -1300,7 +1292,7 @@ abstract class FileBackendStore extends FileBackend {
}
final public function preloadFileStat( array $params ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$success = true; // no network errors
$params['concurrency'] = ( $this->parallelize !== 'off' ) ? $this->concurrency : 1;
@@ -1372,7 +1364,7 @@ abstract class FileBackendStore extends FileBackend {
/**
* Check if a container name is valid.
- * This checks for for length and illegal characters.
+ * This checks for length and illegal characters.
*
* @param string $container
* @return bool
@@ -1623,7 +1615,7 @@ abstract class FileBackendStore extends FileBackend {
* @param array $items
*/
final protected function primeContainerCache( array $items ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$paths = array(); // list of storage paths
$contNames = array(); // (cache key => resolved container name)
@@ -1733,7 +1725,7 @@ abstract class FileBackendStore extends FileBackend {
* @param array $items List of storage paths
*/
final protected function primeFileCache( array $items ) {
- $section = new ProfileSection( __METHOD__ . "-{$this->name}" );
+ $ps = Profiler::instance()->scopedProfileIn( __METHOD__ . "-{$this->name}" );
$paths = array(); // list of storage paths
$pathNames = array(); // (cache key => storage path)
@@ -1755,17 +1747,18 @@ abstract class FileBackendStore extends FileBackend {
// Get all cache entries for these container cache keys...
$values = $this->memCache->getMulti( array_keys( $pathNames ) );
foreach ( $values as $cacheKey => $val ) {
+ $path = $pathNames[$cacheKey];
if ( is_array( $val ) ) {
- $path = $pathNames[$cacheKey];
+ $val['latest'] = false; // never completely trust cache
$this->cheapCache->set( $path, 'stat', $val );
if ( isset( $val['sha1'] ) ) { // some backends store SHA-1 as metadata
$this->cheapCache->set( $path, 'sha1',
- array( 'hash' => $val['sha1'], 'latest' => $val['latest'] ) );
+ array( 'hash' => $val['sha1'], 'latest' => false ) );
}
if ( isset( $val['xattr'] ) ) { // some backends store headers/metadata
$val['xattr'] = self::normalizeXAttributes( $val['xattr'] );
$this->cheapCache->set( $path, 'xattr',
- array( 'map' => $val['xattr'], 'latest' => $val['latest'] ) );
+ array( 'map' => $val['xattr'], 'latest' => false ) );
}
}
}