2 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "xfs_trans.h"
27 #include "xfs_alloc.h"
28 #include "xfs_dmapi.h"
29 #include "xfs_quota.h"
30 #include "xfs_mount.h"
31 #include "xfs_bmap_btree.h"
32 #include "xfs_alloc_btree.h"
33 #include "xfs_ialloc_btree.h"
34 #include "xfs_dir2_sf.h"
35 #include "xfs_attr_sf.h"
36 #include "xfs_dinode.h"
37 #include "xfs_inode.h"
38 #include "xfs_ialloc.h"
39 #include "xfs_btree.h"
41 #include "xfs_rtalloc.h"
42 #include "xfs_error.h"
43 #include "xfs_itable.h"
46 #include "xfs_buf_item.h"
47 #include "xfs_trans_space.h"
48 #include "xfs_utils.h"
49 #include "xfs_iomap.h"
50 #include "xfs_trace.h"
53 #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \
55 #define XFS_STRAT_WRITE_IMAPS 2
56 #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
62 xfs_bmbt_irec_t *imap,
64 int imaps, /* Number of imap entries */
67 xfs_mount_t *mp = ip->i_mount;
68 xfs_fsblock_t start_block;
70 iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
71 iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
72 iomapp->iomap_flags = flags;
74 start_block = imap->br_startblock;
75 if (start_block == HOLESTARTBLOCK) {
76 iomapp->iomap_bn = IOMAP_DADDR_NULL;
77 iomapp->iomap_flags |= IOMAP_HOLE;
78 } else if (start_block == DELAYSTARTBLOCK) {
79 iomapp->iomap_bn = IOMAP_DADDR_NULL;
80 iomapp->iomap_flags |= IOMAP_DELAY;
82 iomapp->iomap_bn = xfs_fsb_to_db(ip, start_block);
83 if (ISUNWRITTEN(imap))
84 iomapp->iomap_flags |= IOMAP_UNWRITTEN;
97 xfs_mount_t *mp = ip->i_mount;
98 xfs_fileoff_t offset_fsb, end_fsb;
101 xfs_bmbt_irec_t imap;
106 ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
107 ASSERT(niomaps && *niomaps == 1);
109 if (XFS_FORCED_SHUTDOWN(mp))
110 return XFS_ERROR(EIO);
112 trace_xfs_iomap_enter(ip, offset, count, flags, NULL);
114 switch (flags & (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE)) {
116 lockmode = xfs_ilock_map_shared(ip);
117 bmapi_flags = XFS_BMAPI_ENTIRE;
120 lockmode = XFS_ILOCK_EXCL;
121 if (flags & BMAPI_IGNSTATE)
122 bmapi_flags |= XFS_BMAPI_IGSTATE|XFS_BMAPI_ENTIRE;
123 xfs_ilock(ip, lockmode);
126 lockmode = XFS_ILOCK_SHARED;
127 bmapi_flags = XFS_BMAPI_ENTIRE;
129 /* Attempt non-blocking lock */
130 if (flags & BMAPI_TRYLOCK) {
131 if (!xfs_ilock_nowait(ip, lockmode))
132 return XFS_ERROR(EAGAIN);
134 xfs_ilock(ip, lockmode);
141 ASSERT(offset <= mp->m_maxioffset);
142 if ((xfs_fsize_t)offset + count > mp->m_maxioffset)
143 count = mp->m_maxioffset - offset;
144 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
145 offset_fsb = XFS_B_TO_FSBT(mp, offset);
147 error = xfs_bmapi(NULL, ip, offset_fsb,
148 (xfs_filblks_t)(end_fsb - offset_fsb),
149 bmapi_flags, NULL, 0, &imap,
150 &nimaps, NULL, NULL);
155 switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
157 /* If we found an extent, return it */
159 (imap.br_startblock != HOLESTARTBLOCK) &&
160 (imap.br_startblock != DELAYSTARTBLOCK)) {
161 trace_xfs_iomap_found(ip, offset, count, flags, &imap);
165 if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
166 error = xfs_iomap_write_direct(ip, offset, count, flags,
167 &imap, &nimaps, nimaps);
169 error = xfs_iomap_write_delay(ip, offset, count, flags,
173 trace_xfs_iomap_alloc(ip, offset, count, flags, &imap);
175 iomap_flags = IOMAP_NEW;
178 /* If we found an extent, return it */
179 xfs_iunlock(ip, lockmode);
182 if (nimaps && !isnullstartblock(imap.br_startblock)) {
183 trace_xfs_iomap_found(ip, offset, count, flags, &imap);
187 error = xfs_iomap_write_allocate(ip, offset, count,
195 xfs_imap_to_bmap(ip, offset, &imap, iomapp, nimaps, iomap_flags);
200 xfs_iunlock(ip, lockmode);
201 return XFS_ERROR(error);
206 xfs_iomap_eof_align_last_fsb(
209 xfs_extlen_t extsize,
210 xfs_fileoff_t *last_fsb)
212 xfs_fileoff_t new_last_fsb = 0;
216 if (XFS_IS_REALTIME_INODE(ip))
219 * If mounted with the "-o swalloc" option, roundup the allocation
220 * request to a stripe width boundary if the file size is >=
221 * stripe width and we are allocating past the allocation eof.
223 else if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC) &&
224 (ip->i_size >= XFS_FSB_TO_B(mp, mp->m_swidth)))
225 new_last_fsb = roundup_64(*last_fsb, mp->m_swidth);
227 * Roundup the allocation request to a stripe unit (m_dalign) boundary
228 * if the file size is >= stripe unit size, and we are allocating past
229 * the allocation eof.
231 else if (mp->m_dalign && (ip->i_size >= XFS_FSB_TO_B(mp, mp->m_dalign)))
232 new_last_fsb = roundup_64(*last_fsb, mp->m_dalign);
235 * Always round up the allocation request to an extent boundary
236 * (when file on a real-time subvolume or has di_extsize hint).
240 align = roundup_64(new_last_fsb, extsize);
243 new_last_fsb = roundup_64(*last_fsb, align);
247 error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof);
251 *last_fsb = new_last_fsb;
257 xfs_cmn_err_fsblock_zero(
259 xfs_bmbt_irec_t *imap)
261 xfs_cmn_err(XFS_PTAG_FSBLOCK_ZERO, CE_ALERT, ip->i_mount,
262 "Access to block zero in inode %llu "
263 "start_block: %llx start_off: %llx "
264 "blkcnt: %llx extent-state: %x\n",
265 (unsigned long long)ip->i_ino,
266 (unsigned long long)imap->br_startblock,
267 (unsigned long long)imap->br_startoff,
268 (unsigned long long)imap->br_blockcount,
274 xfs_iomap_write_direct(
279 xfs_bmbt_irec_t *ret_imap,
283 xfs_mount_t *mp = ip->i_mount;
284 xfs_fileoff_t offset_fsb;
285 xfs_fileoff_t last_fsb;
286 xfs_filblks_t count_fsb, resaligned;
287 xfs_fsblock_t firstfsb;
288 xfs_extlen_t extsz, temp;
294 xfs_bmbt_irec_t imap;
295 xfs_bmap_free_t free_list;
296 uint qblocks, resblks, resrtextents;
301 * Make sure that the dquots are there. This doesn't hold
302 * the ilock across a disk read.
304 error = xfs_qm_dqattach_locked(ip, 0);
306 return XFS_ERROR(error);
308 rt = XFS_IS_REALTIME_INODE(ip);
309 extsz = xfs_get_extsz_hint(ip);
311 offset_fsb = XFS_B_TO_FSBT(mp, offset);
312 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
313 if ((offset + count) > ip->i_size) {
314 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
318 if (found && (ret_imap->br_startblock == HOLESTARTBLOCK))
319 last_fsb = MIN(last_fsb, (xfs_fileoff_t)
320 ret_imap->br_blockcount +
321 ret_imap->br_startoff);
323 count_fsb = last_fsb - offset_fsb;
324 ASSERT(count_fsb > 0);
326 resaligned = count_fsb;
327 if (unlikely(extsz)) {
328 if ((temp = do_mod(offset_fsb, extsz)))
330 if ((temp = do_mod(resaligned, extsz)))
331 resaligned += extsz - temp;
335 resrtextents = qblocks = resaligned;
336 resrtextents /= mp->m_sb.sb_rextsize;
337 resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0);
338 quota_flag = XFS_QMOPT_RES_RTBLKS;
341 resblks = qblocks = XFS_DIOSTRAT_SPACE_RES(mp, resaligned);
342 quota_flag = XFS_QMOPT_RES_REGBLKS;
346 * Allocate and setup the transaction
348 xfs_iunlock(ip, XFS_ILOCK_EXCL);
349 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
350 error = xfs_trans_reserve(tp, resblks,
351 XFS_WRITE_LOG_RES(mp), resrtextents,
352 XFS_TRANS_PERM_LOG_RES,
353 XFS_WRITE_LOG_COUNT);
355 * Check for running out of space, note: need lock to return
358 xfs_trans_cancel(tp, 0);
359 xfs_ilock(ip, XFS_ILOCK_EXCL);
363 error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks, 0, quota_flag);
367 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
368 xfs_trans_ihold(tp, ip);
370 bmapi_flag = XFS_BMAPI_WRITE;
371 if ((flags & BMAPI_DIRECT) && (offset < ip->i_size || extsz))
372 bmapi_flag |= XFS_BMAPI_PREALLOC;
375 * Issue the xfs_bmapi() call to allocate the blocks
377 xfs_bmap_init(&free_list, &firstfsb);
379 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb, bmapi_flag,
380 &firstfsb, 0, &imap, &nimaps, &free_list, NULL);
385 * Complete the transaction
387 error = xfs_bmap_finish(&tp, &free_list, &committed);
390 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
395 * Copy any maps to caller's array and return any error.
402 if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip))) {
403 error = xfs_cmn_err_fsblock_zero(ip, &imap);
411 error0: /* Cancel bmap, unlock inode, unreserve quota blocks, cancel trans */
412 xfs_bmap_cancel(&free_list);
413 xfs_trans_unreserve_quota_nblks(tp, ip, qblocks, 0, quota_flag);
415 error1: /* Just cancel transaction */
416 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
417 *nmaps = 0; /* nothing set-up here */
420 return XFS_ERROR(error);
424 * If the caller is doing a write at the end of the file, then extend the
425 * allocation out to the file system's write iosize. We clean up any extra
426 * space left over when the file is closed in xfs_inactive().
429 xfs_iomap_eof_want_preallocate(
435 xfs_bmbt_irec_t *imap,
439 xfs_fileoff_t start_fsb;
440 xfs_filblks_t count_fsb;
441 xfs_fsblock_t firstblock;
445 if ((offset + count) <= ip->i_size)
449 * If there are any real blocks past eof, then don't
450 * do any speculative allocation.
452 start_fsb = XFS_B_TO_FSBT(mp, ((xfs_ufsize_t)(offset + count - 1)));
453 count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
454 while (count_fsb > 0) {
456 firstblock = NULLFSBLOCK;
457 error = xfs_bmapi(NULL, ip, start_fsb, count_fsb, 0,
458 &firstblock, 0, imap, &imaps, NULL, NULL);
461 for (n = 0; n < imaps; n++) {
462 if ((imap[n].br_startblock != HOLESTARTBLOCK) &&
463 (imap[n].br_startblock != DELAYSTARTBLOCK))
465 start_fsb += imap[n].br_blockcount;
466 count_fsb -= imap[n].br_blockcount;
474 xfs_iomap_write_delay(
479 xfs_bmbt_irec_t *ret_imap,
482 xfs_mount_t *mp = ip->i_mount;
483 xfs_fileoff_t offset_fsb;
484 xfs_fileoff_t last_fsb;
485 xfs_off_t aligned_offset;
486 xfs_fileoff_t ioalign;
487 xfs_fsblock_t firstblock;
490 xfs_bmbt_irec_t imap[XFS_WRITE_IMAPS];
491 int prealloc, flushed = 0;
494 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
497 * Make sure that the dquots are there. This doesn't hold
498 * the ilock across a disk read.
500 error = xfs_qm_dqattach_locked(ip, 0);
502 return XFS_ERROR(error);
504 extsz = xfs_get_extsz_hint(ip);
505 offset_fsb = XFS_B_TO_FSBT(mp, offset);
507 error = xfs_iomap_eof_want_preallocate(mp, ip, offset, count,
508 ioflag, imap, XFS_WRITE_IMAPS, &prealloc);
514 aligned_offset = XFS_WRITEIO_ALIGN(mp, (offset + count - 1));
515 ioalign = XFS_B_TO_FSBT(mp, aligned_offset);
516 last_fsb = ioalign + mp->m_writeio_blocks;
518 last_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)(offset + count)));
521 if (prealloc || extsz) {
522 error = xfs_iomap_eof_align_last_fsb(mp, ip, extsz, &last_fsb);
527 nimaps = XFS_WRITE_IMAPS;
528 firstblock = NULLFSBLOCK;
529 error = xfs_bmapi(NULL, ip, offset_fsb,
530 (xfs_filblks_t)(last_fsb - offset_fsb),
531 XFS_BMAPI_DELAY | XFS_BMAPI_WRITE |
532 XFS_BMAPI_ENTIRE, &firstblock, 1, imap,
533 &nimaps, NULL, NULL);
534 if (error && (error != ENOSPC))
535 return XFS_ERROR(error);
538 * If bmapi returned us nothing, and if we didn't get back EDQUOT,
539 * then we must have run out of space - flush all other inodes with
540 * delalloc blocks and retry without EOF preallocation.
543 trace_xfs_delalloc_enospc(ip, offset, count);
545 return XFS_ERROR(ENOSPC);
547 xfs_iunlock(ip, XFS_ILOCK_EXCL);
548 xfs_flush_inodes(ip);
549 xfs_ilock(ip, XFS_ILOCK_EXCL);
557 if (!(imap[0].br_startblock || XFS_IS_REALTIME_INODE(ip)))
558 return xfs_cmn_err_fsblock_zero(ip, &imap[0]);
567 * Pass in a delayed allocate extent, convert it to real extents;
568 * return to the caller the extent we create which maps on top of
569 * the originating callers request.
571 * Called without a lock on the inode.
573 * We no longer bother to look at the incoming map - all we have to
574 * guarantee is that whatever we allocate fills the required range.
577 xfs_iomap_write_allocate(
581 xfs_bmbt_irec_t *map,
584 xfs_mount_t *mp = ip->i_mount;
585 xfs_fileoff_t offset_fsb, last_block;
586 xfs_fileoff_t end_fsb, map_start_fsb;
587 xfs_fsblock_t first_block;
588 xfs_bmap_free_t free_list;
589 xfs_filblks_t count_fsb;
590 xfs_bmbt_irec_t imap;
592 int nimaps, committed;
599 * Make sure that the dquots are there.
601 error = xfs_qm_dqattach(ip, 0);
603 return XFS_ERROR(error);
605 offset_fsb = XFS_B_TO_FSBT(mp, offset);
606 count_fsb = map->br_blockcount;
607 map_start_fsb = map->br_startoff;
609 XFS_STATS_ADD(xs_xstrat_bytes, XFS_FSB_TO_B(mp, count_fsb));
611 while (count_fsb != 0) {
613 * Set up a transaction with which to allocate the
614 * backing store for the file. Do allocations in a
615 * loop until we get some space in the range we are
616 * interested in. The other space that might be allocated
617 * is in the delayed allocation extent on which we sit
618 * but before our buffer starts.
622 while (nimaps == 0) {
623 tp = xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE);
624 tp->t_flags |= XFS_TRANS_RESERVE;
625 nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
626 error = xfs_trans_reserve(tp, nres,
627 XFS_WRITE_LOG_RES(mp),
628 0, XFS_TRANS_PERM_LOG_RES,
629 XFS_WRITE_LOG_COUNT);
631 xfs_trans_cancel(tp, 0);
632 return XFS_ERROR(error);
634 xfs_ilock(ip, XFS_ILOCK_EXCL);
635 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
636 xfs_trans_ihold(tp, ip);
638 xfs_bmap_init(&free_list, &first_block);
641 * it is possible that the extents have changed since
642 * we did the read call as we dropped the ilock for a
643 * while. We have to be careful about truncates or hole
644 * punchs here - we are not allowed to allocate
645 * non-delalloc blocks here.
647 * The only protection against truncation is the pages
648 * for the range we are being asked to convert are
649 * locked and hence a truncate will block on them
652 * As a result, if we go beyond the range we really
653 * need and hit an delalloc extent boundary followed by
654 * a hole while we have excess blocks in the map, we
655 * will fill the hole incorrectly and overrun the
656 * transaction reservation.
658 * Using a single map prevents this as we are forced to
659 * check each map we look for overlap with the desired
660 * range and abort as soon as we find it. Also, given
661 * that we only return a single map, having one beyond
662 * what we can return is probably a bit silly.
664 * We also need to check that we don't go beyond EOF;
665 * this is a truncate optimisation as a truncate sets
666 * the new file size before block on the pages we
667 * currently have locked under writeback. Because they
668 * are about to be tossed, we don't need to write them
672 end_fsb = XFS_B_TO_FSB(mp, ip->i_size);
673 error = xfs_bmap_last_offset(NULL, ip, &last_block,
678 last_block = XFS_FILEOFF_MAX(last_block, end_fsb);
679 if ((map_start_fsb + count_fsb) > last_block) {
680 count_fsb = last_block - map_start_fsb;
681 if (count_fsb == 0) {
687 /* Go get the actual blocks */
688 error = xfs_bmapi(tp, ip, map_start_fsb, count_fsb,
689 XFS_BMAPI_WRITE, &first_block, 1,
690 &imap, &nimaps, &free_list, NULL);
694 error = xfs_bmap_finish(&tp, &free_list, &committed);
698 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
702 xfs_iunlock(ip, XFS_ILOCK_EXCL);
706 * See if we were able to allocate an extent that
707 * covers at least part of the callers request
709 if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip)))
710 return xfs_cmn_err_fsblock_zero(ip, &imap);
712 if ((offset_fsb >= imap.br_startoff) &&
713 (offset_fsb < (imap.br_startoff +
714 imap.br_blockcount))) {
717 XFS_STATS_INC(xs_xstrat_quick);
722 * So far we have not mapped the requested part of the
723 * file, just surrounding data, try again.
725 count_fsb -= imap.br_blockcount;
726 map_start_fsb = imap.br_startoff + imap.br_blockcount;
730 xfs_bmap_cancel(&free_list);
731 xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
733 xfs_iunlock(ip, XFS_ILOCK_EXCL);
734 return XFS_ERROR(error);
738 xfs_iomap_write_unwritten(
743 xfs_mount_t *mp = ip->i_mount;
744 xfs_fileoff_t offset_fsb;
745 xfs_filblks_t count_fsb;
746 xfs_filblks_t numblks_fsb;
747 xfs_fsblock_t firstfsb;
750 xfs_bmbt_irec_t imap;
751 xfs_bmap_free_t free_list;
756 trace_xfs_unwritten_convert(ip, offset, count);
758 offset_fsb = XFS_B_TO_FSBT(mp, offset);
759 count_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)offset + count);
760 count_fsb = (xfs_filblks_t)(count_fsb - offset_fsb);
763 * Reserve enough blocks in this transaction for two complete extent
764 * btree splits. We may be converting the middle part of an unwritten
765 * extent and in this case we will insert two new extents in the btree
766 * each of which could cause a full split.
768 * This reservation amount will be used in the first call to
769 * xfs_bmbt_split() to select an AG with enough space to satisfy the
770 * rest of the operation.
772 resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0) << 1;
776 * set up a transaction to convert the range of extents
777 * from unwritten to real. Do allocations in a loop until
778 * we have covered the range passed in.
780 * Note that we open code the transaction allocation here
781 * to pass KM_NOFS--we can't risk to recursing back into
782 * the filesystem here as we might be asked to write out
783 * the same inode that we complete here and might deadlock
786 xfs_wait_for_freeze(mp, SB_FREEZE_TRANS);
787 tp = _xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE, KM_NOFS);
788 tp->t_flags |= XFS_TRANS_RESERVE;
789 error = xfs_trans_reserve(tp, resblks,
790 XFS_WRITE_LOG_RES(mp), 0,
791 XFS_TRANS_PERM_LOG_RES,
792 XFS_WRITE_LOG_COUNT);
794 xfs_trans_cancel(tp, 0);
795 return XFS_ERROR(error);
798 xfs_ilock(ip, XFS_ILOCK_EXCL);
799 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
800 xfs_trans_ihold(tp, ip);
803 * Modify the unwritten extent state of the buffer.
805 xfs_bmap_init(&free_list, &firstfsb);
807 error = xfs_bmapi(tp, ip, offset_fsb, count_fsb,
808 XFS_BMAPI_WRITE|XFS_BMAPI_CONVERT, &firstfsb,
809 1, &imap, &nimaps, &free_list, NULL);
811 goto error_on_bmapi_transaction;
813 error = xfs_bmap_finish(&(tp), &(free_list), &committed);
815 goto error_on_bmapi_transaction;
817 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
818 xfs_iunlock(ip, XFS_ILOCK_EXCL);
820 return XFS_ERROR(error);
822 if (!(imap.br_startblock || XFS_IS_REALTIME_INODE(ip)))
823 return xfs_cmn_err_fsblock_zero(ip, &imap);
825 if ((numblks_fsb = imap.br_blockcount) == 0) {
827 * The numblks_fsb value should always get
828 * smaller, otherwise the loop is stuck.
830 ASSERT(imap.br_blockcount);
833 offset_fsb += numblks_fsb;
834 count_fsb -= numblks_fsb;
835 } while (count_fsb > 0);
839 error_on_bmapi_transaction:
840 xfs_bmap_cancel(&free_list);
841 xfs_trans_cancel(tp, (XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT));
842 xfs_iunlock(ip, XFS_ILOCK_EXCL);
843 return XFS_ERROR(error);