eden: remove releasefile/releasedir methods from FileHandle classes

Summary:
We weren't using these and they made some of our handling more complicated.

We now leave the release behavior to the destructor for the instance.

Reviewed By: simpkins

Differential Revision: D3615326

fbshipit-source-id: de39fb4315dd7b08da7c22cbcbd40e21be487102
This commit is contained in:
Wez Furlong 2016-07-26 21:02:09 -07:00 committed by Facebook Github Bot 7
parent 90cfd27c37
commit 957b00da36
7 changed files with 10 additions and 107 deletions

View File

@ -1,19 +0,0 @@
/*
* Copyright (c) 2016, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#include "DirHandle.h"
namespace facebook {
namespace eden {
namespace fusell {
folly::Future<folly::Unit> DirHandle::releasedir() { return folly::Unit{}; }
}
}
}

View File

@ -25,14 +25,6 @@ class DirHandle : public FileHandleBase {
*/
virtual folly::Future<DirList> readdir(DirList&& list, off_t off) = 0;
/**
* Release an open directory
*
* For every opendir call there will be exactly one releasedir
* call.
*/
virtual folly::Future<folly::Unit> releasedir();
/**
* Synchronize directory contents
*

View File

@ -454,14 +454,7 @@ static void disp_open(fuse_req_t req,
fi.fh = dispatcher->getFileHandles().recordHandle(std::move(fh));
if (!RequestData::get().replyOpen(fi)) {
// Was interrupted, tidy up.
auto handle =
dispatcher->getFileHandles().forgetFileHandle(fi.fh);
handle->releasefile().then([handle]() mutable {
// This reset() is going to happen when fh falls out of scope,
// we're just being clear that we want to extend the lifetime
// until after the FileHandle::releasefile has finished.
handle.reset();
});
dispatcher->getFileHandles().forgetGenericHandle(fi.fh);
}
})
.CATCH_ERRORS());
@ -529,11 +522,8 @@ static void disp_release(fuse_req_t req,
request.setRequestFuture(
request.startRequest(dispatcher->getStats().release)
.then([ =, &request, fi = *fi ] {
auto handle = dispatcher->getFileHandles().forgetFileHandle(fi.fh);
return handle->releasefile().then([handle]() mutable {
handle.reset();
RequestData::get().replyError(0);
});
dispatcher->getFileHandles().forgetGenericHandle(fi.fh);
RequestData::get().replyError(0);
})
.CATCH_ERRORS());
}
@ -576,14 +566,8 @@ static void disp_opendir(fuse_req_t req,
fuse_file_info fi = orig_info;
fi.fh = dispatcher->getFileHandles().recordHandle(std::move(dh));
if (!RequestData::get().replyOpen(fi)) {
auto handle = dispatcher->getFileHandles().forgetDirHandle(fi.fh);
// Was interrupted, tidy up
handle->releasedir().then([handle]() mutable {
// This reset() is going to happen when dh falls out of scope,
// we're just being clear that we want to extend the lifetime
// until after the DirHandle::release() has finished.
handle.reset();
});
dispatcher->getFileHandles().forgetGenericHandle(fi.fh);
}
})
.CATCH_ERRORS());
@ -617,11 +601,8 @@ static void disp_releasedir(fuse_req_t req,
request.setRequestFuture(
request.startRequest(dispatcher->getStats().releasedir)
.then([ =, &request, fi = *fi ] {
auto handle = dispatcher->getFileHandles().forgetDirHandle(fi.fh);
return handle->releasedir().then([handle]() mutable {
handle.reset();
RequestData::get().replyError(0);
});
dispatcher->getFileHandles().forgetGenericHandle(fi.fh);
RequestData::get().replyError(0);
})
.CATCH_ERRORS());
}
@ -842,14 +823,7 @@ static void disp_create(fuse_req_t req,
dispatcher->getFileHandles().recordHandle(std::move(info.fh));
if (!RequestData::get().replyCreate(info.entry, fi)) {
// Interrupted, tidy up
auto handle =
dispatcher->getFileHandles().forgetFileHandle(fi.fh);
handle->releasefile().then([handle]() mutable {
// This reset() is going to happen when fh falls out of scope,
// we're just being clear that we want to extend the lifetime
// until after the FileHandle::releasefile has finished.
handle.reset();
});
dispatcher->getFileHandles().forgetGenericHandle(fi.fh);
}
})
.CATCH_ERRORS());

View File

@ -18,9 +18,6 @@ namespace fusell {
bool FileHandle::usesDirectIO() const { return false; }
bool FileHandle::preserveCache() const { return false; }
bool FileHandle::isSeekable() const { return true; }
folly::Future<folly::Unit> FileHandle::releasefile() {
return Unit{};
}
folly::Future<struct flock> FileHandle::getlk(struct flock lock,
uint64_t lock_owner) {

View File

@ -79,21 +79,6 @@ class FileHandle : public FileHandleBase {
*/
virtual folly::Future<folly::Unit> flush(uint64_t lock_owner) = 0;
/**
* Release an open file
*
* Release is called when there are no more references to an open
* file: all file descriptors are closed and all memory mappings
* are unmapped.
*
* For every open call there will be exactly one release call.
*
* The filesystem may reply with an error, but error values are
* not returned to close() or munmap() which triggered the
* release.
*/
virtual folly::Future<folly::Unit> releasefile();
/**
* Synchronize file contents
*

View File

@ -102,24 +102,6 @@ std::shared_ptr<FileHandleBase> FileHandleMap::forgetGenericHandle(
handles->erase(iter);
return result;
}
std::shared_ptr<FileHandle> FileHandleMap::forgetFileHandle(uint64_t fh) {
auto handle = forgetGenericHandle(fh);
auto result = std::dynamic_pointer_cast<FileHandle>(handle);
if (result) {
return result;
}
folly::throwSystemErrorExplicit(EISDIR);
}
std::shared_ptr<DirHandle> FileHandleMap::forgetDirHandle(uint64_t dh) {
auto handle = forgetGenericHandle(dh);
auto result = std::dynamic_pointer_cast<DirHandle>(handle);
if (result) {
return result;
}
folly::throwSystemErrorExplicit(ENOTDIR);
}
}
}
}

View File

@ -57,20 +57,12 @@ class FileHandleMap {
**/
uint64_t recordHandle(std::shared_ptr<FileHandleBase> fh);
/** Delete the association from the fh to a file handle instance.
* Throws EBADF if the file handle is not tracked by this map, or
* EISDIR if the instance is a DirHandle rather than a FileHandle.
/** Delete the association from the fh to a handle instance.
* Throws EBADF if the file handle is not tracked by this map.
* On success, returns the instance. */
std::shared_ptr<FileHandle> forgetFileHandle(uint64_t fh);
/** Delete the association from the fh to a dir handle instance.
* Throws EBADF if the file handle is not tracked by this map, or
* ENOTDIR if the instance is a FileHandle rather than a DirHandle.
* On success, returns the instance. */
std::shared_ptr<DirHandle> forgetDirHandle(uint64_t dh);
std::shared_ptr<FileHandleBase> forgetGenericHandle(uint64_t fh);
private:
std::shared_ptr<FileHandleBase> forgetGenericHandle(uint64_t fh);
folly::Synchronized<
std::unordered_map<uint64_t, std::shared_ptr<FileHandleBase>>>