Skip to content

Commit

Permalink
Merge pull request ceph#17395 from theanalyst/cli-rados-stat2
Browse files Browse the repository at this point in the history
cli: rados: support for high precision time using stat2

Reviewed-by: Kefu Chai <[email protected]>
  • Loading branch information
xiexingguo authored Sep 4, 2017
2 parents 659f891 + f6db580 commit 5ac0969
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
9 changes: 8 additions & 1 deletion doc/man/8/rados.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Options
.. option:: --striper

Uses the striping API of rados rather than the default one.
Available for stat, get, put, append, truncate, rm, ls and all xattr related operation
Available for stat, stat2, get, put, append, truncate, rm, ls
and all xattr related operation


Global commands
Expand Down Expand Up @@ -152,6 +153,12 @@ Pool specific commands
:command:`rmxattr` *name* *attr*
Remove *attr* from the extended attributes of an object.

:command:`stat` *name*
Get stat (ie. mtime, size) of given object

:command:`stat2` *name*
Get stat (similar to stat, but with high precision time) of given object

:command:`listomapkeys` *name*
List all the keys stored in the object map of object name.

Expand Down
2 changes: 1 addition & 1 deletion src/bash_completion/rados
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ _rados()
return 0
;;
rados)
COMPREPLY=( $(compgen -W "lspools mkpool rmpool df ls chown get put create rm listxattr getxattr setxattr rmxattr stat mapext lssnap mksnap rmsnap rollback bench" -- ${cur}) )
COMPREPLY=( $(compgen -W "lspools mkpool rmpool df ls chown get put create rm listxattr getxattr setxattr rmxattr stat stat2 mapext lssnap mksnap rmsnap rollback bench" -- ${cur}) )
return 0
;;
esac
Expand Down
22 changes: 22 additions & 0 deletions src/tools/rados/rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void usage(ostream& out)
" setxattr <obj-name> attr val\n"
" rmxattr <obj-name> attr\n"
" stat <obj-name> stat the named object\n"
" stat2 <obj-name> stat2 the named object (with high precision time)\n"
" mapext <obj-name>\n"
" rollback <obj-name> <snap-name> roll back object to snap <snap-name>\n"
"\n"
Expand Down Expand Up @@ -2253,6 +2254,27 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
<< " mtime " << t << ", size " << size << std::endl;
}
}
else if (strcmp(nargs[0], "stat2") == 0) {
if (!pool_name || nargs.size() < 2)
usage_exit();
string oid(nargs[1]);
uint64_t size;
struct timespec mtime;
if (use_striper) {
ret = striper.stat2(oid, &size, &mtime);
} else {
ret = io_ctx.stat2(oid, &size, &mtime);
}
if (ret < 0) {
cerr << " error stat-ing " << pool_name << "/" << oid << ": "
<< cpp_strerror(ret) << std::endl;
goto out;
} else {
utime_t t(mtime);
cout << pool_name << "/" << oid
<< " mtime " << t << ", size " << size << std::endl;
}
}
else if (strcmp(nargs[0], "get") == 0) {
if (!pool_name || nargs.size() < 3)
usage_exit();
Expand Down

0 comments on commit 5ac0969

Please sign in to comment.