rbd: disable rbd_discard_on_zeroed_write_same for thick-allocation

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos
2021-01-22 16:20:36 +01:00
committed by mergify[bot]
parent 5522a05f59
commit 74d218df8d
2 changed files with 30 additions and 0 deletions

View File

@ -32,6 +32,8 @@ type ClusterConnection struct {
// FIXME: temporary reference for credentials. Remove this when go-ceph
// is used for operations.
Creds *Credentials
discardOnZeroedWriteSameDisabled bool
}
var (
@ -92,3 +94,22 @@ func (cc *ClusterConnection) GetFSAdmin() (*ca.FSAdmin, error) {
return ca.NewFromConn(cc.conn), nil
}
// DisableDiscardOnZeroedWriteSame enables the
// `rbd_discard_on_zeroed_write_same` option in the cluster connection, so that
// writing zero blocks of data are actual writes on the OSDs (doing
// allocations) and not discard calls. This makes writes much slower, but
// enables the option to do thick-provisioning.
func (cc *ClusterConnection) DisableDiscardOnZeroedWriteSame() error {
if cc.discardOnZeroedWriteSameDisabled {
return nil
}
err := cc.conn.SetConfigOption("rbd_discard_on_zeroed_write_same", "false")
if err != nil {
return err
}
cc.discardOnZeroedWriteSameDisabled = true
return nil
}