code: func (devices *DeviceSet) AddDevice(hash, baseHash string, storageOpt map[string]string) error {
  	logrus.WithField("storage-driver", "devicemapper").Debugf("AddDevice START(hash=%s basehash=%s)", hash, baseHash)
  	defer logrus.WithField("storage-driver", "devicemapper").Debugf("AddDevice END(hash=%s basehash=%s)", hash, baseHash)
  
  	// If a deleted device exists, return error.
  	baseInfo, err := devices.lookupDeviceWithLock(baseHash)
  	if err != nil {
  		return err
  	}
  
  	if baseInfo.Deleted {
  		return fmt.Errorf("devmapper: Base device %v has been marked for deferred deletion", baseInfo.Hash)
  	}
  
  	baseInfo.lock.Lock()
  	defer baseInfo.lock.Unlock()
  
  	devices.Lock()
  	defer devices.Unlock()
  
  	// Also include deleted devices in case hash of new device is
  	// same as one of the deleted devices.
  	if info, _ := devices.lookupDevice(hash); info != nil {
  		return fmt.Errorf("devmapper: device %s already exists. Deleted=%v", hash, info.Deleted)
  	}
  
  	size, err := devices.parseStorageOpt(storageOpt)
  	if err != nil {
  		return err
  	}
  
  	if size == 0 {
  		size = baseInfo.Size
  	}
  
  	if size < baseInfo.Size {
  		return fmt.Errorf("devmapper: Container size cannot be smaller than %s", units.HumanSize(float64(baseInfo.Size)))
  	}
  
  	if err := devices.takeSnapshot(hash, baseInfo, size); err != nil {
  		return err
  	}
  
  	// Grow the container rootfs.
  	if size > baseInfo.Size {
  		info, err := devices.lookupDevice(hash)
  		if err != nil {
  			return err
  		}
  
  		if err := devices.growFS(info); err != nil {
  			return err
  		}
  	}
  
  	return nil
  }
docs: // AddDevice adds a device and registers in the hash.