]> err.no Git - linux-2.6/blobdiff - fs/nfs/super.c
knfsd: nfsv4 delegation recall should take reference on client
[linux-2.6] / fs / nfs / super.c
index a2b1af89ca1af331763a35f3b90f83864edd66d7..b878528b64c1a9d0aed22fd19b20339bc1644b22 100644 (file)
@@ -300,7 +300,10 @@ static const struct super_operations nfs4_sops = {
 };
 #endif
 
-static struct shrinker *acl_shrinker;
+static struct shrinker acl_shrinker = {
+       .shrink         = nfs_access_cache_shrinker,
+       .seeks          = DEFAULT_SEEKS,
+};
 
 /*
  * Register the NFS filesystems
@@ -321,7 +324,7 @@ int __init register_nfs_fs(void)
        if (ret < 0)
                goto error_2;
 #endif
-       acl_shrinker = set_shrinker(DEFAULT_SEEKS, nfs_access_cache_shrinker);
+       register_shrinker(&acl_shrinker);
        return 0;
 
 #ifdef CONFIG_NFS_V4
@@ -339,12 +342,11 @@ error_0:
  */
 void __exit unregister_nfs_fs(void)
 {
-       if (acl_shrinker != NULL)
-               remove_shrinker(acl_shrinker);
+       unregister_shrinker(&acl_shrinker);
 #ifdef CONFIG_NFS_V4
        unregister_filesystem(&nfs4_fs_type);
-       nfs_unregister_sysctl();
 #endif
+       nfs_unregister_sysctl();
        unregister_filesystem(&nfs_fs_type);
 }
 
