diff --git a/src/Config/ConfigReadonlyStorage.php b/src/Config/ConfigReadonlyStorage.php
index c5a0347..69b5076 100644
--- a/src/Config/ConfigReadonlyStorage.php
+++ b/src/Config/ConfigReadonlyStorage.php
@@ -3,8 +3,15 @@
 namespace Drupal\config_readonly\Config;
 
 use Drupal\Core\Config\CachedStorage;
+use Drupal\Core\Config\ConfigImporter;
+use Drupal\Core\Config\StorageInterface;
+use Drupal\Core\Cache\CacheBackendInterface;
+use Drupal\Core\Lock\LockBackendInterface;
 use Drupal\Core\Site\Settings;
 
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Symfony\Component\HttpFoundation\RequestStack;
+
 /**
  * Defines the ConfigReadonly storage controller which will fail on write
  * operations.
@@ -12,14 +19,44 @@ use Drupal\Core\Site\Settings;
 class ConfigReadonlyStorage extends CachedStorage {
 
   /**
+   * The used lock backend instance.
+   *
+   * @var \Drupal\Core\Lock\LockBackendInterface
+   */
+  protected $lock;
+
+  /**
+   * The request stack.
+   *
+   * @var \Symfony\Component\HttpFoundation\RequestStack
+   */
+  protected $requestStack;
+
+  /**
+   * Constructs a new ConfigReadonlyStorage.
+   *
+   * @param \Drupal\Core\Config\StorageInterface $storage
+   *   A configuration storage to be cached.
+   * @param \Drupal\Core\Cache\CacheBackendInterface $cache
+   *   A cache backend used to store configuration.
+   * @param \Drupal\Core\Lock\LockBackendInterface $lock
+   *   The lock backend to check if config imports are in progress.
+   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
+   *   The request stack.
+   */
+  public function __construct(StorageInterface $storage, CacheBackendInterface $cache, LockBackendInterface $lock, RequestStack $request_stack) {
+    parent::__construct($storage, $cache);
+    $this->lock = $lock;
+    $this->requestStack = $request_stack;
+  }
+
+  /**
    * {@inheritdoc}
    *
    * @throws Exception
    */
   public function write($name, array $data) {
-    if ($this->read($name) != $data) {
-      $this->checkLock();
-    }
+    $this->checkLock();
     return parent::write($name, $data);
   }
 
@@ -57,7 +94,14 @@ class ConfigReadonlyStorage extends CachedStorage {
     // If settings.php says to lock config changes and if the config importer
     // isn't running (we do not want to lock config imports), then throw an
     // exception.
-    if (Settings::get('config_readonly') && \Drupal::lock()->lockMayBeAvailable('config.importer')) {
+    // @see \Drupal\Core\Config\ConfigImporter::alreadyImporting()
+    if (Settings::get('config_readonly') && $this->lock->lockMayBeAvailable(ConfigImporter::LOCK_NAME)) {
+      $request = $this->requestStack->getCurrentRequest();
+      if ($request && $request->attributes->get(RouteObjectInterface::ROUTE_NAME) === 'system.db_update') {
+        // We seem to be in the middle of running update.php
+        // @todo - always allow or support a flag for blocking it?
+        return;
+      }
       throw new \Exception('Your site configuration active store is currently locked.');
     }
   }
diff --git a/src/ConfigReadonlyServiceProvider.php b/src/ConfigReadonlyServiceProvider.php
index 62b07da..cb0d277 100644
--- a/src/ConfigReadonlyServiceProvider.php
+++ b/src/ConfigReadonlyServiceProvider.php
@@ -30,6 +30,7 @@ class ConfigReadonlyServiceProvider implements ServiceProviderInterface, Service
     if ($container->getParameter('kernel.environment') !== 'install') {
       $definition = $container->getDefinition('config.storage');
       $definition->setClass('Drupal\config_readonly\Config\ConfigReadonlyStorage');
+      $definition->setArguments([new Reference('config.storage.active'), new Reference('cache.config'), new Reference('lock'), new Reference('request_stack')]);
     }
   }
 }
