public:
// cons
- CDentry(const nstring& n, CInode *in) :
+ CDentry(const nstring& n, CInode *in, snapid_t f=0, snapid_t l=CEPH_NOSNAP) :
name(n),
- first(0), last(CEPH_NOSNAP),
+ first(f), last(l),
remote_ino(0), remote_d_type(0),
inode(in), dir(0),
version(0), projected_version(0),
dir_offset(0),
auth_pins(0), nested_auth_pins(0), nested_anchors(0),
lock(this, CEPH_LOCK_DN, WAIT_LOCK_OFFSET) { }
- CDentry(const nstring& n, inodeno_t ino, unsigned char dt, CInode *in=0) :
+ CDentry(const nstring& n, inodeno_t ino, unsigned char dt, CInode *in=0,
+ snapid_t f=0, snapid_t l=CEPH_NOSNAP) :
name(n),
- first(0), last(CEPH_NOSNAP),
+ first(f), last(l),
remote_ino(ino), remote_d_type(dt),
inode(in), dir(0),
version(0), projected_version(0),
* linking fun
*/
-CDentry* CDir::add_null_dentry(const nstring& dname)
+CDentry* CDir::add_null_dentry(const nstring& dname,
+ snapid_t first, snapid_t last)
{
// foreign
assert(lookup(dname) == 0);
// create dentry
- CDentry* dn = new CDentry(dname, 0);
+ CDentry* dn = new CDentry(dname, NULL, first, last);
if (is_auth())
dn->state_set(CDentry::STATE_AUTH);
cache->lru.lru_insert_mid(dn);
}
-CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in)
+CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in,
+ snapid_t first, snapid_t last)
{
// primary
assert(lookup(dname) == 0);
// create dentry
- CDentry* dn = new CDentry(dname, 0);
+ CDentry* dn = new CDentry(dname, NULL, first, last);
if (is_auth())
dn->state_set(CDentry::STATE_AUTH);
cache->lru.lru_insert_mid(dn);
return dn;
}
-CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type)
+CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type,
+ snapid_t first, snapid_t last)
{
// foreign
assert(lookup(dname) == 0);
// create dentry
- CDentry* dn = new CDentry(dname, ino, d_type);
+ CDentry* dn = new CDentry(dname, ino, d_type, NULL, first, last);
if (is_auth())
dn->state_set(CDentry::STATE_AUTH);
cache->lru.lru_insert_mid(dn);
// dname
string dname;
::decode(dname, p);
- dout(24) << "_fetched parsed marker '" << type << "' dname '" << dname << dendl;
+ snapid_t first, last;
+ ::decode(first, p);
+ ::decode(last, p);
+ dout(24) << "_fetched parsed marker '" << type << "' dname '" << dname
+ << " [" << first << "," << last << "]"
+ << dendl;
- CDentry *dn = lookup(dname); // existing dentry?
+ CDentry *dn = lookup(dname, first); // existing dentry?
if (type == 'L') {
// hard link
}
} else {
// (remote) link
- dn = add_remote_dentry(dname, ino, d_type);
+ dn = add_remote_dentry(dname, ino, d_type, first, last);
// link to inode?
CInode *in = cache->get_inode(ino); // we may or may not have it.
} else {
// add inode
CInode *in = 0;
- if (cache->have_inode(inode.ino)) {
- in = cache->get_inode(inode.ino);
+ if (cache->have_inode(inode.ino, first)) {
+ in = cache->get_inode(inode.ino, first);
dout(-12) << "_fetched got (but i already had) " << *in
<< " mode " << in->inode.mode
<< " mtime " << in->inode.mtime << dendl;
// inode
in = new CInode(cache);
in->inode = inode;
+ in->snapid = first;
// symlink?
if (in->is_symlink())
cache->add_inode( in );
// link
- dn = add_primary_dentry(dname, in);
+ dn = add_primary_dentry(dname, in, first, last);
dout(12) << "_fetched got " << *dn << " " << *in << dendl;
//in->hack_accessed = false;
// marker, name, ino
bl.append( "L", 1 ); // remote link
- ::encode(it->first, bl);
+ ::encode(dn->name, bl);
+ ::encode(dn->first, bl);
+ ::encode(dn->last, bl);
::encode(ino, bl);
::encode(d_type, bl);
} else {
// marker, name, inode, [symlink string]
bl.append( "I", 1 ); // inode
- ::encode(it->first, bl);
+ ::encode(dn->name, bl);
+ ::encode(dn->first, bl);
+ ::encode(dn->last, bl);
::encode(in->inode, bl);
if (in->is_symlink()) {
return iter->second;
}
- CDentry* add_null_dentry(const nstring& dname);
- CDentry* add_primary_dentry(const nstring& dname, CInode *in);
- CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type);
+ CDentry* add_null_dentry(const nstring& dname,
+ snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+ CDentry* add_primary_dentry(const nstring& dname, CInode *in,
+ snapid_t first=0, snapid_t last=CEPH_NOSNAP);
+ CDentry* add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned char d_type,
+ snapid_t first=0, snapid_t last=CEPH_NOSNAP);
void remove_dentry( CDentry *dn ); // delete dentry
void link_remote_inode( CDentry *dn, inodeno_t ino, unsigned char d_type);
void link_remote_inode( CDentry *dn, CInode *in );