2012-11-14 15:23:40

by Cyrill Gorcunov

[permalink] [raw]
Subject: [patch 6/7] 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 <[email protected]>
CC: Pavel Emelyanov <[email protected]>
CC: Oleg Nesterov <[email protected]>
CC: Andrey Vagin <[email protected]>
CC: Al Viro <[email protected]>
CC: Alexey Dobriyan <[email protected]>
CC: Andrew Morton <[email protected]>
CC: James Bottomley <[email protected]>
CC: "Aneesh Kumar K.V" <[email protected]>
CC: Alexey Dobriyan <[email protected]>
CC: Matthew Helsley <[email protected]>
CC: "J. Bruce Fields" <[email protected]>
CC: "Aneesh Kumar K.V" <[email protected]>
CC: Tvrtko Ursulin <[email protected]>
---
fs/exportfs/expfs.c | 19 ++++++++++++++-----
include/linux/exportfs.h | 2 ++
2 files changed, 16 insertions(+), 5 deletions(-)
Index: linux-2.6.git/fs/exportfs/expfs.c
===================================================================
--- linux-2.6.git.orig/fs/exportfs/expfs.c
+++ linux-2.6.git/fs/exportfs/expfs.c
@@ -341,10 +341,21 @@ static int export_encode_fh(struct inode
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 connectable)
{
- const struct export_operations *nop = dentry->d_sb->s_export_op;
int error;
struct dentry *p = NULL;
struct inode *inode = dentry->d_inode, *parent = NULL;
@@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *de
*/
parent = p->d_inode;
}
- if (nop && nop->encode_fh)
- error = nop->encode_fh(inode, fid->raw, max_len, parent);
- else
- error = export_encode_fh(inode, fid, max_len, parent);
+
+ error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
dput(p);

return error;
Index: linux-2.6.git/include/linux/exportfs.h
===================================================================
--- linux-2.6.git.orig/include/linux/exportfs.h
+++ linux-2.6.git/include/linux/exportfs.h
@@ -177,6 +177,8 @@ struct export_operations {
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,
int *max_len, int connectable);
extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,


2012-11-14 17:38:01

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [patch 6/7] fs, exportfs: Add exportfs_encode_inode_fh helper

On Wed, Nov 14, 2012 at 07:19:43PM +0400, Cyrill Gorcunov wrote:
> 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).

Looks OK to me.--b.

>
> Signed-off-by: Cyrill Gorcunov <[email protected]>
> CC: Pavel Emelyanov <[email protected]>
> CC: Oleg Nesterov <[email protected]>
> CC: Andrey Vagin <[email protected]>
> CC: Al Viro <[email protected]>
> CC: Alexey Dobriyan <[email protected]>
> CC: Andrew Morton <[email protected]>
> CC: James Bottomley <[email protected]>
> CC: "Aneesh Kumar K.V" <[email protected]>
> CC: Alexey Dobriyan <[email protected]>
> CC: Matthew Helsley <[email protected]>
> CC: "J. Bruce Fields" <[email protected]>
> CC: "Aneesh Kumar K.V" <[email protected]>
> CC: Tvrtko Ursulin <[email protected]>
> ---
> fs/exportfs/expfs.c | 19 ++++++++++++++-----
> include/linux/exportfs.h | 2 ++
> 2 files changed, 16 insertions(+), 5 deletions(-)
> Index: linux-2.6.git/fs/exportfs/expfs.c
> ===================================================================
> --- linux-2.6.git.orig/fs/exportfs/expfs.c
> +++ linux-2.6.git/fs/exportfs/expfs.c
> @@ -341,10 +341,21 @@ static int export_encode_fh(struct inode
> 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 connectable)
> {
> - const struct export_operations *nop = dentry->d_sb->s_export_op;
> int error;
> struct dentry *p = NULL;
> struct inode *inode = dentry->d_inode, *parent = NULL;
> @@ -357,10 +368,8 @@ int exportfs_encode_fh(struct dentry *de
> */
> parent = p->d_inode;
> }
> - if (nop && nop->encode_fh)
> - error = nop->encode_fh(inode, fid->raw, max_len, parent);
> - else
> - error = export_encode_fh(inode, fid, max_len, parent);
> +
> + error = exportfs_encode_inode_fh(inode, fid, max_len, parent);
> dput(p);
>
> return error;
> Index: linux-2.6.git/include/linux/exportfs.h
> ===================================================================
> --- linux-2.6.git.orig/include/linux/exportfs.h
> +++ linux-2.6.git/include/linux/exportfs.h
> @@ -177,6 +177,8 @@ struct export_operations {
> 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,
> int *max_len, int connectable);
> extern struct dentry *exportfs_decode_fh(struct vfsmount *mnt, struct fid *fid,
>

2012-11-15 13:51:37

by Pavel Emelyanov

[permalink] [raw]
Subject: Re: [patch 6/7] fs, exportfs: Add exportfs_encode_inode_fh helper

On 11/14/2012 09:37 PM, J. Bruce Fields wrote:
> On Wed, Nov 14, 2012 at 07:19:43PM +0400, Cyrill Gorcunov wrote:
>> 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).
>
> Looks OK to me.--b.

Thank you, Bruce!

>>
>> Signed-off-by: Cyrill Gorcunov <[email protected]>
>> CC: Pavel Emelyanov <[email protected]>
>> CC: Oleg Nesterov <[email protected]>
>> CC: Andrey Vagin <[email protected]>
>> CC: Al Viro <[email protected]>
>> CC: Alexey Dobriyan <[email protected]>
>> CC: Andrew Morton <[email protected]>
>> CC: James Bottomley <[email protected]>
>> CC: "Aneesh Kumar K.V" <[email protected]>
>> CC: Alexey Dobriyan <[email protected]>
>> CC: Matthew Helsley <[email protected]>
>> CC: "J. Bruce Fields" <[email protected]>
>> CC: "Aneesh Kumar K.V" <[email protected]>
>> CC: Tvrtko Ursulin <[email protected]>

Acked-by: Pavel Emelyanov <[email protected]>