From 0613765a698a9e078ff149e5e53be6524cee7098 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 14 Jan 2016 19:24:59 -0500 Subject: [PATCH] os/FuseStore: improve readdir for omap and attr Use new-style fuse readdir interface for omap and attr. We aren't particularly efficient, but we won't completely break if there are a lot of attrs or omap entries. Signed-off-by: Sage Weil --- src/os/FuseStore.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/os/FuseStore.cc b/src/os/FuseStore.cc index 1895a760d588..4d5d7e42b39f 100644 --- a/src/os/FuseStore.cc +++ b/src/os/FuseStore.cc @@ -470,8 +470,16 @@ static int os_readdir(const char *path, { set keys; fs->store->omap_get_keys(cid, oid, &keys); + unsigned skip = offset; for (auto k : keys) { - filler(buf, k.c_str(), NULL, 0); + if (skip) { + --skip; + continue; + } + ++offset; + int r = filler(buf, k.c_str(), NULL, offset); + if (r) + break; } } break; @@ -480,8 +488,16 @@ static int os_readdir(const char *path, { map aset; fs->store->getattrs(cid, oid, aset); + unsigned skip = offset; for (auto a : aset) { - filler(buf, a.first.c_str(), NULL, 0); + if (skip) { + --skip; + continue; + } + ++offset; + int r = filler(buf, a.first.c_str(), NULL, offset); + if (r) + break; } } break; -- 2.47.3