Lines Matching +full:short +full:- +full:circuits

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
46 return xfs_rtb_to_daddr(ip->i_mount, fsb); in xfs_fsb_to_db()
47 return XFS_FSB_TO_DADDR(ip->i_mount, fsb); in xfs_fsb_to_db()
59 return blkdev_issue_zeroout(xfs_inode_buftarg(ip)->bt_bdev, in xfs_zero_extent()
61 XFS_FSB_TO_BB(ip->i_mount, count_fsb), in xfs_zero_extent()
104 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_count_blocks()
116 switch (ifp->if_format) { in xfs_bmap_count_blocks()
133 *count += btblocks - 1; in xfs_bmap_count_blocks()
152 struct kgetbmap *p = out + bmv->bmv_entries; in xfs_getbmap_report_one()
160 if (isnullstartblock(got->br_startblock) || in xfs_getbmap_report_one()
161 got->br_startblock == DELAYSTARTBLOCK) { in xfs_getbmap_report_one()
163 * Take the flush completion as being a point-in-time snapshot in xfs_getbmap_report_one()
168 if (!(bmv->bmv_iflags & BMV_IF_DELALLOC)) in xfs_getbmap_report_one()
171 p->bmv_oflags |= BMV_OF_DELALLOC; in xfs_getbmap_report_one()
172 p->bmv_block = -2; in xfs_getbmap_report_one()
174 p->bmv_block = xfs_fsb_to_db(ip, got->br_startblock); in xfs_getbmap_report_one()
177 if (got->br_state == XFS_EXT_UNWRITTEN && in xfs_getbmap_report_one()
178 (bmv->bmv_iflags & BMV_IF_PREALLOC)) in xfs_getbmap_report_one()
179 p->bmv_oflags |= BMV_OF_PREALLOC; in xfs_getbmap_report_one()
182 p->bmv_oflags |= BMV_OF_SHARED; in xfs_getbmap_report_one()
184 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, got->br_startoff); in xfs_getbmap_report_one()
185 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, got->br_blockcount); in xfs_getbmap_report_one()
187 bmv->bmv_offset = p->bmv_offset + p->bmv_length; in xfs_getbmap_report_one()
188 bmv->bmv_length = max(0LL, bmv_end - bmv->bmv_offset); in xfs_getbmap_report_one()
189 bmv->bmv_entries++; in xfs_getbmap_report_one()
202 struct kgetbmap *p = out + bmv->bmv_entries; in xfs_getbmap_report_hole()
204 if (bmv->bmv_iflags & BMV_IF_NO_HOLES) in xfs_getbmap_report_hole()
207 p->bmv_block = -1; in xfs_getbmap_report_hole()
208 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, bno); in xfs_getbmap_report_hole()
209 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, end - bno); in xfs_getbmap_report_hole()
211 bmv->bmv_offset = p->bmv_offset + p->bmv_length; in xfs_getbmap_report_hole()
212 bmv->bmv_length = max(0LL, bmv_end - bmv->bmv_offset); in xfs_getbmap_report_hole()
213 bmv->bmv_entries++; in xfs_getbmap_report_hole()
220 return bmv->bmv_length == 0 || bmv->bmv_entries >= bmv->bmv_count - 1; in xfs_getbmap_full()
228 xfs_fileoff_t end = rec->br_startoff + rec->br_blockcount; in xfs_getbmap_next_rec()
233 rec->br_startoff += rec->br_blockcount; in xfs_getbmap_next_rec()
234 if (!isnullstartblock(rec->br_startblock) && in xfs_getbmap_next_rec()
235 rec->br_startblock != DELAYSTARTBLOCK) in xfs_getbmap_next_rec()
236 rec->br_startblock += rec->br_blockcount; in xfs_getbmap_next_rec()
237 rec->br_blockcount = total_end - end; in xfs_getbmap_next_rec()
244 * are mapped, until the passed-in bmv->bmv_count slots have
245 * been filled, or until the formatter short-circuits the loop,
246 * if it is tracking filled-in extents on its own.
254 struct xfs_mount *mp = ip->i_mount; in xfs_getbmap()
255 int iflags = bmv->bmv_iflags; in xfs_getbmap()
264 if (bmv->bmv_iflags & ~BMV_IF_VALID) in xfs_getbmap()
265 return -EINVAL; in xfs_getbmap()
269 return -EINVAL; in xfs_getbmap()
272 return -EINVAL; in xfs_getbmap()
274 if (bmv->bmv_length < -1) in xfs_getbmap()
275 return -EINVAL; in xfs_getbmap()
276 bmv->bmv_entries = 0; in xfs_getbmap()
277 if (bmv->bmv_length == 0) in xfs_getbmap()
305 max_len = mp->m_super->s_maxbytes; in xfs_getbmap()
311 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) { in xfs_getbmap()
312 error = filemap_write_and_wait(VFS_I(ip)->i_mapping); in xfs_getbmap()
322 * ip->i_delayed_blks == 0. in xfs_getbmap()
327 (ip->i_diflags & XFS_DIFLAG_PREALLOC)) in xfs_getbmap()
328 max_len = mp->m_super->s_maxbytes; in xfs_getbmap()
338 switch (ifp->if_format) { in xfs_getbmap()
346 error = -EINVAL; in xfs_getbmap()
350 if (bmv->bmv_length == -1) { in xfs_getbmap()
352 bmv->bmv_length = max(0LL, max_len - bmv->bmv_offset); in xfs_getbmap()
355 bmv_end = bmv->bmv_offset + bmv->bmv_length; in xfs_getbmap()
357 first_bno = bno = XFS_BB_TO_FSBT(mp, bmv->bmv_offset); in xfs_getbmap()
358 len = XFS_BB_TO_FSB(mp, bmv->bmv_length); in xfs_getbmap()
366 * Report a whole-file hole if the delalloc flag is set to in xfs_getbmap()
406 if (bmv->bmv_entries > 0) in xfs_getbmap()
407 out[bmv->bmv_entries - 1].bmv_oflags |= in xfs_getbmap()
443 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_punch_delalloc_range()
458 xfs_trim_extent(&del, start_fsb, end_fsb - start_fsb); in xfs_bmap_punch_delalloc_range()
462 * previous extent on non-delalloc or extents outside the in xfs_bmap_punch_delalloc_range()
481 ac->reserved_blocks += del.br_blockcount; in xfs_bmap_punch_delalloc_range()
491 if (whichfork == XFS_COW_FORK && !ifp->if_bytes) in xfs_bmap_punch_delalloc_range()
506 struct xfs_mount *mp = ip->i_mount; in xfs_can_free_eofblocks()
517 if (!(VFS_I(ip)->i_state & I_FREEING)) in xfs_can_free_eofblocks()
521 if (!S_ISREG(VFS_I(ip)->i_mode)) in xfs_can_free_eofblocks()
528 if (VFS_I(ip)->i_size == 0 && in xfs_can_free_eofblocks()
529 VFS_I(ip)->i_mapping->nrpages == 0 && in xfs_can_free_eofblocks()
530 ip->i_delayed_blks == 0) in xfs_can_free_eofblocks()
534 if (xfs_need_iread_extents(&ip->i_df)) in xfs_can_free_eofblocks()
541 if ((ip->i_diflags & XFS_DIFLAG_PREALLOC) && !ip->i_delayed_blks) in xfs_can_free_eofblocks()
545 * Do not try to free post-EOF blocks if EOF is beyond the end of the in xfs_can_free_eofblocks()
552 last_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); in xfs_can_free_eofblocks()
557 * Check if there is an post-EOF extent to free. If there are any in xfs_can_free_eofblocks()
563 if (ip->i_delayed_blks || in xfs_can_free_eofblocks()
564 xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) in xfs_can_free_eofblocks()
580 struct xfs_mount *mp = ip->i_mount; in xfs_free_eofblocks()
597 if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) { in xfs_free_eofblocks()
598 if (ip->i_delayed_blks) { in xfs_free_eofblocks()
600 round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize), in xfs_free_eofblocks()
607 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); in xfs_free_eofblocks()
617 * Do not update the on-disk file size. If we update the on-disk file in xfs_free_eofblocks()
651 xfs_mount_t *mp = ip->i_mount; in xfs_alloc_file_space()
668 return -EIO; in xfs_alloc_file_space()
675 return -EINVAL; in xfs_alloc_file_space()
684 allocatesize_fsb = endoffset_fsb - startoffset_fsb; in xfs_alloc_file_space()
707 e += extsz - temp; in xfs_alloc_file_space()
714 * The transaction reservation is limited to a 32-bit block in xfs_alloc_file_space()
721 resblks = min_t(xfs_fileoff_t, (e - s), in xfs_alloc_file_space()
731 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, in xfs_alloc_file_space()
744 * xfs_bmapi_write will return -ENOSR. in xfs_alloc_file_space()
754 if (error != -ENOSR) in xfs_alloc_file_space()
758 startoffset_fsb += imapp->br_blockcount; in xfs_alloc_file_space()
759 allocatesize_fsb -= imapp->br_blockcount; in xfs_alloc_file_space()
762 ip->i_diflags |= XFS_DIFLAG_PREALLOC; in xfs_alloc_file_space()
784 struct xfs_mount *mp = ip->i_mount; in xfs_unmap_extent()
789 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks, 0, in xfs_unmap_extent()
831 end = roundup_64(offset + len, rounding) - 1; in xfs_flush_unmap_range()
833 error = filemap_write_and_wait_range(inode->i_mapping, start, end); in xfs_flush_unmap_range()
847 struct xfs_mount *mp = ip->i_mount; in xfs_free_file_space()
884 endoffset_fsb - startoffset_fsb, &done); in xfs_free_file_space()
899 len = XFS_ISIZE(ip) - offset; in xfs_free_file_space()
906 * must make sure that the post-EOF area is also zeroed because the in xfs_free_file_space()
911 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, in xfs_free_file_space()
927 * Trim eofblocks to avoid shifting uninitialized post-eof preallocation in xfs_prepare_shift()
947 offset -= rounding; in xfs_prepare_shift()
991 struct xfs_mount *mp = ip->i_mount; in xfs_collapse_file_space()
1010 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, 0, &tp); in xfs_collapse_file_space()
1059 struct xfs_mount *mp = ip->i_mount; in xfs_insert_file_space()
1079 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, in xfs_insert_file_space()
1147 struct xfs_ifork *ifp = &ip->i_df; in xfs_swap_extents_check_format()
1148 struct xfs_ifork *tifp = &tip->i_df; in xfs_swap_extents_check_format()
1151 if (XFS_IS_QUOTA_ON(ip->i_mount) && in xfs_swap_extents_check_format()
1152 (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) || in xfs_swap_extents_check_format()
1153 !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) || in xfs_swap_extents_check_format()
1154 ip->i_projid != tip->i_projid)) in xfs_swap_extents_check_format()
1155 return -EINVAL; in xfs_swap_extents_check_format()
1158 if (ifp->if_format == XFS_DINODE_FMT_LOCAL || in xfs_swap_extents_check_format()
1159 tifp->if_format == XFS_DINODE_FMT_LOCAL) in xfs_swap_extents_check_format()
1160 return -EINVAL; in xfs_swap_extents_check_format()
1166 if (ifp->if_nextents < tifp->if_nextents) in xfs_swap_extents_check_format()
1167 return -EINVAL; in xfs_swap_extents_check_format()
1173 if (xfs_has_rmapbt(ip->i_mount)) in xfs_swap_extents_check_format()
1181 if (ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_swap_extents_check_format()
1182 tifp->if_format == XFS_DINODE_FMT_BTREE) in xfs_swap_extents_check_format()
1183 return -EINVAL; in xfs_swap_extents_check_format()
1186 if (tifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_swap_extents_check_format()
1187 tifp->if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1188 return -EINVAL; in xfs_swap_extents_check_format()
1191 if (ifp->if_format == XFS_DINODE_FMT_EXTENTS && in xfs_swap_extents_check_format()
1192 ifp->if_nextents > XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1193 return -EINVAL; in xfs_swap_extents_check_format()
1200 * Note that we have to be careful to allow btree->extent conversions in xfs_swap_extents_check_format()
1204 if (tifp->if_format == XFS_DINODE_FMT_BTREE) { in xfs_swap_extents_check_format()
1206 xfs_bmap_bmdr_space(tifp->if_broot) > xfs_inode_fork_boff(ip)) in xfs_swap_extents_check_format()
1207 return -EINVAL; in xfs_swap_extents_check_format()
1208 if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1209 return -EINVAL; in xfs_swap_extents_check_format()
1212 /* Reciprocal target->temp btree format checks */ in xfs_swap_extents_check_format()
1213 if (ifp->if_format == XFS_DINODE_FMT_BTREE) { in xfs_swap_extents_check_format()
1215 xfs_bmap_bmdr_space(ip->i_df.if_broot) > xfs_inode_fork_boff(tip)) in xfs_swap_extents_check_format()
1216 return -EINVAL; in xfs_swap_extents_check_format()
1217 if (ifp->if_nextents <= XFS_IFORK_MAXEXT(tip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1218 return -EINVAL; in xfs_swap_extents_check_format()
1230 error = filemap_write_and_wait(VFS_I(ip)->i_mapping); in xfs_swap_extent_flush()
1233 truncate_pagecache_range(VFS_I(ip), 0, -1); in xfs_swap_extent_flush()
1236 if (VFS_I(ip)->i_mapping->nrpages) in xfs_swap_extent_flush()
1237 return -EINVAL; in xfs_swap_extent_flush()
1265 * file as having shared blocks so that we get the shared-block in xfs_swap_extent_rmap()
1269 tip_flags2 = tip->i_diflags2; in xfs_swap_extent_rmap()
1270 if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK) in xfs_swap_extent_rmap()
1271 tip->i_diflags2 |= XFS_DIFLAG2_REFLINK; in xfs_swap_extent_rmap()
1274 end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip))); in xfs_swap_extent_rmap()
1275 count_fsb = (xfs_filblks_t)(end_fsb - offset_fsb); in xfs_swap_extent_rmap()
1292 ASSERT(tp->t_highest_agno == NULLAGNUMBER); in xfs_swap_extent_rmap()
1350 tirec.br_blockcount -= rlen; in xfs_swap_extent_rmap()
1354 count_fsb -= ilen; in xfs_swap_extent_rmap()
1358 tip->i_diflags2 = tip_flags2; in xfs_swap_extent_rmap()
1363 tip->i_diflags2 = tip_flags2; in xfs_swap_extent_rmap()
1385 if (xfs_inode_has_attr_fork(ip) && ip->i_af.if_nextents > 0 && in xfs_swap_extent_forks()
1386 ip->i_af.if_format != XFS_DINODE_FMT_LOCAL) { in xfs_swap_extent_forks()
1392 if (xfs_inode_has_attr_fork(tip) && tip->i_af.if_nextents > 0 && in xfs_swap_extent_forks()
1393 tip->i_af.if_format != XFS_DINODE_FMT_LOCAL) { in xfs_swap_extent_forks()
1407 if (xfs_has_v3inodes(ip->i_mount)) { in xfs_swap_extent_forks()
1408 if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE) in xfs_swap_extent_forks()
1410 if (tip->i_df.if_format == XFS_DINODE_FMT_BTREE) in xfs_swap_extent_forks()
1417 swap(ip->i_df, tip->i_df); in xfs_swap_extent_forks()
1420 * Fix the on-disk inode values in xfs_swap_extent_forks()
1422 tmp = (uint64_t)ip->i_nblocks; in xfs_swap_extent_forks()
1423 ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks; in xfs_swap_extent_forks()
1424 tip->i_nblocks = tmp + taforkblks - aforkblks; in xfs_swap_extent_forks()
1435 ASSERT(tip->i_delayed_blks == 0); in xfs_swap_extent_forks()
1436 tip->i_delayed_blks = ip->i_delayed_blks; in xfs_swap_extent_forks()
1437 ip->i_delayed_blks = 0; in xfs_swap_extent_forks()
1439 switch (ip->i_df.if_format) { in xfs_swap_extent_forks()
1444 ASSERT(!xfs_has_v3inodes(ip->i_mount) || in xfs_swap_extent_forks()
1450 switch (tip->i_df.if_format) { in xfs_swap_extent_forks()
1456 ASSERT(!xfs_has_v3inodes(ip->i_mount) || in xfs_swap_extent_forks()
1468 * physically logged as a fallback and the scan returns -EAGAIN. We must roll
1482 error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino, in xfs_swap_change_owner()
1485 if (error != -EAGAIN) in xfs_swap_change_owner()
1512 struct xfs_mount *mp = ip->i_mount; in xfs_swap_extents()
1514 struct xfs_bstat *sbp = &sxp->sx_stat; in xfs_swap_extents()
1529 filemap_invalidate_lock_two(VFS_I(ip)->i_mapping, in xfs_swap_extents()
1530 VFS_I(tip)->i_mapping); in xfs_swap_extents()
1533 if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) { in xfs_swap_extents()
1534 error = -EINVAL; in xfs_swap_extents()
1538 /* Verify both files are either real-time or non-realtime */ in xfs_swap_extents()
1540 error = -EINVAL; in xfs_swap_extents()
1551 if (XFS_IS_REALTIME_INODE(ip) && xfs_has_rtgroups(ip->i_mount)) { in xfs_swap_extents()
1552 error = -EOPNOTSUPP; in xfs_swap_extents()
1584 uint32_t ipnext = ip->i_df.if_nextents; in xfs_swap_extents()
1585 uint32_t tipnext = tip->i_df.if_nextents; in xfs_swap_extents()
1604 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, flags, in xfs_swap_extents()
1619 if (sxp->sx_offset != 0 || in xfs_swap_extents()
1620 sxp->sx_length != ip->i_disk_size || in xfs_swap_extents()
1621 sxp->sx_length != tip->i_disk_size) { in xfs_swap_extents()
1622 error = -EFAULT; in xfs_swap_extents()
1634 __func__, ip->i_ino); in xfs_swap_extents()
1647 if ((sbp->bs_ctime.tv_sec != ctime.tv_sec) || in xfs_swap_extents()
1648 (sbp->bs_ctime.tv_nsec != ctime.tv_nsec) || in xfs_swap_extents()
1649 (sbp->bs_mtime.tv_sec != mtime.tv_sec) || in xfs_swap_extents()
1650 (sbp->bs_mtime.tv_nsec != mtime.tv_nsec)) { in xfs_swap_extents()
1651 error = -EBUSY; in xfs_swap_extents()
1656 * Note the trickiness in setting the log flags - we set the owner log in xfs_swap_extents()
1660 * not the pre-swapped inodes. in xfs_swap_extents()
1674 if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^ in xfs_swap_extents()
1675 (tip->i_diflags2 & XFS_DIFLAG2_REFLINK)) { in xfs_swap_extents()
1676 f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1677 ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1678 ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1679 tip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1680 tip->i_diflags2 |= f & XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1685 ASSERT(!ip->i_cowfp || in xfs_swap_extents()
1686 ip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_swap_extents()
1687 ASSERT(!tip->i_cowfp || in xfs_swap_extents()
1688 tip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_swap_extents()
1690 swap(ip->i_cowfp, tip->i_cowfp); in xfs_swap_extents()
1692 if (ip->i_cowfp && ip->i_cowfp->if_bytes) in xfs_swap_extents()
1696 if (tip->i_cowfp && tip->i_cowfp->if_bytes) in xfs_swap_extents()
1738 filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping, in xfs_swap_extents()
1739 VFS_I(tip)->i_mapping); in xfs_swap_extents()