diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2011-10-31 17:47:32 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-11-02 23:56:05 -0400 |
commit | 96218556b03d3c6505e2880a097338bf277fd783 (patch) | |
tree | 0e6d80437979a158af20b73b8d2cd985478e553d /fs/nfs/objlayout/objlayout.c | |
parent | e6c40fe3f4c4967f1cb486191ed4a5d5f55f3f7e (diff) |
pnfs-obj: Get rid of objlayout_{alloc,free}_io_state
This is part of moving objio_osd to use the ORE.
objlayout_io_state had two functions:
1. It was used in the error reporting mechanism at layout_return.
This function is kept intact.
(Later patch will rename objlayout_io_state => objlayout_io_res)
2. Carrier of rw io members into the objio_read/write_paglist API.
This is removed in this patch.
The {r,w}data received from NFS are passed directly to the
objio_{read,write}_paglist API. The io_engine is now allocating
it's own IO state as part of the read/write. The minimal
functionality that was part of the generic allocation is passed
to the io_engine.
So part of this patch is rename of:
ios->ol_state.foo => ios->foo
At objlayout_{read,write}_done an objlayout_io_state is passed that
denotes the result of the IO. (Hence the later name change).
If the IO is successful objlayout calls an objio_free_result() API
immediately (Which for objio_osd causes the release of the io_state).
If the IO ended in an error it is hanged onto until reported in
layout_return and is released later through the objio_free_result()
API. (All this is not new just renamed and cleaned)
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/objlayout/objlayout.c')
-rw-r--r-- | fs/nfs/objlayout/objlayout.c | 124 |
1 files changed, 31 insertions, 93 deletions
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c index 99c807df11dc..a82053ae5595 100644 --- a/fs/nfs/objlayout/objlayout.c +++ b/fs/nfs/objlayout/objlayout.c | |||
@@ -156,59 +156,23 @@ last_byte_offset(u64 start, u64 len) | |||
156 | return end > start ? end - 1 : NFS4_MAX_UINT64; | 156 | return end > start ? end - 1 : NFS4_MAX_UINT64; |
157 | } | 157 | } |
158 | 158 | ||
159 | static struct objlayout_io_state * | 159 | void _fix_verify_io_params(struct pnfs_layout_segment *lseg, |
160 | objlayout_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, | 160 | struct page ***p_pages, unsigned *p_pgbase, |
161 | struct page **pages, | 161 | u64 offset, unsigned long count) |
162 | unsigned pgbase, | ||
163 | loff_t offset, | ||
164 | size_t count, | ||
165 | struct pnfs_layout_segment *lseg, | ||
166 | void *rpcdata, | ||
167 | gfp_t gfp_flags) | ||
168 | { | 162 | { |
169 | struct objlayout_io_state *state; | ||
170 | u64 lseg_end_offset; | 163 | u64 lseg_end_offset; |
171 | 164 | ||
172 | dprintk("%s: allocating io_state\n", __func__); | ||
173 | if (objio_alloc_io_state(lseg, &state, gfp_flags)) | ||
174 | return NULL; | ||
175 | |||
176 | BUG_ON(offset < lseg->pls_range.offset); | 165 | BUG_ON(offset < lseg->pls_range.offset); |
177 | lseg_end_offset = end_offset(lseg->pls_range.offset, | 166 | lseg_end_offset = end_offset(lseg->pls_range.offset, |
178 | lseg->pls_range.length); | 167 | lseg->pls_range.length); |
179 | BUG_ON(offset >= lseg_end_offset); | 168 | BUG_ON(offset >= lseg_end_offset); |
180 | if (offset + count > lseg_end_offset) { | 169 | WARN_ON(offset + count > lseg_end_offset); |
181 | count = lseg->pls_range.length - | ||
182 | (offset - lseg->pls_range.offset); | ||
183 | dprintk("%s: truncated count %Zd\n", __func__, count); | ||
184 | } | ||
185 | 170 | ||
186 | if (pgbase > PAGE_SIZE) { | 171 | if (*p_pgbase > PAGE_SIZE) { |
187 | pages += pgbase >> PAGE_SHIFT; | 172 | dprintk("%s: pgbase(0x%x) > PAGE_SIZE\n", __func__, *p_pgbase); |
188 | pgbase &= ~PAGE_MASK; | 173 | *p_pages += *p_pgbase >> PAGE_SHIFT; |
174 | *p_pgbase &= ~PAGE_MASK; | ||
189 | } | 175 | } |
190 | |||
191 | INIT_LIST_HEAD(&state->err_list); | ||
192 | state->lseg = lseg; | ||
193 | state->rpcdata = rpcdata; | ||
194 | state->pages = pages; | ||
195 | state->pgbase = pgbase; | ||
196 | state->nr_pages = (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
197 | state->offset = offset; | ||
198 | state->count = count; | ||
199 | state->sync = 0; | ||
200 | |||
201 | return state; | ||
202 | } | ||
203 | |||
204 | static void | ||
205 | objlayout_free_io_state(struct objlayout_io_state *state) | ||
206 | { | ||
207 | dprintk("%s: freeing io_state\n", __func__); | ||
208 | if (unlikely(!state)) | ||
209 | return; | ||
210 | |||
211 | objio_free_io_state(state); | ||
212 | } | 176 | } |
213 | 177 | ||
214 | /* | 178 | /* |
@@ -217,12 +181,10 @@ objlayout_free_io_state(struct objlayout_io_state *state) | |||
217 | static void | 181 | static void |
218 | objlayout_iodone(struct objlayout_io_state *state) | 182 | objlayout_iodone(struct objlayout_io_state *state) |
219 | { | 183 | { |
220 | dprintk("%s: state %p status\n", __func__, state); | ||
221 | |||
222 | if (likely(state->status >= 0)) { | 184 | if (likely(state->status >= 0)) { |
223 | objlayout_free_io_state(state); | 185 | objio_free_result(state); |
224 | } else { | 186 | } else { |
225 | struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout); | 187 | struct objlayout *objlay = state->objlay; |
226 | 188 | ||
227 | spin_lock(&objlay->lock); | 189 | spin_lock(&objlay->lock); |
228 | objlay->delta_space_valid = OBJ_DSU_INVALID; | 190 | objlay->delta_space_valid = OBJ_DSU_INVALID; |
@@ -289,15 +251,15 @@ objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync) | |||
289 | { | 251 | { |
290 | struct nfs_read_data *rdata = state->rpcdata; | 252 | struct nfs_read_data *rdata = state->rpcdata; |
291 | 253 | ||
292 | state->status = status; | 254 | state->status = rdata->task.tk_status = status; |
293 | dprintk("%s: Begin status=%zd eof=%d\n", __func__, | ||
294 | status, rdata->res.eof); | ||
295 | rdata->task.tk_status = status; | ||
296 | if (status >= 0) | 255 | if (status >= 0) |
297 | rdata->res.count = status; | 256 | rdata->res.count = status; |
298 | objlayout_iodone(state); | 257 | objlayout_iodone(state); |
299 | /* must not use state after this point */ | 258 | /* must not use state after this point */ |
300 | 259 | ||
260 | dprintk("%s: Return status=%zd eof=%d sync=%d\n", __func__, | ||
261 | status, rdata->res.eof, sync); | ||
262 | |||
301 | if (sync) | 263 | if (sync) |
302 | pnfs_ld_read_done(rdata); | 264 | pnfs_ld_read_done(rdata); |
303 | else { | 265 | else { |
@@ -314,7 +276,6 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
314 | { | 276 | { |
315 | loff_t offset = rdata->args.offset; | 277 | loff_t offset = rdata->args.offset; |
316 | size_t count = rdata->args.count; | 278 | size_t count = rdata->args.count; |
317 | struct objlayout_io_state *state; | ||
318 | int err; | 279 | int err; |
319 | loff_t eof; | 280 | loff_t eof; |
320 | 281 | ||
@@ -331,20 +292,14 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
331 | } | 292 | } |
332 | 293 | ||
333 | rdata->res.eof = (offset + count) >= eof; | 294 | rdata->res.eof = (offset + count) >= eof; |
295 | _fix_verify_io_params(rdata->lseg, &rdata->args.pages, | ||
296 | &rdata->args.pgbase, | ||
297 | rdata->args.offset, rdata->args.count); | ||
334 | 298 | ||
335 | state = objlayout_alloc_io_state(NFS_I(rdata->inode)->layout, | ||
336 | rdata->args.pages, rdata->args.pgbase, | ||
337 | offset, count, | ||
338 | rdata->lseg, rdata, | ||
339 | GFP_KERNEL); | ||
340 | if (unlikely(!state)) { | ||
341 | err = -ENOMEM; | ||
342 | goto out; | ||
343 | } | ||
344 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", | 299 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", |
345 | __func__, rdata->inode->i_ino, offset, count, rdata->res.eof); | 300 | __func__, rdata->inode->i_ino, offset, count, rdata->res.eof); |
346 | 301 | ||
347 | err = objio_read_pagelist(state); | 302 | err = objio_read_pagelist(rdata); |
348 | out: | 303 | out: |
349 | if (unlikely(err)) { | 304 | if (unlikely(err)) { |
350 | rdata->pnfs_error = err; | 305 | rdata->pnfs_error = err; |
@@ -374,23 +329,18 @@ void | |||
374 | objlayout_write_done(struct objlayout_io_state *state, ssize_t status, | 329 | objlayout_write_done(struct objlayout_io_state *state, ssize_t status, |
375 | bool sync) | 330 | bool sync) |
376 | { | 331 | { |
377 | struct nfs_write_data *wdata; | 332 | struct nfs_write_data *wdata = state->rpcdata; |
378 | 333 | ||
379 | dprintk("%s: Begin\n", __func__); | 334 | state->status = wdata->task.tk_status = status; |
380 | wdata = state->rpcdata; | ||
381 | state->status = status; | ||
382 | wdata->task.tk_status = status; | ||
383 | if (status >= 0) { | 335 | if (status >= 0) { |
384 | wdata->res.count = status; | 336 | wdata->res.count = status; |
385 | wdata->verf.committed = state->committed; | 337 | wdata->verf.committed = state->committed; |
386 | dprintk("%s: Return status %d committed %d\n", | 338 | } |
387 | __func__, wdata->task.tk_status, | ||
388 | wdata->verf.committed); | ||
389 | } else | ||
390 | dprintk("%s: Return status %d\n", | ||
391 | __func__, wdata->task.tk_status); | ||
392 | objlayout_iodone(state); | 339 | objlayout_iodone(state); |
393 | /* must not use state after this point */ | 340 | /* must not use oir after this point */ |
341 | |||
342 | dprintk("%s: Return status %zd committed %d sync=%d\n", __func__, | ||
343 | status, wdata->verf.committed, sync); | ||
394 | 344 | ||
395 | if (sync) | 345 | if (sync) |
396 | pnfs_ld_write_done(wdata); | 346 | pnfs_ld_write_done(wdata); |
@@ -407,25 +357,13 @@ enum pnfs_try_status | |||
407 | objlayout_write_pagelist(struct nfs_write_data *wdata, | 357 | objlayout_write_pagelist(struct nfs_write_data *wdata, |
408 | int how) | 358 | int how) |
409 | { | 359 | { |
410 | struct objlayout_io_state *state; | ||
411 | int err; | 360 | int err; |
412 | 361 | ||
413 | state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout, | 362 | _fix_verify_io_params(wdata->lseg, &wdata->args.pages, |
414 | wdata->args.pages, | 363 | &wdata->args.pgbase, |
415 | wdata->args.pgbase, | 364 | wdata->args.offset, wdata->args.count); |
416 | wdata->args.offset, | ||
417 | wdata->args.count, | ||
418 | wdata->lseg, wdata, | ||
419 | GFP_NOFS); | ||
420 | if (unlikely(!state)) { | ||
421 | err = -ENOMEM; | ||
422 | goto out; | ||
423 | } | ||
424 | 365 | ||
425 | state->sync = how & FLUSH_SYNC; | 366 | err = objio_write_pagelist(wdata, how); |
426 | |||
427 | err = objio_write_pagelist(state, how & FLUSH_STABLE); | ||
428 | out: | ||
429 | if (unlikely(err)) { | 367 | if (unlikely(err)) { |
430 | wdata->pnfs_error = err; | 368 | wdata->pnfs_error = err; |
431 | dprintk("%s: Returned Error %d\n", __func__, err); | 369 | dprintk("%s: Returned Error %d\n", __func__, err); |
@@ -564,7 +502,7 @@ encode_accumulated_error(struct objlayout *objlay, __be32 *p) | |||
564 | merge_ioerr(&accumulated_err, ioerr); | 502 | merge_ioerr(&accumulated_err, ioerr); |
565 | } | 503 | } |
566 | list_del(&state->err_list); | 504 | list_del(&state->err_list); |
567 | objlayout_free_io_state(state); | 505 | objio_free_result(state); |
568 | } | 506 | } |
569 | 507 | ||
570 | pnfs_osd_xdr_encode_ioerr(p, &accumulated_err); | 508 | pnfs_osd_xdr_encode_ioerr(p, &accumulated_err); |
@@ -632,7 +570,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, | |||
632 | goto loop_done; | 570 | goto loop_done; |
633 | } | 571 | } |
634 | list_del(&state->err_list); | 572 | list_del(&state->err_list); |
635 | objlayout_free_io_state(state); | 573 | objio_free_result(state); |
636 | } | 574 | } |
637 | loop_done: | 575 | loop_done: |
638 | spin_unlock(&objlay->lock); | 576 | spin_unlock(&objlay->lock); |