Introduce InodeDispatcher::lookupInodeBase().

Summary:
This is an alternative to `InodeDispatcher::lookup()` that does not result
in `RequestData::get()` being called, which is important for requests that
do not originate from FUSE.

The `::lookup()` call takes the `InodeBase` and invokes its `getattr()` method,
which in the case of `TreeEntryFileInode::getattr()`, creates a `fusell::Dispatcher::Attr`
whose constructor calls the following:

```
Dispatcher::Attr::Attr() : timeout(1.0) {
  memset(&st, 0, sizeof(st));
  auto& req = RequestData::get();
  auto mount = req.getChannel().getMountPoint();
  st.st_uid = mount->getUid();
  st.st_gid = mount->getGid();
}
```

So the only reason this is done at all is to set `st_uid` and `st_gid`.

And then the only reason `Attr` is needed is to set the following fields on a `fuse_entry_param`:

```
attr
attr_timeout
entry_timeout
```

So it is possible that we can find a better way to streamline all of this, but this was
the easiest shortcut I could implement myself right now.

Reviewed By: wez

Differential Revision: D3351819

fbshipit-source-id: b095c085ee4a9b9a81438db093869fd0acf1f8ad
This commit is contained in:
Michael Bolin 2016-05-26 09:49:10 -07:00 committed by Facebook Github Bot 8
parent 4db509b508
commit 4897086780
2 changed files with 20 additions and 5 deletions

View File

@ -263,6 +263,17 @@ fuse_entry_param InodeDispatcher::computeEntryParam(
folly::Future<fuse_entry_param> InodeDispatcher::lookup(
fuse_ino_t parent,
PathComponentPiece namepiece) {
auto name = namepiece.copy();
auto inode = lookupInodeBase(parent, namepiece).get();
return inode->getattr().then([=](Dispatcher::Attr attr) {
auto node = mountPoint_->getNameMgr()->getNodeById(inode->getNodeId());
return computeEntryParam(attr, node);
});
}
folly::Future<std::shared_ptr<InodeBase>> InodeDispatcher::lookupInodeBase(
fuse_ino_t parent,
PathComponentPiece namepiece) {
auto dir = getDirInode(parent);
// First, see if we already have the Inode loaded
@ -276,8 +287,7 @@ folly::Future<fuse_entry_param> InodeDispatcher::lookup(
return (existing_inode ? makeFuture(existing_inode)
: dir->getChildByName(namepiece))
.then([ =, name = namepiece.copy() ](
std::shared_ptr<InodeBase> inode) mutable {
.then([=](std::shared_ptr<InodeBase> inode) mutable {
if (!inode) {
throwSystemErrorExplicit(ENOENT);
}
@ -287,9 +297,7 @@ folly::Future<fuse_entry_param> InodeDispatcher::lookup(
recordInode(inode);
}
return inode->getattr().then([=](Dispatcher::Attr attr) {
return computeEntryParam(attr, node);
});
return inode;
});
}

View File

@ -78,6 +78,13 @@ class InodeDispatcher : public Dispatcher {
folly::Future<fuse_entry_param> lookup(
fuse_ino_t parent,
PathComponentPiece name) override;
/**
* Similar to lookup(), except this does not require an active FUSE request.
*/
folly::Future<std::shared_ptr<InodeBase>> lookupInodeBase(
fuse_ino_t parent,
PathComponentPiece name);
folly::Future<folly::Unit> forget(fuse_ino_t ino,
unsigned long nlookup) override;
folly::Future<std::unique_ptr<FileHandle>> open(