diff options
-rw-r--r-- | fs/xfs/xfs_iomap.c | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 20576146369f..991291068378 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -51,11 +51,11 @@ | |||
51 | #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP | 51 | #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP |
52 | 52 | ||
53 | STATIC int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, | 53 | STATIC int xfs_iomap_write_direct(struct xfs_inode *, xfs_off_t, size_t, |
54 | int, struct xfs_bmbt_irec *, int *); | 54 | struct xfs_bmbt_irec *, int); |
55 | STATIC int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, int, | 55 | STATIC int xfs_iomap_write_delay(struct xfs_inode *, xfs_off_t, size_t, |
56 | struct xfs_bmbt_irec *, int *); | 56 | struct xfs_bmbt_irec *); |
57 | STATIC int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, size_t, | 57 | STATIC int xfs_iomap_write_allocate(struct xfs_inode *, xfs_off_t, size_t, |
58 | struct xfs_bmbt_irec *, int *); | 58 | struct xfs_bmbt_irec *); |
59 | 59 | ||
60 | int | 60 | int |
61 | xfs_iomap( | 61 | xfs_iomap( |
@@ -134,12 +134,12 @@ xfs_iomap( | |||
134 | } | 134 | } |
135 | 135 | ||
136 | if (flags & BMAPI_DIRECT) { | 136 | if (flags & BMAPI_DIRECT) { |
137 | error = xfs_iomap_write_direct(ip, offset, count, flags, | 137 | error = xfs_iomap_write_direct(ip, offset, count, imap, |
138 | imap, nimaps); | 138 | *nimaps); |
139 | } else { | 139 | } else { |
140 | error = xfs_iomap_write_delay(ip, offset, count, flags, | 140 | error = xfs_iomap_write_delay(ip, offset, count, imap); |
141 | imap, nimaps); | ||
142 | } | 141 | } |
142 | |||
143 | if (!error) { | 143 | if (!error) { |
144 | trace_xfs_iomap_alloc(ip, offset, count, flags, imap); | 144 | trace_xfs_iomap_alloc(ip, offset, count, flags, imap); |
145 | } | 145 | } |
@@ -155,13 +155,10 @@ xfs_iomap( | |||
155 | break; | 155 | break; |
156 | } | 156 | } |
157 | 157 | ||
158 | error = xfs_iomap_write_allocate(ip, offset, count, | 158 | error = xfs_iomap_write_allocate(ip, offset, count, imap); |
159 | imap, nimaps); | ||
160 | break; | 159 | break; |
161 | } | 160 | } |
162 | 161 | ||
163 | ASSERT(*nimaps <= 1); | ||
164 | |||
165 | out: | 162 | out: |
166 | if (lockmode) | 163 | if (lockmode) |
167 | xfs_iunlock(ip, lockmode); | 164 | xfs_iunlock(ip, lockmode); |
@@ -241,9 +238,8 @@ xfs_iomap_write_direct( | |||
241 | xfs_inode_t *ip, | 238 | xfs_inode_t *ip, |
242 | xfs_off_t offset, | 239 | xfs_off_t offset, |
243 | size_t count, | 240 | size_t count, |
244 | int flags, | ||
245 | xfs_bmbt_irec_t *imap, | 241 | xfs_bmbt_irec_t *imap, |
246 | int *nmaps) | 242 | int nmaps) |
247 | { | 243 | { |
248 | xfs_mount_t *mp = ip->i_mount; | 244 | xfs_mount_t *mp = ip->i_mount; |
249 | xfs_fileoff_t offset_fsb; | 245 | xfs_fileoff_t offset_fsb; |
@@ -279,7 +275,7 @@ xfs_iomap_write_direct( | |||
279 | if (error) | 275 | if (error) |
280 | goto error_out; | 276 | goto error_out; |
281 | } else { | 277 | } else { |
282 | if (*nmaps && (imap->br_startblock == HOLESTARTBLOCK)) | 278 | if (nmaps && (imap->br_startblock == HOLESTARTBLOCK)) |
283 | last_fsb = MIN(last_fsb, (xfs_fileoff_t) | 279 | last_fsb = MIN(last_fsb, (xfs_fileoff_t) |
284 | imap->br_blockcount + | 280 | imap->br_blockcount + |
285 | imap->br_startoff); | 281 | imap->br_startoff); |
@@ -331,7 +327,7 @@ xfs_iomap_write_direct( | |||
331 | xfs_trans_ijoin(tp, ip); | 327 | xfs_trans_ijoin(tp, ip); |
332 | 328 | ||
333 | bmapi_flag = XFS_BMAPI_WRITE; | 329 | bmapi_flag = XFS_BMAPI_WRITE; |
334 | if ((flags & BMAPI_DIRECT) && (offset < ip->i_size || extsz)) | 330 | if (offset < ip->i_size || extsz) |
335 | bmapi_flag |= XFS_BMAPI_PREALLOC; | 331 | bmapi_flag |= XFS_BMAPI_PREALLOC; |
336 | 332 | ||
337 | /* | 333 | /* |
@@ -370,7 +366,6 @@ xfs_iomap_write_direct( | |||
370 | goto error_out; | 366 | goto error_out; |
371 | } | 367 | } |
372 | 368 | ||
373 | *nmaps = 1; | ||
374 | return 0; | 369 | return 0; |
375 | 370 | ||
376 | error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ | 371 | error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ |
@@ -379,7 +374,6 @@ error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */ | |||
379 | 374 | ||
380 | error1: /* Just cancel transaction */ | 375 | error1: /* Just cancel transaction */ |
381 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); | 376 | xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT); |
382 | *nmaps = 0; /* nothing set-up here */ | ||
383 | 377 | ||
384 | error_out: | 378 | error_out: |
385 | return XFS_ERROR(error); | 379 | return XFS_ERROR(error); |
@@ -396,7 +390,6 @@ xfs_iomap_eof_want_preallocate( | |||
396 | xfs_inode_t *ip, | 390 | xfs_inode_t *ip, |
397 | xfs_off_t offset, | 391 | xfs_off_t offset, |
398 | size_t count, | 392 | size_t count, |
399 | int ioflag, | ||
400 | xfs_bmbt_irec_t *imap, | 393 | xfs_bmbt_irec_t *imap, |
401 | int nimaps, | 394 | int nimaps, |
402 | int *prealloc) | 395 | int *prealloc) |
@@ -440,9 +433,7 @@ xfs_iomap_write_delay( | |||
440 | xfs_inode_t *ip, | 433 | xfs_inode_t *ip, |
441 | xfs_off_t offset, | 434 | xfs_off_t offset, |
442 | size_t count, | 435 | size_t count, |
443 | int ioflag, | 436 | xfs_bmbt_irec_t *ret_imap) |
444 | xfs_bmbt_irec_t *ret_imap, | ||
445 | int *nmaps) | ||
446 | { | 437 | { |
447 | xfs_mount_t *mp = ip->i_mount; | 438 | xfs_mount_t *mp = ip->i_mount; |
448 | xfs_fileoff_t offset_fsb; | 439 | xfs_fileoff_t offset_fsb; |
@@ -470,7 +461,7 @@ xfs_iomap_write_delay( | |||
470 | offset_fsb = XFS_B_TO_FSBT(mp, offset); | 461 | offset_fsb = XFS_B_TO_FSBT(mp, offset); |
471 | 462 | ||
472 | error = xfs_iomap_eof_want_preallocate(mp, ip, offset, count, | 463 | error = xfs_iomap_eof_want_preallocate(mp, ip, offset, count, |
473 | ioflag, imap, XFS_WRITE_IMAPS, &prealloc); | 464 | imap, XFS_WRITE_IMAPS, &prealloc); |
474 | if (error) | 465 | if (error) |
475 | return error; | 466 | return error; |
476 | 467 | ||
@@ -523,8 +514,6 @@ retry: | |||
523 | return xfs_cmn_err_fsblock_zero(ip, &imap[0]); | 514 | return xfs_cmn_err_fsblock_zero(ip, &imap[0]); |
524 | 515 | ||
525 | *ret_imap = imap[0]; | 516 | *ret_imap = imap[0]; |
526 | *nmaps = 1; | ||
527 | |||
528 | return 0; | 517 | return 0; |
529 | } | 518 | } |
530 | 519 | ||
@@ -543,8 +532,7 @@ xfs_iomap_write_allocate( | |||
543 | xfs_inode_t *ip, | 532 | xfs_inode_t *ip, |
544 | xfs_off_t offset, | 533 | xfs_off_t offset, |
545 | size_t count, | 534 | size_t count, |
546 | xfs_bmbt_irec_t *imap, | 535 | xfs_bmbt_irec_t *imap) |
547 | int *retmap) | ||
548 | { | 536 | { |
549 | xfs_mount_t *mp = ip->i_mount; | 537 | xfs_mount_t *mp = ip->i_mount; |
550 | xfs_fileoff_t offset_fsb, last_block; | 538 | xfs_fileoff_t offset_fsb, last_block; |
@@ -557,8 +545,6 @@ xfs_iomap_write_allocate( | |||
557 | int error = 0; | 545 | int error = 0; |
558 | int nres; | 546 | int nres; |
559 | 547 | ||
560 | *retmap = 0; | ||
561 | |||
562 | /* | 548 | /* |
563 | * Make sure that the dquots are there. | 549 | * Make sure that the dquots are there. |
564 | */ | 550 | */ |
@@ -680,7 +666,6 @@ xfs_iomap_write_allocate( | |||
680 | if ((offset_fsb >= imap->br_startoff) && | 666 | if ((offset_fsb >= imap->br_startoff) && |
681 | (offset_fsb < (imap->br_startoff + | 667 | (offset_fsb < (imap->br_startoff + |
682 | imap->br_blockcount))) { | 668 | imap->br_blockcount))) { |
683 | *retmap = 1; | ||
684 | XFS_STATS_INC(xs_xstrat_quick); | 669 | XFS_STATS_INC(xs_xstrat_quick); |
685 | return 0; | 670 | return 0; |
686 | } | 671 | } |