if (p.end()) {
ldout(cct, 10) << "insert_trace -- no trace" << dendl;
- if (request->dentry &&
- request->dentry->dir &&
- (request->dentry->dir->parent_inode->flags & I_COMPLETE)) {
- ldout(cct, 10) << " clearing I_COMPLETE on " << *request->dentry->dir->parent_inode << dendl;
- request->dentry->dir->parent_inode->flags &= ~I_COMPLETE;
- request->dentry->dir->release_count++;
+ Dentry *d = request->dentry();
+ if (d && d->dir &&
+ (d->dir->parent_inode->flags & I_COMPLETE)) {
+ ldout(cct, 10) << " clearing I_COMPLETE on " << *d->dir->parent_inode << dendl;
+ d->dir->parent_inode->flags &= ~I_COMPLETE;
+ d->dir->release_count++;
}
return NULL;
}
Dir *dir = diri->open_dir();
insert_dentry_inode(dir, dname, &dlease, in, request->sent_stamp, session, true,
((request->head.op == CEPH_MDS_OP_RENAME) ?
- request->old_dentry : NULL));
+ request->old_dentry() : NULL));
} else {
if (diri->dir && diri->dir->dentries.count(dname)) {
Dentry *dn = diri->dir->dentries[dname];
bool is_hash = false;
Inode *in = NULL;
+ Dentry *de = NULL;
Cap *cap = NULL;
if (req->resend_mds >= 0) {
if (cct->_conf->client_use_random_mds)
goto random_mds;
- if (req->inode) {
- in = req->inode;
+ in = req->inode();
+ de = req->dentry();
+ if (in) {
ldout(cct, 20) << "choose_target_mds starting with req->inode " << *in << dendl;
if (req->path.depth()) {
hash = ceph_str_hash(in->dir_layout.dl_dir_hash,
<< " => " << hash << dendl;
is_hash = true;
}
- } else if (req->dentry) {
- if (req->dentry->inode) {
- in = req->dentry->inode;
+ } else if (de) {
+ if (de->inode) {
+ in = de->inode;
ldout(cct, 20) << "choose_target_mds starting with req->dentry inode " << *in << dendl;
} else {
- in = req->dentry->dir->parent_inode;
+ in = de->dir->parent_inode;
hash = ceph_str_hash(in->dir_layout.dl_dir_hash,
- req->dentry->name.data(),
- req->dentry->name.length());
+ de->name.data(),
+ de->name.length());
ldout(cct, 20) << "choose_target_mds dentry dir hash is " << (int)in->dir_layout.dl_dir_hash
- << " on " << req->dentry->name
+ << " on " << de->name
<< " => " << hash << dendl;
is_hash = true;
}
// created. for now, do this by name. someday, do this by the
// ino... which we know! FIXME.
Inode *target = 0; // ptarget may be NULL
- if (request->dentry) {
+ Dentry *d = request->dentry();
+ if (d) {
// rename is special: we handle old_dentry unlink explicitly in insert_dentry_inode(), so
// we need to compensate and do the same here.
- if (request->old_dentry) {
- unlink(request->old_dentry, false);
+ Dentry *od = request->old_dentry();
+ if (od) {
+ unlink(od, false);
}
ldout(cct, 10) << "make_request got traceless reply, looking up #"
- << request->dentry->dir->parent_inode->ino << "/" << request->dentry->name
+ << d->dir->parent_inode->ino << "/" << d->name
<< " got_ino " << got_created_ino
<< " ino " << created_ino
<< dendl;
- r = _do_lookup(request->dentry->dir->parent_inode, request->dentry->name, &target);
+ r = _do_lookup(d->dir->parent_inode, d->name, &target);
} else {
+ Inode *in = request->inode();
ldout(cct, 10) << "make_request got traceless reply, forcing getattr on #"
- << request->inode->ino << dendl;
- r = _getattr(request->inode, request->regetattr_mask, uid, gid, true);
- target = request->inode;
+ << in->ino << dendl;
+ r = _getattr(in, request->regetattr_mask, uid, gid, true);
+ target = in;
}
if (r >= 0) {
if (ptarget)
{
ldout(cct, 20) << "encode_cap_releases enter (req: "
<< req << ", mds: " << mds << ")" << dendl;
- if (req->inode_drop && req->inode)
- encode_inode_release(req->inode, req,
+ if (req->inode_drop && req->inode())
+ encode_inode_release(req->inode(), req,
mds, req->inode_drop,
req->inode_unless);
- if (req->old_inode_drop && req->old_inode)
- encode_inode_release(req->old_inode, req,
+ if (req->old_inode_drop && req->old_inode())
+ encode_inode_release(req->old_inode(), req,
mds, req->old_inode_drop,
req->old_inode_unless);
- if (req->other_inode_drop && req->other_inode)
- encode_inode_release(req->other_inode, req,
+ if (req->other_inode_drop && req->other_inode())
+ encode_inode_release(req->other_inode(), req,
mds, req->other_inode_drop,
req->other_inode_unless);
- if (req->dentry_drop && req->dentry)
- encode_dentry_release(req->dentry, req,
+ if (req->dentry_drop && req->dentry())
+ encode_dentry_release(req->dentry(), req,
mds, req->dentry_drop,
req->dentry_unless);
- if (req->old_dentry_drop && req->old_dentry)
- encode_dentry_release(req->old_dentry, req,
+ if (req->old_dentry_drop && req->old_dentry())
+ encode_dentry_release(req->old_dentry(), req,
mds, req->old_dentry_drop,
req->old_dentry_unless);
ldout(cct, 25) << "encode_cap_releases exit (req: "
ldout(cct, 10) << "send_request rebuilding request " << request->get_tid()
<< " for mds." << mds << dendl;
MClientRequest *r = build_client_request(request);
- if (request->dentry)
+ if (request->dentry())
r->set_dentry_wanted();
if (request->got_unsafe)
r->set_replayed_op();
}
request->mds = mds;
- if (request->inode && request->inode->caps.count(mds))
- request->sent_on_mseq = request->inode->caps[mds]->mseq;
+ Inode *in = request->inode();
+ if (in && in->caps.count(mds))
+ request->sent_on_mseq = in->caps[mds]->mseq;
session->requests.push_back(&request->item);
// if the filepath's haven't been set, set them!
if (request->path.empty()) {
- if (request->inode)
- request->inode->make_nosnap_relative_path(request->path);
- else if (request->dentry) {
- if (request->dentry->inode)
- request->dentry->inode->make_nosnap_relative_path(request->path);
- else if (request->dentry->dir) {
- request->dentry->dir->parent_inode->make_nosnap_relative_path(request->path);
- request->path.push_dentry(request->dentry->name);
+ Inode *in = request->inode();
+ Dentry *de = request->dentry();
+ if (in)
+ in->make_nosnap_relative_path(request->path);
+ else if (de) {
+ if (de->inode)
+ de->inode->make_nosnap_relative_path(request->path);
+ else if (de->dir) {
+ de->dir->parent_inode->make_nosnap_relative_path(request->path);
+ request->path.push_dentry(de->name);
}
else ldout(cct, 1) << "Warning -- unable to construct a filepath!"
<< " No path, inode, or appropriately-endowed dentry given!"
<< " from mds." << request->mds << dendl;
request->send_to_auth = true;
request->resend_mds = choose_target_mds(request);
+ Inode *in = request->inode();
if (request->resend_mds >= 0 &&
request->resend_mds == request->mds &&
- (request->inode == NULL ||
- request->inode->caps.count(request->resend_mds) == 0 ||
- request->sent_on_mseq == request->inode->caps[request->resend_mds]->mseq)) {
+ (in == NULL ||
+ in->caps.count(request->resend_mds) == 0 ||
+ request->sent_on_mseq == in->caps[request->resend_mds]->mseq)) {
// have to return ESTALE
} else {
request->caller_cond->Signal();
dir->make_nosnap_relative_path(path);
path.push_dentry(name);
req->set_filepath(path);
- req->inode = dir;
+ req->set_inode(dir);
req->head.args.getattr.mask = 0;
ldout(cct, 10) << "_do_lookup on " << path << dendl;
}
// success
- (*pdn)->get();
return 0;
}
filepath path;
in->make_nosnap_relative_path(path);
req->set_filepath(path);
- req->inode = in;
+ req->set_inode(in);
req->head.args.getattr.mask = mask;
int res = make_request(req, uid, gid);
filepath path;
in->make_nosnap_relative_path(path);
req->set_filepath(path);
- req->inode = in;
+ req->set_inode(in);
if (mask & CEPH_SETATTR_MODE) {
req->head.args.setattr.mode = attr->st_mode;
filepath path;
diri->make_nosnap_relative_path(path);
req->set_filepath(path);
- req->inode = diri;
+ req->set_inode(diri);
req->head.args.readdir.frag = fg;
if (dirp->last_name.length()) {
req->path2.set_path(dirp->last_name.c_str());
req->head.args.open.mode = mode;
req->head.args.open.pool = -1;
req->head.args.open.old_size = in->size; // for O_TRUNC
- req->inode = in;
+ req->set_inode(in);
result = make_request(req, uid, gid);
}
MetaRequest *req = new MetaRequest(CEPH_MDS_OP_LOOKUPPARENT);
filepath path(in->ino);
req->set_filepath(path);
- req->inode = in;
+ req->set_inode(in);
int res = make_request(req, -1, -1);
if (res < 0)
break;
in->make_nosnap_relative_path(path);
req->set_filepath(path);
req->set_string2(name);
- req->inode = in;
+ req->set_inode(in);
req->head.args.setxattr.flags = flags;
bufferlist bl;
in->make_nosnap_relative_path(path);
req->set_filepath(path);
req->set_filepath2(name);
- req->inode = in;
+ req->set_inode(in);
int res = make_request(req, uid, gid);
dir->make_nosnap_relative_path(path);
path.push_dentry(name);
req->set_filepath(path);
- req->inode = dir;
+ req->set_inode(dir);
req->head.args.mknod.mode = mode;
req->head.args.mknod.rdev = rdev;
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- int res = get_or_create(dir, name, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
res = make_request(req, uid, gid, inp);
dir->make_nosnap_relative_path(path);
path.push_dentry(name);
req->set_filepath(path);
- req->inode = dir;
+ req->set_inode(dir);
req->head.args.open.flags = flags | O_CREAT;
req->head.args.open.mode = mode;
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- int res = get_or_create(dir, name, &req->dentry);
+ bufferlist extra_bl;
+ inodeno_t created_ino;
+
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
res = make_request(req, uid, gid, inp, created);
if (res < 0) {
dir->make_nosnap_relative_path(path);
path.push_dentry(name);
req->set_filepath(path);
- req->inode = dir;
+ req->set_inode(dir);
req->head.args.mkdir.mode = mode;
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- int res = get_or_create(dir, name, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
ldout(cct, 10) << "_mkdir: making request" << dendl;
res = make_request(req, uid, gid, inp);
dir->make_nosnap_relative_path(path);
path.push_dentry(name);
req->set_filepath(path);
- req->inode = dir;
+ req->set_inode(dir);
req->set_string2(target);
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- int res = get_or_create(dir, name, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
res = make_request(req, uid, gid, inp);
path.push_dentry(name);
req->set_filepath(path);
- int res = get_or_create(dir, name, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- res = _lookup(dir, name, &req->other_inode);
+ Inode *otherin;
+ res = _lookup(dir, name, &otherin);
+ req->set_other_inode(otherin);
req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
- req->inode = dir;
+ req->set_inode(dir);
res = make_request(req, uid, gid);
if (res == 0) {
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
req->inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
- req->inode = dir;
+ req->set_inode(dir);
- int res = get_or_create(dir, name, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, name, &de);
if (res < 0)
goto fail;
- res = _lookup(dir, name, &req->inode);
+ req->set_dentry(de);
+ Inode *in;
+ res = _lookup(dir, name, &in);
+ if (res < 0)
+ goto fail;
+ req->set_inode(in);
res = make_request(req, uid, gid);
if (res == 0) {
req->set_filepath(to);
req->set_filepath2(from);
- int res = get_or_create(fromdir, fromname, &req->old_dentry);
+ Dentry *oldde;
+ int res = get_or_create(fromdir, fromname, &oldde);
if (res < 0)
goto fail;
+ req->set_old_dentry(oldde);
req->old_dentry_drop = CEPH_CAP_FILE_SHARED;
req->old_dentry_unless = CEPH_CAP_FILE_EXCL;
- res = get_or_create(todir, toname, &req->dentry);
+ Dentry *de;
+ res = get_or_create(todir, toname, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
req->dentry_drop = CEPH_CAP_FILE_SHARED;
req->dentry_unless = CEPH_CAP_FILE_EXCL;
- res = _lookup(fromdir, fromname, &req->old_inode);
+ Inode *oldin;
+ res = _lookup(fromdir, fromname, &oldin);
if (res < 0)
goto fail;
+ req->set_old_inode(oldin);
req->old_inode_drop = CEPH_CAP_LINK_SHARED;
- res = _lookup(todir, toname, &req->other_inode);
+ Inode *otherin;
+ res = _lookup(todir, toname, &otherin);
+ if (res < 0)
+ goto fail;
+ req->set_other_inode(otherin);
req->other_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL;
- req->inode = todir;
+ req->set_inode(todir);
Inode *target;
res = make_request(req, uid, gid, &target);
filepath existing(in->ino);
req->set_filepath2(existing);
- req->inode = dir;
+ req->set_inode(dir);
req->inode_drop = CEPH_CAP_FILE_SHARED;
req->inode_unless = CEPH_CAP_FILE_EXCL;
- int res = get_or_create(dir, newname, &req->dentry);
+ Dentry *de;
+ int res = get_or_create(dir, newname, &de);
if (res < 0)
goto fail;
+ req->set_dentry(de);
res = make_request(req, uid, gid, inp);
ldout(cct, 10) << "link result is " << res << dendl;