if (cct->_conf->client_acl_type == "posix_acl")
acl_type = POSIX_ACL;
- lru.lru_set_max(cct->_conf->client_cache_size);
lru.lru_set_midpoint(cct->_conf->client_cache_mid);
// file handles
// *** FIXME ***
// empty lru
- lru.lru_set_max(0);
trim_cache();
assert(lru.lru_get_size() == 0);
void Client::trim_cache(bool trim_kernel_dcache)
{
- ldout(cct, 20) << "trim_cache size " << lru.lru_get_size() << " max " << lru.lru_get_max() << dendl;
+ uint64_t max = cct->_conf->client_cache_size;
+ ldout(cct, 20) << "trim_cache size " << lru.lru_get_size() << " max " << max << dendl;
unsigned last = 0;
while (lru.lru_get_size() != last) {
last = lru.lru_get_size();
- if (lru.lru_get_size() <= lru.lru_get_max()) break;
+ if (!unmounting && lru.lru_get_size() <= max) break;
// trim!
Dentry *dn = static_cast<Dentry*>(lru.lru_get_next_expire());
trim_dentry(dn);
}
- if (trim_kernel_dcache && lru.lru_get_size() > lru.lru_get_max())
+ if (trim_kernel_dcache && lru.lru_get_size() > max)
_invalidate_kernel_dcache();
// hose root?
MetaSession *tsession = _get_or_open_mds_session(peer_mds);
if (in->caps.count(peer_mds)) {
Cap *tcap = in->caps[peer_mds];
- if (tcap->cap_id != m->peer.cap_id ||
+ if (tcap->cap_id == m->peer.cap_id &&
ceph_seq_cmp(tcap->seq, m->peer.seq) < 0) {
tcap->cap_id = m->peer.cap_id;
tcap->seq = m->peer.seq - 1;
int Client::may_setattr(Inode *in, struct ceph_statx *stx, int mask,
const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *in << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *in << "; " << perms << dendl;
int r = _getattr_for_perm(in, perms);
if (r < 0)
goto out;
int Client::may_open(Inode *in, int flags, const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *in << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *in << "; " << perms << dendl;
unsigned want = 0;
if ((flags & O_ACCMODE) == O_WRONLY)
int Client::may_lookup(Inode *dir, const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *dir << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *dir << "; " << perms << dendl;
int r = _getattr_for_perm(dir, perms);
if (r < 0)
goto out;
int Client::may_create(Inode *dir, const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *dir << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *dir << "; " << perms << dendl;
int r = _getattr_for_perm(dir, perms);
if (r < 0)
goto out;
int Client::may_delete(Inode *dir, const char *name, const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *dir << "; " << "; name " << name << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *dir << "; " << "; name " << name << "; " << perms << dendl;
int r = _getattr_for_perm(dir, perms);
if (r < 0)
goto out;
int Client::may_hardlink(Inode *in, const UserPerm& perms)
{
- ldout(cct, 20) << __func__ << *in << "; " << perms << dendl;
+ ldout(cct, 20) << __func__ << " " << *in << "; " << perms << dendl;
int r = _getattr_for_perm(in, perms);
if (r < 0)
goto out;
{
Mutex::Locker lock(client_lock);
- assert(initialized);
+ if (!initialized)
+ return -ENOTCONN;
int r;
r = authenticate();
{
Mutex::Locker lock(client_lock);
- assert(mounted); // caller is confused?
+ if (unmounting)
+ return;
ldout(cct, 2) << "unmounting" << dendl;
unmounting = true;
wait_sync_caps(last_flush_tid);
// empty lru cache
- lru.lru_set_max(0);
trim_cache();
while (lru.lru_get_size() > 0 ||
tout(cct) << relexisting << std::endl;
tout(cct) << relpath << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
filepath existing(relexisting);
InodeRef in, dir;
tout(cct) << "unlink" << std::endl;
tout(cct) << relpath << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relpath) == "/")
return -EISDIR;
tout(cct) << relfrom << std::endl;
tout(cct) << relto << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relfrom) == "/" || std::string(relto) == "/")
return -EBUSY;
tout(cct) << mode << std::endl;
ldout(cct, 10) << "mkdir: " << relpath << dendl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relpath) == "/")
return -EEXIST;
tout(cct) << relpath << std::endl;
tout(cct) << mode << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
//get through existing parts of path
filepath path(relpath);
unsigned int i;
tout(cct) << "rmdir" << std::endl;
tout(cct) << relpath << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relpath) == "/")
return -EBUSY;
tout(cct) << mode << std::endl;
tout(cct) << rdev << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relpath) == "/")
return -EEXIST;
tout(cct) << target << std::endl;
tout(cct) << relpath << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (std::string(relpath) == "/")
return -EEXIST;
tout(cct) << "readlink" << std::endl;
tout(cct) << relpath << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms, false);
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
mask &= ~CEPH_SETATTR_MODE;
ldout(cct,10) << "changing mode to " << stx->stx_mode << dendl;
- } else if (kill_sguid && S_ISREG(in->mode)) {
+ } else if (kill_sguid && S_ISREG(in->mode) && (in->mode & (S_IXUSR|S_IXGRP|S_IXOTH))) {
/* Must squash the any setuid/setgid bits with an ownership change */
- in->mode &= ~S_ISUID;
- if ((in->mode & (S_ISGID|S_IXGRP)) == (S_ISGID|S_IXGRP))
- in->mode &= ~S_ISGID;
+ in->mode &= ~(S_ISUID|S_ISGID);
mark_caps_dirty(in, CEPH_CAP_AUTH_EXCL);
}
stat_to_statx(attr, &stx);
mask &= ~CEPH_SETATTR_BTIME;
+
+ if ((mask & CEPH_SETATTR_UID) && attr->st_uid == static_cast<uid_t>(-1)) {
+ mask &= ~CEPH_SETATTR_UID;
+ }
+ if ((mask & CEPH_SETATTR_GID) && attr->st_gid == static_cast<uid_t>(-1)) {
+ mask &= ~CEPH_SETATTR_GID;
+ }
+
return _setattrx(in, &stx, mask, perms);
}
tout(cct) << relpath << std::endl;
tout(cct) << mask << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
tout(cct) << relpath << std::endl;
tout(cct) << mask << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms, !(flags & AT_SYMLINK_NOFOLLOW));
tout(cct) << fd << std::endl;
tout(cct) << mask << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << fd << std::endl;
tout(cct) << mask << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
Mutex::Locker lock(client_lock);
tout(cct) << "stat" << std::endl;
tout(cct) << relpath << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms, true, mask);
Mutex::Locker lock(client_lock);
tout(cct) << "statx" << std::endl;
tout(cct) << relpath << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
Mutex::Locker lock(client_lock);
tout(cct) << "lstat" << std::endl;
tout(cct) << relpath << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
// don't follow symlinks
tout(cct) << "chmod" << std::endl;
tout(cct) << relpath << std::endl;
tout(cct) << mode << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
tout(cct) << "fchmod" << std::endl;
tout(cct) << fd << std::endl;
tout(cct) << mode << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << "lchmod" << std::endl;
tout(cct) << relpath << std::endl;
tout(cct) << mode << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
// don't follow symlinks
tout(cct) << relpath << std::endl;
tout(cct) << new_uid << std::endl;
tout(cct) << new_gid << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
struct stat attr;
attr.st_uid = new_uid;
attr.st_gid = new_gid;
- int mask = 0;
- if (new_uid != static_cast<uid_t>(-1)) mask |= CEPH_SETATTR_UID;
- if (new_gid != static_cast<gid_t>(-1)) mask |= CEPH_SETATTR_GID;
- return _setattr(in, &attr, mask, perms);
+ return _setattr(in, &attr, CEPH_SETATTR_UID|CEPH_SETATTR_GID, perms);
}
int Client::fchown(int fd, uid_t new_uid, gid_t new_gid, const UserPerm& perms)
tout(cct) << fd << std::endl;
tout(cct) << new_uid << std::endl;
tout(cct) << new_gid << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << relpath << std::endl;
tout(cct) << new_uid << std::endl;
tout(cct) << new_gid << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
// don't follow symlinks
tout(cct) << relpath << std::endl;
tout(cct) << buf->modtime << std::endl;
tout(cct) << buf->actime << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
tout(cct) << relpath << std::endl;
tout(cct) << buf->modtime << std::endl;
tout(cct) << buf->actime << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
// don't follow symlinks
tout(cct) << fd << std::endl;
tout(cct) << operation << std::endl;
tout(cct) << owner << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
Mutex::Locker lock(client_lock);
tout(cct) << "opendir" << std::endl;
tout(cct) << relpath << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms, true);
void Client::rewinddir(dir_result_t *dirp)
{
Mutex::Locker lock(client_lock);
-
ldout(cct, 3) << "rewinddir(" << dirp << ")" << dendl;
+
+ if (unmounting)
+ return;
+
dir_result_t *d = static_cast<dir_result_t*>(dirp);
_readdir_drop_dirp_buffer(d);
d->reset();
ldout(cct, 3) << "seekdir(" << dirp << ", " << offset << ")" << dendl;
+ if (unmounting)
+ return;
+
if (offset == dirp->offset)
return;
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
dir_result_t *dirp = static_cast<dir_result_t*>(d);
ldout(cct, 10) << "readdir_r_cb " << *dirp->inode << " offset " << hex << dirp->offset
tout(cct) << relpath << std::endl;
tout(cct) << ceph_flags_sys2wire(flags) << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *fh = NULL;
#if defined(__linux__) && defined(O_PATH)
Mutex::Locker lock(client_lock);
ldout(cct, 3) << "lookup_hash enter(" << ino << ", #" << dirino << "/" << name << ")" << dendl;
+ if (unmounting)
+ return -ENOTCONN;
+
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPHASH);
filepath path(ino);
req->set_filepath(path);
Mutex::Locker lock(client_lock);
ldout(cct, 3) << "lookup_ino enter(" << ino << ")" << dendl;
+ if (unmounting)
+ return -ENOTCONN;
+
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPINO);
filepath path(ino);
req->set_filepath(path);
Mutex::Locker lock(client_lock);
ldout(cct, 3) << "lookup_parent enter(" << ino->ino << ")" << dendl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (!ino->dn_set.empty()) {
// if we exposed the parent here, we'd need to check permissions,
// but right now we just rely on the MDS doing so in make_request
Mutex::Locker lock(client_lock);
ldout(cct, 3) << "lookup_name enter(" << ino->ino << ")" << dendl;
+ if (unmounting)
+ return -ENOTCONN;
+
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPNAME);
req->set_filepath2(filepath(parent->ino));
req->set_filepath(filepath(ino->ino));
tout(cct) << "close" << std::endl;
tout(cct) << fd << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *fh = get_filehandle(fd);
if (!fh)
return -EBADF;
tout(cct) << offset << std::endl;
tout(cct) << whence << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << size << std::endl;
tout(cct) << offset << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << size << std::endl;
tout(cct) << offset << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *fh = get_filehandle(fd);
if (!fh)
return -EBADF;
tout(cct) << fd << std::endl;
tout(cct) << offset << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *fh = get_filehandle(fd);
if (!fh)
return -EBADF;
return r;
/* clear the setuid/setgid bits, if any */
- if (unlikely((in->mode & S_ISUID) ||
- (in->mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) {
+ if (unlikely(in->mode & (S_ISUID|S_ISGID)) && size > 0) {
struct ceph_statx stx = { 0 };
put_cap_ref(in, CEPH_CAP_AUTH_SHARED);
tout(cct) << fd << std::endl;
tout(cct) << length << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << fd << std::endl;
tout(cct) << syncdataonly << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << "fstat mask " << hex << mask << dec << std::endl;
tout(cct) << fd << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
tout(cct) << "fstatx flags " << hex << flags << " want " << want << dec << std::endl;
tout(cct) << fd << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
Mutex::Locker lock(client_lock);
tout(cct) << "chdir" << std::endl;
tout(cct) << relpath << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
void Client::getcwd(string& dir, const UserPerm& perms)
{
Mutex::Locker l(client_lock);
- _getcwd(dir, perms);
+ if (!unmounting)
+ _getcwd(dir, perms);
}
int Client::statfs(const char *path, struct statvfs *stbuf,
Mutex::Locker l(client_lock);
tout(cct) << "statfs" << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
ceph_statfs stats;
C_SaferCond cond;
int Client::sync_fs()
{
Mutex::Locker l(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
return _sync_fs();
}
int Client::mksnap(const char *relpath, const char *name, const UserPerm& perm)
{
Mutex::Locker l(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perm);
Inode *snapdir = open_snapdir(in.get());
return _mkdir(snapdir, name, 0, perm);
}
+
int Client::rmsnap(const char *relpath, const char *name, const UserPerm& perms)
{
Mutex::Locker l(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
int Client::get_caps_issued(const char *path, const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath p(path);
InodeRef in;
int r = path_walk(p, &in, perms, true);
tout(cct) << "ll_lookup" << std::endl;
tout(cct) << name << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
int r = 0;
if (!cct->_conf->fuse_default_permissions) {
r = may_lookup(parent, perms);
tout(cct) << "ll_lookupx" << std::endl;
tout(cct) << name << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
int r = 0;
if (!cct->_conf->fuse_default_permissions) {
r = may_lookup(parent, perms);
unsigned int want, unsigned int flags, const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
filepath fp(name, 0);
InodeRef in;
int rc;
tout(cct) << ino.val << std::endl;
tout(cct) << count << std::endl;
+ // Ignore forget if we're no longer mounted
+ if (unmounting)
+ return true;
+
if (ino == 1) return true; // ignore forget on root.
bool last = false;
Inode *Client::ll_get_inode(ino_t ino)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return NULL;
+
vinodeno_t vino = _map_faked_ino(ino);
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
if (p == inode_map.end())
Inode *Client::ll_get_inode(vinodeno_t vino)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return NULL;
+
unordered_map<vinodeno_t,Inode*>::iterator p = inode_map.find(vino);
if (p == inode_map.end())
return NULL;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
int res = _ll_getattr(in, CEPH_STAT_CAP_INODE_ALL, perms);
if (res == 0)
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
int res = 0;
unsigned mask = statx_to_mask(flags, want);
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef target(in);
int res = _ll_setattrx(in, stx, mask, perms, &target);
if (res == 0) {
stat_to_statx(attr, &stx);
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef target(in);
int res = _ll_setattrx(in, &stx, mask, perms, &target);
if (res == 0) {
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, true, CEPH_STAT_CAP_XATTR);
if (r < 0)
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, false, CEPH_STAT_CAP_XATTR);
if (r < 0)
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, true, CEPH_STAT_CAP_XATTR);
if (r < 0)
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, false, CEPH_STAT_CAP_XATTR);
if (r < 0)
int Client::flistxattr(int fd, char *list, size_t size, const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, true);
if (r < 0)
const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, false);
if (r < 0)
int Client::fremovexattr(int fd, const char *name, const UserPerm& perms)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
_setxattr_maybe_wait_for_osdmap(name, value, size);
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, true);
if (r < 0)
_setxattr_maybe_wait_for_osdmap(name, value, size);
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
InodeRef in;
int r = Client::path_walk(path, &in, perms, false);
if (r < 0)
_setxattr_maybe_wait_for_osdmap(name, value, size);
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_getxattr " << vino << " " << name << " size " << size << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_listxattr " << vino << " size " << size << dendl;
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_setxattr " << vino << " " << name << " size " << size << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_removexattr " << vino << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_readlink " << vino << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_mknod " << vparent << " " << name << dendl;
unsigned caps = statx_to_mask(flags, want);
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_mknodx " << vparent << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_mkdir " << vparent << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_mkdirx " << vparent << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_symlink " << vparent << " " << name << " -> " << value
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
ldout(cct, 3) << "ll_symlinkx " << vparent << " " << name << " -> " << value
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_unlink " << vino << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_rmdir " << vino << " " << name << dendl;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vparent = _get_vino(parent);
vinodeno_t vnewparent = _get_vino(newparent);
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
vinodeno_t vnewparent = _get_vino(newparent);
int Client::ll_osdaddr(int osd, uint32_t *addr)
{
Mutex::Locker lock(client_lock);
+
entity_addr_t g;
bool exists = objecter->with_osdmap([&](const OSDMap& o) {
if (!o.exists(osd))
*addr = ntohl(nb_addr);
return 0;
}
+
uint32_t Client::ll_stripe_unit(Inode *in)
{
Mutex::Locker lock(client_lock);
file_layout_t* layout)
{
Mutex::Locker lock(client_lock);
+
inodeno_t ino = ll_get_inodeno(in);
uint32_t object_size = layout->object_size;
uint32_t su = layout->stripe_unit;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_opendir " << vino << dendl;
ldout(cct, 3) << "ll_releasedir " << dirp << dendl;
tout(cct) << "ll_releasedir" << std::endl;
tout(cct) << (unsigned long)dirp << std::endl;
+
+ if (unmounting)
+ return -ENOTCONN;
+
_closedir(dirp);
return 0;
}
tout(cct) << "ll_fsyncdir" << std::endl;
tout(cct) << (unsigned long)dirp << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _fsync(dirp->inode.get(), false);
}
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = _get_vino(in);
ldout(cct, 3) << "ll_open " << vino << " " << ceph_flags_sys2wire(flags) << dendl;
Mutex::Locker lock(client_lock);
InodeRef in;
+ if (unmounting)
+ return -ENOTCONN;
+
int r = _ll_create(parent, name, mode, flags, &in, CEPH_STAT_CAP_INODE_ALL,
fhp, perms);
if (r >= 0) {
Mutex::Locker lock(client_lock);
InodeRef in;
+ if (unmounting)
+ return -ENOTCONN;
int r = _ll_create(parent, name, mode, oflags, &in, caps, fhp, perms);
if (r >= 0) {
tout(cct) << offset << std::endl;
tout(cct) << whence << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _lseek(fh, offset, whence);
}
tout(cct) << off << std::endl;
tout(cct) << len << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _read(fh, off, len, bl);
}
file_layout_t* layout)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
vinodeno_t vino = ll_get_vino(in);
object_t oid = file_object_t(vino.ino, blockid);
C_SaferCond onfinish;
Cond cond;
bool done;
int r = 0;
- Context *onsafe;
+ Context *onsafe = nullptr;
if (length == 0) {
return -EINVAL;
/* lock just in time */
client_lock.Lock();
+ if (unmounting) {
+ client_lock.Unlock();
+ delete onsafe;
+ return -ENOTCONN;
+ }
objecter->write(oid,
object_locator_t(layout->pool_id),
tout(cct) << off << std::endl;
tout(cct) << len << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
int r = _write(fh, off, len, data, NULL, 0);
ldout(cct, 3) << "ll_write " << fh << " " << off << "~" << len << " = " << r
<< dendl;
tout(cct) << "ll_flush" << std::endl;
tout(cct) << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _flush(fh);
}
tout(cct) << "ll_fsync" << std::endl;
tout(cct) << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
int r = _fsync(fh, syncdataonly);
if (r) {
// If we're returning an error, clear it from the FH
tout(cct) << "ll_fallocate " << mode << " " << offset << " " << length << std::endl;
tout(cct) << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _fallocate(fh, mode, offset, length);
}
Mutex::Locker lock(client_lock);
tout(cct) << "fallocate " << " " << fd << mode << " " << offset << " " << length << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *fh = get_filehandle(fd);
if (!fh)
return -EBADF;
tout(cct) << "ll_release (fh)" << std::endl;
tout(cct) << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
if (ll_unclosed_fh_set.count(fh))
ll_unclosed_fh_set.erase(fh);
return _release_fh(fh);
ldout(cct, 3) << "ll_getlk (fh)" << fh << " " << fh->inode->ino << dendl;
tout(cct) << "ll_getk (fh)" << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _getlk(fh, fl, owner);
}
ldout(cct, 3) << "ll_setlk (fh) " << fh << " " << fh->inode->ino << dendl;
tout(cct) << "ll_setk (fh)" << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _setlk(fh, fl, owner, sleep);
}
ldout(cct, 3) << "ll_flock (fh) " << fh << " " << fh->inode->ino << dendl;
tout(cct) << "ll_flock (fh)" << (unsigned long)fh << std::endl;
+ if (unmounting)
+ return -ENOTCONN;
+
return _flock(fh, cmd, owner);
}
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
filepath path(relpath);
InodeRef in;
int r = path_walk(path, &in, perms);
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
int64_t Client::get_default_pool_id()
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
/* first data pool is the default */
return mdsmap->get_first_data_pool();
}
int64_t Client::get_pool_id(const char *pool_name)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
return objecter->with_osdmap(std::mem_fn(&OSDMap::lookup_pg_pool_name),
pool_name);
}
string Client::get_pool_name(int64_t pool)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return string();
+
return objecter->with_osdmap([pool](const OSDMap& o) {
return o.have_pg_pool(pool) ? o.get_pool_name(pool) : string();
});
int Client::get_pool_replication(int64_t pool)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
return objecter->with_osdmap([pool](const OSDMap& o) {
return o.have_pg_pool(pool) ? o.get_pg_pool(pool)->get_size() : -ENOENT;
});
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
int Client::get_osd_crush_location(int id, vector<pair<string, string> >& path)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
if (id < 0)
return -EINVAL;
return objecter->with_osdmap([&](const OSDMap& o) {
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
int Client::get_osd_addr(int osd, entity_addr_t& addr)
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
return objecter->with_osdmap([&](const OSDMap& o) {
if (!o.exists(osd))
return -ENOENT;
{
Mutex::Locker lock(client_lock);
+ if (unmounting)
+ return -ENOTCONN;
+
Fh *f = get_filehandle(fd);
if (!f)
return -EBADF;
int Client::get_local_osd()
{
Mutex::Locker lock(client_lock);
+
+ if (unmounting)
+ return -ENOTCONN;
+
objecter->with_osdmap([this](const OSDMap& o) {
if (o.get_epoch() != local_osd_epoch) {
local_osd = o.find_osd_on_ip(messenger->get_myaddr());
if (cur == root_ancestor)
break;
+ // deleted inode
+ if (cur->nlink == 0) {
+ cur = root_ancestor;
+ break;
+ }
+
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPNAME);
filepath path(cur->ino);
req->set_filepath(path);
{
Mutex::Locker lock(client_lock);
- if (changed.count("client_cache_size") ||
- changed.count("client_cache_mid")) {
- lru.lru_set_max(cct->_conf->client_cache_size);
+ if (changed.count("client_cache_mid")) {
lru.lru_set_midpoint(cct->_conf->client_cache_mid);
}
if (changed.count("client_acl_type")) {