@@ -730,7 +732,7 @@ static int nfs_parse_mount_options(char *raw,
                                return 0;
                        if (option < 0 || option > 65535)
                                return 0;
-                       mnt->nfs_server.address.sin_port = htonl(option);
+                       mnt->nfs_server.address.sin_port = htons(option);
                        break;
                case Opt_rsize:
                        if (match_int(args, &mnt->rsize))
@@ -909,13 +911,13 @@ static int nfs_parse_mount_options(char *raw,
                        kfree(string);
 
                        switch (token) {
-                       case Opt_udp:
+                       case Opt_xprt_udp:
                                mnt->flags &= ~NFS_MOUNT_TCP;
                                mnt->nfs_server.protocol = IPPROTO_UDP;
                                mnt->timeo = 7;
                                mnt->retrans = 5;
                                break;
-                       case Opt_tcp:
+                       case Opt_xprt_tcp:
                                mnt->flags |= NFS_MOUNT_TCP;
                                mnt->nfs_server.protocol = IPPROTO_TCP;
                                mnt->timeo = 600;
@@ -934,10 +936,10 @@ static int nfs_parse_mount_options(char *raw,
                        kfree(string);
 
                        switch (token) {
-                       case Opt_udp:
+                       case Opt_xprt_udp:
                                mnt->mount_server.protocol = IPPROTO_UDP;
                                break;
-                       case Opt_tcp:
+                       case Opt_xprt_tcp:
                                mnt->mount_server.protocol = IPPROTO_TCP;
                                break;
                        default:
@@ -1151,20 +1153,20 @@ static int nfs_validate_mount_data(struct nfs_mount_data **options,
                c = strchr(dev_name, ':');
                if (c == NULL)
                        return -EINVAL;
-               len = c - dev_name - 1;
+               len = c - dev_name;
                if (len > sizeof(data->hostname))
-                       return -EINVAL;
+                       return -ENAMETOOLONG;
                strncpy(data->hostname, dev_name, len);
                args.nfs_server.hostname = data->hostname;
 
                c++;
                if (strlen(c) > NFS_MAXPATHLEN)
-                       return -EINVAL;
+                       return -ENAMETOOLONG;
                args.nfs_server.export_path = c;
 
                status = nfs_try_mount(&args, mntfh);
                if (status)
-                       return -EINVAL;
+                       return status;
 
                /*
                 * Translate to nfs_mount_data, which nfs_fill_super
@@ -1301,34 +1303,6 @@ static void nfs_clone_super(struct super_block *sb,
        nfs_initialise_sb(sb);
 }
 
-static int nfs_set_super(struct super_block *s, void *_server)
-{
-       struct nfs_server *server = _server;
-       int ret;
-
-       s->s_fs_info = server;
-       ret = set_anon_super(s, server);
-       if (ret == 0)
-               server->s_dev = s->s_dev;
-       return ret;
-}
-
-static int nfs_compare_super(struct super_block *sb, void *data)
-{
-       struct nfs_server *server = data, *old = NFS_SB(sb);
-
-       if (memcmp(&old->nfs_client->cl_addr,
-                               &server->nfs_client->cl_addr,
-                               sizeof(old->nfs_client->cl_addr)) != 0)
-               return 0;
-       /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
-       if (old->flags & NFS_MOUNT_UNSHARED)
-               return 0;
-       if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
-               return 0;
-       return 1;
-}
-
 #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
 
 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
@@ -1357,9 +1331,46 @@ static int nfs_compare_mount_options(const struct super_block *s, const struct n
                goto Ebusy;
        if (clnt_a->cl_auth->au_flavor != clnt_b->cl_auth->au_flavor)
                goto Ebusy;
-       return 0;
+       return 1;
 Ebusy:
-       return -EBUSY;
+       return 0;
+}
+
+struct nfs_sb_mountdata {
+       struct nfs_server *server;
+       int mntflags;
+};
+
+static int nfs_set_super(struct super_block *s, void *data)
+{
+       struct nfs_sb_mountdata *sb_mntdata = data;
+       struct nfs_server *server = sb_mntdata->server;
+       int ret;
+
+       s->s_flags = sb_mntdata->mntflags;
+       s->s_fs_info = server;
+       ret = set_anon_super(s, server);
+       if (ret == 0)
+               server->s_dev = s->s_dev;
+       return ret;
+}
+
+static int nfs_compare_super(struct super_block *sb, void *data)
+{
+       struct nfs_sb_mountdata *sb_mntdata = data;
+       struct nfs_server *server = sb_mntdata->server, *old = NFS_SB(sb);
+       int mntflags = sb_mntdata->mntflags;
+
+       if (memcmp(&old->nfs_client->cl_addr,
+                               &server->nfs_client->cl_addr,
+                               sizeof(old->nfs_client->cl_addr)) != 0)
+               return 0;
+       /* Note: NFS_MOUNT_UNSHARED == NFS4_MOUNT_UNSHARED */
+       if (old->flags & NFS_MOUNT_UNSHARED)
+               return 0;
+       if (memcmp(&old->fsid, &server->fsid, sizeof(old->fsid)) != 0)
+               return 0;
+       return nfs_compare_mount_options(sb, server, mntflags);
 }
 
 static int nfs_get_sb(struct file_system_type *fs_type,
@@ -1371,6 +1382,9 @@ static int nfs_get_sb(struct file_system_type *fs_type,
        struct nfs_mount_data *data = raw_data;
        struct dentry *mntroot;
        int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+       struct nfs_sb_mountdata sb_mntdata = {
+               .mntflags = flags,
+       };
        int error;
 
        /* Validate the mount data */
@@ -1384,28 +1398,25 @@ static int nfs_get_sb(struct file_system_type *fs_type,
                error = PTR_ERR(server);
                goto out;
        }
+       sb_mntdata.server = server;
 
        if (server->flags & NFS_MOUNT_UNSHARED)
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(fs_type, compare_super, nfs_set_super, server);
+       s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
        }
 
        if (s->s_fs_info != server) {
-               error = nfs_compare_mount_options(s, server, flags);
                nfs_free_server(server);
                server = NULL;
-               if (error < 0)
-                       goto error_splat_super;
        }
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               s->s_flags = flags;
                nfs_fill_super(s, data);
        }
 
@@ -1458,6 +1469,9 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
        struct nfs_server *server;
        struct dentry *mntroot;
        int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+       struct nfs_sb_mountdata sb_mntdata = {
+               .mntflags = flags,
+       };
        int error;
 
        dprintk("--> nfs_xdev_get_sb()\n");
@@ -1468,28 +1482,25 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
                error = PTR_ERR(server);
                goto out_err_noserver;
        }
+       sb_mntdata.server = server;
 
        if (server->flags & NFS_MOUNT_UNSHARED)
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
+       s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
        }
 
        if (s->s_fs_info != server) {
-               error = nfs_compare_mount_options(s, server, flags);
                nfs_free_server(server);
                server = NULL;
-               if (error < 0)
-                       goto error_splat_super;
        }
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               s->s_flags = flags;
                nfs_clone_super(s, data->sb);
        }
 
@@ -1666,7 +1677,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
                /* while calculating len, pretend ':' is '\0' */
                len = c - dev_name;
                if (len > NFS4_MAXNAMLEN)
-                       return -EINVAL;
+                       return -ENAMETOOLONG;
                *hostname = kzalloc(len, GFP_KERNEL);
                if (*hostname == NULL)
                        return -ENOMEM;
@@ -1675,7 +1686,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
                c++;                    /* step over the ':' */
                len = strlen(c);
                if (len > NFS4_MAXPATHLEN)
-                       return -EINVAL;
+                       return -ENAMETOOLONG;
                *mntpath = kzalloc(len + 1, GFP_KERNEL);
                if (*mntpath == NULL)
                        return -ENOMEM;
@@ -1683,6 +1694,9 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
 
                dprintk("MNTPATH: %s\n", *mntpath);
 
+               if (args.client_address == NULL)
+                       goto out_no_client_address;
+
                *ip_addr = args.client_address;
 
                break;
@@ -1703,6 +1717,10 @@ out_inval_auth:
 out_no_address:
        dfprintk(MOUNT, "NFS4: mount program didn't pass remote address\n");
        return -EINVAL;
+
+out_no_client_address:
+       dfprintk(MOUNT, "NFS4: mount program didn't pass callback address\n");
+       return -EINVAL;
 }
 
 /*
@@ -1720,6 +1738,9 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
        struct dentry *mntroot;
        char *mntpath = NULL, *hostname = NULL, *ip_addr = NULL;
        int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+       struct nfs_sb_mountdata sb_mntdata = {
+               .mntflags = flags,
+       };
        int error;
 
        /* Validate the mount data */
@@ -1735,12 +1756,13 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
                error = PTR_ERR(server);
                goto out;
        }
