NFS: Reduce the NFS mount code stack usage.

This appears to fix the Oops reported in
http://bugzilla.kernel.org/show_bug.cgi?id=10826

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

+40 -28
+40 -28
fs/nfs/super.c
··· 1216 { 1217 struct nfs_mount_data *data = (struct nfs_mount_data *)options; 1218 1219 - memset(args, 0, sizeof(*args)); 1220 - 1221 if (data == NULL) 1222 goto out_no_data; 1223 ··· 1583 { 1584 struct nfs_server *server = NULL; 1585 struct super_block *s; 1586 - struct nfs_fh mntfh; 1587 - struct nfs_parsed_mount_data data; 1588 struct dentry *mntroot; 1589 int (*compare_super)(struct super_block *, void *) = nfs_compare_super; 1590 struct nfs_sb_mountdata sb_mntdata = { 1591 .mntflags = flags, 1592 }; 1593 - int error; 1594 1595 - security_init_mnt_opts(&data.lsm_opts); 1596 1597 /* Validate the mount data */ 1598 - error = nfs_validate_mount_data(raw_data, &data, &mntfh, dev_name); 1599 if (error < 0) 1600 goto out; 1601 1602 /* Get a volume representation */ 1603 - server = nfs_create_server(&data, &mntfh); 1604 if (IS_ERR(server)) { 1605 error = PTR_ERR(server); 1606 goto out; ··· 1633 1634 if (!s->s_root) { 1635 /* initial superblock/root creation */ 1636 - nfs_fill_super(s, &data); 1637 } 1638 1639 - mntroot = nfs_get_root(s, &mntfh); 1640 if (IS_ERR(mntroot)) { 1641 error = PTR_ERR(mntroot); 1642 goto error_splat_super; 1643 } 1644 1645 - error = security_sb_set_mnt_opts(s, &data.lsm_opts); 1646 if (error) 1647 goto error_splat_root; 1648 ··· 1652 error = 0; 1653 1654 out: 1655 - kfree(data.nfs_server.hostname); 1656 - kfree(data.mount_server.hostname); 1657 - security_free_mnt_opts(&data.lsm_opts); 1658 return error; 1659 1660 out_err_nosb: ··· 1805 struct sockaddr_in *ap; 1806 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options; 1807 char *c; 1808 - 1809 - memset(args, 0, sizeof(*args)); 1810 1811 if (data == NULL) 1812 goto out_no_data; ··· 1963 static int nfs4_get_sb(struct file_system_type *fs_type, 1964 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) 1965 { 1966 - struct nfs_parsed_mount_data data; 1967 struct super_block *s; 1968 struct nfs_server *server; 1969 - struct nfs_fh mntfh; 1970 struct dentry *mntroot; 1971 int (*compare_super)(struct super_block *, void *) = nfs_compare_super; 1972 struct nfs_sb_mountdata sb_mntdata = { 1973 .mntflags = flags, 1974 }; 1975 - int error; 1976 1977 - security_init_mnt_opts(&data.lsm_opts); 1978 1979 /* Validate the mount data */ 1980 - error = nfs4_validate_mount_data(raw_data, &data, dev_name); 1981 if (error < 0) 1982 goto out; 1983 1984 /* Get a volume representation */ 1985 - server = nfs4_create_server(&data, &mntfh); 1986 if (IS_ERR(server)) { 1987 error = PTR_ERR(server); 1988 goto out; ··· 2018 nfs4_fill_super(s); 2019 } 2020 2021 - mntroot = nfs4_get_root(s, &mntfh); 2022 if (IS_ERR(mntroot)) { 2023 error = PTR_ERR(mntroot); 2024 goto error_splat_super; 2025 } 2026 2027 - error = security_sb_set_mnt_opts(s, &data.lsm_opts); 2028 if (error) 2029 goto error_splat_root; 2030 ··· 2034 error = 0; 2035 2036 out: 2037 - kfree(data.client_address); 2038 - kfree(data.nfs_server.export_path); 2039 - kfree(data.nfs_server.hostname); 2040 - security_free_mnt_opts(&data.lsm_opts); 2041 return error; 2042 2043 out_free:
··· 1216 { 1217 struct nfs_mount_data *data = (struct nfs_mount_data *)options; 1218 1219 if (data == NULL) 1220 goto out_no_data; 1221 ··· 1585 { 1586 struct nfs_server *server = NULL; 1587 struct super_block *s; 1588 + struct nfs_parsed_mount_data *data; 1589 + struct nfs_fh *mntfh; 1590 struct dentry *mntroot; 1591 int (*compare_super)(struct super_block *, void *) = nfs_compare_super; 1592 struct nfs_sb_mountdata sb_mntdata = { 1593 .mntflags = flags, 1594 }; 1595 + int error = -ENOMEM; 1596 1597 + data = kzalloc(sizeof(*data), GFP_KERNEL); 1598 + mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); 1599 + if (data == NULL || mntfh == NULL) 1600 + goto out_free_fh; 1601 + 1602 + security_init_mnt_opts(&data->lsm_opts); 1603 1604 /* Validate the mount data */ 1605 + error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name); 1606 if (error < 0) 1607 goto out; 1608 1609 /* Get a volume representation */ 1610 + server = nfs_create_server(data, mntfh); 1611 if (IS_ERR(server)) { 1612 error = PTR_ERR(server); 1613 goto out; ··· 1630 1631 if (!s->s_root) { 1632 /* initial superblock/root creation */ 1633 + nfs_fill_super(s, data); 1634 } 1635 1636 + mntroot = nfs_get_root(s, mntfh); 1637 if (IS_ERR(mntroot)) { 1638 error = PTR_ERR(mntroot); 1639 goto error_splat_super; 1640 } 1641 1642 + error = security_sb_set_mnt_opts(s, &data->lsm_opts); 1643 if (error) 1644 goto error_splat_root; 1645 ··· 1649 error = 0; 1650 1651 out: 1652 + kfree(data->nfs_server.hostname); 1653 + kfree(data->mount_server.hostname); 1654 + security_free_mnt_opts(&data->lsm_opts); 1655 + out_free_fh: 1656 + kfree(mntfh); 1657 + kfree(data); 1658 return error; 1659 1660 out_err_nosb: ··· 1799 struct sockaddr_in *ap; 1800 struct nfs4_mount_data *data = (struct nfs4_mount_data *)options; 1801 char *c; 1802 1803 if (data == NULL) 1804 goto out_no_data; ··· 1959 static int nfs4_get_sb(struct file_system_type *fs_type, 1960 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) 1961 { 1962 + struct nfs_parsed_mount_data *data; 1963 struct super_block *s; 1964 struct nfs_server *server; 1965 + struct nfs_fh *mntfh; 1966 struct dentry *mntroot; 1967 int (*compare_super)(struct super_block *, void *) = nfs_compare_super; 1968 struct nfs_sb_mountdata sb_mntdata = { 1969 .mntflags = flags, 1970 }; 1971 + int error = -ENOMEM; 1972 1973 + data = kzalloc(sizeof(*data), GFP_KERNEL); 1974 + mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); 1975 + if (data == NULL || mntfh == NULL) 1976 + goto out_free_fh; 1977 + 1978 + security_init_mnt_opts(&data->lsm_opts); 1979 1980 /* Validate the mount data */ 1981 + error = nfs4_validate_mount_data(raw_data, data, dev_name); 1982 if (error < 0) 1983 goto out; 1984 1985 /* Get a volume representation */ 1986 + server = nfs4_create_server(data, mntfh); 1987 if (IS_ERR(server)) { 1988 error = PTR_ERR(server); 1989 goto out; ··· 2009 nfs4_fill_super(s); 2010 } 2011 2012 + mntroot = nfs4_get_root(s, mntfh); 2013 if (IS_ERR(mntroot)) { 2014 error = PTR_ERR(mntroot); 2015 goto error_splat_super; 2016 } 2017 2018 + error = security_sb_set_mnt_opts(s, &data->lsm_opts); 2019 if (error) 2020 goto error_splat_root; 2021 ··· 2025 error = 0; 2026 2027 out: 2028 + kfree(data->client_address); 2029 + kfree(data->nfs_server.export_path); 2030 + kfree(data->nfs_server.hostname); 2031 + security_free_mnt_opts(&data->lsm_opts); 2032 + out_free_fh: 2033 + kfree(mntfh); 2034 + kfree(data); 2035 return error; 2036 2037 out_free: