diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-04-16 16:22:46 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-05-14 15:09:22 -0400 |
commit | 364d015e5208e4669a4ae9fab2ab104ff26bc159 (patch) | |
tree | 33d949fe10f70dda0d9ab018e6c47595c25b700b /fs/nfs/nfs4namespace.c | |
parent | fbca779a8d240d82ef1439247033fd491f81547c (diff) |
NFSv4: Reduce the stack footprint of try_location()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4namespace.c')
-rw-r--r-- | fs/nfs/nfs4namespace.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/nfs/nfs4namespace.c b/fs/nfs/nfs4namespace.c index f071d12c613b..832f9b50f7a0 100644 --- a/fs/nfs/nfs4namespace.c +++ b/fs/nfs/nfs4namespace.c | |||
@@ -115,6 +115,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
115 | char *page, char *page2, | 115 | char *page, char *page2, |
116 | const struct nfs4_fs_location *location) | 116 | const struct nfs4_fs_location *location) |
117 | { | 117 | { |
118 | const size_t addr_bufsize = sizeof(struct sockaddr_storage); | ||
118 | struct vfsmount *mnt = ERR_PTR(-ENOENT); | 119 | struct vfsmount *mnt = ERR_PTR(-ENOENT); |
119 | char *mnt_path; | 120 | char *mnt_path; |
120 | unsigned int maxbuflen; | 121 | unsigned int maxbuflen; |
@@ -126,9 +127,12 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
126 | mountdata->mnt_path = mnt_path; | 127 | mountdata->mnt_path = mnt_path; |
127 | maxbuflen = mnt_path - 1 - page2; | 128 | maxbuflen = mnt_path - 1 - page2; |
128 | 129 | ||
130 | mountdata->addr = kmalloc(addr_bufsize, GFP_KERNEL); | ||
131 | if (mountdata->addr == NULL) | ||
132 | return ERR_PTR(-ENOMEM); | ||
133 | |||
129 | for (s = 0; s < location->nservers; s++) { | 134 | for (s = 0; s < location->nservers; s++) { |
130 | const struct nfs4_string *buf = &location->servers[s]; | 135 | const struct nfs4_string *buf = &location->servers[s]; |
131 | struct sockaddr_storage addr; | ||
132 | 136 | ||
133 | if (buf->len <= 0 || buf->len >= maxbuflen) | 137 | if (buf->len <= 0 || buf->len >= maxbuflen) |
134 | continue; | 138 | continue; |
@@ -137,11 +141,10 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
137 | continue; | 141 | continue; |
138 | 142 | ||
139 | mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, | 143 | mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, |
140 | (struct sockaddr *)&addr, sizeof(addr)); | 144 | mountdata->addr, addr_bufsize); |
141 | if (mountdata->addrlen == 0) | 145 | if (mountdata->addrlen == 0) |
142 | continue; | 146 | continue; |
143 | 147 | ||
144 | mountdata->addr = (struct sockaddr *)&addr; | ||
145 | rpc_set_port(mountdata->addr, NFS_PORT); | 148 | rpc_set_port(mountdata->addr, NFS_PORT); |
146 | 149 | ||
147 | memcpy(page2, buf->data, buf->len); | 150 | memcpy(page2, buf->data, buf->len); |
@@ -156,6 +159,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, | |||
156 | if (!IS_ERR(mnt)) | 159 | if (!IS_ERR(mnt)) |
157 | break; | 160 | break; |
158 | } | 161 | } |
162 | kfree(mountdata->addr); | ||
159 | return mnt; | 163 | return mnt; |
160 | } | 164 | } |
161 | 165 | ||