+       sb_mntdata.server = server;
 
        if (server->flags & NFS4_MOUNT_UNSHARED)
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(fs_type, compare_super, nfs_set_super, server);
+       s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_free;
@@ -1753,7 +1775,6 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               s->s_flags = flags;
                nfs4_fill_super(s);
        }
 
@@ -1807,6 +1828,9 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
        struct nfs_server *server;
        struct dentry *mntroot;
        int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+       struct nfs_sb_mountdata sb_mntdata = {
+               .mntflags = flags,
+       };
        int error;
 
        dprintk("--> nfs4_xdev_get_sb()\n");
@@ -1817,12 +1841,13 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
                error = PTR_ERR(server);
                goto out_err_noserver;
        }
+       sb_mntdata.server = server;
 
        if (server->flags & NFS4_MOUNT_UNSHARED)
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
+       s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
@@ -1835,7 +1860,6 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               s->s_flags = flags;
                nfs4_clone_super(s, data->sb);
        }
 
@@ -1878,6 +1902,9 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
        struct dentry *mntroot;
        struct nfs_fh mntfh;
        int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
+       struct nfs_sb_mountdata sb_mntdata = {
+               .mntflags = flags,
+       };
        int error;
 
        dprintk("--> nfs4_referral_get_sb()\n");
@@ -1888,12 +1915,13 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
                error = PTR_ERR(server);
                goto out_err_noserver;
        }
+       sb_mntdata.server = server;
 
        if (server->flags & NFS4_MOUNT_UNSHARED)
                compare_super = NULL;
 
        /* Get a superblock - note that we may end up sharing one that already exists */
-       s = sget(&nfs_fs_type, compare_super, nfs_set_super, server);
+       s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata);
        if (IS_ERR(s)) {
                error = PTR_ERR(s);
                goto out_err_nosb;
@@ -1906,7 +1934,6 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type, int flags,
 
        if (!s->s_root) {
                /* initial superblock/root creation */
-               s->s_flags = flags;
                nfs4_fill_super(s);
        }