aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@openvz.org>2012-12-17 19:05:08 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 20:15:27 -0500
commit711c7bf9914060d7aaf3c1a15f38094a5d5e748f (patch)
tree9e77f75166d591c2a3979494253793add2df607a
parentab49bdecc3ebb46ab661f5f05d5c5ea9606406c6 (diff)
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: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Pavel 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: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/exportfs/expfs.c19
-rw-r--r--include/linux/exportfs.h2
2 files changed, 16 insertions, 5 deletions
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 10f137381ac7..606bb074c501 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -341,10 +341,21 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,
341 return type; 341 return type;
342} 342}
343 343
344int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
345 int *max_len, struct inode *parent)
346{
347 const struct export_operations *nop = inode->i_sb->s_export_op;
348
349 if (nop && nop->encode_fh)
350 return nop->encode_fh(inode, fid->raw, max_len, parent);
351
352 return export_encode_fh(inode, fid, max_len, parent);
353}
354EXPORT_SYMBOL_GPL(exportfs_encode_inode_fh);
355
344int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len, 356int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, int *max_len,
345 int connectable) 357 int connectable)
346{ 358{
347 const struct export_operations *nop = dentry->d_sb->s_export_op;
348 int error; 359 int error;
349 struct dentry *p = NULL; 360 struct dentry *p = NULL;
350 struct inode *inode = dentry->d_inode, *parent = NULL; 361 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 */ 368 */
358 parent = p->d_inode; 369 parent = p->d_inode;
359 } 370 }
360 if (nop && nop->encode_fh) 371
361 error = nop->encode_fh(inode, fid->raw, max_len, parent); 372 error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
362 else
363 error = export_encode_fh(inode, fid, max_len, parent);
364 dput(p); 373 dput(p);
365 374
366 return error; 375 return error;
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 12291a7ee275..c7e6b6392ab8 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -177,6 +177,8 @@ struct export_operations {
177 int (*commit_metadata)(struct inode *inode); 177 int (*commit_metadata)(struct inode *inode);
178}; 178};
179 179
180extern int exportfs_encode_inode_fh(struct inode *inode, struct fid *fid,
181 int *max_len, struct inode *parent);
180extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid, 182extern int exportfs_encode_fh(struct dentry *dentry, struct fid *fid,
181 int *max_len, int connectable); 183 int *max_len, int connectable);
182extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid, 184extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,