mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
10be70e0a3
Summary: Make a few minor tweaks to the strace-style logging added in D5464387. - Call the log categories "eden.strace.<mount_path>" instead of "eden/strace<mount_path>". The folly logging library uses '.' to separate nodes in the log category hierarchy, so this puts all of the strace messages under the "eden.strace" category, which it itself part of the "eden" category. The "<mount_path>" will contain slashes inside it, but slashes are not treated specially in log category names. - Rename `EdenMount::getLogger()` to `EdenMount::getStraceLogger()` since this logger should be used only for strace-style events, and not for general log messages for this mount point. Reviewed By: bolinfest Differential Revision: D5515245 fbshipit-source-id: 9d833d9fbff47c6a57a7afefeae92755ff0e28b7
114 lines
2.8 KiB
C++
114 lines
2.8 KiB
C++
/*
|
|
* Copyright (c) 2016-present, 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 "eden/fs/inodes/FileHandle.h"
|
|
|
|
#include <folly/experimental/logging/xlog.h>
|
|
#include "eden/fs/inodes/EdenMount.h"
|
|
#include "eden/fs/inodes/FileInode.h"
|
|
#include "eden/fs/inodes/TreeInode.h"
|
|
#include "eden/fs/store/LocalStore.h"
|
|
|
|
namespace facebook {
|
|
namespace eden {
|
|
|
|
FileHandle::FileHandle(FileInodePtr inode, int flags)
|
|
: inode_(std::move(inode)), openFlags_(flags) {}
|
|
|
|
folly::Future<fusell::Dispatcher::Attr> FileHandle::getattr() {
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"getattr({})",
|
|
inode_->getNodeId());
|
|
return inode_->getattr();
|
|
}
|
|
|
|
folly::Future<fusell::Dispatcher::Attr> FileHandle::setattr(
|
|
const struct stat& attr,
|
|
int to_set) {
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"setattr({})",
|
|
inode_->getNodeId());
|
|
return inode_->setattr(attr, to_set);
|
|
}
|
|
|
|
bool FileHandle::preserveCache() const {
|
|
return true;
|
|
}
|
|
|
|
bool FileHandle::isSeekable() const {
|
|
return true;
|
|
}
|
|
|
|
folly::Future<fusell::BufVec> FileHandle::read(size_t size, off_t off) {
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"read({})",
|
|
inode_->getNodeId());
|
|
return inode_->read(size, off);
|
|
}
|
|
|
|
folly::Future<size_t> FileHandle::write(fusell::BufVec&& buf, off_t off) {
|
|
SCOPE_SUCCESS {
|
|
auto myname = inode_->getPath();
|
|
if (myname.hasValue()) {
|
|
inode_->getMount()->getJournal().wlock()->addDelta(
|
|
std::make_unique<JournalDelta>(JournalDelta{myname.value()}));
|
|
}
|
|
};
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"write({})",
|
|
inode_->getNodeId());
|
|
return inode_->write(std::move(buf), off);
|
|
}
|
|
|
|
folly::Future<size_t> FileHandle::write(folly::StringPiece str, off_t off) {
|
|
SCOPE_SUCCESS {
|
|
auto myname = inode_->getPath();
|
|
if (myname.hasValue()) {
|
|
inode_->getMount()->getJournal().wlock()->addDelta(
|
|
std::make_unique<JournalDelta>(JournalDelta{myname.value()}));
|
|
}
|
|
};
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"write({})",
|
|
inode_->getNodeId());
|
|
return inode_->write(str, off);
|
|
}
|
|
|
|
folly::Future<folly::Unit> FileHandle::flush(uint64_t lock_owner) {
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"flush({})",
|
|
inode_->getNodeId());
|
|
inode_->flush(lock_owner);
|
|
return folly::Unit{};
|
|
}
|
|
|
|
folly::Future<folly::Unit> FileHandle::fsync(bool datasync) {
|
|
FB_LOGF(
|
|
inode_->getMount()->getStraceLogger(),
|
|
DBG7,
|
|
"fsync({})",
|
|
inode_->getNodeId());
|
|
inode_->fsync(datasync);
|
|
return folly::Unit{};
|
|
}
|
|
}
|
|
}
|