Ceph uses extended file attributes to store file meta data. It is a list of key / value pairs. Some file systems implementations do not allow to store more than 2048 characters in the value associated with a key. To overcome this limitation Ceph implements chained extended attributes.
A value that is 5120 character long will be stored in three separate attributes:
- user.key : first 2048 characters
- user.key@1 : next 2048 characters
- user.key@2 : last 1024 characters
The proposed unit tests may be used as a documentation describing in detail how it is implemented from the caller point of view.
- int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
- int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
- int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
- int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
- int chain_listxattr(const char *fn, char *names, size_t len);
- int chain_flistxattr(int fd, char *names, size_t len);
- int chain_removexattr(const char *fn, const char *name);
- int chain_fremovexattr(int fd, const char *name);
The function translate_raw_name substitutes @@ into @. When the trailing
character is a @, it breaks. However, such an occurrence cannot be created by chain_setxattr because it always create pairs of @. Instead of silently breaking the loop, the function should probably return on error so that the caller can ignore it.
The function chain_fgetxattr_len may return on error if fgetxattr returns on error. However, it is only called after another attr function returned success and the tests cannot create the conditions under which it would fail.
The function chain_fsetxattr contains untested code being discussed on the mailing list
dependency to the underlying filesystem
If the file system in which the tests are run does not support extended attributes, the tests are not run. The detection uses the same logic as the one implemented in FileStore::_detect_fs. The test should be run as part of teuthology to check how it behaves when used with the supported file systems.
minimizing the noise
The output of the tests are silenced to reduce the output when testing assertions ( except for the dout_emergency function which cannot be controlled).