CEPH_RBD_API: options on image create
Hi,
It was mentioned several times eralier that it would be nice to pass options as key/value configuration pairs on image create instead of expanding rbd_create/rbd_clone/rbd_copy for every possible configuration override.
What do you think about this API?
Introduce rbd_image_options_t and functions to manipulate it:
int rbd_image_options_create(rbd_image_options_t* opts);
void rbd_image_options_destroy(rbd_image_options_t opts);
int rbd_image_options_set(rbd_image_options_t opts, int optname,
const void* optval, size_t optlen);
int rbd_image_options_get(rbd_image_options_t opts, int optname,
void* optval, size_t* optlen);
void rbd_image_options_iterate(rbd_image_options_t opts,
void (*func)(int* optname, void* optval, size_t* optlen));
Functions that return a value return 0 on success, and -ERROR on failure.
optname is a constant like RBD_OPTION_STRIPE_UNIT, RBD_OPTION_STRIPE_COUNT...
Pass options as additional argument to rbd_create, rbd_clone (and may be rbd_copy) functions:
int rbd_create4(rados_ioctx_t io, const char *name, uint64_t size,
uint64_t features, int *order, rbd_image_options_t opts);
int rbd_clone3(rados_ioctx_t p_ioctx, const char *p_name,
const char *p_snapname, rados_ioctx_t c_ioctx, const char *c_name, uint64_t features, int *c_order, rbd_image_options_t opts);
int rbd_copy3(rbd_image_t src, rbd_image_t dest, rbd_image_options_t opts); // possibly
Example:
rbd_image_options_t opts;
int r;
r = rbd_image_options_create(&opts);
assert(r == 0);uint64_t stripe_unit = 65536;
r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_UNIT,
&stripe_unit, size_of(stripe_unit));
assert(r == 0);
uint64_t stripe_count = 16;
r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_COUNT,
&stripe_count, size_of(stripe_count));
assert(r == 0);
const char* journal_object_pool = "journal";
r = rbd_image_options_set(opts, RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool, strlen(journal_object_pool) + 1);assert(r == 0);
r = rbd_create4(io, name, size, features, int *order, rbd_image_options_t opts);
cleanup:rbd_image_options_destroy(opts);
Signature · 1 line
Mykola Golub
In general, I like the approach.
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated RBD_OPTION_STRIPE_UNIT as a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string? Therefore, I would vote for passing strings a la librados rados_conf_set.
Perhaps rbd_create4 and rbd_clone3 should move the order and features options to rbd_image_options_t as well?
Signature · 4 lines
Jason Dillaman ----- Original Message -----
Quoted 84 lines
From: "Mykola Golub" <[email protected]>
To: [email protected]
Cc: "Jason Dillaman" <[email protected]>, "Josh Durgin" <[email protected]>
Sent: Wednesday, September 30, 2015 2:50:45 AM
Subject:CEPH_RBD_API: options on image createHi,
It was mentioned several times eralier that it would be nice to pass options as key/value configuration pairs on image create instead of expanding rbd_create/rbd_clone/rbd_copy for every possible configuration override.
What do you think about this API?
Introduce
rbd_image_options_tand functions to manipulate it:int
rbd_image_options_create(rbd_image_options_t* opts);void
rbd_image_options_destroy(rbd_image_options_t opts);int rbd_image_options_set(rbd_image_options_t opts, int optname,
const void* optval, size_t optlen);int rbd_image_options_get(rbd_image_options_t opts, int optname,
void* optval, size_t* optlen);void rbd_image_options_iterate(rbd_image_options_t opts,
void (*func)(int* optname, void* optval, size_t* optlen));Functions that return a value return 0 on success, and
-ERRORon failure.optname is a constant like
RBD_OPTION_STRIPE_UNIT,RBD_OPTION_STRIPE_COUNT...Pass options as additional argument to
rbd_create,rbd_clone(and may berbd_copy) functions:int rbd_create4(rados_ioctx_t io, const char *name,
uint64_tsize,uint64_t features, int *order, rbd_image_options_t opts);int rbd_clone3(rados_ioctx_t
p_ioctx, const char*p_name,
const char*p_snapname,rados_ioctx_tc_ioctx, const char*c_name,uint64_tfeatures, int*c_order,rbd_image_options_topts);int
rbd_copy3(rbd_image_t src, rbd_image_t dest, rbd_image_options_t opts); // possiblyExample:
rbd_image_options_topts;
int r;
r =rbd_image_options_create(&opts);
assert(r == 0);uint64_tstripe_unit= 65536;
r = rbd_image_options_set(opts,RBD_OPTION_STRIPE_UNIT,&stripe_unit, size_of(stripe_unit)); assert(r == 0); uint64_t stripe_count = 16; r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_COUNT, &stripe_count, size_of(stripe_count));assert(r == 0);
const char*journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
assert(r == 0);
r =rbd_create4(io, name, size, features, int *order, rbd_image_options_t opts);cleanup:
rbd_image_options_destroy(opts);--
Mykola Golub
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · Jason Dillaman
In general, I like the approach.
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated
RBD_OPTION_STRIPE_UNITas a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string? Therefore, I would vote for passing strings a la libradosrados_conf_set.
It seems like that'd be a bit clunky from C, since you'd need to create and fill in buffers for each option.
For safety we could have typed rbd_image_options_{get,set} for char* and uint64_t - it doesn't seem like we need any other types right now, since uint64_t is a superset of what we use int for.
Another alternative is a single get/set that takes a tagged union, e.g.
struct rbd_image_option {
int option;
int type;
union {
uint64_t ui
int i
char* s // NUL-terminated
};
}where type is an enum of RBD_OPTION_TYPE_{UINT64,INT,STRING} or similar.
Quoted 1 line
Perhaps
rbd_create4andrbd_clone3should move the order and features options torbd_image_options_tas well?
Sounds good - no reason to keep mandatory parameters for options with defaults.
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Hi,
It was mentioned several times eralier that it would be nice to pass options as key/value configuration pairs on image create instead of expanding rbd_create/rbd_clone/rbd_copy for every possible configuration override.
What do you think about this API?
Introduce
rbd_image_options_tand functions to manipulate it:int
rbd_image_options_create(rbd_image_options_t* opts);void
rbd_image_options_destroy(rbd_image_options_t opts);int rbd_image_options_set(rbd_image_options_t opts, int optname,
const void* optval, size_t optlen);int rbd_image_options_get(rbd_image_options_t opts, int optname,
void* optval, size_t* optlen);void rbd_image_options_iterate(rbd_image_options_t opts,
void (*func)(int* optname, void* optval, size_t* optlen));Functions that return a value return 0 on success, and
-ERRORon failure.optname is a constant like
RBD_OPTION_STRIPE_UNIT,RBD_OPTION_STRIPE_COUNT...Pass options as additional argument to
rbd_create,rbd_clone(and may berbd_copy) functions:int rbd_create4(rados_ioctx_t io, const char *name,
uint64_tsize,uint64_t features, int *order, rbd_image_options_t opts);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
int rbd_clone3(rados_ioctx_t
p_ioctx, const char*p_name,
const char*p_snapname,rados_ioctx_tc_ioctx, const char*c_name,uint64_tfeatures, int*c_order,rbd_image_options_topts);int
rbd_copy3(rbd_image_t src, rbd_image_t dest, rbd_image_options_t opts); // possibly
I'm ambivalent about a copy3. If you'd like to implement it, it should use the form that creates the destination image:
int rbd_copy3(rbd_image_t src, rados_ioctx_t dest_io_ctx,
const char *destname);
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Example:
rbd_image_options_topts;
int r;
r =rbd_image_options_create(&opts);
assert(r == 0);uint64_tstripe_unit= 65536;
r = rbd_image_options_set(opts,RBD_OPTION_STRIPE_UNIT,&stripe_unit, size_of(stripe_unit)); assert(r == 0); uint64_t stripe_count = 16; r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_COUNT, &stripe_count, size_of(stripe_count));assert(r == 0);
const char*journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
assert(r == 0);
r =rbd_create4(io, name, size, features, int *order, rbd_image_options_t opts);
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cleanup:
rbd_image_options_destroy(opts);
I like the API in general. The ability to reuse the same options or make small changes to them is nice.
Josh
Quoted 7 lines · Jason Dillaman
In general, I like the approach.
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated
RBD_OPTION_STRIPE_UNITas a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string?
Then rbd_image_options_set() will fail with EINVAL, because the option type (size) is a part of interface.
I do this by analogy to setsockopt(2):
http://pubs.opengroup.org/onlinepubs/009695399/functions/setsockopt.html
Note option type documented for every option there, and it works fairly well.
Following a common practice is an additional argument to this approach to me.
Quoted 2 lines
Therefore, I would vote for passing strings a la librados
rados_conf_set.
I'd rather don't use this approach, as it adds unnecessary work on both user (encode the option to string) and backend (decode from string) sides.
Quoted 2 lines
Perhaps
rbd_create4andrbd_clone3should move the order and features options torbd_image_options_tas well?
My initial thought was that a user would want to set features and orders more frequently than other options, so keeping them as additional arguments would be useful. But now thinking more about it, I agree that they can be moved to options.
Quoted 94 lines
Signature · 4 lines
Jason Dillaman ----- Original Message -----Quoted 77 lines
From: "Mykola Golub" <[email protected]>
To: [email protected]
Cc: "Jason Dillaman" <[email protected]>, "Josh Durgin" <[email protected]>
Sent: Wednesday, September 30, 2015 2:50:45 AM
Subject:CEPH_RBD_API: options on image createHi,
It was mentioned several times eralier that it would be nice to pass options as key/value configuration pairs on image create instead of expanding rbd_create/rbd_clone/rbd_copy for every possible configuration override.
What do you think about this API?
Introduce
rbd_image_options_tand functions to manipulate it:int
rbd_image_options_create(rbd_image_options_t* opts);void
rbd_image_options_destroy(rbd_image_options_t opts);int rbd_image_options_set(rbd_image_options_t opts, int optname,
const void* optval, size_t optlen);int rbd_image_options_get(rbd_image_options_t opts, int optname,
void* optval, size_t* optlen);void rbd_image_options_iterate(rbd_image_options_t opts,
void (*func)(int* optname, void* optval, size_t* optlen));Functions that return a value return 0 on success, and
-ERRORon failure.optname is a constant like
RBD_OPTION_STRIPE_UNIT,RBD_OPTION_STRIPE_COUNT...Pass options as additional argument to
rbd_create,rbd_clone(and may berbd_copy) functions:int rbd_create4(rados_ioctx_t io, const char *name,
uint64_tsize,uint64_t features, int *order, rbd_image_options_t opts);int rbd_clone3(rados_ioctx_t
p_ioctx, const char*p_name,
const char*p_snapname,rados_ioctx_tc_ioctx, const char*c_name,uint64_tfeatures, int*c_order,rbd_image_options_topts);int
rbd_copy3(rbd_image_t src, rbd_image_t dest, rbd_image_options_t opts); // possiblyExample:
rbd_image_options_topts;
int r;
r =rbd_image_options_create(&opts);
assert(r == 0);uint64_tstripe_unit= 65536;
r = rbd_image_options_set(opts,RBD_OPTION_STRIPE_UNIT,&stripe_unit, size_of(stripe_unit)); assert(r == 0); uint64_t stripe_count = 16; r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_COUNT, &stripe_count, size_of(stripe_count));assert(r == 0);
const char*journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
assert(r == 0);
r =rbd_create4(io, name, size, features, int *order, rbd_image_options_t opts);cleanup:
rbd_image_options_destroy(opts);Quoted 7 lines
--
Mykola Golub
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Mykola Golub
Quoted 11 lines · Josh Durgin
Quoted 3 lines · Jason Dillaman
In general, I like the approach.
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated
RBD_OPTION_STRIPE_UNITas a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string? Therefore, I would vote for passing strings a la libradosrados_conf_set.It seems like that'd be a bit clunky from C, since you'd need to create and fill in buffers for each option.
For safety we could have typed rbd_image_options_{get,set} for char* and
uint64_t- it doesn't seem like we need any other types right now, sinceuint64_tis a superset of what we use int for.
I like this approach much more than using string, due to its simplicity. I prefer it if my reasoning about my initial version I sent in the response to Jason doesn't change your mind, guys.
Quoted 13 lines
Another alternative is a single get/set that takes a tagged union, e.g.
struct rbd_image_option { int option; int type; union { uint64_t ui int i char* s // NUL-terminated }; }
Quoted 2 lines
where type is an enum of RBD_OPTION_TYPE_{UINT64,INT,STRING} or similar.
Could do this way, it is ok to me too, though I like it a little less than my version as I expect the code to encode/decode this would be a little more complicated.
So, summarizing, I am listing the discussed approaches in the order I like them from more to less.
1) initial variant (void*, lenght)
2) rbd_image_options_{get,set}_{uint64,str}
3) struct rbd_image_option
4) use string for options
Please tell me what you like more, I agree to do any way.
Thanks.
Quoted 92 lines
Quoted 2 lines
Perhaps
rbd_create4andrbd_clone3should move the order and features options torbd_image_options_tas well?Sounds good - no reason to keep mandatory parameters for options with defaults.
Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
Hi,
It was mentioned several times eralier that it would be nice to pass options as key/value configuration pairs on image create instead of expanding rbd_create/rbd_clone/rbd_copy for every possible configuration override.
What do you think about this API?
Introduce
rbd_image_options_tand functions to manipulate it:int
rbd_image_options_create(rbd_image_options_t* opts);void
rbd_image_options_destroy(rbd_image_options_t opts);int rbd_image_options_set(rbd_image_options_t opts, int optname,
const void* optval, size_t optlen);int rbd_image_options_get(rbd_image_options_t opts, int optname,
void* optval, size_t* optlen);void rbd_image_options_iterate(rbd_image_options_t opts,
void (*func)(int* optname, void* optval, size_t* optlen));Functions that return a value return 0 on success, and
-ERRORon failure.optname is a constant like
RBD_OPTION_STRIPE_UNIT,RBD_OPTION_STRIPE_COUNT...Pass options as additional argument to
rbd_create,rbd_clone(and may berbd_copy) functions:int rbd_create4(rados_ioctx_t io, const char *name,
uint64_tsize,uint64_t features, int *order, rbd_image_options_t opts);Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
int rbd_clone3(rados_ioctx_t
p_ioctx, const char*p_name,
const char*p_snapname,rados_ioctx_tc_ioctx, const char*c_name,uint64_tfeatures, int*c_order,rbd_image_options_topts);int
rbd_copy3(rbd_image_t src, rbd_image_t dest, rbd_image_options_t opts); // possiblyI'm ambivalent about a copy3. If you'd like to implement it, it should use the form that creates the destination image:
int rbd_copy3(rbd_image_t src,
rados_ioctx_tdest_io_ctx,const char *destname);Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Example:
rbd_image_options_topts;
int r;
r =rbd_image_options_create(&opts);
assert(r == 0);uint64_tstripe_unit= 65536;
r = rbd_image_options_set(opts,RBD_OPTION_STRIPE_UNIT,&stripe_unit, size_of(stripe_unit)); assert(r == 0); uint64_t stripe_count = 16; r = rbd_image_options_set(opts, RBD_OPTION_STRIPE_COUNT, &stripe_count, size_of(stripe_count));assert(r == 0);
const char*journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
assert(r == 0);
r =rbd_create4(io, name, size, features, int *order, rbd_image_options_t opts);Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cleanup:
rbd_image_options_destroy(opts);I like the API in general. The ability to reuse the same options or make small changes to them is nice.
Josh
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
Mykola Golub
Quoted 11 lines
Quoted 5 lines
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated
RBD_OPTION_STRIPE_UNITas a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string?Then
rbd_image_options_set()will fail with EINVAL, because the option type (size) is a part of interface.I do this by analogy to setsockopt(2):
Quoted 7 lines
http://pubs.opengroup.org/onlinepubs/009695399/functions/setsockopt.html
Note option type documented for every option there, and it works fairly well.
Following a common practice is an additional argument to this approach to me.
Except for the following cases:
sizeof(char*) == sizeof(uint32_t) (32bit)sizeof(char*) == sizeof(uint64_t) (64bit)
Signature · 1 line
Jason Dillaman
Quoted 16 lines · Jason Dillaman
Quoted 16 lines
Quoted 5 lines
I am concerned about passing a void* + length to specify the option value since you really can't protect against the user providing data in the incorrect format. For example, if the backend treated
RBD_OPTION_STRIPE_UNITas a 4byte int, what happens if someone passes a 2- or 8-byte int or a 4-byte char* string?Then
rbd_image_options_set()will fail with EINVAL, because the option type (size) is a part of interface.I do this by analogy to setsockopt(2):
http://pubs.opengroup.org/onlinepubs/009695399/functions/setsockopt.html
Note option type documented for every option there, and it works fairly well.
Quoted 7 lines
Quoted 2 lines
Following a common practice is an additional argument to this approach to me.
Except for the following cases:
sizeof(char*)==sizeof(uint32_t)(32bit)sizeof(char*)==sizeof(uint64_t)(64bit)
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char* journal_object_pool = "journal";
r = rbd_image_options_set(opts, RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool, strlen(journal_object_pool) + 1);
Signature · 1 line
Mykola Golub
Quoted 4 lines
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Quoted 8 lines
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char*
journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
My original example was a string of length 4 vs a 4-byte int, but you said you were thinking of sizeof(type) instead. I think this style of interface is great if you need to pass any arbitrary data along, but will we ever expect to pass along anything besides a string or an (u)int(32/64)?
On the flip-side, what will the C++ interface look like? An equivalent API would imply passing a boost::any. While certainly future-proof, something about that doesn't sit right with me as an API. I think I would lean more towards something like xyz_set(const std::string&), xyz_set(uint64_t), et al.
I've been witness to too many type-casting issues in the past (in fact just hit one last night within CephContext), which makes me lean more towards having the compiler be able to enforce type-correctness.
--
Jason
Quoted 13 lines · Jason Dillaman
Quoted 4 lines
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Quoted 8 lines
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char*
journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);
Quoted 5 lines
My original example was a string of length 4 vs a 4-byte int, but you said you were thinking of sizeof(type) instead. I think this style of interface is great if you need to pass any arbitrary data along, but will we ever expect to pass along anything besides a string or an (u)int(32/64)?
I don't know, sure you have much more experience here, so if you hardly expect other types in future, I would be rather then for rbd_image_options_set_{uint64,str}() functions.
Quoted 5 lines
On the flip-side, what will the C++ interface look like? An equivalent API would imply passing a
boost::any. While certainly future-proof, something about that doesn't sit right with me as an API. I think I would lean more towards something likexyz_set(const std::string&),xyz_set(uint64_t), et al.
For C++ I was also thinking about xyz_set(const std::string&), xyz_set(uint64_t) variants, i.e:
int rbd::Image::options::set(int optname, const std::string& val); int rbd::Image::options::set(int optname, uint64_t val);
...
Signature · 1 line
Mykola Golub
Quoted 20 lines · Mykola Golub
Quoted 13 lines · Jason Dillaman
Quoted 4 lines
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Quoted 8 lines
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char*
journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);Quoted 5 lines
My original example was a string of length 4 vs a 4-byte int, but you said you were thinking of sizeof(type) instead. I think this style of interface is great if you need to pass any arbitrary data along, but will we ever expect to pass along anything besides a string or an (u)int(32/64)?
Quoted 3 lines
I don't know, sure you have much more experience here, so if you hardly expect other types in future, I would be rather then for rbd_image_options_set_{uint64,str}() functions.
Having a str and int variant seems like the best path to me. Maybe int64 though, so that signed values are possible?
sage
Quoted 21 lines
Quoted 5 lines
On the flip-side, what will the C++ interface look like? An equivalent API would imply passing a
boost::any. While certainly future-proof, something about that doesn't sit right with me as an API. I think I would lean more towards something likexyz_set(const std::string&),xyz_set(uint64_t), et al.For C++ I was also thinking about
xyz_set(const std::string&),xyz_set(uint64_t)variants, i.e:int
rbd::Image::options::set(int optname, const std::string& val); intrbd::Image::options::set(int optname, uint64_t val);
...Signature · 5 lines
Mykola Golub -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 21 lines · Sage Weil
Quoted 20 lines · Mykola Golub
Quoted 18 lines · Jason Dillaman
Quoted 4 lines
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Quoted 8 lines
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char*
journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);My original example was a string of length 4 vs a 4-byte int, but you said you were thinking of sizeof(type) instead. I think this style of interface is great if you need to pass any arbitrary data along, but will we ever expect to pass along anything besides a string or an (u)int(32/64)?
Quoted 3 lines
Quoted 3 lines
I don't know, sure you have much more experience here, so if you hardly expect other types in future, I would be rather then for rbd_image_options_set_{uint64,str}() functions.
This is my favorite option too.
Quoted 2 lines
Having a str and int variant seems like the best path to me. Maybe int64 though, so that signed values are possible?
Don't think we need any signed values currently. It doesn't cause any ABI problems to add signed ints or other types later, since it'll already be overloaded in C++, and for C they need to be new functions anyway.
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
On the flip-side, what will the C++ interface look like? An equivalent API would imply passing a
boost::any. While certainly future-proof, something about that doesn't sit right with me as an API. I think I would lean more towards something likexyz_set(const std::string&),xyz_set(uint64_t), et al.For C++ I was also thinking about
xyz_set(const std::string&),xyz_set(uint64_t)variants, i.e:int
rbd::Image::options::set(int optname, const std::string& val); intrbd::Image::options::set(int optname, uint64_t val);
Sounds good to me.
Josh
Thank you all for your comments! I will come back with PR and pull request.
Signature · 1 line
Mykola Golub
Quoted 56 lines · Josh Durgin
Quoted 21 lines · Sage Weil
Quoted 20 lines · Mykola Golub
Quoted 18 lines · Jason Dillaman
Quoted 4 lines
But we don't need them to match between different platforms, no? Is linking 64bit code with 32bit possible (supported)?
Quoted 8 lines
Also, for this particular (char*) case, length would actually be the length of the string, not the pointer length. From my example:
const char*
journal_object_pool= "journal";
r = rbd_image_options_set(opts,RBD_OPTION_JOURNAL_OBJECT_POOL,
journal_object_pool,strlen(journal_object_pool)+ 1);My original example was a string of length 4 vs a 4-byte int, but you said you were thinking of sizeof(type) instead. I think this style of interface is great if you need to pass any arbitrary data along, but will we ever expect to pass along anything besides a string or an (u)int(32/64)?
Quoted 3 lines
Quoted 3 lines
I don't know, sure you have much more experience here, so if you hardly expect other types in future, I would be rather then for rbd_image_options_set_{uint64,str}() functions.
This is my favorite option too.
Quoted 2 lines
Having a str and int variant seems like the best path to me. Maybe int64 though, so that signed values are possible?
Don't think we need any signed values currently. It doesn't cause any ABI problems to add signed ints or other types later, since it'll already be overloaded in C++, and for C they need to be new functions anyway.
Quoted 11 lines
Quoted 11 lines
Quoted 5 lines
On the flip-side, what will the C++ interface look like? An equivalent API would imply passing a
boost::any. While certainly future-proof, something about that doesn't sit right with me as an API. I think I would lean more towards something likexyz_set(const std::string&),xyz_set(uint64_t), et al.For C++ I was also thinking about
xyz_set(const std::string&),xyz_set(uint64_t)variants, i.e:int
rbd::Image::options::set(int optname, const std::string& val); intrbd::Image::options::set(int optname, uint64_t val);Sounds good to me.
Josh
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 2 lines · Mykola Golub
Thank you all for your comments! I will come back with PR and pull request.
Here it is: https://github.com/ceph/ceph/pull/6369
Signature · 1 line
Mykola Golub