Add ability for ceph driver to report discard

Currently, ceph backend has supported discard.
RBD images are sparse, thus size after creation is equal to 0 MB.
The main issue with sparse images is that images grow to
eventually reach their entire size. The thing is Ceph doesn’t know
anything that this happening on top of that block especially
if you have a filesystem. You can easily write the entire filesystem
and then delete everything, Ceph will still believe that the block is
fully used and will keep that metric.
However thanks to the discard support on the block device,
the filesystem can send discard flush commands to the block.
In the end, the storage will free up blocks.
This feature was added into the Kernel 3.18.

So far the openstack enable discard support for virtual machine
ephemeral root disk.
a link to external (Ceph) docs:
http://docs.ceph.com/docs/master/rbd/rbd-openstack/

this bp enable discard support for the attached volume.

Thanks Danny Wilson's work, on this basis, I just add support for CEPH
https://blueprints.launchpad.net/cinder/+spec/cinder-backend-report-discard  #noqa

test:
[root@2C5_19_CG1 ~]# rados -p vms_20 ls|grep rbd_data.63bd1445fe6 |wc -l
478
after deleting files in the virtual machine
[root@2C5_19_CG1 ~]# rados -p vms_20 ls|grep rbd_data.63bd1445fe6 |wc -l
354
So, this patch adds ability for ceph driver to report discard

Change-Id: I094163b99d858384584966d65e9d8756c74a0c15
Implements: blueprint ceph-report-discard
This commit is contained in:
Ji-Wei 2016-08-11 17:22:49 +08:00 committed by JiWei
parent 451e4fcda4
commit bea5437ecb
2 changed files with 3 additions and 1 deletions

View File

@ -879,7 +879,8 @@ class RBDTestCase(test.TestCase):
'auth_username': None,
'secret_type': 'ceph',
'secret_uuid': None,
'volume_id': self.volume_a.id
'volume_id': self.volume_a.id,
'discard': True,
}
}
actual = self.driver.initialize_connection(self.volume_a, None)

View File

@ -831,6 +831,7 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
'secret_type': 'ceph',
'secret_uuid': self.configuration.rbd_secret_uuid,
'volume_id': volume.id,
"discard": True,
}
}
LOG.debug('connection data: %s', data)