]> granicus.if.org Git - zfs/commitdiff
Illumos 6367 - spa_config_tryenter incorrectly handles the multiple-lock case
authorSaso Kiselkov <skiselkov@gmail.com>
Wed, 23 Dec 2015 20:02:43 +0000 (21:02 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 12 Jan 2016 19:05:28 +0000 (11:05 -0800)
6367 spa_config_tryenter incorrectly handles the multiple-lock case
Reviewed by: Alek Pinchuk <alek.pinchuk@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
Reviewed by: Prashanth Sreenivasa <prashksp@gmail.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Steven Hartland <steven.hartland@multiplay.co.uk>
Approved by: Matthew Ahrens <mahrens@delphix.com>

References:
  https://www.illumos.org/issues/6367
  https://github.com/illumos/illumos-gate/commit/e495b6e

Ported-by: kernelOfTruth kerneloftruth@gmail.com
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
module/zfs/spa_misc.c

index 409dce12121276ce97e08d0a3477112e4957c1a5..ec7c807a49c4a62363258074613b937753a07db0 100644 (file)
@@ -21,7 +21,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2014 Spectra Logic Corporation, All rights reserved.
  */
 
@@ -385,14 +385,16 @@ spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw)
                if (rw == RW_READER) {
                        if (scl->scl_writer || scl->scl_write_wanted) {
                                mutex_exit(&scl->scl_lock);
-                               spa_config_exit(spa, locks ^ (1 << i), tag);
+                               spa_config_exit(spa, locks & ((1 << i) - 1),
+                                   tag);
                                return (0);
                        }
                } else {
                        ASSERT(scl->scl_writer != curthread);
                        if (!refcount_is_zero(&scl->scl_count)) {
                                mutex_exit(&scl->scl_lock);
-                               spa_config_exit(spa, locks ^ (1 << i), tag);
+                               spa_config_exit(spa, locks & ((1 << i) - 1),
+                                   tag);
                                return (0);
                        }
                        scl->scl_writer = curthread;