Blob Blame History Raw
From: Luis Henriques <lhenriques@suse.com>
Date: Thu, 21 Mar 2019 10:20:09 +0000
Subject: ceph: factor out ceph_lookup_inode()
Git-commit: 3886274adf34a4e38417772e3d1c0b213380004e
Patch-mainline: v5.2-rc1
References: bsc#1138681

This function will be used by __fh_to_dentry and by the quotas code, to
find quota realm inodes that are not visible in the mountpoint.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: "Yan, Zheng" <zyan@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 fs/ceph/export.c |   14 ++++++++++++--
 fs/ceph/super.h  |    1 +
 2 files changed, 13 insertions(+), 2 deletions(-)

--- a/fs/ceph/export.c
+++ b/fs/ceph/export.c
@@ -58,7 +58,7 @@ static int ceph_encode_fh(struct inode *
 	return type;
 }
 
-static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
+struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino)
 {
 	struct ceph_mds_client *mdsc = ceph_sb_to_client(sb)->mdsc;
 	struct inode *inode;
@@ -90,13 +90,23 @@ static struct dentry *__fh_to_dentry(str
 			ihold(inode);
 		ceph_mdsc_put_request(req);
 		if (!inode)
-			return ERR_PTR(-ESTALE);
+			return err < 0 ? ERR_PTR(err) : ERR_PTR(-ESTALE);
 		if (inode->i_nlink == 0) {
 			iput(inode);
 			return ERR_PTR(-ESTALE);
 		}
 	}
 
+	return inode;
+}
+
+static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino)
+{
+	struct inode *inode = ceph_lookup_inode(sb, ino);
+
+	if (IS_ERR(inode))
+		return ERR_CAST(inode);
+
 	return d_obtain_alias(inode);
 }
 
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1057,6 +1057,7 @@ extern long ceph_ioctl(struct file *file
 
 /* export.c */
 extern const struct export_operations ceph_export_ops;
+struct inode *ceph_lookup_inode(struct super_block *sb, u64 ino);
 
 /* locks.c */
 extern __init void ceph_flock_init(void);