Lines Matching refs:ip
41 xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb) in xfs_fsb_to_db() argument
43 if (XFS_IS_REALTIME_INODE(ip)) in xfs_fsb_to_db()
44 return XFS_FSB_TO_BB(ip->i_mount, fsb); in xfs_fsb_to_db()
45 return XFS_FSB_TO_DADDR(ip->i_mount, fsb); in xfs_fsb_to_db()
57 struct xfs_inode *ip, in xfs_zero_extent() argument
61 struct xfs_mount *mp = ip->i_mount; in xfs_zero_extent()
62 struct xfs_buftarg *target = xfs_inode_buftarg(ip); in xfs_zero_extent()
63 xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb); in xfs_zero_extent()
106 struct xfs_inode *ip, in xfs_bmap_count_blocks() argument
111 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_count_blocks()
112 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_count_blocks()
125 error = xfs_iread_extents(tp, ip, whichfork); in xfs_bmap_count_blocks()
129 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork); in xfs_bmap_count_blocks()
153 struct xfs_inode *ip, in xfs_getbmap_report_one() argument
163 error = xfs_reflink_trim_around_shared(ip, got, &shared); in xfs_getbmap_report_one()
181 p->bmv_block = xfs_fsb_to_db(ip, got->br_startblock); in xfs_getbmap_report_one()
191 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, got->br_startoff); in xfs_getbmap_report_one()
192 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, got->br_blockcount); in xfs_getbmap_report_one()
202 struct xfs_inode *ip, in xfs_getbmap_report_hole() argument
215 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, bno); in xfs_getbmap_report_hole()
216 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, end - bno); in xfs_getbmap_report_hole()
257 struct xfs_inode *ip, in xfs_getbmap() argument
261 struct xfs_mount *mp = ip->i_mount; in xfs_getbmap()
294 xfs_ilock(ip, XFS_IOLOCK_SHARED); in xfs_getbmap()
297 lock = xfs_ilock_attr_map_shared(ip); in xfs_getbmap()
298 if (!xfs_inode_has_attr_fork(ip)) in xfs_getbmap()
305 xfs_ilock(ip, lock); in xfs_getbmap()
308 if (!xfs_ifork_ptr(ip, whichfork)) in xfs_getbmap()
311 if (xfs_get_cowextsz_hint(ip)) in xfs_getbmap()
314 max_len = XFS_ISIZE(ip); in xfs_getbmap()
318 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) { in xfs_getbmap()
319 error = filemap_write_and_wait(VFS_I(ip)->i_mapping); in xfs_getbmap()
333 if (xfs_get_extsz_hint(ip) || in xfs_getbmap()
334 (ip->i_diflags & XFS_DIFLAG_PREALLOC)) in xfs_getbmap()
337 max_len = XFS_ISIZE(ip); in xfs_getbmap()
339 lock = xfs_ilock_data_map_shared(ip); in xfs_getbmap()
343 ifp = xfs_ifork_ptr(ip, whichfork); in xfs_getbmap()
367 error = xfs_iread_extents(NULL, ip, whichfork); in xfs_getbmap()
371 if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) { in xfs_getbmap()
377 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno, in xfs_getbmap()
378 XFS_B_TO_FSB(mp, XFS_ISIZE(ip))); in xfs_getbmap()
390 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno, in xfs_getbmap()
404 error = xfs_getbmap_report_one(ip, bmv, out, bmv_end, in xfs_getbmap()
411 xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); in xfs_getbmap()
419 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, in xfs_getbmap()
430 xfs_iunlock(ip, lock); in xfs_getbmap()
432 xfs_iunlock(ip, XFS_IOLOCK_SHARED); in xfs_getbmap()
444 struct xfs_inode *ip, in xfs_bmap_punch_delalloc_range() argument
449 struct xfs_mount *mp = ip->i_mount; in xfs_bmap_punch_delalloc_range()
450 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork); in xfs_bmap_punch_delalloc_range()
458 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_bmap_punch_delalloc_range()
459 if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got)) in xfs_bmap_punch_delalloc_range()
478 xfs_bmap_del_extent_delay(ip, whichfork, &icur, &got, &del); in xfs_bmap_punch_delalloc_range()
484 xfs_inode_clear_cowblocks_tag(ip); in xfs_bmap_punch_delalloc_range()
487 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_bmap_punch_delalloc_range()
496 struct xfs_inode *ip) in xfs_can_free_eofblocks() argument
498 struct xfs_mount *mp = ip->i_mount; in xfs_can_free_eofblocks()
509 if (!(VFS_I(ip)->i_state & I_FREEING)) in xfs_can_free_eofblocks()
510 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL); in xfs_can_free_eofblocks()
513 if (!S_ISREG(VFS_I(ip)->i_mode)) in xfs_can_free_eofblocks()
520 if (VFS_I(ip)->i_size == 0 && in xfs_can_free_eofblocks()
521 VFS_I(ip)->i_mapping->nrpages == 0 && in xfs_can_free_eofblocks()
522 ip->i_delayed_blks == 0) in xfs_can_free_eofblocks()
526 if (xfs_need_iread_extents(&ip->i_df)) in xfs_can_free_eofblocks()
533 if ((ip->i_diflags & XFS_DIFLAG_PREALLOC) && !ip->i_delayed_blks) in xfs_can_free_eofblocks()
541 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip)); in xfs_can_free_eofblocks()
542 if (xfs_inode_has_bigrtalloc(ip)) in xfs_can_free_eofblocks()
551 xfs_ilock(ip, XFS_ILOCK_SHARED); in xfs_can_free_eofblocks()
552 if (xfs_iext_lookup_extent(ip, &ip->i_df, end_fsb, &icur, &imap)) in xfs_can_free_eofblocks()
554 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_can_free_eofblocks()
565 struct xfs_inode *ip) in xfs_free_eofblocks() argument
568 struct xfs_mount *mp = ip->i_mount; in xfs_free_eofblocks()
572 error = xfs_qm_dqattach(ip); in xfs_free_eofblocks()
577 inode_dio_wait(VFS_I(ip)); in xfs_free_eofblocks()
585 if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND)) { in xfs_free_eofblocks()
586 if (ip->i_delayed_blks) { in xfs_free_eofblocks()
587 xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, in xfs_free_eofblocks()
588 round_up(XFS_ISIZE(ip), mp->m_sb.sb_blocksize), in xfs_free_eofblocks()
591 xfs_inode_clear_eofblocks_tag(ip); in xfs_free_eofblocks()
601 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_free_eofblocks()
602 xfs_trans_ijoin(tp, ip, 0); in xfs_free_eofblocks()
610 error = xfs_itruncate_extents_flags(&tp, ip, XFS_DATA_FORK, in xfs_free_eofblocks()
611 XFS_ISIZE(ip), XFS_BMAPI_NODISCARD); in xfs_free_eofblocks()
619 xfs_inode_clear_eofblocks_tag(ip); in xfs_free_eofblocks()
629 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_free_eofblocks()
635 struct xfs_inode *ip, in xfs_alloc_file_space() argument
639 xfs_mount_t *mp = ip->i_mount; in xfs_alloc_file_space()
650 if (xfs_is_always_cow_inode(ip)) in xfs_alloc_file_space()
653 trace_xfs_alloc_file_space(ip); in xfs_alloc_file_space()
658 error = xfs_qm_dqattach(ip); in xfs_alloc_file_space()
665 rt = XFS_IS_REALTIME_INODE(ip); in xfs_alloc_file_space()
666 extsz = xfs_get_extsz_hint(ip); in xfs_alloc_file_space()
719 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, in xfs_alloc_file_space()
724 error = xfs_iext_count_extend(tp, ip, XFS_DATA_FORK, in xfs_alloc_file_space()
738 error = xfs_bmapi_write(tp, ip, startoffset_fsb, in xfs_alloc_file_space()
750 ip->i_diflags |= XFS_DIFLAG_PREALLOC; in xfs_alloc_file_space()
751 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_alloc_file_space()
754 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_alloc_file_space()
761 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_alloc_file_space()
767 struct xfs_inode *ip, in xfs_unmap_extent() argument
772 struct xfs_mount *mp = ip->i_mount; in xfs_unmap_extent()
777 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks, 0, in xfs_unmap_extent()
782 error = xfs_iext_count_extend(tp, ip, XFS_DATA_FORK, in xfs_unmap_extent()
787 error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done); in xfs_unmap_extent()
793 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_unmap_extent()
804 struct xfs_inode *ip, in xfs_flush_unmap_range() argument
808 struct inode *inode = VFS_I(ip); in xfs_flush_unmap_range()
817 rounding = max_t(xfs_off_t, xfs_inode_alloc_unitsize(ip), PAGE_SIZE); in xfs_flush_unmap_range()
830 struct xfs_inode *ip, in xfs_free_file_space() argument
834 struct xfs_mount *mp = ip->i_mount; in xfs_free_file_space()
839 trace_xfs_free_file_space(ip); in xfs_free_file_space()
841 error = xfs_qm_dqattach(ip); in xfs_free_file_space()
852 error = xfs_flush_unmap_range(ip, offset, len); in xfs_free_file_space()
860 if (xfs_inode_has_bigrtalloc(ip)) { in xfs_free_file_space()
870 error = xfs_unmap_extent(ip, startoffset_fsb, in xfs_free_file_space()
883 if (offset >= XFS_ISIZE(ip)) in xfs_free_file_space()
885 if (offset + len > XFS_ISIZE(ip)) in xfs_free_file_space()
886 len = XFS_ISIZE(ip) - offset; in xfs_free_file_space()
887 error = xfs_zero_range(ip, offset, len, NULL); in xfs_free_file_space()
897 if (offset + len >= XFS_ISIZE(ip) && offset_in_page(offset + len) > 0) { in xfs_free_file_space()
898 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping, in xfs_free_file_space()
907 struct xfs_inode *ip, in xfs_prepare_shift() argument
917 if (xfs_can_free_eofblocks(ip)) { in xfs_prepare_shift()
918 error = xfs_free_eofblocks(ip); in xfs_prepare_shift()
931 rounding = xfs_inode_alloc_unitsize(ip); in xfs_prepare_shift()
940 error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip)); in xfs_prepare_shift()
949 if (xfs_inode_has_cow_data(ip)) { in xfs_prepare_shift()
950 error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF, in xfs_prepare_shift()
973 struct xfs_inode *ip, in xfs_collapse_file_space() argument
977 struct xfs_mount *mp = ip->i_mount; in xfs_collapse_file_space()
984 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL); in xfs_collapse_file_space()
986 trace_xfs_collapse_file_space(ip); in xfs_collapse_file_space()
988 error = xfs_free_file_space(ip, offset, len); in xfs_collapse_file_space()
992 error = xfs_prepare_shift(ip, offset); in xfs_collapse_file_space()
1000 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_collapse_file_space()
1001 xfs_trans_ijoin(tp, ip, 0); in xfs_collapse_file_space()
1004 error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb, in xfs_collapse_file_space()
1018 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_collapse_file_space()
1023 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_collapse_file_space()
1041 struct xfs_inode *ip, in xfs_insert_file_space() argument
1045 struct xfs_mount *mp = ip->i_mount; in xfs_insert_file_space()
1053 xfs_assert_ilocked(ip, XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL); in xfs_insert_file_space()
1055 trace_xfs_insert_file_space(ip); in xfs_insert_file_space()
1057 error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb); in xfs_insert_file_space()
1061 error = xfs_prepare_shift(ip, offset); in xfs_insert_file_space()
1070 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_insert_file_space()
1071 xfs_trans_ijoin(tp, ip, 0); in xfs_insert_file_space()
1073 error = xfs_iext_count_extend(tp, ip, XFS_DATA_FORK, in xfs_insert_file_space()
1083 error = xfs_bmap_split_extent(tp, ip, stop_fsb); in xfs_insert_file_space()
1092 error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb, in xfs_insert_file_space()
1099 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_insert_file_space()
1104 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_insert_file_space()
1130 struct xfs_inode *ip, /* target inode */ in xfs_swap_extents_check_format() argument
1133 struct xfs_ifork *ifp = &ip->i_df; in xfs_swap_extents_check_format()
1137 if (XFS_IS_QUOTA_ON(ip->i_mount) && in xfs_swap_extents_check_format()
1138 (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) || in xfs_swap_extents_check_format()
1139 !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) || in xfs_swap_extents_check_format()
1140 ip->i_projid != tip->i_projid)) in xfs_swap_extents_check_format()
1159 if (xfs_has_rmapbt(ip->i_mount)) in xfs_swap_extents_check_format()
1173 tifp->if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1191 if (xfs_inode_has_attr_fork(ip) && in xfs_swap_extents_check_format()
1192 xfs_bmap_bmdr_space(tifp->if_broot) > xfs_inode_fork_boff(ip)) in xfs_swap_extents_check_format()
1194 if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)) in xfs_swap_extents_check_format()
1201 xfs_bmap_bmdr_space(ip->i_df.if_broot) > xfs_inode_fork_boff(tip)) in xfs_swap_extents_check_format()
1212 struct xfs_inode *ip) in xfs_swap_extent_flush() argument
1216 error = filemap_write_and_wait(VFS_I(ip)->i_mapping); in xfs_swap_extent_flush()
1219 truncate_pagecache_range(VFS_I(ip), 0, -1); in xfs_swap_extent_flush()
1222 if (VFS_I(ip)->i_mapping->nrpages) in xfs_swap_extent_flush()
1233 struct xfs_inode *ip, in xfs_swap_extent_rmap() argument
1256 if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK) in xfs_swap_extent_rmap()
1260 end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip))); in xfs_swap_extent_rmap()
1283 error = xfs_bmapi_read(ip, tirec.br_startoff, in xfs_swap_extent_rmap()
1290 trace_xfs_swap_extent_rmap_remap_piece(ip, &irec); in xfs_swap_extent_rmap()
1300 error = xfs_iext_count_extend(tp, ip, in xfs_swap_extent_rmap()
1319 xfs_bmap_unmap_extent(tp, ip, XFS_DATA_FORK, &irec); in xfs_swap_extent_rmap()
1322 xfs_bmap_map_extent(tp, ip, XFS_DATA_FORK, &uirec); in xfs_swap_extent_rmap()
1348 trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_); in xfs_swap_extent_rmap()
1357 struct xfs_inode *ip, in xfs_swap_extent_forks() argument
1371 if (xfs_inode_has_attr_fork(ip) && ip->i_af.if_nextents > 0 && in xfs_swap_extent_forks()
1372 ip->i_af.if_format != XFS_DINODE_FMT_LOCAL) { in xfs_swap_extent_forks()
1373 error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &junk, in xfs_swap_extent_forks()
1393 if (xfs_has_v3inodes(ip->i_mount)) { in xfs_swap_extent_forks()
1394 if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE) in xfs_swap_extent_forks()
1403 swap(ip->i_df, tip->i_df); in xfs_swap_extent_forks()
1408 tmp = (uint64_t)ip->i_nblocks; in xfs_swap_extent_forks()
1409 ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks; in xfs_swap_extent_forks()
1422 tip->i_delayed_blks = ip->i_delayed_blks; in xfs_swap_extent_forks()
1423 ip->i_delayed_blks = 0; in xfs_swap_extent_forks()
1425 switch (ip->i_df.if_format) { in xfs_swap_extent_forks()
1430 ASSERT(!xfs_has_v3inodes(ip->i_mount) || in xfs_swap_extent_forks()
1442 ASSERT(!xfs_has_v3inodes(ip->i_mount) || in xfs_swap_extent_forks()
1461 struct xfs_inode *ip, in xfs_swap_change_owner() argument
1468 error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino, in xfs_swap_change_owner()
1483 xfs_trans_ijoin(tp, ip, 0); in xfs_swap_change_owner()
1485 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_swap_change_owner()
1494 struct xfs_inode *ip, /* target inode */ in xfs_swap_extents() argument
1498 struct xfs_mount *mp = ip->i_mount; in xfs_swap_extents()
1514 lock_two_nondirectories(VFS_I(ip), VFS_I(tip)); in xfs_swap_extents()
1515 filemap_invalidate_lock_two(VFS_I(ip)->i_mapping, in xfs_swap_extents()
1519 if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) { in xfs_swap_extents()
1525 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) { in xfs_swap_extents()
1530 error = xfs_qm_dqattach(ip); in xfs_swap_extents()
1538 error = xfs_swap_extent_flush(ip); in xfs_swap_extents()
1558 uint32_t ipnext = ip->i_df.if_nextents; in xfs_swap_extents()
1587 xfs_lock_two_inodes(ip, XFS_ILOCK_EXCL, tip, XFS_ILOCK_EXCL); in xfs_swap_extents()
1588 xfs_trans_ijoin(tp, ip, 0); in xfs_swap_extents()
1594 sxp->sx_length != ip->i_disk_size || in xfs_swap_extents()
1600 trace_xfs_swap_extent_before(ip, 0); in xfs_swap_extents()
1604 error = xfs_swap_extents_check_format(ip, tip); in xfs_swap_extents()
1608 __func__, ip->i_ino); in xfs_swap_extents()
1619 ctime = inode_get_ctime(VFS_I(ip)); in xfs_swap_extents()
1620 mtime = inode_get_mtime(VFS_I(ip)); in xfs_swap_extents()
1640 error = xfs_swap_extent_rmap(&tp, ip, tip); in xfs_swap_extents()
1642 error = xfs_swap_extent_forks(tp, ip, tip, &src_log_flags, in xfs_swap_extents()
1648 if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^ in xfs_swap_extents()
1650 f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1651 ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1652 ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK; in xfs_swap_extents()
1659 ASSERT(!ip->i_cowfp || in xfs_swap_extents()
1660 ip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS); in xfs_swap_extents()
1664 swap(ip->i_cowfp, tip->i_cowfp); in xfs_swap_extents()
1666 if (ip->i_cowfp && ip->i_cowfp->if_bytes) in xfs_swap_extents()
1667 xfs_inode_set_cowblocks_tag(ip); in xfs_swap_extents()
1669 xfs_inode_clear_cowblocks_tag(ip); in xfs_swap_extents()
1676 xfs_trans_log_inode(tp, ip, src_log_flags); in xfs_swap_extents()
1686 error = xfs_swap_change_owner(&tp, ip, tip); in xfs_swap_extents()
1691 error = xfs_swap_change_owner(&tp, tip, ip); in xfs_swap_extents()
1705 trace_xfs_swap_extent_after(ip, 0); in xfs_swap_extents()
1709 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_swap_extents()
1712 filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping, in xfs_swap_extents()
1714 unlock_two_nondirectories(VFS_I(ip), VFS_I(tip)); in xfs_swap_extents()