From: Sage Weil Date: Tue, 7 Apr 2015 22:24:16 +0000 (-0700) Subject: os/newstore: open by handle X-Git-Tag: v9.1.0~242^2~84 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97bda73ebf0aa559803dd8d44dcd1fc84b550ef3;p=ceph.git os/newstore: open by handle Signed-off-by: Sage Weil --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 828d534a48c3..abb7a7a000fd 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -802,6 +802,7 @@ OPTION(newstore_fid_prealloc, OPT_INT, 1024) OPTION(newstore_nid_prealloc, OPT_INT, 1024) OPTION(newstore_overlay_max_length, OPT_INT, 65536) OPTION(newstore_overlay_max, OPT_INT, 32) +OPTION(newstore_open_by_handle, OPT_BOOL, true) OPTION(filestore_omap_backend, OPT_STR, "leveldb") diff --git a/src/os/newstore/NewStore.cc b/src/os/newstore/NewStore.cc index d32cb987bba7..9d8a2d6859af 100644 --- a/src/os/newstore/NewStore.cc +++ b/src/os/newstore/NewStore.cc @@ -41,7 +41,6 @@ - DBObjectMap::clone lock ordering - HashIndex::get_path_contents_by_hash - HashIndex::list_by_hash - * open-by-handle * use work queue for wal fsyncs and kv record removals * avoid mtime updates when doing open-by-handle * abstract out fs specifics @@ -1854,6 +1853,18 @@ int NewStore::_recover_next_fid() int NewStore::_open_fid(fid_t fid) { + if (fid.handle.length() && g_conf->newstore_open_by_handle) { + int fd = fs->open_handle(path_fd, fid.handle, O_RDWR); + if (fd >= 0) { + dout(30) << __func__ << " " << fid << " = " << fd + << " (open by handle)" << dendl; + return fd; + } + int err = -errno; + dout(30) << __func__ << " " << fid << " = " << cpp_strerror(err) + << " (with open by handle, falling back to file name)" << dendl; + } + char fn[32]; snprintf(fn, sizeof(fn), "%u/%u", fid.fset, fid.fno); int fd = ::openat(frag_fd, fn, O_RDWR); @@ -1928,15 +1939,18 @@ int NewStore::_create_fid(TransContext *txc, fid_t *fid) return r; } -#if 0 - // store a handle, too - void *hp; - size_t hlen; - int r = fd_to_handle(fd, &hp, &hlen); - if (r >= 0) { - fid->handle = string((char *)hp, hlen); + if (g_conf->newstore_open_by_handle) { + int r = fs->get_handle(fd, &fid->handle); + if (r < 0) { + dout(30) << __func__ << " get_handle got " << cpp_strerror(r) << dendl; + } else { + dout(30) << __func__ << " got handle: "; + bufferlist bl; + bl.append(fid->handle); + bl.hexdump(*_dout); + *_dout << dendl; + } } -#endif dout(30) << __func__ << " " << *fid << " = " << fd << dendl; return fd;