Openstack make volume deletion super fast

Posted: May 24, 2014 in Uncategorized

In my Folsom Openstack setup intalled by DevStack, it takes more than 5minutes to delete a volume with the size 50 GB.

Why it takes a longer time.

When a volume is deleted, Openstack tries to clean the memory allocated for the volume. Volume memory is cleaned by writing zeros to the volume (dd if=/dev/zero ). Memory is cleaned as a security measure.  If the volume is deleted without cleaning the memory, the data stored in the volume may be visible to the volumes which will be created next. When the volume is larger (say 50GB) this memory cleaning takes a long time.

What are the work arounds

The default behavior can be changed by editing the Cinder configurations in /etc/cinder/cinder.conf  file.

Skipp clearing the volume memory

Setting volume_clear to none makes Openstack skipping clearing the volume memory

# Method used to wipe old volumes (valid options are: none,
# zero, shred) (string value)
Setting volume_clear=clear will clear the volumes.
If volume_clear=shred, Openstack will use the Linux “shred -n3″ command to clean the volumes which will securely overwrite the volume 3 times.
Clear only first part of volume
If you specify some value other than zero, Openstack will clear only that amount of MegaBytes of memory from the beginning of the memory allocated for the volume. This is useful  when the volume contains encrypted data because deleting part of the encrypted data will prevent it from being decrypted.
# Size in MiB to wipe at start of old volumes. 0 => all
# (integer value)
Please note that if volume_clear=none, this configuration parameter is ignored.
Delete only blocks that data is written on to

Setting lvm_type to thin will make Openstack to delete only the blocks some data has written on to. Openstack keep track of the blocks which data is written.

# Type of LVM volumes to deploy; (default or thin) (string
# value)
Openstack volume deletion code commit is pasted here for more clarification.
def clear_volume(self, volume):
         """unprovision old volumes to prevent data leaking between users."""
         vol_path = self.local_path(volume)
         size_in_g = volume.get('size')
         size_in_m = FLAGS.volume_clear_size
         if not size_in_g:
         if FLAGS.volume_clear == 'none':
 "Performing secure delete on volume: %s") % volume['id'])
         if FLAGS.volume_clear == 'zero':
             if size_in_m == 0:
                 return self._copy_volume('/dev/zero', vol_path, size_in_g)
                 clear_cmd = ['shred', '-n0', '-z', '-s%dMiB' % size_in_m]
         elif FLAGS.volume_clear == 'shred':
             clear_cmd = ['shred', '-n3']
             if size_in_m:
                 clear_cmd.append('-s%dMiB' % size_in_m)
             LOG.error(_("Error unrecognized volume_clear option: %s"),
         self._execute(*clear_cmd, run_as_root=True)
  1. […] 参考链接: […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s