Lines Matching refs:ip
40 xfs_fsb_to_db(struct xfs_inode *ip, xfs_fsblock_t fsb)
42 if (XFS_IS_REALTIME_INODE(ip))
43 return XFS_FSB_TO_BB(ip->i_mount, fsb);
44 return XFS_FSB_TO_DADDR(ip->i_mount, fsb);
56 struct xfs_inode *ip,
60 struct xfs_mount *mp = ip->i_mount;
61 struct xfs_buftarg *target = xfs_inode_buftarg(ip);
62 xfs_daddr_t sector = xfs_fsb_to_db(ip, start_fsb);
84 mp = ap->ip->i_mount;
85 align = xfs_get_extsz_hint(ap->ip);
157 ap->ip->i_d.di_nblocks += ralen;
158 xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
160 ap->ip->i_delayed_blks -= ralen;
165 xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
209 struct xfs_inode *ip,
214 struct xfs_mount *mp = ip->i_mount;
215 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
229 error = xfs_iread_extents(tp, ip, whichfork);
234 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
258 struct xfs_inode *ip,
268 error = xfs_reflink_trim_around_shared(ip, got, &shared);
282 if (got->br_startoff < XFS_B_TO_FSB(ip->i_mount, XFS_ISIZE(ip)))
288 p->bmv_block = xfs_fsb_to_db(ip, got->br_startblock);
298 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, got->br_startoff);
299 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, got->br_blockcount);
309 struct xfs_inode *ip,
322 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, bno);
323 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, end - bno);
364 struct xfs_inode *ip,
368 struct xfs_mount *mp = ip->i_mount;
400 ifp = XFS_IFORK_PTR(ip, whichfork);
402 xfs_ilock(ip, XFS_IOLOCK_SHARED);
405 if (!XFS_IFORK_Q(ip))
409 lock = xfs_ilock_attr_map_shared(ip);
416 if (xfs_get_cowextsz_hint(ip))
419 max_len = XFS_ISIZE(ip);
422 xfs_ilock(ip, lock);
426 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_d.di_size)) {
427 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
437 * ip->i_delayed_blks == 0.
441 if (xfs_get_extsz_hint(ip) ||
442 (ip->i_d.di_flags &
446 max_len = XFS_ISIZE(ip);
448 lock = xfs_ilock_data_map_shared(ip);
475 error = xfs_iread_extents(NULL, ip, whichfork);
480 if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
486 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno,
487 XFS_B_TO_FSB(mp, XFS_ISIZE(ip)));
499 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno,
513 error = xfs_getbmap_report_one(ip, bmv, out, bmv_end,
520 xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
526 xfs_getbmap_report_hole(ip, bmv, out, bmv_end,
537 xfs_iunlock(ip, lock);
539 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
551 struct xfs_inode *ip,
555 struct xfs_ifork *ifp = &ip->i_df;
563 xfs_ilock(ip, XFS_ILOCK_EXCL);
564 if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got))
583 error = xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur,
590 xfs_iunlock(ip, XFS_ILOCK_EXCL);
600 xfs_can_free_eofblocks(struct xfs_inode *ip, bool force)
603 if (!S_ISREG(VFS_I(ip)->i_mode))
610 if (VFS_I(ip)->i_size == 0 &&
611 VFS_I(ip)->i_mapping->nrpages == 0 &&
612 ip->i_delayed_blks == 0)
616 if (!(ip->i_df.if_flags & XFS_IFEXTENTS))
623 if (ip->i_d.di_flags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
624 if (!force || ip->i_delayed_blks == 0)
637 struct xfs_inode *ip)
646 struct xfs_mount *mp = ip->i_mount;
652 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
659 xfs_ilock(ip, XFS_ILOCK_SHARED);
660 error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
661 xfs_iunlock(ip, XFS_ILOCK_SHARED);
669 ip->i_delayed_blks)) {
673 error = xfs_qm_dqattach(ip);
678 inode_dio_wait(VFS_I(ip));
687 xfs_ilock(ip, XFS_ILOCK_EXCL);
688 xfs_trans_ijoin(tp, ip, 0);
696 error = xfs_itruncate_extents_flags(&tp, ip, XFS_DATA_FORK,
697 XFS_ISIZE(ip), XFS_BMAPI_NODISCARD);
707 xfs_inode_clear_eofblocks_tag(ip);
710 xfs_iunlock(ip, XFS_ILOCK_EXCL);
717 struct xfs_inode *ip,
722 xfs_mount_t *mp = ip->i_mount;
737 trace_xfs_alloc_file_space(ip);
742 error = xfs_qm_dqattach(ip);
749 rt = XFS_IS_REALTIME_INODE(ip);
750 extsz = xfs_get_extsz_hint(ip);
816 xfs_ilock(ip, XFS_ILOCK_EXCL);
817 error = xfs_trans_reserve_quota_nblks(tp, ip, qblocks,
822 xfs_trans_ijoin(tp, ip, 0);
824 error = xfs_bmapi_write(tp, ip, startoffset_fsb,
830 ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
831 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
834 xfs_iunlock(ip, XFS_ILOCK_EXCL);
852 xfs_trans_unreserve_quota_nblks(tp, ip, (long)qblocks, 0, quota_flag);
856 xfs_iunlock(ip, XFS_ILOCK_EXCL);
862 struct xfs_inode *ip,
867 struct xfs_mount *mp = ip->i_mount;
878 xfs_ilock(ip, XFS_ILOCK_EXCL);
879 error = xfs_trans_reserve_quota(tp, mp, ip->i_udquot, ip->i_gdquot,
880 ip->i_pdquot, resblks, 0, XFS_QMOPT_RES_REGBLKS);
884 xfs_trans_ijoin(tp, ip, 0);
886 error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
892 xfs_iunlock(ip, XFS_ILOCK_EXCL);
903 struct xfs_inode *ip,
907 struct xfs_mount *mp = ip->i_mount;
908 struct inode *inode = VFS_I(ip);
925 struct xfs_inode *ip,
929 struct xfs_mount *mp = ip->i_mount;
934 trace_xfs_free_file_space(ip);
936 error = xfs_qm_dqattach(ip);
947 if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) {
959 error = xfs_unmap_extent(ip, startoffset_fsb,
972 if (offset >= XFS_ISIZE(ip))
974 if (offset + len > XFS_ISIZE(ip))
975 len = XFS_ISIZE(ip) - offset;
976 error = iomap_zero_range(VFS_I(ip), offset, len, NULL,
987 if (offset + len >= XFS_ISIZE(ip) && offset_in_page(offset + len) > 0) {
988 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
997 struct xfs_inode *ip,
1000 struct xfs_mount *mp = ip->i_mount;
1007 if (xfs_can_free_eofblocks(ip, true)) {
1008 error = xfs_free_eofblocks(ip);
1028 error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
1037 if (xfs_inode_has_cow_data(ip)) {
1038 error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF,
1061 struct xfs_inode *ip,
1065 struct xfs_mount *mp = ip->i_mount;
1072 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
1073 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
1075 trace_xfs_collapse_file_space(ip);
1077 error = xfs_free_file_space(ip, offset, len);
1081 error = xfs_prepare_shift(ip, offset);
1089 xfs_ilock(ip, XFS_ILOCK_EXCL);
1090 xfs_trans_ijoin(tp, ip, 0);
1093 error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
1107 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1112 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1130 struct xfs_inode *ip,
1134 struct xfs_mount *mp = ip->i_mount;
1142 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
1143 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
1145 trace_xfs_insert_file_space(ip);
1147 error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
1151 error = xfs_prepare_shift(ip, offset);
1160 xfs_ilock(ip, XFS_ILOCK_EXCL);
1161 xfs_trans_ijoin(tp, ip, 0);
1168 error = xfs_bmap_split_extent(tp, ip, stop_fsb);
1177 error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
1184 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1189 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1215 struct xfs_inode *ip, /* target inode */
1218 struct xfs_ifork *ifp = &ip->i_df;
1222 if (XFS_IS_QUOTA_ON(ip->i_mount) &&
1223 (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) ||
1224 !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) ||
1225 ip->i_d.di_projid != tip->i_d.di_projid))
1244 if (xfs_sb_version_hasrmapbt(&ip->i_mount->m_sb))
1258 tifp->if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1276 if (XFS_IFORK_Q(ip) &&
1277 XFS_BMAP_BMDR_SPACE(tifp->if_broot) > XFS_IFORK_BOFF(ip))
1279 if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1286 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > XFS_IFORK_BOFF(tip))
1297 struct xfs_inode *ip)
1301 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
1304 truncate_pagecache_range(VFS_I(ip), 0, -1);
1307 if (VFS_I(ip)->i_mapping->nrpages)
1318 struct xfs_inode *ip,
1341 if (ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK)
1345 end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
1368 error = xfs_bmapi_read(ip, tirec.br_startoff,
1375 trace_xfs_swap_extent_rmap_remap_piece(ip, &irec);
1388 xfs_bmap_unmap_extent(tp, ip, &irec);
1391 xfs_bmap_map_extent(tp, ip, &uirec);
1417 trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
1426 struct xfs_inode *ip,
1440 if (XFS_IFORK_Q(ip) && ip->i_afp->if_nextents > 0 &&
1441 ip->i_afp->if_format != XFS_DINODE_FMT_LOCAL) {
1442 error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &junk,
1462 if (xfs_sb_version_has_v3inode(&ip->i_mount->m_sb)) {
1463 if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE)
1472 swap(ip->i_df, tip->i_df);
1477 tmp = (uint64_t)ip->i_d.di_nblocks;
1478 ip->i_d.di_nblocks = tip->i_d.di_nblocks - taforkblks + aforkblks;
1491 tip->i_delayed_blks = ip->i_delayed_blks;
1492 ip->i_delayed_blks = 0;
1494 switch (ip->i_df.if_format) {
1499 ASSERT(!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) ||
1511 ASSERT(!xfs_sb_version_has_v3inode(&ip->i_mount->m_sb) ||
1530 struct xfs_inode *ip,
1537 error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino,
1552 xfs_trans_ijoin(tp, ip, 0);
1554 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1563 struct xfs_inode *ip, /* target inode */
1567 struct xfs_mount *mp = ip->i_mount;
1583 lock_two_nondirectories(VFS_I(ip), VFS_I(tip));
1585 xfs_lock_two_inodes(ip, XFS_MMAPLOCK_EXCL, tip, XFS_MMAPLOCK_EXCL);
1588 if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) {
1594 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
1599 error = xfs_qm_dqattach(ip);
1607 error = xfs_swap_extent_flush(ip);
1627 uint32_t ipnext = ip->i_df.if_nextents;
1656 xfs_lock_two_inodes(ip, XFS_ILOCK_EXCL, tip, XFS_ILOCK_EXCL);
1658 xfs_trans_ijoin(tp, ip, 0);
1664 sxp->sx_length != ip->i_d.di_size ||
1670 trace_xfs_swap_extent_before(ip, 0);
1674 error = xfs_swap_extents_check_format(ip, tip);
1678 __func__, ip->i_ino);
1689 if ((sbp->bs_ctime.tv_sec != VFS_I(ip)->i_ctime.tv_sec) ||
1690 (sbp->bs_ctime.tv_nsec != VFS_I(ip)->i_ctime.tv_nsec) ||
1691 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
1692 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
1708 error = xfs_swap_extent_rmap(&tp, ip, tip);
1710 error = xfs_swap_extent_forks(tp, ip, tip, &src_log_flags,
1716 if ((ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK) ^
1718 f = ip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
1719 ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK;
1720 ip->i_d.di_flags2 |= tip->i_d.di_flags2 & XFS_DIFLAG2_REFLINK;
1727 ASSERT(!ip->i_cowfp ||
1728 ip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS);
1732 swap(ip->i_cowfp, tip->i_cowfp);
1734 if (ip->i_cowfp && ip->i_cowfp->if_bytes)
1735 xfs_inode_set_cowblocks_tag(ip);
1737 xfs_inode_clear_cowblocks_tag(ip);
1744 xfs_trans_log_inode(tp, ip, src_log_flags);
1754 error = xfs_swap_change_owner(&tp, ip, tip);
1759 error = xfs_swap_change_owner(&tp, tip, ip);
1773 trace_xfs_swap_extent_after(ip, 0);
1777 xfs_iunlock(ip, lock_flags);
1779 unlock_two_nondirectories(VFS_I(ip), VFS_I(tip));