                 opts.cb()
 
 _smc_storage_queue = []
-_smc_storage_queue_lock = false
+_smc_storage_queue_running = 0
 
 smc_storage = (opts) =>
     opts = defaults opts,

    process_smc_storage_queue()

process_smc_storage_queue = () ->
    if _smc_storage_queue_lock
        return
    if _smc_storage_queue.length > 0
        opts = _smc_storage_queue.shift()
        _smc_storage_queue_lock = true
        cb = opts.cb
        opts.cb = (err, output) =>
            _smc_storage_queue_lock = false
            process_smc_storage_queue()
            cb(err, output)
        _smc_storage_no_queue(opts)

## server-side: Storage server code
###########################

# We limit the maximum number of simultaneous smc_storage.py calls to allow at once, since
# this allows us to control ZFS contention, deadlocking, etc.
SMC_STORAGE_LIMIT = 3

# Execute a command using the smc_storage script.
_smc_storage_no_queue = (opts) =>
