ceph: ensure d_name/d_parent stability in ceph_mdsc_lease_send_msg()
Signed-off-by: "Yan, Zheng" <zyan@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
parent
41883ba8ee
commit
8f2a98ef3c
|
@ -1433,8 +1433,7 @@ static bool __dentry_lease_is_valid(struct ceph_dentry_info *di)
|
|||
return false;
|
||||
}
|
||||
|
||||
static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags,
|
||||
struct inode *dir)
|
||||
static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags)
|
||||
{
|
||||
struct ceph_dentry_info *di;
|
||||
struct ceph_mds_session *session = NULL;
|
||||
|
@ -1466,7 +1465,7 @@ static int dentry_lease_is_valid(struct dentry *dentry, unsigned int flags,
|
|||
spin_unlock(&dentry->d_lock);
|
||||
|
||||
if (session) {
|
||||
ceph_mdsc_lease_send_msg(session, dir, dentry,
|
||||
ceph_mdsc_lease_send_msg(session, dentry,
|
||||
CEPH_MDS_LEASE_RENEW, seq);
|
||||
ceph_put_mds_session(session);
|
||||
}
|
||||
|
@ -1566,7 +1565,7 @@ static int ceph_d_revalidate(struct dentry *dentry, unsigned int flags)
|
|||
ceph_snap(d_inode(dentry)) == CEPH_SNAPDIR) {
|
||||
valid = 1;
|
||||
} else {
|
||||
valid = dentry_lease_is_valid(dentry, flags, dir);
|
||||
valid = dentry_lease_is_valid(dentry, flags);
|
||||
if (valid == -ECHILD)
|
||||
return valid;
|
||||
if (valid || dir_lease_is_valid(dir, dentry)) {
|
||||
|
|
|
@ -3941,31 +3941,33 @@ bad:
|
|||
}
|
||||
|
||||
void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
|
||||
struct inode *inode,
|
||||
struct dentry *dentry, char action,
|
||||
u32 seq)
|
||||
{
|
||||
struct ceph_msg *msg;
|
||||
struct ceph_mds_lease *lease;
|
||||
int len = sizeof(*lease) + sizeof(u32);
|
||||
int dnamelen = 0;
|
||||
struct inode *dir;
|
||||
int len = sizeof(*lease) + sizeof(u32) + NAME_MAX;
|
||||
|
||||
dout("lease_send_msg inode %p dentry %p %s to mds%d\n",
|
||||
inode, dentry, ceph_lease_op_name(action), session->s_mds);
|
||||
dnamelen = dentry->d_name.len;
|
||||
len += dnamelen;
|
||||
dout("lease_send_msg identry %p %s to mds%d\n",
|
||||
dentry, ceph_lease_op_name(action), session->s_mds);
|
||||
|
||||
msg = ceph_msg_new(CEPH_MSG_CLIENT_LEASE, len, GFP_NOFS, false);
|
||||
if (!msg)
|
||||
return;
|
||||
lease = msg->front.iov_base;
|
||||
lease->action = action;
|
||||
lease->ino = cpu_to_le64(ceph_vino(inode).ino);
|
||||
lease->first = lease->last = cpu_to_le64(ceph_vino(inode).snap);
|
||||
lease->seq = cpu_to_le32(seq);
|
||||
put_unaligned_le32(dnamelen, lease + 1);
|
||||
memcpy((void *)(lease + 1) + 4, dentry->d_name.name, dnamelen);
|
||||
|
||||
spin_lock(&dentry->d_lock);
|
||||
dir = d_inode(dentry->d_parent);
|
||||
lease->ino = cpu_to_le64(ceph_ino(dir));
|
||||
lease->first = lease->last = cpu_to_le64(ceph_snap(dir));
|
||||
|
||||
put_unaligned_le32(dentry->d_name.len, lease + 1);
|
||||
memcpy((void *)(lease + 1) + 4,
|
||||
dentry->d_name.name, dentry->d_name.len);
|
||||
spin_unlock(&dentry->d_lock);
|
||||
/*
|
||||
* if this is a preemptive lease RELEASE, no need to
|
||||
* flush request stream, since the actual request will
|
||||
|
|
|
@ -505,7 +505,6 @@ extern char *ceph_mdsc_build_path(struct dentry *dentry, int *plen, u64 *base,
|
|||
|
||||
extern void __ceph_mdsc_drop_dentry_lease(struct dentry *dentry);
|
||||
extern void ceph_mdsc_lease_send_msg(struct ceph_mds_session *session,
|
||||
struct inode *inode,
|
||||
struct dentry *dentry, char action,
|
||||
u32 seq);
|
||||
|
||||
|
|
Loading…
Reference in New Issue