On Fri, Oct 21, 2016 at 01:07:00PM +0200, Igor Mammedov wrote:
[...]
> How about following behavior:
>
> 1) memory-backend-file,mem-path=/some_dir,size=2G
> - uses truncate to extend temporary file created in "mem-path" to 'size'
> for this case to work 'size' is mandatory
>
> 2) memory-backend-file,mem-path=/existing_file,size=2G
> - uses truncate to extend/shrink file "mem-path" to 'size'
> for this case 'size' could be made optional,
> if we take in account that backend could be used as persistent
> storage then shrinking or extending "mem-path" would be corruption
> as backend has no idea about internal layout if mapped file.
> We can do something like this here:
>
> if (is_size_opt_provided and size_of(mem-path) != 0) {
> error_out with "mem-path=foo size XXX doesn't match 'size=xxx' option"
> } else if (is_size_opt_provided and size_of(mem-path) == 0) {
> // may be we don't need this case and
> // just fold this in above error case
> truncate(mem-path) // extend/shrink
> } else {
> set_size_opt(size_of(mem-path))
> }
Agreed.
--
Eduardo