From 460837e900de83b16e76786aab106c3f8b14dfb4 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Wed, 11 Nov 2020 08:53:52 +0100 Subject: [PATCH] rados: add LIBRADOS_OP_FLAG_* constants The LIBRADOS_OP_FLAG_* constants can be passed to rbd_writesame() and other operations that will be added in the future. Signed-off-by: Niels de Vos --- rados/rados.go | 27 +++++++++++++++++++++++++++ rados/rados_nautilus.go | 12 ++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 rados/rados_nautilus.go diff --git a/rados/rados.go b/rados/rados.go index d1f000a..b18fe08 100644 --- a/rados/rados.go +++ b/rados/rados.go @@ -25,6 +25,33 @@ const ( RadosAllNamespaces = AllNamespaces ) +// OpFlags are flags that can be set on a per-op basis. +type OpFlags uint + +const ( + // OpFlagNone can be use to not set any flags. + OpFlagNone = OpFlags(0) + // OpFlagExcl marks an op to fail a create operation if the object + // already exists. + OpFlagExcl = OpFlags(C.LIBRADOS_OP_FLAG_EXCL) + // OpFlagFailOk allows the transaction to succeed even if the flagged + // op fails. + OpFlagFailOk = OpFlags(C.LIBRADOS_OP_FLAG_FAILOK) + // OpFlagFAdviseRandom indicates read/write op random. + OpFlagFAdviseRandom = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_RANDOM) + // OpFlagFAdviseSequential indicates read/write op sequential. + OpFlagFAdviseSequential = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_SEQUENTIAL) + // OpFlagFAdviseWillNeed indicates read/write data will be accessed in + // the near future (by someone). + OpFlagFAdviseWillNeed = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_WILLNEED) + // OpFlagFAdviseDontNeed indicates read/write data will not accessed in + // the near future (by anyone). + OpFlagFAdviseDontNeed = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_DONTNEED) + // OpFlagFAdviseNoCache indicates read/write data will not accessed + // again (by *this* client). + OpFlagFAdviseNoCache = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_NOCACHE) +) + // Version returns the major, minor, and patch components of the version of // the RADOS library linked against. func Version() (int, int, int) { diff --git a/rados/rados_nautilus.go b/rados/rados_nautilus.go new file mode 100644 index 0000000..e12e62a --- /dev/null +++ b/rados/rados_nautilus.go @@ -0,0 +1,12 @@ +// +build !mimic + +package rados + +// #include +import "C" + +const ( + // OpFlagFAdviseFUA optionally support FUA (force unit access) on write + // requests. + OpFlagFAdviseFUA = OpFlags(C.LIBRADOS_OP_FLAG_FADVISE_FUA) +)