Commit 711c7bf9 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Linus Torvalds

fs, exportfs: add exportfs_encode_inode_fh() helper

We will need this helper in the next patch to provide a file handle for
inotify marks in /proc/pid/fdinfo output.

The patch is rather providing the way to use inodes directly when dentry
is not available (like in case of inotify system).
Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: default avatarPavel Emelyanov <xemul@parallels.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Andrey Vagin <avagin@openvz.org>
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: James Bottomley <jbottomley@parallels.com>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Matthew Helsley <matt.helsley@gmail.com>
Cc: "J. Bruce Fields" <bfields@fieldses.org>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@onelan.co.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ab49bdec
...@@ -341,10 +341,21 @@ static int export_encode_fh(struct inode *inode, struct fid *fid, ...@@ -341,10 +341,21 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
return type; return type;
} }
int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
int *max_len, struct inode *parent)
{
const struct export_operations *nop = inode->i_sb->s_export_op;
if (nop && nop->encode_fh)
return nop->encode_fh(inode, fid->raw, max_len, parent);
return export_encode_fh(inode, fid, max_len, parent);
}
EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
int connectable) int connectable)
{ {
const struct export_operations *nop = dentry->d_sb->s_export_op;
int error; int error;
struct dentry *p = NULL; struct dentry *p = NULL;
struct inode *inode = dentry->d_inode, *parent = NULL; struct inode *inode = dentry->d_inode, *parent = NULL;
...@@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, ...@@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
*/ */
parent = p->d_inode; parent = p->d_inode;
} }
if (nop && nop->encode_fh)
error = nop->encode_fh(inode, fid->raw, max_len, parent); error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
else
error = export_encode_fh(inode, fid, max_len, parent);
dput(p); dput(p);
return error; return error;
......
...@@ -177,6 +177,8 @@ struct export_operations { ...@@ -177,6 +177,8 @@ struct export_operations {
int (*commit_metadata)(struct inode *inode); int (*commit_metadata)(struct inode *inode);
}; };
extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
int *max_len, struct inode *parent);
extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
int *max_len, int connectable); int *max_len, int connectable);
extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
......
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