Commit 10f11c34 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Linus Torvalds

knfsd: exportfs: remove CALL macro

Currently exportfs uses a way to call methods very differently from the rest
of the kernel.  This patch changes it to the standard conventions for method
calls.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNeil Brown <neilb@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d37065cd
...@@ -6,11 +6,36 @@ ...@@ -6,11 +6,36 @@
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/namei.h> #include <linux/namei.h>
struct export_operations export_op_default; #define dprintk(fmt, args...) do{}while(0)
#define CALL(ops,fun) ((ops->fun)?(ops->fun):export_op_default.fun)
#define dprintk(fmt, args...) do{}while(0) static int get_name(struct dentry *dentry, char *name,
struct dentry *child);
static struct dentry *exportfs_get_dentry(struct super_block *sb, void *obj)
{
struct dentry *result = ERR_PTR(-ESTALE);
if (sb->s_export_op->get_dentry) {
result = sb->s_export_op->get_dentry(sb, obj);
if (!result)
result = ERR_PTR(-ESTALE);
}
return result;
}
static int exportfs_get_name(struct dentry *dir, char *name,
struct dentry *child)
{
struct export_operations *nop = dir->d_sb->s_export_op;
if (nop->get_name)
return nop->get_name(dir, name, child);
else
return get_name(dir, name, child);
}
static struct dentry * static struct dentry *
find_acceptable_alias(struct dentry *result, find_acceptable_alias(struct dentry *result,
...@@ -78,7 +103,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -78,7 +103,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
{ {
struct dentry *result = NULL; struct dentry *result = NULL;
struct dentry *target_dir; struct dentry *target_dir;
int err; int err = -ESTALE;
struct export_operations *nops = sb->s_export_op; struct export_operations *nops = sb->s_export_op;
struct dentry *alias; struct dentry *alias;
int noprogress; int noprogress;
...@@ -87,14 +112,10 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -87,14 +112,10 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
/* /*
* Attempt to find the inode. * Attempt to find the inode.
*/ */
result = CALL(sb->s_export_op,get_dentry)(sb,obj); result = exportfs_get_dentry(sb, obj);
err = -ESTALE; if (IS_ERR(result))
if (result == NULL) return result;
goto err_out;
if (IS_ERR(result)) {
err = PTR_ERR(result);
goto err_out;
}
if (S_ISDIR(result->d_inode->i_mode) && if (S_ISDIR(result->d_inode->i_mode) &&
(result->d_flags & DCACHE_DISCONNECTED)) { (result->d_flags & DCACHE_DISCONNECTED)) {
/* it is an unconnected directory, we must connect it */ /* it is an unconnected directory, we must connect it */
...@@ -122,12 +143,12 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -122,12 +143,12 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
if (parent == NULL) if (parent == NULL)
goto err_result; goto err_result;
target_dir = CALL(sb->s_export_op,get_dentry)(sb,parent); target_dir = exportfs_get_dentry(sb,parent);
if (IS_ERR(target_dir)) if (IS_ERR(target_dir)) {
err = PTR_ERR(target_dir); err = PTR_ERR(target_dir);
if (target_dir == NULL || IS_ERR(target_dir))
goto err_result; goto err_result;
} }
}
/* /*
* Now we need to make sure that target_dir is properly connected. * Now we need to make sure that target_dir is properly connected.
* It may already be, as the flag isn't always updated when connection * It may already be, as the flag isn't always updated when connection
...@@ -177,18 +198,27 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -177,18 +198,27 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
spin_unlock(&pd->d_lock); spin_unlock(&pd->d_lock);
noprogress = 0; noprogress = 0;
} else { } else {
/* we have hit the top of a disconnected path. Try /*
* to find parent and connect * We have hit the top of a disconnected path, try to
* note: racing with some other process renaming a * find parent and connect.
* directory isn't much of a problem here. If someone *
* renames the directory, it will end up properly * Racing with some other process renaming a directory
* connected, which is what we want * isn't much of a problem here. If someone renames
* the directory, it will end up properly connected,
* which is what we want
*
* Getting the parent can't be supported generically,
* the locking is too icky.
*
* Instead we just return EACCES. If server reboots
* or inodes get flushed, you lose
*/ */
struct dentry *ppd; struct dentry *ppd = ERR_PTR(-EACCES);
struct dentry *npd; struct dentry *npd;
mutex_lock(&pd->d_inode->i_mutex); mutex_lock(&pd->d_inode->i_mutex);
ppd = CALL(nops,get_parent)(pd); if (nops->get_parent)
ppd = nops->get_parent(pd);
mutex_unlock(&pd->d_inode->i_mutex); mutex_unlock(&pd->d_inode->i_mutex);
if (IS_ERR(ppd)) { if (IS_ERR(ppd)) {
...@@ -199,7 +229,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -199,7 +229,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
break; break;
} }
dprintk("find_exported_dentry: find name of %lu in %lu\n", pd->d_inode->i_ino, ppd->d_inode->i_ino); dprintk("find_exported_dentry: find name of %lu in %lu\n", pd->d_inode->i_ino, ppd->d_inode->i_ino);
err = CALL(nops,get_name)(ppd, nbuf, pd); err = exportfs_get_name(ppd, nbuf, pd);
if (err) { if (err) {
dput(ppd); dput(ppd);
dput(pd); dput(pd);
...@@ -250,7 +280,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -250,7 +280,7 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
/* if we weren't after a directory, have one more step to go */ /* if we weren't after a directory, have one more step to go */
if (result != target_dir) { if (result != target_dir) {
struct dentry *nresult; struct dentry *nresult;
err = CALL(nops,get_name)(target_dir, nbuf, result); err = exportfs_get_name(target_dir, nbuf, result);
if (!err) { if (!err) {
mutex_lock(&target_dir->d_inode->i_mutex); mutex_lock(&target_dir->d_inode->i_mutex);
nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf)); nresult = lookup_one_len(nbuf, target_dir, strlen(nbuf));
...@@ -286,23 +316,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent, ...@@ -286,23 +316,9 @@ find_exported_dentry(struct super_block *sb, void *obj, void *parent,
dput(target_dir); dput(target_dir);
err_result: err_result:
dput(result); dput(result);
err_out:
return ERR_PTR(err); return ERR_PTR(err);
} }
static struct dentry *get_parent(struct dentry *child)
{
/* get_parent cannot be supported generically, the locking
* is too icky.
* instead, we just return EACCES. If server reboots or inodes
* get flushed, you lose
*/
return ERR_PTR(-EACCES);
}
struct getdents_callback { struct getdents_callback {
char *name; /* name that was found. It already points to a char *name; /* name that was found. It already points to a
buffer NAME_MAX+1 is size */ buffer NAME_MAX+1 is size */
...@@ -392,11 +408,6 @@ static int get_name(struct dentry *dentry, char *name, ...@@ -392,11 +408,6 @@ static int get_name(struct dentry *dentry, char *name,
return error; return error;
} }
static struct dentry *get_dentry(struct super_block *sb, void *vobjp)
{
return ERR_PTR(-ESTALE);
}
/** /**
* export_encode_fh - default export_operations->encode_fh function * export_encode_fh - default export_operations->encode_fh function
* @dentry: the dentry to encode * @dentry: the dentry to encode
...@@ -473,8 +484,14 @@ int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len, ...@@ -473,8 +484,14 @@ int exportfs_encode_fh(struct dentry *dentry, __u32 *fh, int *max_len,
int connectable) int connectable)
{ {
struct export_operations *nop = dentry->d_sb->s_export_op; struct export_operations *nop = dentry->d_sb->s_export_op;
int error;
if (nop->encode_fh)
error = nop->encode_fh(dentry, fh, max_len, connectable);
else
error = export_encode_fh(dentry, fh, max_len, connectable);
return CALL(nop, encode_fh)(dentry, fh, max_len, connectable); return error;
} }
EXPORT_SYMBOL_GPL(exportfs_encode_fh); EXPORT_SYMBOL_GPL(exportfs_encode_fh);
...@@ -483,21 +500,20 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len, ...@@ -483,21 +500,20 @@ struct dentry *exportfs_decode_fh(struct vfsmount *mnt, __u32 *fh, int fh_len,
void *context) void *context)
{ {
struct export_operations *nop = mnt->mnt_sb->s_export_op; struct export_operations *nop = mnt->mnt_sb->s_export_op;
struct dentry *result;
return CALL(nop, decode_fh)(mnt->mnt_sb, fh, fh_len, fileid_type, if (nop->decode_fh) {
result = nop->decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type,
acceptable, context);
} else {
result = export_decode_fh(mnt->mnt_sb, fh, fh_len, fileid_type,
acceptable, context); acceptable, context);
}
return result;
} }
EXPORT_SYMBOL_GPL(exportfs_decode_fh); EXPORT_SYMBOL_GPL(exportfs_decode_fh);
struct export_operations export_op_default = {
.decode_fh = export_decode_fh,
.encode_fh = export_encode_fh,
.get_name = get_name,
.get_parent = get_parent,
.get_dentry = get_dentry,
};
EXPORT_SYMBOL(find_exported_dentry); EXPORT_SYMBOL(find_exported_dentry);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
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