Lines Matching +full:ip +full:- +full:block

1 // SPDX-License-Identifier: GPL-2.0+
39 * through the use of a copy-on-write mechanism. At a high level, that
40 * means that when we want to write to a shared block, we allocate a new
41 * block, write the data to the new block, and if that succeeds we map the
42 * new block into the file.
45 * of disk blocks to dirty-but-not-yet-mapped file blocks as long as
49 * The delalloc mechanism begins when the kernel wants to make a block
51 * create a delalloc mapping, which is a regular in-core extent, but without
53 * a flag that this is a delalloc mapping, and a worst-case estimate of how
63 * D: --RRRRRRSSSRRRRRRRR--- (data fork)
64 * C: ------DDDDDDD--------- (CoW fork)
72 * D: --RRRRRRSSSRRRRRRRR---
73 * C: ------UUUUUUU---------
75 * We want to adapt the delalloc mechanism for copy-on-write, since the
85 * Block-aligned directio writes will use the same mechanism as buffered
93 * D: --RRRRRRSSSRRRRRRRR---
94 * C: ------UUrrUUU---------
96 * CoW remapping must be done after the data block write completes,
98 * the new block has been written. Since the new mappings are kept in a
104 * only to remap the blocks that we've actually written out -- we must
109 * D: --RRRRRRrrSRRRRRRRR---
110 * C: ------UU--UUU---------
122 * Given an AG extent, find the lowest-numbered run of shared blocks
159 * Trim the mapping to the next block where there's a change in the
161 * find the lowest-numbered extent of shared blocks that coincides with
162 * the given block mapping. If the shared extent overlaps the start of
170 struct xfs_inode *ip, in xfs_reflink_trim_around_shared() argument
182 if (!xfs_is_cow_inode(ip) || !xfs_bmap_is_written_extent(irec)) { in xfs_reflink_trim_around_shared()
187 trace_xfs_reflink_trim_around_shared(ip, irec); in xfs_reflink_trim_around_shared()
189 agno = XFS_FSB_TO_AGNO(ip->i_mount, irec->br_startblock); in xfs_reflink_trim_around_shared()
190 agbno = XFS_FSB_TO_AGBNO(ip->i_mount, irec->br_startblock); in xfs_reflink_trim_around_shared()
191 aglen = irec->br_blockcount; in xfs_reflink_trim_around_shared()
193 error = xfs_reflink_find_shared(ip->i_mount, NULL, agno, agbno, in xfs_reflink_trim_around_shared()
209 irec->br_blockcount = flen; in xfs_reflink_trim_around_shared()
219 irec->br_blockcount = fbno - agbno; in xfs_reflink_trim_around_shared()
226 struct xfs_inode *ip, in xfs_bmap_trim_cow() argument
231 if (xfs_is_always_cow_inode(ip) && in xfs_bmap_trim_cow()
232 !isnullstartblock(imap->br_startblock)) { in xfs_bmap_trim_cow()
238 return xfs_reflink_trim_around_shared(ip, imap, shared); in xfs_bmap_trim_cow()
243 struct xfs_inode *ip, in xfs_reflink_convert_cow_locked() argument
253 if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, &got)) in xfs_reflink_convert_cow_locked()
262 return -EIO; in xfs_reflink_convert_cow_locked()
269 error = xfs_bmap_add_extent_unwritten_real(NULL, ip, in xfs_reflink_convert_cow_locked()
274 } while (xfs_iext_next_extent(ip->i_cowfp, &icur, &got)); in xfs_reflink_convert_cow_locked()
282 struct xfs_inode *ip, in xfs_reflink_convert_cow() argument
286 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_convert_cow()
289 xfs_filblks_t count_fsb = end_fsb - offset_fsb; in xfs_reflink_convert_cow()
294 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_reflink_convert_cow()
295 error = xfs_reflink_convert_cow_locked(ip, offset_fsb, count_fsb); in xfs_reflink_convert_cow()
296 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_convert_cow()
307 struct xfs_inode *ip, in xfs_find_trim_cow_extent() argument
313 xfs_fileoff_t offset_fsb = imap->br_startoff; in xfs_find_trim_cow_extent()
314 xfs_filblks_t count_fsb = imap->br_blockcount; in xfs_find_trim_cow_extent()
323 if (!xfs_iext_lookup_extent(ip, ip->i_cowfp, offset_fsb, &icur, cmap)) in xfs_find_trim_cow_extent()
324 cmap->br_startoff = offset_fsb + count_fsb; in xfs_find_trim_cow_extent()
325 if (cmap->br_startoff > offset_fsb) { in xfs_find_trim_cow_extent()
326 xfs_trim_extent(imap, imap->br_startoff, in xfs_find_trim_cow_extent()
327 cmap->br_startoff - imap->br_startoff); in xfs_find_trim_cow_extent()
328 return xfs_bmap_trim_cow(ip, imap, shared); in xfs_find_trim_cow_extent()
332 if (isnullstartblock(cmap->br_startblock)) { in xfs_find_trim_cow_extent()
333 xfs_trim_extent(imap, cmap->br_startoff, cmap->br_blockcount); in xfs_find_trim_cow_extent()
337 /* real extent found - no need to allocate */ in xfs_find_trim_cow_extent()
346 struct xfs_inode *ip, in xfs_reflink_allocate_cow() argument
353 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_allocate_cow()
354 xfs_fileoff_t offset_fsb = imap->br_startoff; in xfs_reflink_allocate_cow()
355 xfs_filblks_t count_fsb = imap->br_blockcount; in xfs_reflink_allocate_cow()
362 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_reflink_allocate_cow()
363 if (!ip->i_cowfp) { in xfs_reflink_allocate_cow()
364 ASSERT(!xfs_is_reflink_inode(ip)); in xfs_reflink_allocate_cow()
365 xfs_ifork_init_cow(ip); in xfs_reflink_allocate_cow()
368 error = xfs_find_trim_cow_extent(ip, imap, cmap, shared, &found); in xfs_reflink_allocate_cow()
374 resaligned = xfs_aligned_fsb_count(imap->br_startoff, in xfs_reflink_allocate_cow()
375 imap->br_blockcount, xfs_get_cowextsz_hint(ip)); in xfs_reflink_allocate_cow()
378 xfs_iunlock(ip, *lockmode); in xfs_reflink_allocate_cow()
379 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp); in xfs_reflink_allocate_cow()
381 xfs_ilock(ip, *lockmode); in xfs_reflink_allocate_cow()
386 error = xfs_qm_dqattach_locked(ip, false); in xfs_reflink_allocate_cow()
393 error = xfs_find_trim_cow_extent(ip, imap, cmap, shared, &found); in xfs_reflink_allocate_cow()
401 error = xfs_trans_reserve_quota_nblks(tp, ip, resblks, 0, in xfs_reflink_allocate_cow()
406 xfs_trans_ijoin(tp, ip, 0); in xfs_reflink_allocate_cow()
410 error = xfs_bmapi_write(tp, ip, imap->br_startoff, imap->br_blockcount, in xfs_reflink_allocate_cow()
416 xfs_inode_set_cowblocks_tag(ip); in xfs_reflink_allocate_cow()
426 return -ENOSPC; in xfs_reflink_allocate_cow()
434 if (!convert_now || cmap->br_state == XFS_EXT_NORM) in xfs_reflink_allocate_cow()
436 trace_xfs_reflink_convert_cow(ip, cmap); in xfs_reflink_allocate_cow()
437 return xfs_reflink_convert_cow_locked(ip, offset_fsb, count_fsb); in xfs_reflink_allocate_cow()
440 xfs_trans_unreserve_quota_nblks(tp, ip, (long)resblks, 0, in xfs_reflink_allocate_cow()
448 * Cancel CoW reservations for some block range of an inode.
458 struct xfs_inode *ip, in xfs_reflink_cancel_cow_blocks() argument
464 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); in xfs_reflink_cancel_cow_blocks()
469 if (!xfs_inode_has_cow_data(ip)) in xfs_reflink_cancel_cow_blocks()
471 if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got)) in xfs_reflink_cancel_cow_blocks()
477 xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb); in xfs_reflink_cancel_cow_blocks()
485 trace_xfs_reflink_cancel_cow(ip, &del); in xfs_reflink_cancel_cow_blocks()
488 error = xfs_bmap_del_extent_delay(ip, XFS_COW_FORK, in xfs_reflink_cancel_cow_blocks()
493 ASSERT((*tpp)->t_firstblock == NULLFSBLOCK); in xfs_reflink_cancel_cow_blocks()
508 xfs_bmap_del_extent_cow(ip, &icur, &got, &del); in xfs_reflink_cancel_cow_blocks()
511 error = xfs_trans_reserve_quota_nblks(NULL, ip, in xfs_reflink_cancel_cow_blocks()
512 -(long)del.br_blockcount, 0, in xfs_reflink_cancel_cow_blocks()
526 if (!ifp->if_bytes) in xfs_reflink_cancel_cow_blocks()
527 xfs_inode_clear_cowblocks_tag(ip); in xfs_reflink_cancel_cow_blocks()
539 struct xfs_inode *ip, in xfs_reflink_cancel_cow_range() argument
549 trace_xfs_reflink_cancel_cow_range(ip, offset, count); in xfs_reflink_cancel_cow_range()
550 ASSERT(ip->i_cowfp); in xfs_reflink_cancel_cow_range()
552 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset); in xfs_reflink_cancel_cow_range()
556 end_fsb = XFS_B_TO_FSB(ip->i_mount, offset + count); in xfs_reflink_cancel_cow_range()
559 error = xfs_trans_alloc(ip->i_mount, &M_RES(ip->i_mount)->tr_write, in xfs_reflink_cancel_cow_range()
564 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_reflink_cancel_cow_range()
565 xfs_trans_ijoin(tp, ip, 0); in xfs_reflink_cancel_cow_range()
568 error = xfs_reflink_cancel_cow_blocks(ip, &tp, offset_fsb, end_fsb, in xfs_reflink_cancel_cow_range()
575 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_cancel_cow_range()
580 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_cancel_cow_range()
582 trace_xfs_reflink_cancel_cow_range_error(ip, error, _RET_IP_); in xfs_reflink_cancel_cow_range()
593 * every remap operation and we'd like to keep the block reservation
598 struct xfs_inode *ip, in xfs_reflink_end_cow_extent() argument
604 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_end_cow_extent()
606 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK); in xfs_reflink_end_cow_extent()
612 if (ifp->if_bytes == 0) { in xfs_reflink_end_cow_extent()
618 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, in xfs_reflink_end_cow_extent()
628 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_reflink_end_cow_extent()
629 xfs_trans_ijoin(tp, ip, 0); in xfs_reflink_end_cow_extent()
636 if (!xfs_iext_lookup_extent_before(ip, ifp, end_fsb, &icur, &got) || in xfs_reflink_end_cow_extent()
649 xfs_trim_extent(&del, offset_fsb, *end_fsb - offset_fsb); in xfs_reflink_end_cow_extent()
665 error = __xfs_bunmapi(tp, ip, del.br_startoff, &rlen, 0, 1); in xfs_reflink_end_cow_extent()
670 xfs_trim_extent(&del, del.br_startoff + rlen, del.br_blockcount - rlen); in xfs_reflink_end_cow_extent()
671 trace_xfs_reflink_cow_remap(ip, &del); in xfs_reflink_end_cow_extent()
677 xfs_bmap_map_extent(tp, ip, &del); in xfs_reflink_end_cow_extent()
679 /* Charge this new data fork mapping to the on-disk quota. */ in xfs_reflink_end_cow_extent()
680 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_DELBCOUNT, in xfs_reflink_end_cow_extent()
684 xfs_bmap_del_extent_cow(ip, &icur, &got, &del); in xfs_reflink_end_cow_extent()
687 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_end_cow_extent()
697 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_end_cow_extent()
706 struct xfs_inode *ip, in xfs_reflink_end_cow() argument
714 trace_xfs_reflink_end_cow(ip, offset, count); in xfs_reflink_end_cow()
716 offset_fsb = XFS_B_TO_FSBT(ip->i_mount, offset); in xfs_reflink_end_cow()
717 end_fsb = XFS_B_TO_FSB(ip->i_mount, offset + count); in xfs_reflink_end_cow()
732 * region. There are also have post-eof checks in the writeback in xfs_reflink_end_cow()
752 error = xfs_reflink_end_cow_extent(ip, offset_fsb, &end_fsb); in xfs_reflink_end_cow()
755 trace_xfs_reflink_end_cow_error(ip, error, _RET_IP_); in xfs_reflink_end_cow()
769 if (!xfs_sb_version_hasreflink(&mp->m_sb)) in xfs_reflink_recover_cow()
772 for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) { in xfs_reflink_recover_cow()
782 * Reflinking (Block) Ranges of Two Files Together
792 * - Read src's bmbt at the start of srange ("imap")
793 * - If imap doesn't exist, make imap appear to start at the end of srange
795 * - If imap starts before srange, advance imap to start at srange.
796 * - If imap goes beyond srange, truncate imap to end at the end of srange.
797 * - Punch (imap start - srange start + imap len) blocks from dest at
799 * - If imap points to a real range of pblks,
802 * (drange start + imap start - srange start)
803 * - Advance drange and srange by (imap start - srange start + imap len)
805 * Finally, if the reflink made dest longer, update both the in-core and
806 * on-disk file sizes.
812 * ----SSSSSSS-SSSSS----SSSSSS (src file)
813 * <-------------------->
817 * --DDDDDDDDDDDDDDDDDDD--DDD (dest file)
818 * <-------------------->
819 * '-' means a hole, and 'S' and 'D' are written blocks in the src and dest.
826 * ----SSSSSSS-SSSSS----SSSSSS
827 * <------->
828 * --DDDDD---------DDDDD--DDD
829 * <------->
833 * ----SSSSSSS-SSSSS----SSSSSS
834 * <------->
835 * --DDDDD--SSSSSSSDDDDD--DDD
836 * <------->
841 * ----SSSSSSS-SSSSS----SSSSSS
842 * <---->
843 * --DDDDD--SSSSSSS-SSSSS-DDD
844 * <---->
849 * ----SSSSSSS-SSSSS----SSSSSS
850 * <----->
851 * --DDDDD--SSSSSSS-SSSSS----SSS
852 * <----->
865 struct xfs_mount *mp = src->i_mount; in xfs_reflink_set_inode_flag()
872 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_reflink_set_inode_flag()
877 if (src->i_ino == dest->i_ino) in xfs_reflink_set_inode_flag()
885 src->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK; in xfs_reflink_set_inode_flag()
891 if (src->i_ino == dest->i_ino) in xfs_reflink_set_inode_flag()
897 dest->i_d.di_flags2 |= XFS_DIFLAG2_REFLINK; in xfs_reflink_set_inode_flag()
924 struct xfs_mount *mp = dest->i_mount; in xfs_reflink_update_dest()
931 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); in xfs_reflink_update_dest()
941 dest->i_d.di_size = newlen; in xfs_reflink_update_dest()
945 dest->i_d.di_cowextsize = cowextsize; in xfs_reflink_update_dest()
946 dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; in xfs_reflink_update_dest()
975 if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) in xfs_reflink_ag_has_free_space()
981 error = -ENOSPC; in xfs_reflink_ag_has_free_space()
992 struct xfs_inode *ip, in xfs_reflink_remap_extent() argument
997 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_remap_extent()
1009 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, resblks, 0, 0, &tp); in xfs_reflink_remap_extent()
1013 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_reflink_remap_extent()
1014 xfs_trans_ijoin(tp, ip, 0); in xfs_reflink_remap_extent()
1022 error = xfs_bmapi_read(ip, dmap->br_startoff, dmap->br_blockcount, in xfs_reflink_remap_extent()
1026 ASSERT(nimaps == 1 && smap.br_startoff == dmap->br_startoff); in xfs_reflink_remap_extent()
1033 dmap->br_blockcount = min(dmap->br_blockcount, smap.br_blockcount); in xfs_reflink_remap_extent()
1034 ASSERT(dmap->br_blockcount == smap.br_blockcount); in xfs_reflink_remap_extent()
1036 trace_xfs_reflink_remap_extent_dest(ip, &smap); in xfs_reflink_remap_extent()
1039 * Two extents mapped to the same physical block must not have in xfs_reflink_remap_extent()
1043 if (dmap->br_startblock == smap.br_startblock) { in xfs_reflink_remap_extent()
1044 if (dmap->br_state != smap.br_state) in xfs_reflink_remap_extent()
1045 error = -EFSCORRUPTED; in xfs_reflink_remap_extent()
1050 if (dmap->br_state == XFS_EXT_UNWRITTEN && in xfs_reflink_remap_extent()
1057 XFS_FSB_TO_AGNO(mp, dmap->br_startblock)); in xfs_reflink_remap_extent()
1063 * Compute quota reservation if we think the quota block counter for in xfs_reflink_remap_extent()
1073 * enough quota block count reservation to handle the blocks in that in xfs_reflink_remap_extent()
1074 * extent. We log only the delta to the quota block counts, so if the in xfs_reflink_remap_extent()
1080 * the delalloc reservation gives the block count back to the quota in xfs_reflink_remap_extent()
1089 qres += dmap->br_blockcount; in xfs_reflink_remap_extent()
1091 error = xfs_trans_reserve_quota_nblks(tp, ip, qres, 0, in xfs_reflink_remap_extent()
1102 xfs_bmap_unmap_extent(tp, ip, &smap); in xfs_reflink_remap_extent()
1104 qdelta -= smap.br_blockcount; in xfs_reflink_remap_extent()
1114 error = __xfs_bunmapi(NULL, ip, smap.br_startoff, &len, 0, 1); in xfs_reflink_remap_extent()
1126 xfs_bmap_map_extent(tp, ip, dmap); in xfs_reflink_remap_extent()
1127 qdelta += dmap->br_blockcount; in xfs_reflink_remap_extent()
1130 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_BCOUNT, qdelta); in xfs_reflink_remap_extent()
1133 newlen = XFS_FSB_TO_B(mp, dmap->br_startoff + dmap->br_blockcount); in xfs_reflink_remap_extent()
1135 if (newlen > i_size_read(VFS_I(ip))) { in xfs_reflink_remap_extent()
1136 trace_xfs_reflink_update_inode_size(ip, newlen); in xfs_reflink_remap_extent()
1137 i_size_write(VFS_I(ip), newlen); in xfs_reflink_remap_extent()
1138 ip->i_d.di_size = newlen; in xfs_reflink_remap_extent()
1139 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_reflink_remap_extent()
1149 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_remap_extent()
1152 trace_xfs_reflink_remap_extent_error(ip, error, _RET_IP_); in xfs_reflink_remap_extent()
1167 struct xfs_mount *mp = src->i_mount; in xfs_reflink_remap_blocks()
1201 error = -EFSCORRUPTED; in xfs_reflink_remap_blocks()
1214 error = -EINTR; in xfs_reflink_remap_blocks()
1221 len -= imap.br_blockcount; in xfs_reflink_remap_blocks()
1228 XFS_FSB_TO_B(src->i_mount, remapped_len)); in xfs_reflink_remap_blocks()
1234 * zero any speculative post-EOF preallocations that sit between the old EOF
1239 struct xfs_inode *ip, in xfs_reflink_zero_posteof() argument
1242 loff_t isize = i_size_read(VFS_I(ip)); in xfs_reflink_zero_posteof()
1247 trace_xfs_zero_eof(ip, isize, pos - isize); in xfs_reflink_zero_posteof()
1248 return iomap_zero_range(VFS_I(ip), isize, pos - isize, NULL, in xfs_reflink_zero_posteof()
1260 * EOF block in the source dedupe range because it's not a complete block match,
1261 * hence can introduce a corruption into the file that has it's block replaced.
1264 * "block aligned" for the purposes of cloning entire files. However, if the
1265 * source file range includes the EOF block and it lands within the existing EOF
1269 * XFS doesn't support partial block sharing, so in both cases we have check
1271 * down to the previous whole block and ignore the partial EOF block. While this
1272 * means we can't dedupe the last block of a file, this is an acceptible
1275 * For cloning, we want to share the partial EOF block if it is also the new EOF
1276 * block of the destination file. If the partial EOF block lies inside the
1279 * -EINVAL in this case.
1301 /* Check file eligibility and prepare for block sharing. */ in xfs_reflink_remap_prep()
1302 ret = -EINVAL; in xfs_reflink_remap_prep()
1316 /* Attach dquots to dest inode before changing block map */ in xfs_reflink_remap_prep()
1322 * Zero existing post-eof speculative preallocations in the destination in xfs_reflink_remap_prep()
1340 loff_t flen = *len + (pos_out - XFS_ISIZE(dest)); in xfs_reflink_remap_prep()
1358 struct xfs_inode *ip, in xfs_reflink_inode_has_shared_extents() argument
1362 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_inode_has_shared_extents()
1373 ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK); in xfs_reflink_inode_has_shared_extents()
1374 if (!(ifp->if_flags & XFS_IFEXTENTS)) { in xfs_reflink_inode_has_shared_extents()
1375 error = xfs_iread_extents(tp, ip, XFS_DATA_FORK); in xfs_reflink_inode_has_shared_extents()
1381 found = xfs_iext_lookup_extent(ip, ifp, 0, &icur, &got); in xfs_reflink_inode_has_shared_extents()
1394 /* Is there still a shared block here? */ in xfs_reflink_inode_has_shared_extents()
1414 struct xfs_inode *ip, in xfs_reflink_clear_inode_flag() argument
1420 ASSERT(xfs_is_reflink_inode(ip)); in xfs_reflink_clear_inode_flag()
1422 error = xfs_reflink_inode_has_shared_extents(*tpp, ip, &needs_flag); in xfs_reflink_clear_inode_flag()
1430 error = xfs_reflink_cancel_cow_blocks(ip, tpp, 0, XFS_MAX_FILEOFF, in xfs_reflink_clear_inode_flag()
1436 trace_xfs_reflink_unset_inode_flag(ip); in xfs_reflink_clear_inode_flag()
1437 ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_reflink_clear_inode_flag()
1438 xfs_inode_clear_cowblocks_tag(ip); in xfs_reflink_clear_inode_flag()
1439 xfs_trans_log_inode(*tpp, ip, XFS_ILOG_CORE); in xfs_reflink_clear_inode_flag()
1450 struct xfs_inode *ip) in xfs_reflink_try_clear_inode_flag() argument
1452 struct xfs_mount *mp = ip->i_mount; in xfs_reflink_try_clear_inode_flag()
1457 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_write, 0, 0, 0, &tp); in xfs_reflink_try_clear_inode_flag()
1461 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_reflink_try_clear_inode_flag()
1462 xfs_trans_ijoin(tp, ip, 0); in xfs_reflink_try_clear_inode_flag()
1464 error = xfs_reflink_clear_inode_flag(ip, &tp); in xfs_reflink_try_clear_inode_flag()
1472 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_try_clear_inode_flag()
1477 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_reflink_try_clear_inode_flag()
1482 * Pre-COW all shared blocks within a given byte range of a file and turn off
1487 struct xfs_inode *ip, in xfs_reflink_unshare() argument
1491 struct inode *inode = VFS_I(ip); in xfs_reflink_unshare()
1494 if (!xfs_is_reflink_inode(ip)) in xfs_reflink_unshare()
1497 trace_xfs_reflink_unshare(ip, offset, len); in xfs_reflink_unshare()
1506 error = filemap_write_and_wait_range(inode->i_mapping, offset, len); in xfs_reflink_unshare()
1511 error = xfs_reflink_try_clear_inode_flag(ip); in xfs_reflink_unshare()
1517 trace_xfs_reflink_unshare_error(ip, error, _RET_IP_); in xfs_reflink_unshare()