aboutsummaryrefslogtreecommitdiffstats
path: root/fs/orangefs
diff options
context:
space:
mode:
authorMartin Brandenburg <martin@omnibond.com>2016-02-17 12:55:42 -0500
committerMike Marshall <hubcap@omnibond.com>2016-02-24 17:07:50 -0500
commitee3b8d377ca014b0ec4ea8988ba6fbe8463bd8d9 (patch)
treed14c7a6eb47e21e980868294cdb11ce606444d8a /fs/orangefs
parentadcf34a2893386c99e80feee36e30a782b3815e7 (diff)
orangefs: free readdir buffer index before the dir_emit loop
We only need it while the service operation is actually in progress since it is only used to co-ordinate the client-core's memory use. The kernel allocates its own space. Also clean up some comments which mislead the reader into thinking the readdir buffers are shared memory. Signed-off-by: Martin Brandenburg <martin@omnibond.com> Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs')
-rw-r--r--fs/orangefs/dir.c34
1 files changed, 9 insertions, 25 deletions
diff --git a/fs/orangefs/dir.c b/fs/orangefs/dir.c
index c9b8d0ced833..43e3aeb529ea 100644
--- a/fs/orangefs/dir.c
+++ b/fs/orangefs/dir.c
@@ -9,7 +9,6 @@
9#include "orangefs-bufmap.h" 9#include "orangefs-bufmap.h"
10 10
11struct readdir_handle_s { 11struct readdir_handle_s {
12 int buffer_index;
13 struct orangefs_readdir_response_s readdir_response; 12 struct orangefs_readdir_response_s readdir_response;
14 void *dents_buf; 13 void *dents_buf;
15}; 14};
@@ -143,7 +142,7 @@ out:
143} 142}
144 143
145static long readdir_handle_ctor(struct readdir_handle_s *rhandle, void *buf, 144static long readdir_handle_ctor(struct readdir_handle_s *rhandle, void *buf,
146 size_t size, int buffer_index) 145 size_t size)
147{ 146{
148 long ret; 147 long ret;
149 148
@@ -152,17 +151,10 @@ static long readdir_handle_ctor(struct readdir_handle_s *rhandle, void *buf,
152 ("Invalid NULL buffer specified in readdir_handle_ctor\n"); 151 ("Invalid NULL buffer specified in readdir_handle_ctor\n");
153 return -ENOMEM; 152 return -ENOMEM;
154 } 153 }
155 if (buffer_index < 0) {
156 gossip_err
157 ("Invalid buffer index specified in readdir_handle_ctor\n");
158 return -EINVAL;
159 }
160 rhandle->buffer_index = buffer_index;
161 rhandle->dents_buf = buf; 154 rhandle->dents_buf = buf;
162 ret = decode_dirents(buf, size, &rhandle->readdir_response); 155 ret = decode_dirents(buf, size, &rhandle->readdir_response);
163 if (ret < 0) { 156 if (ret < 0) {
164 gossip_err("Could not decode readdir from buffer %ld\n", ret); 157 gossip_err("Could not decode readdir from buffer %ld\n", ret);
165 rhandle->buffer_index = -1;
166 gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n", buf); 158 gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n", buf);
167 vfree(buf); 159 vfree(buf);
168 rhandle->dents_buf = NULL; 160 rhandle->dents_buf = NULL;
@@ -179,10 +171,6 @@ static void readdir_handle_dtor(struct readdir_handle_s *rhandle)
179 kfree(rhandle->readdir_response.dirent_array); 171 kfree(rhandle->readdir_response.dirent_array);
180 rhandle->readdir_response.dirent_array = NULL; 172 rhandle->readdir_response.dirent_array = NULL;
181 173
182 if (rhandle->buffer_index >= 0) {
183 orangefs_readdir_index_put(rhandle->buffer_index);
184 rhandle->buffer_index = -1;
185 }
186 if (rhandle->dents_buf) { 174 if (rhandle->dents_buf) {
187 gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n", 175 gossip_debug(GOSSIP_DIR_DEBUG, "vfree %p\n",
188 rhandle->dents_buf); 176 rhandle->dents_buf);
@@ -236,7 +224,6 @@ static int orangefs_readdir(struct file *file, struct dir_context *ctx)
236 "orangefs_readdir called on %s (pos=%llu)\n", 224 "orangefs_readdir called on %s (pos=%llu)\n",
237 dentry->d_name.name, llu(pos)); 225 dentry->d_name.name, llu(pos));
238 226
239 rhandle.buffer_index = -1;
240 rhandle.dents_buf = NULL; 227 rhandle.dents_buf = NULL;
241 memset(&rhandle.readdir_response, 0, sizeof(rhandle.readdir_response)); 228 memset(&rhandle.readdir_response, 0, sizeof(rhandle.readdir_response));
242 229
@@ -244,6 +231,10 @@ static int orangefs_readdir(struct file *file, struct dir_context *ctx)
244 if (!new_op) 231 if (!new_op)
245 return -ENOMEM; 232 return -ENOMEM;
246 233
234 /*
235 * Only the indices are shared. No memory is actually shared, but the
236 * mechanism is used.
237 */
247 new_op->uses_shared_memory = 1; 238 new_op->uses_shared_memory = 1;
248 new_op->upcall.req.readdir.refn = orangefs_inode->refn; 239 new_op->upcall.req.readdir.refn = orangefs_inode->refn;
249 new_op->upcall.req.readdir.max_dirent_count = 240 new_op->upcall.req.readdir.max_dirent_count =
@@ -274,23 +265,19 @@ get_new_buffer_index:
274 new_op->downcall.status, 265 new_op->downcall.status,
275 ret); 266 ret);
276 267
268 orangefs_readdir_index_put(buffer_index);
269
277 if (ret == -EAGAIN && op_state_purged(new_op)) { 270 if (ret == -EAGAIN && op_state_purged(new_op)) {
278 /* 271 /* Client-core indices are invalid after it restarted. */
279 * readdir shared memory aread has been wiped due to
280 * pvfs2-client-core restarting, so we must get a new
281 * index into the shared memory.
282 */
283 gossip_debug(GOSSIP_DIR_DEBUG, 272 gossip_debug(GOSSIP_DIR_DEBUG,
284 "%s: Getting new buffer_index for retry of readdir..\n", 273 "%s: Getting new buffer_index for retry of readdir..\n",
285 __func__); 274 __func__);
286 orangefs_readdir_index_put(buffer_index);
287 goto get_new_buffer_index; 275 goto get_new_buffer_index;
288 } 276 }
289 277
290 if (ret == -EIO && op_state_purged(new_op)) { 278 if (ret == -EIO && op_state_purged(new_op)) {
291 gossip_err("%s: Client is down. Aborting readdir call.\n", 279 gossip_err("%s: Client is down. Aborting readdir call.\n",
292 __func__); 280 __func__);
293 orangefs_readdir_index_put(buffer_index);
294 goto out_free_op; 281 goto out_free_op;
295 } 282 }
296 283
@@ -298,7 +285,6 @@ get_new_buffer_index:
298 gossip_debug(GOSSIP_DIR_DEBUG, 285 gossip_debug(GOSSIP_DIR_DEBUG,
299 "Readdir request failed. Status:%d\n", 286 "Readdir request failed. Status:%d\n",
300 new_op->downcall.status); 287 new_op->downcall.status);
301 orangefs_readdir_index_put(buffer_index);
302 if (ret >= 0) 288 if (ret >= 0)
303 ret = new_op->downcall.status; 289 ret = new_op->downcall.status;
304 goto out_free_op; 290 goto out_free_op;
@@ -307,13 +293,11 @@ get_new_buffer_index:
307 bytes_decoded = 293 bytes_decoded =
308 readdir_handle_ctor(&rhandle, 294 readdir_handle_ctor(&rhandle,
309 new_op->downcall.trailer_buf, 295 new_op->downcall.trailer_buf,
310 new_op->downcall.trailer_size, 296 new_op->downcall.trailer_size);
311 buffer_index);
312 if (bytes_decoded < 0) { 297 if (bytes_decoded < 0) {
313 gossip_err("orangefs_readdir: Could not decode trailer buffer into a readdir response %d\n", 298 gossip_err("orangefs_readdir: Could not decode trailer buffer into a readdir response %d\n",
314 ret); 299 ret);
315 ret = bytes_decoded; 300 ret = bytes_decoded;
316 orangefs_readdir_index_put(buffer_index);
317 goto out_free_op; 301 goto out_free_op;
318 } 302 }
319 303