Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librados: extend C API for so it accepts keys with NUL chars #20314

Merged
merged 2 commits into from Mar 27, 2018

Conversation

branch-predictor
Copy link
Contributor

Librados C API functions that operate on OMAP accept key values that are NUL-terminated. This makes them unsuitable for operation on keys that have NULs embedded in them (like those produced by librbd). This PR adds new API functions:

  • rados_omap_get_next2
  • rados_write_op_omap_cmp2
  • rados_write_op_omap_set2
  • rados_write_op_omap_rm_keys2
  • rados_read_op_omap_cmp2
  • rados_read_op_omap_get_vals_by_keys2

that accept or provide actual key length in bytes and therefore are not limiting key values to first NUL encountered.

Signed-off-by: Piotr Dałek piotr.dalek@corp.ovh.com

@branch-predictor
Copy link
Contributor Author

@jdurgin @tchaikov @liewegas can someone take a look at this? Thanks!

size_t val_len,
int *prval)
{
bufferlist bl;
bl.append(val, val_len);
std::map<std::string, pair<bufferlist, int> > assertions;
string lkey = string(key, key_len);

assertions[key] = std::make_pair(bl, comparison_operator);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mea to change key to lkey here?

@liewegas
Copy link
Member

Can you add tests to test/librados/omap.cc for these?

Otherwise looks good! Is this fixing a user in-tree that is passing 0's in the keys, or is it to support a new out-of-tree omap user?

@branch-predictor
Copy link
Contributor Author

branch-predictor commented Mar 13, 2018 via email

Librados C API functions that operate on OMAP accept key values that
are NUL-terminated. This makes them unsuitable for operation on keys
that have NULs embedded in them (like those produced by librbd).
This commit adds new API functions:
- rados_omap_get_next2
- rados_write_op_omap_cmp2
- rados_write_op_omap_set2
- rados_write_op_omap_rm_keys2
- rados_read_op_omap_cmp2
- rados_read_op_omap_get_vals_by_keys2

that accept or provide actual key length in bytes and therefore are not
limiting key values to first NUL encountered.

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
@branch-predictor branch-predictor force-pushed the bp-librados-nntk branch 3 times, most recently from f96c041 to 3d19dfb Compare March 15, 2018 13:12
Unit tests for new apis:

* rados_omap_get_next2
* rados_write_op_omap_cmp2
* rados_write_op_omap_set2
* rados_write_op_omap_rm_keys2
* rados_read_op_omap_cmp2
* rados_read_op_omap_get_vals_by_keys2

Signed-off-by: Piotr Dałek <piotr.dalek@corp.ovh.com>
@branch-predictor
Copy link
Contributor Author

@liewegas done:

$ CEPH_CONF="./ceph.conf"  bin/ceph_test_rados_api_c_read_operations
Running main() from gmock_main.cc                                                                                                                 
[==========] Running 16 tests from 1 test case.                                                                                                   
[----------] Global test environment set-up.                                                                                                      
[----------] 16 tests from CReadOpsTest                                                                                                           
[ RUN      ] CReadOpsTest.NewDelete                                                                                                               
[       OK ] CReadOpsTest.NewDelete (0 ms)                                                                                                        
[ RUN      ] CReadOpsTest.SetOpFlags                                                                                                              
[       OK ] CReadOpsTest.SetOpFlags (27 ms)                                                                                                      
[ RUN      ] CReadOpsTest.AssertExists                                                                                                            
[       OK ] CReadOpsTest.AssertExists (31 ms)                                                                                                    
[ RUN      ] CReadOpsTest.AssertVersion                                                                                                           
[       OK ] CReadOpsTest.AssertVersion (17 ms)                                                                                                   
[ RUN      ] CReadOpsTest.CmpXattr                                                                                                                
[       OK ] CReadOpsTest.CmpXattr (39 ms)                                                                                                        
[ RUN      ] CReadOpsTest.Read                                                                                                                    
[       OK ] CReadOpsTest.Read (15 ms)                                                                                                            
[ RUN      ] CReadOpsTest.Checksum                                                                                                                
[       OK ] CReadOpsTest.Checksum (14 ms)                                                                                                        
[ RUN      ] CReadOpsTest.RWOrderedRead                                                                                                           
[       OK ] CReadOpsTest.RWOrderedRead (12 ms)                                                                                                   
[ RUN      ] CReadOpsTest.ShortRead                                                                                                               
[       OK ] CReadOpsTest.ShortRead (14 ms)                                                                                                       
[ RUN      ] CReadOpsTest.Exec                                                                                                                    
[       OK ] CReadOpsTest.Exec (17 ms)                                                                                                            
[ RUN      ] CReadOpsTest.ExecUserBuf                                                                                                             
[       OK ] CReadOpsTest.ExecUserBuf (13 ms)                                                                                                     
[ RUN      ] CReadOpsTest.Stat                                                                                                                    
[       OK ] CReadOpsTest.Stat (15 ms)                                                                                                            
[ RUN      ] CReadOpsTest.Omap                                                                                                                    
[       OK ] CReadOpsTest.Omap (46 ms)                                                                                                            
[ RUN      ] CReadOpsTest.OmapNuls                                                                                                                
[       OK ] CReadOpsTest.OmapNuls (40 ms)                                                                                                        
[ RUN      ] CReadOpsTest.GetXattrs                                                                                                               
[       OK ] CReadOpsTest.GetXattrs (40 ms)                                                                                                       
[ RUN      ] CReadOpsTest.CmpExt                                                                                                                  
[       OK ] CReadOpsTest.CmpExt (14 ms)                                                                                                          
[----------] 16 tests from CReadOpsTest (357 ms total)                                                                                            
                                                                                                                                                  
[----------] Global test environment tear-down                                                                                                    
[==========] 16 tests from 1 test case ran. (2193 ms total)                                                                                       
[  PASSED  ] 16 tests.                                                                                                                            

@tchaikov
Copy link
Contributor

retest this please

@tchaikov tchaikov merged commit 81b00f5 into ceph:master Mar 27, 2018
@branch-predictor branch-predictor deleted the bp-librados-nntk branch May 27, 2019 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants