mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 00:38:55 +00:00
ceph: move encode_fh to new API
Use parent_inode has a flag for whether nfsd wants a connectable fh, but generate one opportunistically so that we can take advantage of the additional info in there. Signed-off-by: Sage Weil <sage@newdream.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b0b0382bb4
commit
c862868bb4
@ -40,38 +40,49 @@ struct ceph_nfs_confh {
|
|||||||
u32 parent_name_hash;
|
u32 parent_name_hash;
|
||||||
} __attribute__ ((packed));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
|
/*
|
||||||
int connectable)
|
* The presence of @parent_inode here tells us whether NFS wants a
|
||||||
|
* connectable file handle. However, we want to make a connectionable
|
||||||
|
* file handle unconditionally so that the MDS gets as much of a hint
|
||||||
|
* as possible. That means we only use @parent_dentry to indicate
|
||||||
|
* whether nfsd wants a connectable fh, and whether we should indicate
|
||||||
|
* failure from a too-small @max_len.
|
||||||
|
*/
|
||||||
|
static int ceph_encode_fh(struct inode *inode, u32 *rawfh, int *max_len,
|
||||||
|
struct inode *parent_inode)
|
||||||
{
|
{
|
||||||
int type;
|
int type;
|
||||||
struct ceph_nfs_fh *fh = (void *)rawfh;
|
struct ceph_nfs_fh *fh = (void *)rawfh;
|
||||||
struct ceph_nfs_confh *cfh = (void *)rawfh;
|
struct ceph_nfs_confh *cfh = (void *)rawfh;
|
||||||
struct dentry *parent;
|
|
||||||
struct inode *inode = dentry->d_inode;
|
|
||||||
int connected_handle_length = sizeof(*cfh)/4;
|
int connected_handle_length = sizeof(*cfh)/4;
|
||||||
int handle_length = sizeof(*fh)/4;
|
int handle_length = sizeof(*fh)/4;
|
||||||
|
struct dentry *dentry = d_find_alias(inode);
|
||||||
|
struct dentry *parent;
|
||||||
|
|
||||||
/* don't re-export snaps */
|
/* don't re-export snaps */
|
||||||
if (ceph_snap(inode) != CEPH_NOSNAP)
|
if (ceph_snap(inode) != CEPH_NOSNAP)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
spin_lock(&dentry->d_lock);
|
/* if we found an alias, generate a connectable fh */
|
||||||
parent = dentry->d_parent;
|
if (*max_len >= connected_handle_length && dentry) {
|
||||||
if (*max_len >= connected_handle_length) {
|
|
||||||
dout("encode_fh %p connectable\n", dentry);
|
dout("encode_fh %p connectable\n", dentry);
|
||||||
cfh->ino = ceph_ino(dentry->d_inode);
|
spin_lock(&dentry->d_lock);
|
||||||
|
parent = dentry->d_parent;
|
||||||
|
cfh->ino = ceph_ino(inode);
|
||||||
cfh->parent_ino = ceph_ino(parent->d_inode);
|
cfh->parent_ino = ceph_ino(parent->d_inode);
|
||||||
cfh->parent_name_hash = ceph_dentry_hash(parent->d_inode,
|
cfh->parent_name_hash = ceph_dentry_hash(parent->d_inode,
|
||||||
dentry);
|
dentry);
|
||||||
*max_len = connected_handle_length;
|
*max_len = connected_handle_length;
|
||||||
type = 2;
|
type = 2;
|
||||||
|
spin_unlock(&dentry->d_lock);
|
||||||
} else if (*max_len >= handle_length) {
|
} else if (*max_len >= handle_length) {
|
||||||
if (connectable) {
|
if (parent_inode) {
|
||||||
|
/* nfsd wants connectable */
|
||||||
*max_len = connected_handle_length;
|
*max_len = connected_handle_length;
|
||||||
type = 255;
|
type = 255;
|
||||||
} else {
|
} else {
|
||||||
dout("encode_fh %p\n", dentry);
|
dout("encode_fh %p\n", dentry);
|
||||||
fh->ino = ceph_ino(dentry->d_inode);
|
fh->ino = ceph_ino(inode);
|
||||||
*max_len = handle_length;
|
*max_len = handle_length;
|
||||||
type = 1;
|
type = 1;
|
||||||
}
|
}
|
||||||
@ -79,7 +90,6 @@ static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
|
|||||||
*max_len = handle_length;
|
*max_len = handle_length;
|
||||||
type = 255;
|
type = 255;
|
||||||
}
|
}
|
||||||
spin_unlock(&dentry->d_lock);
|
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,9 +257,7 @@ static struct dentry *ceph_fh_to_parent(struct super_block *sb,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct export_operations ceph_export_ops = {
|
const struct export_operations ceph_export_ops = {
|
||||||
#ifdef CEPH_BREAKAGE_FIXED
|
|
||||||
.encode_fh = ceph_encode_fh,
|
.encode_fh = ceph_encode_fh,
|
||||||
#endif
|
|
||||||
.fh_to_dentry = ceph_fh_to_dentry,
|
.fh_to_dentry = ceph_fh_to_dentry,
|
||||||
.fh_to_parent = ceph_fh_to_parent,
|
.fh_to_parent = ceph_fh_to_parent,
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user