46 #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \
48 #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
70 if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
72 else if (mp->m_dalign)
76 new_last_fsb = roundup_64(*last_fsb, align);
85 align = roundup_64(new_last_fsb, extsize);
88 new_last_fsb = roundup_64(*last_fsb, align);
96 *last_fsb = new_last_fsb;
107 "Access to block zero in inode %llu "
108 "start_block: %llx start_off: %llx "
109 "blkcnt: %llx extent-state: %x\n",
110 (
unsigned long long)ip->i_ino,
126 xfs_mount_t *
mp = ip->i_mount;
138 uint qblocks, resblks, resrtextents;
151 if ((offset + count) > XFS_ISIZE(ip)) {
161 count_fsb = last_fsb - offset_fsb;
164 resaligned = count_fsb;
166 if ((temp =
do_mod(offset_fsb, extsz)))
168 if ((temp =
do_mod(resaligned, extsz)))
169 resaligned += extsz -
temp;
173 resrtextents = qblocks = resaligned;
174 resrtextents /= mp->m_sb.sb_rextsize;
203 goto out_trans_cancel;
208 if (offset < XFS_ISIZE(ip) || extsz)
215 xfs_bmap_init(&free_list, &firstfsb);
218 &firstfsb, 0, imap, &nimaps, &free_list);
220 goto out_bmap_cancel;
227 goto out_bmap_cancel;
249 xfs_trans_unreserve_quota_nblks(tp, ip, (
long)qblocks, 0, quota_flag);
277 int found_delalloc = 0;
280 if (offset + count <= XFS_ISIZE(ip))
289 while (count_fsb > 0) {
296 for (n = 0; n < imaps; n++) {
320 struct xfs_mount *
mp,
321 struct xfs_inode *
ip)
325 if (!(mp->m_flags & XFS_MOUNT_DFLT_IOSIZE)) {
338 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
339 freesp = mp->m_sb.sb_fdblocks;
340 if (freesp < mp->m_low_space[XFS_LOWSP_5_PCNT]) {
342 if (freesp < mp->m_low_space[XFS_LOWSP_4_PCNT])
344 if (freesp < mp->m_low_space[XFS_LOWSP_3_PCNT])
346 if (freesp < mp->m_low_space[XFS_LOWSP_2_PCNT])
348 if (freesp < mp->m_low_space[XFS_LOWSP_1_PCNT])
352 alloc_blocks >>= shift;
355 if (alloc_blocks < mp->m_writeio_blocks)
356 alloc_blocks = mp->m_writeio_blocks;
368 xfs_mount_t *
mp = ip->i_mount;
371 xfs_off_t aligned_offset;
376 int prealloc, flushed = 0;
379 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
404 last_fsb = ioalign + alloc_blocks;
409 if (prealloc || extsz) {
419 if (last_fsb >
XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes))
422 ASSERT(last_fsb > offset_fsb);
443 trace_xfs_delalloc_enospc(ip, offset, count);
447 if (error == ENOSPC) {
483 xfs_mount_t *
mp = ip->i_mount;
490 int nimaps, committed;
507 while (count_fsb != 0) {
518 while (nimaps == 0) {
533 xfs_bmap_init(&free_list, &first_block);
574 if ((map_start_fsb + count_fsb) > last_block) {
575 count_fsb = last_block - map_start_fsb;
576 if (count_fsb == 0) {
590 imap, &nimaps, &free_list);
641 xfs_mount_t *
mp = ip->i_mount;
655 trace_xfs_unwritten_convert(ip, offset, count);
685 sb_start_intwrite(mp->m_super);
703 xfs_bmap_init(&free_list, &firstfsb);
707 1, &imap, &nimaps, &free_list);
709 goto error_on_bmapi_transaction;
717 if (i_size > offset + count)
718 i_size = offset +
count;
720 i_size = xfs_new_eof(ip, i_size);
722 ip->i_d.di_size = i_size;
728 goto error_on_bmapi_transaction;
746 offset_fsb += numblks_fsb;
747 count_fsb -= numblks_fsb;
748 }
while (count_fsb > 0);
752 error_on_bmapi_transaction: