Commit 81a6cf2d authored by Sage Weil's avatar Sage Weil

ceph: invalidate affected dentry leases on aborted requests

If we abort a request, we return to caller, but the request may still
complete.  And if we hold the dir FILE_EXCL bit, we may not release a
lease when sending a request.  A simple un-tar, control-c, un-tar again
will reproduce the bug (manifested as a 'Cannot open: File exists').

Ensure we invalidate affected dentry leases (as well dir I_COMPLETE) so
we don't have valid (but incorrect) leases.  Do the same, consistently, at
other sites where I_COMPLETE is similarly cleared.
Signed-off-by: default avatarSage Weil <sage@newdream.net>
parent b4556396
...@@ -888,13 +888,22 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -888,13 +888,22 @@ static int ceph_rename(struct inode *old_dir, struct dentry *old_dentry,
/* ensure target dentry is invalidated, despite /* ensure target dentry is invalidated, despite
rehashing bug in vfs_rename_dir */ rehashing bug in vfs_rename_dir */
new_dentry->d_time = jiffies; ceph_invalidate_dentry_lease(new_dentry);
ceph_dentry(new_dentry)->lease_shared_gen = 0;
} }
ceph_mdsc_put_request(req); ceph_mdsc_put_request(req);
return err; return err;
} }
/*
* Ensure a dentry lease will no longer revalidate.
*/
void ceph_invalidate_dentry_lease(struct dentry *dentry)
{
spin_lock(&dentry->d_lock);
dentry->d_time = jiffies;
ceph_dentry(dentry)->lease_shared_gen = 0;
spin_unlock(&dentry->d_lock);
}
/* /*
* Check if dentry lease is valid. If not, delete the lease. Try to * Check if dentry lease is valid. If not, delete the lease. Try to
......
...@@ -938,8 +938,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, ...@@ -938,8 +938,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
ceph_inode(req->r_locked_dir); ceph_inode(req->r_locked_dir);
dout(" clearing %p complete (empty trace)\n", dout(" clearing %p complete (empty trace)\n",
req->r_locked_dir); req->r_locked_dir);
spin_lock(&req->r_locked_dir->i_lock);
ci->i_ceph_flags &= ~CEPH_I_COMPLETE; ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
ci->i_release_count++; ci->i_release_count++;
spin_unlock(&req->r_locked_dir->i_lock);
if (req->r_dentry)
ceph_invalidate_dentry_lease(req->r_dentry);
if (req->r_old_dentry)
ceph_invalidate_dentry_lease(req->r_old_dentry);
} }
return 0; return 0;
} }
...@@ -1011,13 +1018,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req, ...@@ -1011,13 +1018,15 @@ int ceph_fill_trace(struct super_block *sb, struct ceph_mds_request *req,
req->r_old_dentry->d_name.len, req->r_old_dentry->d_name.len,
req->r_old_dentry->d_name.name, req->r_old_dentry->d_name.name,
dn, dn->d_name.len, dn->d_name.name); dn, dn->d_name.len, dn->d_name.name);
/* ensure target dentry is invalidated, despite /* ensure target dentry is invalidated, despite
rehashing bug in vfs_rename_dir */ rehashing bug in vfs_rename_dir */
dn->d_time = jiffies; ceph_invalidate_dentry_lease(dn);
ceph_dentry(dn)->lease_shared_gen = 0;
/* take overwritten dentry's readdir offset */ /* take overwritten dentry's readdir offset */
ceph_dentry(req->r_old_dentry)->offset = ceph_dentry(req->r_old_dentry)->offset =
ceph_dentry(dn)->offset; ceph_dentry(dn)->offset;
dn = req->r_old_dentry; /* use old_dentry */ dn = req->r_old_dentry; /* use old_dentry */
in = dn->d_inode; in = dn->d_inode;
} }
......
...@@ -1732,12 +1732,17 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, ...@@ -1732,12 +1732,17 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
struct ceph_inode_info *ci = struct ceph_inode_info *ci =
ceph_inode(req->r_locked_dir); ceph_inode(req->r_locked_dir);
dout("aborted, clearing I_COMPLETE on %p\n", dout("aborted, clearing I_COMPLETE on %p, leases\n",
req->r_locked_dir); req->r_locked_dir);
spin_lock(&req->r_locked_dir->i_lock); spin_lock(&req->r_locked_dir->i_lock);
ci->i_ceph_flags &= ~CEPH_I_COMPLETE; ci->i_ceph_flags &= ~CEPH_I_COMPLETE;
ci->i_release_count++; ci->i_release_count++;
spin_unlock(&req->r_locked_dir->i_lock); spin_unlock(&req->r_locked_dir->i_lock);
if (req->r_dentry)
ceph_invalidate_dentry_lease(req->r_dentry);
if (req->r_old_dentry)
ceph_invalidate_dentry_lease(req->r_old_dentry);
} }
} else { } else {
err = req->r_err; err = req->r_err;
......
...@@ -871,6 +871,7 @@ extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req, ...@@ -871,6 +871,7 @@ extern struct dentry *ceph_finish_lookup(struct ceph_mds_request *req,
extern void ceph_dentry_lru_add(struct dentry *dn); extern void ceph_dentry_lru_add(struct dentry *dn);
extern void ceph_dentry_lru_touch(struct dentry *dn); extern void ceph_dentry_lru_touch(struct dentry *dn);
extern void ceph_dentry_lru_del(struct dentry *dn); extern void ceph_dentry_lru_del(struct dentry *dn);
extern void ceph_invalidate_dentry_lease(struct dentry *dentry);
/* /*
* our d_ops vary depending on whether the inode is live, * our d_ops vary depending on whether the inode is live,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment