mirror of
https://github.com/ceph/ceph
synced 2025-01-18 09:02:08 +00:00
mds: look at inode locks to determine whether to expose stable or projected inode fields
And clean up the set_trace_dist() hacks.
This commit is contained in:
parent
241d02c2de
commit
ee50c988c6
@ -423,8 +423,14 @@ static int fill_inode(struct inode *inode,
|
||||
|
||||
spin_lock(&inode->i_lock);
|
||||
|
||||
/*
|
||||
* provided version will be odd if inode value is projected,
|
||||
* even if stable. skip the update if we have a newer info
|
||||
* (e.g., due to inode info racing form multiple MDSs), or if
|
||||
* we are getting projected (unstable) inode info.
|
||||
*/
|
||||
if (le64_to_cpu(info->version) > 0 &&
|
||||
ci->i_version == le64_to_cpu(info->version))
|
||||
(ci->i_version & ~1) > le64_to_cpu(info->version))
|
||||
goto no_change;
|
||||
|
||||
issued = __ceph_caps_issued(ci, NULL);
|
||||
|
@ -1301,18 +1301,15 @@ void CInode::decode_snap_blob(bufferlist& snapbl)
|
||||
|
||||
|
||||
bool CInode::encode_inodestat(bufferlist& bl, Session *session,
|
||||
snapid_t snapid, bool projected)
|
||||
snapid_t snapid)
|
||||
{
|
||||
int client = session->inst.name.num();
|
||||
|
||||
bool valid = true;
|
||||
|
||||
// pick a version!
|
||||
inode_t *i;
|
||||
if (projected)
|
||||
i = get_projected_inode();
|
||||
else
|
||||
i = &inode;
|
||||
inode_t *oi = &inode;
|
||||
inode_t *pi = get_projected_inode();
|
||||
|
||||
map<string, bufferptr> *pxattrs = &xattrs;
|
||||
|
||||
@ -1329,7 +1326,7 @@ bool CInode::encode_inodestat(bufferlist& bl, Session *session,
|
||||
<< " " << p->second.inode.rstat
|
||||
<< dendl;
|
||||
assert(p->second.first <= snapid && snapid <= p->first);
|
||||
i = &p->second.inode;
|
||||
pi = oi = &p->second.inode;
|
||||
pxattrs = &p->second.xattrs;
|
||||
}
|
||||
}
|
||||
@ -1339,9 +1336,14 @@ bool CInode::encode_inodestat(bufferlist& bl, Session *session,
|
||||
*/
|
||||
struct ceph_mds_reply_inode e;
|
||||
memset(&e, 0, sizeof(e));
|
||||
e.ino = i->ino;
|
||||
e.ino = oi->ino;
|
||||
e.snapid = snapid ? (__u64)snapid:CEPH_NOSNAP; // 0 -> NOSNAP
|
||||
e.version = i->version;
|
||||
e.rdev = oi->rdev;
|
||||
|
||||
// "fake" a version that is old (stable) version, +1 if projected.
|
||||
e.version = (oi->version * 2) + is_projected();
|
||||
|
||||
inode_t *i = filelock.is_xlocked_by_client(client) ? pi:oi;
|
||||
e.layout = i->layout;
|
||||
e.size = i->size;
|
||||
e.max_size = i->max_size;
|
||||
@ -1350,23 +1352,27 @@ bool CInode::encode_inodestat(bufferlist& bl, Session *session,
|
||||
i->mtime.encode_timeval(&e.mtime);
|
||||
i->atime.encode_timeval(&e.atime);
|
||||
e.time_warp_seq = i->time_warp_seq;
|
||||
e.mode = i->mode;
|
||||
e.uid = i->uid;
|
||||
e.gid = i->gid;
|
||||
e.nlink = i->nlink;
|
||||
|
||||
|
||||
e.files = i->dirstat.nfiles;
|
||||
e.subdirs = i->dirstat.nsubdirs;
|
||||
i->rstat.rctime.encode_timeval(&e.rctime);
|
||||
e.rbytes = i->rstat.rbytes;
|
||||
e.rfiles = i->rstat.rfiles;
|
||||
e.rsubdirs = i->rstat.rsubdirs;
|
||||
|
||||
i = authlock.is_xlocked_by_client(client) ? pi:oi;
|
||||
e.mode = i->mode;
|
||||
e.uid = i->uid;
|
||||
e.gid = i->gid;
|
||||
|
||||
i = linklock.is_xlocked_by_client(client) ? pi:oi;
|
||||
e.nlink = i->nlink;
|
||||
|
||||
e.rdev = i->rdev;
|
||||
e.fragtree.nsplits = dirfragtree._splits.size();
|
||||
|
||||
Capability *cap = get_client_cap(client);
|
||||
|
||||
i = xattrlock.is_xlocked_by_client(client) ? pi:oi;
|
||||
bool had_latest_xattrs = cap && (cap->issued() & CEPH_CAP_XATTR_RDCACHE) &&
|
||||
cap->client_xattr_version == i->xattr_version;
|
||||
|
||||
|
@ -422,7 +422,7 @@ private:
|
||||
|
||||
|
||||
// for giving to clients
|
||||
bool encode_inodestat(bufferlist& bl, Session *session, snapid_t snapid=CEPH_NOSNAP, bool projected=false);
|
||||
bool encode_inodestat(bufferlist& bl, Session *session, snapid_t snapid=CEPH_NOSNAP);
|
||||
|
||||
|
||||
// -- locks --
|
||||
|
@ -540,7 +540,7 @@ void Server::early_reply(MDRequest *mdr, CInode *tracei, CDentry *tracedn)
|
||||
snapid_t snapid = CEPH_NOSNAP;
|
||||
CInode *snapdiri = 0;
|
||||
if (tracei || tracedn)
|
||||
set_trace_dist(mdr->session, reply, tracei, tracedn, snapid, snapdiri, true, mdr);
|
||||
set_trace_dist(mdr->session, reply, tracei, tracedn, snapid, snapdiri, mdr);
|
||||
|
||||
messenger->send_message(reply, client_inst);
|
||||
|
||||
@ -622,7 +622,7 @@ void Server::reply_request(MDRequest *mdr, MClientReply *reply, CInode *tracei,
|
||||
// send reply, with trace, and possible leases
|
||||
if (!did_early_reply && // don't issue leases if we sent an earlier reply already
|
||||
(tracei || tracedn))
|
||||
set_trace_dist(session, reply, tracei, tracedn, snapid, snapdiri);
|
||||
set_trace_dist(session, reply, tracei, tracedn, snapid, snapdiri, mdr);
|
||||
messenger->send_message(reply, client_inst);
|
||||
}
|
||||
|
||||
@ -668,7 +668,7 @@ void Server::encode_null_lease(bufferlist& bl)
|
||||
*/
|
||||
void Server::set_trace_dist(Session *session, MClientReply *reply, CInode *in, CDentry *dn,
|
||||
snapid_t snapid, CInode *snapdiri,
|
||||
bool expose_projected_inode, MDRequest *mdr)
|
||||
MDRequest *mdr)
|
||||
{
|
||||
// inode, dentry, dir, ..., inode
|
||||
bufferlist bl;
|
||||
@ -701,7 +701,7 @@ void Server::set_trace_dist(Session *session, MClientReply *reply, CInode *in, C
|
||||
dout(10) << "set_trace_dist snaprealm " << *realm << dendl;
|
||||
}
|
||||
|
||||
in->encode_inodestat(bl, session, snapid, expose_projected_inode);
|
||||
in->encode_inodestat(bl, session, snapid);
|
||||
dout(20) << "set_trace_dist added snapid " << snapid << " " << *in << dendl;
|
||||
|
||||
if (snapid != CEPH_NOSNAP && in == snapdiri) {
|
||||
@ -715,7 +715,7 @@ void Server::set_trace_dist(Session *session, MClientReply *reply, CInode *in, C
|
||||
|
||||
// back to the live tree
|
||||
snapid = CEPH_NOSNAP;
|
||||
in->encode_inodestat(bl, session, snapid, false);
|
||||
in->encode_inodestat(bl, session, snapid);
|
||||
numi++;
|
||||
dout(20) << "set_trace_dist added snapid " << snapid << " " << *in << dendl;
|
||||
|
||||
@ -736,8 +736,6 @@ void Server::set_trace_dist(Session *session, MClientReply *reply, CInode *in, C
|
||||
dentry:
|
||||
dout(15) << "set_trace_dist " << *dn << dendl;
|
||||
|
||||
expose_projected_inode = false;
|
||||
|
||||
::encode(dn->get_name(), bl);
|
||||
if (snapid == CEPH_NOSNAP)
|
||||
lmask = mds->locker->issue_client_lease(dn, client, bl, now, session);
|
||||
|
@ -80,7 +80,7 @@ public:
|
||||
void reply_request(MDRequest *mdr, MClientReply *reply, CInode *tracei = 0, CDentry *tracedn = 0);
|
||||
void set_trace_dist(Session *session, MClientReply *reply, CInode *in, CDentry *dn,
|
||||
snapid_t snapid, CInode *snapdiri,
|
||||
bool projected = false, MDRequest *mdr = 0);
|
||||
MDRequest *mdr = 0);
|
||||
|
||||
void encode_empty_dirstat(bufferlist& bl);
|
||||
void encode_infinite_lease(bufferlist& bl);
|
||||
|
Loading…
Reference in New Issue
Block a user