From: Aaron Schulz Date: Tue, 18 Mar 2014 06:47:53 +0000 (-0700) Subject: Make use of strong consistency with Ceph RGW X-Git-Tag: 1.31.0-rc.0~16572 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=6112acac292e4a7cf926cf556138e7b711e2c9eb;p=lhc%2Fweb%2Fwiklou.git Make use of strong consistency with Ceph RGW Change-Id: Ic3b764363e91c3279d3dc017ddce630dae26bec5 --- diff --git a/includes/filebackend/FileBackendStore.php b/includes/filebackend/FileBackendStore.php index 16300af3ae..2d8214edc5 100644 --- a/includes/filebackend/FileBackendStore.php +++ b/includes/filebackend/FileBackendStore.php @@ -648,7 +648,8 @@ abstract class FileBackendStore extends FileBackend { $stat = $this->doGetFileStat( $params ); wfProfileOut( __METHOD__ . '-miss-' . $this->name ); if ( is_array( $stat ) ) { // file exists - $stat['latest'] = $latest; + // Strongly consistent backends can automatically set "latest" + $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest; $this->cheapCache->set( $path, 'stat', $stat ); $this->setFileCache( $path, $stat ); // update persistent cache if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata @@ -1295,7 +1296,8 @@ abstract class FileBackendStore extends FileBackend { continue; // this shouldn't happen } if ( is_array( $stat ) ) { // file exists - $stat['latest'] = $latest; + // Strongly consistent backends can automatically set "latest" + $stat['latest'] = isset( $stat['latest'] ) ? $stat['latest'] : $latest; $this->cheapCache->set( $path, 'stat', $stat ); $this->setFileCache( $path, $stat ); // update persistent cache if ( isset( $stat['sha1'] ) ) { // some backends store SHA-1 as metadata diff --git a/includes/filebackend/SwiftFileBackend.php b/includes/filebackend/SwiftFileBackend.php index 706da96c46..7050226985 100644 --- a/includes/filebackend/SwiftFileBackend.php +++ b/includes/filebackend/SwiftFileBackend.php @@ -72,6 +72,9 @@ class SwiftFileBackend extends FileBackendStore { /** @var int UNIX timestamp */ protected $authErrorTimestamp = null; + /** @var bool Whether the server is an Ceph RGW */ + protected $isRGW = false; + /** * @see FileBackendStore::__construct() * Additional $config params include: @@ -1518,6 +1521,9 @@ class SwiftFileBackend extends FileBackendStore { 'md5' => ctype_xdigit( $rhdrs['etag'] ) ? $rhdrs['etag'] : null, 'xattr' => array( 'metadata' => $metadata, 'headers' => $headers ) ); + if ( $this->isRGW ) { + $stat['latest'] = true; // strong consistency + } } elseif ( $rcode === 404 ) { $stat = false; } else { @@ -1582,6 +1588,10 @@ class SwiftFileBackend extends FileBackendStore { return null; } } + // Ceph RGW does not use in URLs (OpenStack Swift uses "/v1/") + if ( substr( $this->authCreds['storage_url'], -3 ) === '/v1' ) { + $this->isRGW = true; // take advantage of strong consistency + } } return $this->authCreds;