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

rgw_file: wip parentref #13607

Merged
merged 2 commits into from Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/include/rados/rgw_file.h
Expand Up @@ -27,7 +27,7 @@ extern "C" {

#define LIBRGW_FILE_VER_MAJOR 1
#define LIBRGW_FILE_VER_MINOR 1
#define LIBRGW_FILE_VER_EXTRA 1
#define LIBRGW_FILE_VER_EXTRA 2

#define LIBRGW_FILE_VERSION(maj, min, extra) ((maj << 16) + (min << 8) + extra)
#define LIBRGW_FILE_VERSION_CODE LIBRGW_FILE_VERSION(LIBRGW_FILE_VER_MAJOR, LIBRGW_FILE_VER_MINOR, LIBRGW_FILE_VER_EXTRA)
Expand Down Expand Up @@ -91,6 +91,7 @@ void rgwfile_version(int *major, int *minor, int *extra);
*/
#define RGW_LOOKUP_FLAG_NONE 0x0000
#define RGW_LOOKUP_FLAG_CREATE 0x0001
#define RGW_LOOKUP_FLAG_RCB 0x0002 /* readdir callback hint */

int rgw_lookup(struct rgw_fs *rgw_fs,
struct rgw_file_handle *parent_fh, const char *path,
Expand Down
13 changes: 9 additions & 4 deletions src/rgw/rgw_file.cc
Expand Up @@ -1377,17 +1377,22 @@ int rgw_lookup(struct rgw_fs *rgw_fs,
LookupFHResult fhr;

if (parent->is_root()) {
/* special: lookup on root itself */
if (strcmp(path, "/") == 0) {
rgw_fh = fs->ref(parent);
/* special: parent lookup--note lack of ref()! */
if (unlikely((strcmp(path, "..") == 0) ||
(strcmp(path, "/") == 0))) {
rgw_fh = parent;
} else {
fhr = fs->stat_bucket(parent, path, RGWFileHandle::FLAG_NONE);
rgw_fh = get<0>(fhr);
if (! rgw_fh)
return -ENOENT;
}
} else {
fhr = fs->stat_leaf(parent, path, RGWFileHandle::FLAG_NONE);
/* lookup in a readdir callback */
uint32_t sl_flags = (flags & RGW_LOOKUP_FLAG_RCB)
? RGWFileHandle::FLAG_NONE
: RGWFileHandle::FLAG_EXACT_MATCH;
fhr = fs->stat_leaf(parent, path, sl_flags);
if (! get<0>(fhr)) {
if (! (flags & RGW_LOOKUP_FLAG_CREATE))
return -ENOENT;
Expand Down