/** * @see FileBackend::doOperationsInternal() * @return Status */ protected final function doOperationsInternal(array $ops, array $opts) { wfProfileIn(__METHOD__); wfProfileIn(__METHOD__ . '-' . $this->name); $status = Status::newGood(); // Build up a list of FileOps... $performOps = $this->getOperationsInternal($ops); // Acquire any locks as needed... if (empty($opts['nonLocking'])) { // Build up a list of files to lock... $paths = $this->getPathsToLockForOpsInternal($performOps); // Try to lock those files for the scope of this function... $scopeLockS = $this->getScopedFileLocks($paths['sh'], LockManager::LOCK_UW, $status); $scopeLockE = $this->getScopedFileLocks($paths['ex'], LockManager::LOCK_EX, $status); if (!$status->isOK()) { wfProfileOut(__METHOD__ . '-' . $this->name); wfProfileOut(__METHOD__); return $status; // abort } } // Clear any file cache entries (after locks acquired) if (empty($opts['preserveCache'])) { $this->clearCache(); } // Load from the persistent file and container caches $this->primeFileCache($performOps); $this->primeContainerCache($performOps); // Actually attempt the operation batch... $subStatus = FileOpBatch::attempt($performOps, $opts, $this->fileJournal); // Merge errors into status fields $status->merge($subStatus); $status->success = $subStatus->success; // not done in merge() wfProfileOut(__METHOD__ . '-' . $this->name); wfProfileOut(__METHOD__); return $status; }
protected final function doOperationsInternal(array $ops, array $opts) { $ps = $this->scopedProfileSection(__METHOD__ . "-{$this->name}"); $status = $this->newStatus(); // Fix up custom header name/value pairs... $ops = array_map([$this, 'sanitizeOpHeaders'], $ops); // Build up a list of FileOps... $performOps = $this->getOperationsInternal($ops); // Acquire any locks as needed... if (empty($opts['nonLocking'])) { // Build up a list of files to lock... $paths = $this->getPathsToLockForOpsInternal($performOps); // Try to lock those files for the scope of this function... $scopeLock = $this->getScopedFileLocks($paths, 'mixed', $status); if (!$status->isOK()) { return $status; // abort } } // Clear any file cache entries (after locks acquired) if (empty($opts['preserveCache'])) { $this->clearCache(); } // Build the list of paths involved $paths = []; foreach ($performOps as $performOp) { $paths = array_merge($paths, $performOp->storagePathsRead()); $paths = array_merge($paths, $performOp->storagePathsChanged()); } // Enlarge the cache to fit the stat entries of these files $this->cheapCache->resize(max(2 * count($paths), self::CACHE_CHEAP_SIZE)); // Load from the persistent container caches $this->primeContainerCache($paths); // Get the latest stat info for all the files (having locked them) $ok = $this->preloadFileStat(['srcs' => $paths, 'latest' => true]); if ($ok) { // Actually attempt the operation batch... $opts = $this->setConcurrencyFlags($opts); $subStatus = FileOpBatch::attempt($performOps, $opts, $this->fileJournal); } else { // If we could not even stat some files, then bail out... $subStatus = $this->newStatus('backend-fail-internal', $this->name); foreach ($ops as $i => $op) { // mark each op as failed $subStatus->success[$i] = false; ++$subStatus->failCount; } $this->logger->error(get_class($this) . "-{$this->name} " . " stat failure; aborted operations: " . FormatJson::encode($ops)); } // Merge errors into StatusValue fields $status->merge($subStatus); $status->success = $subStatus->success; // not done in merge() // Shrink the stat cache back to normal size $this->cheapCache->resize(self::CACHE_CHEAP_SIZE); return $status; }
protected final function doOperationsInternal(array $ops, array $opts) { $section = new ProfileSection(__METHOD__ . "-{$this->name}"); $status = Status::newGood(); // Fix up custom header name/value pairs... $ops = array_map(array($this, 'stripInvalidHeadersFromOp'), $ops); // Build up a list of FileOps... $performOps = $this->getOperationsInternal($ops); // Acquire any locks as needed... if (empty($opts['nonLocking'])) { // Build up a list of files to lock... $paths = $this->getPathsToLockForOpsInternal($performOps); // Try to lock those files for the scope of this function... $scopeLock = $this->getScopedFileLocks($paths, 'mixed', $status); if (!$status->isOK()) { return $status; // abort } } // Clear any file cache entries (after locks acquired) if (empty($opts['preserveCache'])) { $this->clearCache(); } // Build the list of paths involved $paths = array(); foreach ($performOps as $op) { $paths = array_merge($paths, $op->storagePathsRead()); $paths = array_merge($paths, $op->storagePathsChanged()); } // Load from the persistent container caches $this->primeContainerCache($paths); // Get the latest stat info for all the files (having locked them) $this->preloadFileStat(array('srcs' => $paths, 'latest' => true)); // Actually attempt the operation batch... $opts = $this->setConcurrencyFlags($opts); $subStatus = FileOpBatch::attempt($performOps, $opts, $this->fileJournal); // Merge errors into status fields $status->merge($subStatus); $status->success = $subStatus->success; // not done in merge() return $status; }