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);
76 struct xfs_mount *mp = ap->ip->i_mount;
90 align = xfs_get_extsz_hint(ap->ip);
177 ap->ip->i_nblocks += ap->length;
178 xfs_trans_log_inode(ap->tp, ap->ip, XFS_ILOG_CORE);
180 ap->ip->i_delayed_blks -= ap->length;
185 xfs_trans_mod_dquot_byino(ap->tp, ap->ip,
253 struct xfs_inode *ip,
258 struct xfs_mount *mp = ip->i_mount;
259 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, whichfork);
272 error = xfs_iread_extents(tp, ip, whichfork);
276 cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
300 struct xfs_inode *ip,
310 error = xfs_reflink_trim_around_shared(ip, got, &shared);
328 p->bmv_block = xfs_fsb_to_db(ip, got->br_startblock);
338 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, got->br_startoff);
339 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, got->br_blockcount);
349 struct xfs_inode *ip,
362 p->bmv_offset = XFS_FSB_TO_BB(ip->i_mount, bno);
363 p->bmv_length = XFS_FSB_TO_BB(ip->i_mount, end - bno);
404 struct xfs_inode *ip,
408 struct xfs_mount *mp = ip->i_mount;
441 xfs_ilock(ip, XFS_IOLOCK_SHARED);
444 lock = xfs_ilock_attr_map_shared(ip);
445 if (!xfs_inode_has_attr_fork(ip))
452 xfs_ilock(ip, lock);
455 if (!xfs_ifork_ptr(ip, whichfork))
458 if (xfs_get_cowextsz_hint(ip))
461 max_len = XFS_ISIZE(ip);
465 (ip->i_delayed_blks || XFS_ISIZE(ip) > ip->i_disk_size)) {
466 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
476 * ip->i_delayed_blks == 0.
480 if (xfs_get_extsz_hint(ip) ||
481 (ip->i_diflags &
485 max_len = XFS_ISIZE(ip);
487 lock = xfs_ilock_data_map_shared(ip);
491 ifp = xfs_ifork_ptr(ip, whichfork);
515 error = xfs_iread_extents(NULL, ip, whichfork);
519 if (!xfs_iext_lookup_extent(ip, ifp, bno, &icur, &got)) {
525 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno,
526 XFS_B_TO_FSB(mp, XFS_ISIZE(ip)));
538 xfs_getbmap_report_hole(ip, bmv, out, bmv_end, bno,
552 error = xfs_getbmap_report_one(ip, bmv, out, bmv_end,
559 xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
567 xfs_getbmap_report_hole(ip, bmv, out, bmv_end,
578 xfs_iunlock(ip, lock);
580 xfs_iunlock(ip, XFS_IOLOCK_SHARED);
592 struct xfs_inode *ip,
596 struct xfs_mount *mp = ip->i_mount;
597 struct xfs_ifork *ifp = &ip->i_df;
606 xfs_ilock(ip, XFS_ILOCK_EXCL);
607 if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got))
626 error = xfs_bmap_del_extent_delay(ip, XFS_DATA_FORK, &icur,
633 xfs_iunlock(ip, XFS_ILOCK_EXCL);
644 struct xfs_inode *ip,
648 struct xfs_mount *mp = ip->i_mount;
658 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL) ||
659 (VFS_I(ip)->i_state & I_FREEING));
662 if (!S_ISREG(VFS_I(ip)->i_mode))
669 if (VFS_I(ip)->i_size == 0 &&
670 VFS_I(ip)->i_mapping->nrpages == 0 &&
671 ip->i_delayed_blks == 0)
675 if (xfs_need_iread_extents(&ip->i_df))
682 if (ip->i_diflags & (XFS_DIFLAG_PREALLOC | XFS_DIFLAG_APPEND))
683 if (!force || ip->i_delayed_blks == 0)
691 end_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_ISIZE(ip));
692 if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1)
702 xfs_ilock(ip, XFS_ILOCK_SHARED);
703 error = xfs_bmapi_read(ip, end_fsb, last_fsb - end_fsb, &imap, &nimaps,
705 xfs_iunlock(ip, XFS_ILOCK_SHARED);
713 return imap.br_startblock != HOLESTARTBLOCK || ip->i_delayed_blks;
723 struct xfs_inode *ip)
726 struct xfs_mount *mp = ip->i_mount;
730 error = xfs_qm_dqattach(ip);
735 inode_dio_wait(VFS_I(ip));
743 xfs_ilock(ip, XFS_ILOCK_EXCL);
744 xfs_trans_ijoin(tp, ip, 0);
752 error = xfs_itruncate_extents_flags(&tp, ip, XFS_DATA_FORK,
753 XFS_ISIZE(ip), XFS_BMAPI_NODISCARD);
761 xfs_inode_clear_eofblocks_tag(ip);
771 xfs_iunlock(ip, XFS_ILOCK_EXCL);
777 struct xfs_inode *ip,
781 xfs_mount_t *mp = ip->i_mount;
792 trace_xfs_alloc_file_space(ip);
797 error = xfs_qm_dqattach(ip);
804 rt = XFS_IS_REALTIME_INODE(ip);
805 extsz = xfs_get_extsz_hint(ip);
858 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write,
863 error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
866 error = xfs_iext_count_upgrade(tp, ip,
871 error = xfs_bmapi_write(tp, ip, startoffset_fsb,
877 ip->i_diflags |= XFS_DIFLAG_PREALLOC;
878 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
881 xfs_iunlock(ip, XFS_ILOCK_EXCL);
904 xfs_iunlock(ip, XFS_ILOCK_EXCL);
910 struct xfs_inode *ip,
915 struct xfs_mount *mp = ip->i_mount;
920 error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_write, resblks, 0,
925 error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
928 error = xfs_iext_count_upgrade(tp, ip, XFS_IEXT_PUNCH_HOLE_CNT);
932 error = xfs_bunmapi(tp, ip, startoffset_fsb, len_fsb, 0, 2, done);
938 xfs_iunlock(ip, XFS_ILOCK_EXCL);
949 struct xfs_inode *ip,
953 struct xfs_mount *mp = ip->i_mount;
954 struct inode *inode = VFS_I(ip);
971 struct xfs_inode *ip,
975 struct xfs_mount *mp = ip->i_mount;
980 trace_xfs_free_file_space(ip);
982 error = xfs_qm_dqattach(ip);
993 if (XFS_IS_REALTIME_INODE(ip) && mp->m_sb.sb_rextsize > 1) {
1005 error = xfs_unmap_extent(ip, startoffset_fsb,
1018 if (offset >= XFS_ISIZE(ip))
1020 if (offset + len > XFS_ISIZE(ip))
1021 len = XFS_ISIZE(ip) - offset;
1022 error = xfs_zero_range(ip, offset, len, NULL);
1032 if (offset + len >= XFS_ISIZE(ip) && offset_in_page(offset + len) > 0) {
1033 error = filemap_write_and_wait_range(VFS_I(ip)->i_mapping,
1042 struct xfs_inode *ip,
1045 struct xfs_mount *mp = ip->i_mount;
1052 if (xfs_can_free_eofblocks(ip, true)) {
1053 error = xfs_free_eofblocks(ip);
1073 error = xfs_flush_unmap_range(ip, offset, XFS_ISIZE(ip));
1082 if (xfs_inode_has_cow_data(ip)) {
1083 error = xfs_reflink_cancel_cow_range(ip, offset, NULLFILEOFF,
1106 struct xfs_inode *ip,
1110 struct xfs_mount *mp = ip->i_mount;
1117 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
1118 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
1120 trace_xfs_collapse_file_space(ip);
1122 error = xfs_free_file_space(ip, offset, len);
1126 error = xfs_prepare_shift(ip, offset);
1134 xfs_ilock(ip, XFS_ILOCK_EXCL);
1135 xfs_trans_ijoin(tp, ip, 0);
1138 error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb,
1152 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1157 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1175 struct xfs_inode *ip,
1179 struct xfs_mount *mp = ip->i_mount;
1187 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
1188 ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL));
1190 trace_xfs_insert_file_space(ip);
1192 error = xfs_bmap_can_insert_extents(ip, stop_fsb, shift_fsb);
1196 error = xfs_prepare_shift(ip, offset);
1205 xfs_ilock(ip, XFS_ILOCK_EXCL);
1206 xfs_trans_ijoin(tp, ip, 0);
1208 error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
1211 error = xfs_iext_count_upgrade(tp, ip, XFS_IEXT_PUNCH_HOLE_CNT);
1220 error = xfs_bmap_split_extent(tp, ip, stop_fsb);
1229 error = xfs_bmap_insert_extents(tp, ip, &next_fsb, shift_fsb,
1236 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1241 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1267 struct xfs_inode *ip, /* target inode */
1270 struct xfs_ifork *ifp = &ip->i_df;
1274 if (XFS_IS_QUOTA_ON(ip->i_mount) &&
1275 (!uid_eq(VFS_I(ip)->i_uid, VFS_I(tip)->i_uid) ||
1276 !gid_eq(VFS_I(ip)->i_gid, VFS_I(tip)->i_gid) ||
1277 ip->i_projid != tip->i_projid))
1296 if (xfs_has_rmapbt(ip->i_mount))
1310 tifp->if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1328 if (xfs_inode_has_attr_fork(ip) &&
1329 XFS_BMAP_BMDR_SPACE(tifp->if_broot) > xfs_inode_fork_boff(ip))
1331 if (tifp->if_nextents <= XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK))
1338 XFS_BMAP_BMDR_SPACE(ip->i_df.if_broot) > xfs_inode_fork_boff(tip))
1349 struct xfs_inode *ip)
1353 error = filemap_write_and_wait(VFS_I(ip)->i_mapping);
1356 truncate_pagecache_range(VFS_I(ip), 0, -1);
1359 if (VFS_I(ip)->i_mapping->nrpages)
1370 struct xfs_inode *ip,
1393 if (ip->i_diflags2 & XFS_DIFLAG2_REFLINK)
1397 end_fsb = XFS_B_TO_FSB(ip->i_mount, i_size_read(VFS_I(ip)));
1420 error = xfs_bmapi_read(ip, tirec.br_startoff,
1427 trace_xfs_swap_extent_rmap_remap_piece(ip, &irec);
1437 error = xfs_iext_count_may_overflow(ip,
1441 error = xfs_iext_count_upgrade(tp, ip,
1452 error = xfs_iext_count_upgrade(tp, ip,
1462 xfs_bmap_unmap_extent(tp, ip, &irec);
1465 xfs_bmap_map_extent(tp, ip, &uirec);
1491 trace_xfs_swap_extent_rmap_error(ip, error, _RET_IP_);
1500 struct xfs_inode *ip,
1514 if (xfs_inode_has_attr_fork(ip) && ip->i_af.if_nextents > 0 &&
1515 ip->i_af.if_format != XFS_DINODE_FMT_LOCAL) {
1516 error = xfs_bmap_count_blocks(tp, ip, XFS_ATTR_FORK, &junk,
1536 if (xfs_has_v3inodes(ip->i_mount)) {
1537 if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE)
1546 swap(ip->i_df, tip->i_df);
1551 tmp = (uint64_t)ip->i_nblocks;
1552 ip->i_nblocks = tip->i_nblocks - taforkblks + aforkblks;
1565 tip->i_delayed_blks = ip->i_delayed_blks;
1566 ip->i_delayed_blks = 0;
1568 switch (ip->i_df.if_format) {
1573 ASSERT(!xfs_has_v3inodes(ip->i_mount) ||
1585 ASSERT(!xfs_has_v3inodes(ip->i_mount) ||
1604 struct xfs_inode *ip,
1611 error = xfs_bmbt_change_owner(tp, ip, XFS_DATA_FORK, ip->i_ino,
1626 xfs_trans_ijoin(tp, ip, 0);
1628 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
1637 struct xfs_inode *ip, /* target inode */
1641 struct xfs_mount *mp = ip->i_mount;
1657 lock_two_nondirectories(VFS_I(ip), VFS_I(tip));
1658 filemap_invalidate_lock_two(VFS_I(ip)->i_mapping,
1662 if ((VFS_I(ip)->i_mode & S_IFMT) != (VFS_I(tip)->i_mode & S_IFMT)) {
1668 if (XFS_IS_REALTIME_INODE(ip) != XFS_IS_REALTIME_INODE(tip)) {
1673 error = xfs_qm_dqattach(ip);
1681 error = xfs_swap_extent_flush(ip);
1701 uint32_t ipnext = ip->i_df.if_nextents;
1730 xfs_lock_two_inodes(ip, XFS_ILOCK_EXCL, tip, XFS_ILOCK_EXCL);
1731 xfs_trans_ijoin(tp, ip, 0);
1737 sxp->sx_length != ip->i_disk_size ||
1743 trace_xfs_swap_extent_before(ip, 0);
1747 error = xfs_swap_extents_check_format(ip, tip);
1751 __func__, ip->i_ino);
1762 ctime = inode_get_ctime(VFS_I(ip));
1765 (sbp->bs_mtime.tv_sec != VFS_I(ip)->i_mtime.tv_sec) ||
1766 (sbp->bs_mtime.tv_nsec != VFS_I(ip)->i_mtime.tv_nsec)) {
1782 error = xfs_swap_extent_rmap(&tp, ip, tip);
1784 error = xfs_swap_extent_forks(tp, ip, tip, &src_log_flags,
1790 if ((ip->i_diflags2 & XFS_DIFLAG2_REFLINK) ^
1792 f = ip->i_diflags2 & XFS_DIFLAG2_REFLINK;
1793 ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK;
1794 ip->i_diflags2 |= tip->i_diflags2 & XFS_DIFLAG2_REFLINK;
1801 ASSERT(!ip->i_cowfp ||
1802 ip->i_cowfp->if_format == XFS_DINODE_FMT_EXTENTS);
1806 swap(ip->i_cowfp, tip->i_cowfp);
1808 if (ip->i_cowfp && ip->i_cowfp->if_bytes)
1809 xfs_inode_set_cowblocks_tag(ip);
1811 xfs_inode_clear_cowblocks_tag(ip);
1818 xfs_trans_log_inode(tp, ip, src_log_flags);
1828 error = xfs_swap_change_owner(&tp, ip, tip);
1833 error = xfs_swap_change_owner(&tp, tip, ip);
1847 trace_xfs_swap_extent_after(ip, 0);
1851 xfs_iunlock(ip, XFS_ILOCK_EXCL);
1854 filemap_invalidate_unlock_two(VFS_I(ip)->i_mapping,
1856 unlock_two_nondirectories(VFS_I(ip), VFS_I(tip));