Skip to content

Commit 3c454cf

Browse files
committed
ceph: use LOOKUPINO to make unconnected nfs fh more reliable
If we are unable to locate an inode by ino, ask the MDS using the new LOOKUPINO command. Signed-off-by: Sage Weil <sage@newdream.net>
1 parent aedfec5 commit 3c454cf

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎fs/ceph/export.c‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ static int ceph_encode_fh(struct dentry *dentry, u32 *rawfh, int *max_len,
8686
static struct dentry *__fh_to_dentry(struct super_block *sb,
8787
struct ceph_nfs_fh *fh)
8888
{
89+
struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
8990
struct inode *inode;
9091
struct dentry *dentry;
9192
struct ceph_vino vino;
@@ -95,8 +96,22 @@ static struct dentry *__fh_to_dentry(struct super_block *sb,
9596
vino.ino = fh->ino;
9697
vino.snap = CEPH_NOSNAP;
9798
inode = ceph_find_inode(sb, vino);
98-
if (!inode)
99-
return ERR_PTR(-ESTALE);
99+
if (!inode) {
100+
struct ceph_mds_request *req;
101+
102+
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LOOKUPINO,
103+
USE_ANY_MDS);
104+
if (IS_ERR(req))
105+
return ERR_CAST(req);
106+
107+
req->r_ino1 = vino;
108+
req->r_num_caps = 1;
109+
err = ceph_mdsc_do_request(mdsc, NULL, req);
110+
ceph_mdsc_put_request(req);
111+
inode = ceph_find_inode(sb, vino);
112+
if (!inode)
113+
return ERR_PTR(-ESTALE);
114+
}
100115

101116
dentry = d_obtain_alias(inode);
102117
if (IS_ERR(dentry)) {

‎include/linux/ceph/ceph_fs.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ enum {
313313
CEPH_MDS_OP_GETATTR = 0x00101,
314314
CEPH_MDS_OP_LOOKUPHASH = 0x00102,
315315
CEPH_MDS_OP_LOOKUPPARENT = 0x00103,
316+
CEPH_MDS_OP_LOOKUPINO = 0x00104,
316317

317318
CEPH_MDS_OP_SETXATTR = 0x01105,
318319
CEPH_MDS_OP_RMXATTR = 0x01106,

0 commit comments

Comments
 (0)