Lines Matching refs:ip

58 	struct xfs_inode	*ip)  in xfs_get_extsz_hint()  argument
64 if (xfs_is_always_cow_inode(ip)) in xfs_get_extsz_hint()
66 if ((ip->i_diflags & XFS_DIFLAG_EXTSIZE) && ip->i_extsize) in xfs_get_extsz_hint()
67 return ip->i_extsize; in xfs_get_extsz_hint()
68 if (XFS_IS_REALTIME_INODE(ip)) in xfs_get_extsz_hint()
69 return ip->i_mount->m_sb.sb_rextsize; in xfs_get_extsz_hint()
81 struct xfs_inode *ip) in xfs_get_cowextsz_hint() argument
86 if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_get_cowextsz_hint()
87 a = ip->i_cowextsize; in xfs_get_cowextsz_hint()
88 b = xfs_get_extsz_hint(ip); in xfs_get_cowextsz_hint()
113 struct xfs_inode *ip) in xfs_ilock_data_map_shared() argument
117 if (xfs_need_iread_extents(&ip->i_df)) in xfs_ilock_data_map_shared()
119 xfs_ilock(ip, lock_mode); in xfs_ilock_data_map_shared()
125 struct xfs_inode *ip) in xfs_ilock_attr_map_shared() argument
129 if (xfs_inode_has_attr_fork(ip) && xfs_need_iread_extents(&ip->i_af)) in xfs_ilock_attr_map_shared()
131 xfs_ilock(ip, lock_mode); in xfs_ilock_attr_map_shared()
187 xfs_inode_t *ip, in xfs_ilock() argument
190 trace_xfs_ilock(ip, lock_flags, _RET_IP_); in xfs_ilock()
195 down_write_nested(&VFS_I(ip)->i_rwsem, in xfs_ilock()
198 down_read_nested(&VFS_I(ip)->i_rwsem, in xfs_ilock()
203 down_write_nested(&VFS_I(ip)->i_mapping->invalidate_lock, in xfs_ilock()
206 down_read_nested(&VFS_I(ip)->i_mapping->invalidate_lock, in xfs_ilock()
211 mrupdate_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); in xfs_ilock()
213 mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); in xfs_ilock()
230 xfs_inode_t *ip, in xfs_ilock_nowait() argument
233 trace_xfs_ilock_nowait(ip, lock_flags, _RET_IP_); in xfs_ilock_nowait()
238 if (!down_write_trylock(&VFS_I(ip)->i_rwsem)) in xfs_ilock_nowait()
241 if (!down_read_trylock(&VFS_I(ip)->i_rwsem)) in xfs_ilock_nowait()
246 if (!down_write_trylock(&VFS_I(ip)->i_mapping->invalidate_lock)) in xfs_ilock_nowait()
249 if (!down_read_trylock(&VFS_I(ip)->i_mapping->invalidate_lock)) in xfs_ilock_nowait()
254 if (!mrtryupdate(&ip->i_lock)) in xfs_ilock_nowait()
257 if (!mrtryaccess(&ip->i_lock)) in xfs_ilock_nowait()
264 up_write(&VFS_I(ip)->i_mapping->invalidate_lock); in xfs_ilock_nowait()
266 up_read(&VFS_I(ip)->i_mapping->invalidate_lock); in xfs_ilock_nowait()
269 up_write(&VFS_I(ip)->i_rwsem); in xfs_ilock_nowait()
271 up_read(&VFS_I(ip)->i_rwsem); in xfs_ilock_nowait()
290 xfs_inode_t *ip, in xfs_iunlock() argument
296 up_write(&VFS_I(ip)->i_rwsem); in xfs_iunlock()
298 up_read(&VFS_I(ip)->i_rwsem); in xfs_iunlock()
301 up_write(&VFS_I(ip)->i_mapping->invalidate_lock); in xfs_iunlock()
303 up_read(&VFS_I(ip)->i_mapping->invalidate_lock); in xfs_iunlock()
306 mrunlock_excl(&ip->i_lock); in xfs_iunlock()
308 mrunlock_shared(&ip->i_lock); in xfs_iunlock()
310 trace_xfs_iunlock(ip, lock_flags, _RET_IP_); in xfs_iunlock()
319 xfs_inode_t *ip, in xfs_ilock_demote() argument
327 mrdemote(&ip->i_lock); in xfs_ilock_demote()
329 downgrade_write(&VFS_I(ip)->i_mapping->invalidate_lock); in xfs_ilock_demote()
331 downgrade_write(&VFS_I(ip)->i_rwsem); in xfs_ilock_demote()
333 trace_xfs_ilock_demote(ip, lock_flags, _RET_IP_); in xfs_ilock_demote()
359 struct xfs_inode *ip, in xfs_isilocked() argument
364 return !!ip->i_lock.mr_writer; in xfs_isilocked()
365 return rwsem_is_locked(&ip->i_lock.mr_lock); in xfs_isilocked()
369 return __xfs_rwsem_islocked(&VFS_I(ip)->i_mapping->invalidate_lock, in xfs_isilocked()
374 return __xfs_rwsem_islocked(&VFS_I(ip)->i_rwsem, in xfs_isilocked()
597 struct xfs_inode *ip) in xfs_ip2xflags() argument
601 if (ip->i_diflags & XFS_DIFLAG_ANY) { in xfs_ip2xflags()
602 if (ip->i_diflags & XFS_DIFLAG_REALTIME) in xfs_ip2xflags()
604 if (ip->i_diflags & XFS_DIFLAG_PREALLOC) in xfs_ip2xflags()
606 if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE) in xfs_ip2xflags()
608 if (ip->i_diflags & XFS_DIFLAG_APPEND) in xfs_ip2xflags()
610 if (ip->i_diflags & XFS_DIFLAG_SYNC) in xfs_ip2xflags()
612 if (ip->i_diflags & XFS_DIFLAG_NOATIME) in xfs_ip2xflags()
614 if (ip->i_diflags & XFS_DIFLAG_NODUMP) in xfs_ip2xflags()
616 if (ip->i_diflags & XFS_DIFLAG_RTINHERIT) in xfs_ip2xflags()
618 if (ip->i_diflags & XFS_DIFLAG_PROJINHERIT) in xfs_ip2xflags()
620 if (ip->i_diflags & XFS_DIFLAG_NOSYMLINKS) in xfs_ip2xflags()
622 if (ip->i_diflags & XFS_DIFLAG_EXTSIZE) in xfs_ip2xflags()
624 if (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) in xfs_ip2xflags()
626 if (ip->i_diflags & XFS_DIFLAG_NODEFRAG) in xfs_ip2xflags()
628 if (ip->i_diflags & XFS_DIFLAG_FILESTREAM) in xfs_ip2xflags()
632 if (ip->i_diflags2 & XFS_DIFLAG2_ANY) { in xfs_ip2xflags()
633 if (ip->i_diflags2 & XFS_DIFLAG2_DAX) in xfs_ip2xflags()
635 if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_ip2xflags()
639 if (xfs_inode_has_attr_fork(ip)) in xfs_ip2xflags()
686 struct xfs_inode *ip, in xfs_inode_inherit_flags() argument
691 umode_t mode = VFS_I(ip)->i_mode; in xfs_inode_inherit_flags()
698 ip->i_extsize = pip->i_extsize; in xfs_inode_inherit_flags()
704 xfs_has_realtime(ip->i_mount)) in xfs_inode_inherit_flags()
708 ip->i_extsize = pip->i_extsize; in xfs_inode_inherit_flags()
729 ip->i_diflags |= di_flags; in xfs_inode_inherit_flags()
741 failaddr = xfs_inode_validate_extsize(ip->i_mount, ip->i_extsize, in xfs_inode_inherit_flags()
742 VFS_I(ip)->i_mode, ip->i_diflags); in xfs_inode_inherit_flags()
744 ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | in xfs_inode_inherit_flags()
746 ip->i_extsize = 0; in xfs_inode_inherit_flags()
753 struct xfs_inode *ip, in xfs_inode_inherit_flags2() argument
759 ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE; in xfs_inode_inherit_flags2()
760 ip->i_cowextsize = pip->i_cowextsize; in xfs_inode_inherit_flags2()
763 ip->i_diflags2 |= XFS_DIFLAG2_DAX; in xfs_inode_inherit_flags2()
766 failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, in xfs_inode_inherit_flags2()
767 VFS_I(ip)->i_mode, ip->i_diflags, ip->i_diflags2); in xfs_inode_inherit_flags2()
769 ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; in xfs_inode_inherit_flags2()
770 ip->i_cowextsize = 0; in xfs_inode_inherit_flags2()
793 struct xfs_inode *ip; in xfs_init_new_inode() local
815 error = xfs_iget(mp, tp, ino, XFS_IGET_CREATE, XFS_ILOCK_EXCL, &ip); in xfs_init_new_inode()
819 ASSERT(ip != NULL); in xfs_init_new_inode()
820 inode = VFS_I(ip); in xfs_init_new_inode()
823 ip->i_projid = prid; in xfs_init_new_inode()
842 ip->i_disk_size = 0; in xfs_init_new_inode()
843 ip->i_df.if_nextents = 0; in xfs_init_new_inode()
844 ASSERT(ip->i_nblocks == 0); in xfs_init_new_inode()
850 ip->i_extsize = 0; in xfs_init_new_inode()
851 ip->i_diflags = 0; in xfs_init_new_inode()
855 ip->i_cowextsize = 0; in xfs_init_new_inode()
856 ip->i_crtime = tv; in xfs_init_new_inode()
865 ip->i_df.if_format = XFS_DINODE_FMT_DEV; in xfs_init_new_inode()
871 xfs_inode_inherit_flags(ip, pip); in xfs_init_new_inode()
873 xfs_inode_inherit_flags2(ip, pip); in xfs_init_new_inode()
876 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_init_new_inode()
877 ip->i_df.if_bytes = 0; in xfs_init_new_inode()
878 ip->i_df.if_u1.if_root = NULL; in xfs_init_new_inode()
894 ip->i_forkoff = xfs_default_attroffset(ip) >> 3; in xfs_init_new_inode()
895 xfs_ifork_init_attr(ip, XFS_DINODE_FMT_EXTENTS, 0); in xfs_init_new_inode()
901 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_init_new_inode()
902 xfs_trans_log_inode(tp, ip, flags); in xfs_init_new_inode()
905 xfs_setup_inode(ip); in xfs_init_new_inode()
907 *ipp = ip; in xfs_init_new_inode()
919 xfs_inode_t *ip) in xfs_droplink() argument
921 if (VFS_I(ip)->i_nlink == 0) { in xfs_droplink()
922 xfs_alert(ip->i_mount, in xfs_droplink()
924 __func__, ip->i_ino); in xfs_droplink()
928 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); in xfs_droplink()
930 drop_nlink(VFS_I(ip)); in xfs_droplink()
931 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_droplink()
933 if (VFS_I(ip)->i_nlink) in xfs_droplink()
936 return xfs_iunlink(tp, ip); in xfs_droplink()
945 xfs_inode_t *ip) in xfs_bumplink() argument
947 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); in xfs_bumplink()
949 inc_nlink(VFS_I(ip)); in xfs_bumplink()
950 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bumplink()
965 struct xfs_inode *ip = NULL; in xfs_create() local
1030 is_dir ? 2 : 1, rdev, prid, init_xattrs, &ip); in xfs_create()
1044 error = xfs_dir_createname(tp, dp, name, ip->i_ino, in xfs_create()
1054 error = xfs_dir_init(tp, ip, dp); in xfs_create()
1074 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); in xfs_create()
1084 *ipp = ip; in xfs_create()
1095 if (ip) { in xfs_create()
1096 xfs_finish_inode_setup(ip); in xfs_create()
1097 xfs_irele(ip); in xfs_create()
1117 struct xfs_inode *ip = NULL; in xfs_create_tmpfile() local
1154 0, 0, prid, false, &ip); in xfs_create_tmpfile()
1166 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp); in xfs_create_tmpfile()
1168 error = xfs_iunlink(tp, ip); in xfs_create_tmpfile()
1180 *ipp = ip; in xfs_create_tmpfile()
1191 if (ip) { in xfs_create_tmpfile()
1192 xfs_finish_inode_setup(ip); in xfs_create_tmpfile()
1193 xfs_irele(ip); in xfs_create_tmpfile()
1306 struct xfs_inode *ip) in xfs_itruncate_clear_reflink_flags() argument
1311 if (!xfs_is_reflink_inode(ip)) in xfs_itruncate_clear_reflink_flags()
1313 dfork = xfs_ifork_ptr(ip, XFS_DATA_FORK); in xfs_itruncate_clear_reflink_flags()
1314 cfork = xfs_ifork_ptr(ip, XFS_COW_FORK); in xfs_itruncate_clear_reflink_flags()
1316 ip->i_diflags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_itruncate_clear_reflink_flags()
1318 xfs_inode_clear_cowblocks_tag(ip); in xfs_itruncate_clear_reflink_flags()
1345 struct xfs_inode *ip, in xfs_itruncate_extents_flags() argument
1350 struct xfs_mount *mp = ip->i_mount; in xfs_itruncate_extents_flags()
1356 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_itruncate_extents_flags()
1357 ASSERT(!atomic_read(&VFS_I(ip)->i_count) || in xfs_itruncate_extents_flags()
1358 xfs_isilocked(ip, XFS_IOLOCK_EXCL)); in xfs_itruncate_extents_flags()
1359 ASSERT(new_size <= XFS_ISIZE(ip)); in xfs_itruncate_extents_flags()
1361 ASSERT(ip->i_itemp != NULL); in xfs_itruncate_extents_flags()
1362 ASSERT(ip->i_itemp->ili_lock_flags == 0); in xfs_itruncate_extents_flags()
1363 ASSERT(!XFS_NOT_DQATTACHED(mp, ip)); in xfs_itruncate_extents_flags()
1365 trace_xfs_itruncate_extents_start(ip, new_size); in xfs_itruncate_extents_flags()
1388 error = __xfs_bunmapi(tp, ip, first_unmap_block, &unmap_len, in xfs_itruncate_extents_flags()
1401 error = xfs_reflink_cancel_cow_blocks(ip, &tp, in xfs_itruncate_extents_flags()
1406 xfs_itruncate_clear_reflink_flags(ip); in xfs_itruncate_extents_flags()
1413 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_itruncate_extents_flags()
1415 trace_xfs_itruncate_extents_end(ip, new_size); in xfs_itruncate_extents_flags()
1424 xfs_inode_t *ip) in xfs_release() argument
1426 xfs_mount_t *mp = ip->i_mount; in xfs_release()
1429 if (!S_ISREG(VFS_I(ip)->i_mode) || (VFS_I(ip)->i_mode == 0)) in xfs_release()
1449 truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED); in xfs_release()
1451 xfs_iflags_clear(ip, XFS_IDIRTY_RELEASE); in xfs_release()
1452 if (ip->i_delayed_blks > 0) { in xfs_release()
1453 error = filemap_flush(VFS_I(ip)->i_mapping); in xfs_release()
1460 if (VFS_I(ip)->i_nlink == 0) in xfs_release()
1469 if (!xfs_ilock_nowait(ip, XFS_IOLOCK_EXCL)) in xfs_release()
1472 if (xfs_can_free_eofblocks(ip, false)) { in xfs_release()
1487 if (xfs_iflags_test(ip, XFS_IDIRTY_RELEASE)) in xfs_release()
1490 error = xfs_free_eofblocks(ip); in xfs_release()
1495 if (ip->i_delayed_blks) in xfs_release()
1496 xfs_iflags_set(ip, XFS_IDIRTY_RELEASE); in xfs_release()
1500 xfs_iunlock(ip, XFS_IOLOCK_EXCL); in xfs_release()
1511 struct xfs_inode *ip) in xfs_inactive_truncate() argument
1513 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_truncate()
1522 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_inactive_truncate()
1523 xfs_trans_ijoin(tp, ip, 0); in xfs_inactive_truncate()
1530 ip->i_disk_size = 0; in xfs_inactive_truncate()
1531 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_inactive_truncate()
1533 error = xfs_itruncate_extents(&tp, ip, XFS_DATA_FORK, 0); in xfs_inactive_truncate()
1537 ASSERT(ip->i_df.if_nextents == 0); in xfs_inactive_truncate()
1543 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_truncate()
1549 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_inactive_truncate()
1560 struct xfs_inode *ip) in xfs_inactive_ifree() argument
1562 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_ifree()
1615 xfs_ilock(ip, XFS_ILOCK_EXCL); in xfs_inactive_ifree()
1616 xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); in xfs_inactive_ifree()
1618 error = xfs_ifree(tp, ip); in xfs_inactive_ifree()
1619 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_inactive_ifree()
1638 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_ICOUNT, -1); in xfs_inactive_ifree()
1651 struct xfs_inode *ip) in xfs_inode_needs_inactive() argument
1653 struct xfs_mount *mp = ip->i_mount; in xfs_inode_needs_inactive()
1654 struct xfs_ifork *cow_ifp = xfs_ifork_ptr(ip, XFS_COW_FORK); in xfs_inode_needs_inactive()
1660 if (VFS_I(ip)->i_mode == 0) in xfs_inode_needs_inactive()
1675 if (xfs_is_metadata_inode(ip)) in xfs_inode_needs_inactive()
1683 if (VFS_I(ip)->i_nlink == 0) in xfs_inode_needs_inactive()
1696 return xfs_can_free_eofblocks(ip, true); in xfs_inode_needs_inactive()
1709 xfs_inode_t *ip) in xfs_inactive() argument
1719 if (VFS_I(ip)->i_mode == 0) { in xfs_inactive()
1720 ASSERT(ip->i_df.if_broot_bytes == 0); in xfs_inactive()
1724 mp = ip->i_mount; in xfs_inactive()
1725 ASSERT(!xfs_iflags_test(ip, XFS_IRECOVERY)); in xfs_inactive()
1735 if (xfs_is_metadata_inode(ip)) in xfs_inactive()
1739 if (xfs_inode_has_cow_data(ip)) in xfs_inactive()
1740 xfs_reflink_cancel_cow_range(ip, 0, NULLFILEOFF, true); in xfs_inactive()
1742 if (VFS_I(ip)->i_nlink != 0) { in xfs_inactive()
1752 if (xfs_can_free_eofblocks(ip, true)) in xfs_inactive()
1753 error = xfs_free_eofblocks(ip); in xfs_inactive()
1758 if (S_ISREG(VFS_I(ip)->i_mode) && in xfs_inactive()
1759 (ip->i_disk_size != 0 || XFS_ISIZE(ip) != 0 || in xfs_inactive()
1760 ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0)) in xfs_inactive()
1763 if (xfs_iflags_test(ip, XFS_IQUOTAUNCHECKED)) { in xfs_inactive()
1772 xfs_qm_dqdetach(ip); in xfs_inactive()
1774 error = xfs_qm_dqattach(ip); in xfs_inactive()
1779 if (S_ISLNK(VFS_I(ip)->i_mode)) in xfs_inactive()
1780 error = xfs_inactive_symlink(ip); in xfs_inactive()
1782 error = xfs_inactive_truncate(ip); in xfs_inactive()
1791 if (xfs_inode_has_attr_fork(ip)) { in xfs_inactive()
1792 error = xfs_attr_inactive(ip); in xfs_inactive()
1797 ASSERT(ip->i_forkoff == 0); in xfs_inactive()
1802 error = xfs_inactive_ifree(ip); in xfs_inactive()
1809 xfs_qm_dqdetach(ip); in xfs_inactive()
1857 struct xfs_inode *ip; in xfs_iunlink_lookup() local
1860 ip = radix_tree_lookup(&pag->pag_ici_root, agino); in xfs_iunlink_lookup()
1861 if (!ip) { in xfs_iunlink_lookup()
1871 if (WARN_ON_ONCE(!ip->i_ino)) { in xfs_iunlink_lookup()
1875 ASSERT(!xfs_iflags_test(ip, XFS_IRECLAIMABLE | XFS_IRECLAIM)); in xfs_iunlink_lookup()
1877 return ip; in xfs_iunlink_lookup()
1890 struct xfs_inode *ip; in xfs_iunlink_update_backref() local
1896 ip = xfs_iunlink_lookup(pag, next_agino); in xfs_iunlink_update_backref()
1897 if (!ip) in xfs_iunlink_update_backref()
1900 ip->i_prev_unlinked = prev_agino; in xfs_iunlink_update_backref()
2006 struct xfs_inode *ip) in xfs_iunlink_insert_inode() argument
2011 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink_insert_inode()
2042 error = xfs_iunlink_log_inode(tp, ip, pag, next_agino); in xfs_iunlink_insert_inode()
2045 ip->i_next_unlinked = next_agino; in xfs_iunlink_insert_inode()
2049 ip->i_prev_unlinked = NULLAGINO; in xfs_iunlink_insert_inode()
2063 struct xfs_inode *ip) in xfs_iunlink() argument
2070 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_iunlink()
2071 ASSERT(VFS_I(ip)->i_mode != 0); in xfs_iunlink()
2072 trace_xfs_iunlink(ip); in xfs_iunlink()
2074 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_iunlink()
2081 error = xfs_iunlink_insert_inode(tp, pag, agibp, ip); in xfs_iunlink()
2092 struct xfs_inode *ip) in xfs_iunlink_remove_inode() argument
2096 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink_remove_inode()
2101 trace_xfs_iunlink_remove(ip); in xfs_iunlink_remove_inode()
2119 error = xfs_iunlink_log_inode(tp, ip, pag, NULLAGINO); in xfs_iunlink_remove_inode()
2127 error = xfs_iunlink_update_backref(pag, ip->i_prev_unlinked, in xfs_iunlink_remove_inode()
2128 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
2130 error = xfs_iunlink_reload_next(tp, agibp, ip->i_prev_unlinked, in xfs_iunlink_remove_inode()
2131 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
2138 prev_ip = xfs_iunlink_lookup(pag, ip->i_prev_unlinked); in xfs_iunlink_remove_inode()
2143 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
2144 prev_ip->i_next_unlinked = ip->i_next_unlinked; in xfs_iunlink_remove_inode()
2148 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
2151 ip->i_next_unlinked = NULLAGINO; in xfs_iunlink_remove_inode()
2152 ip->i_prev_unlinked = 0; in xfs_iunlink_remove_inode()
2163 struct xfs_inode *ip) in xfs_iunlink_remove() argument
2168 trace_xfs_iunlink_remove(ip); in xfs_iunlink_remove()
2175 return xfs_iunlink_remove_inode(tp, pag, agibp, ip); in xfs_iunlink_remove()
2191 struct xfs_inode *ip; in xfs_ifree_mark_inode_stale() local
2195 ip = radix_tree_lookup(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, inum)); in xfs_ifree_mark_inode_stale()
2198 if (!ip) { in xfs_ifree_mark_inode_stale()
2209 spin_lock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2210 if (ip->i_ino != inum || __xfs_iflags_test(ip, XFS_ISTALE)) in xfs_ifree_mark_inode_stale()
2219 if (ip != free_ip) { in xfs_ifree_mark_inode_stale()
2220 if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) { in xfs_ifree_mark_inode_stale()
2221 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2227 ip->i_flags |= XFS_ISTALE; in xfs_ifree_mark_inode_stale()
2234 iip = ip->i_itemp; in xfs_ifree_mark_inode_stale()
2235 if (__xfs_iflags_test(ip, XFS_IFLUSHING)) { in xfs_ifree_mark_inode_stale()
2250 __xfs_iflags_set(ip, XFS_IFLUSHING); in xfs_ifree_mark_inode_stale()
2251 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2262 if (ip != free_ip) in xfs_ifree_mark_inode_stale()
2263 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_ifree_mark_inode_stale()
2267 if (ip != free_ip) in xfs_ifree_mark_inode_stale()
2268 xfs_iunlock(ip, XFS_ILOCK_EXCL); in xfs_ifree_mark_inode_stale()
2270 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2365 struct xfs_inode *ip) in xfs_ifree() argument
2367 struct xfs_mount *mp = ip->i_mount; in xfs_ifree()
2370 struct xfs_inode_log_item *iip = ip->i_itemp; in xfs_ifree()
2373 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); in xfs_ifree()
2374 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_ifree()
2375 ASSERT(ip->i_df.if_nextents == 0); in xfs_ifree()
2376 ASSERT(ip->i_disk_size == 0 || !S_ISREG(VFS_I(ip)->i_mode)); in xfs_ifree()
2377 ASSERT(ip->i_nblocks == 0); in xfs_ifree()
2379 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_ifree()
2387 error = xfs_difree(tp, pag, ip->i_ino, &xic); in xfs_ifree()
2391 error = xfs_iunlink_remove(tp, pag, ip); in xfs_ifree()
2400 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { in xfs_ifree()
2401 kmem_free(ip->i_df.if_u1.if_data); in xfs_ifree()
2402 ip->i_df.if_u1.if_data = NULL; in xfs_ifree()
2403 ip->i_df.if_bytes = 0; in xfs_ifree()
2406 VFS_I(ip)->i_mode = 0; /* mark incore inode as free */ in xfs_ifree()
2407 ip->i_diflags = 0; in xfs_ifree()
2408 ip->i_diflags2 = mp->m_ino_geo.new_diflags2; in xfs_ifree()
2409 ip->i_forkoff = 0; /* mark the attr fork not in use */ in xfs_ifree()
2410 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_ifree()
2411 if (xfs_iflags_test(ip, XFS_IPRESERVE_DM_FIELDS)) in xfs_ifree()
2412 xfs_iflags_clear(ip, XFS_IPRESERVE_DM_FIELDS); in xfs_ifree()
2423 VFS_I(ip)->i_generation++; in xfs_ifree()
2424 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_ifree()
2427 error = xfs_ifree_cluster(tp, pag, ip, &xic); in xfs_ifree()
2440 struct xfs_inode *ip) in xfs_iunpin() argument
2442 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); in xfs_iunpin()
2444 trace_xfs_inode_unpin_nowait(ip, _RET_IP_); in xfs_iunpin()
2447 xfs_log_force_seq(ip->i_mount, ip->i_itemp->ili_commit_seq, 0, NULL); in xfs_iunpin()
2453 struct xfs_inode *ip) in __xfs_iunpin_wait() argument
2455 wait_queue_head_t *wq = bit_waitqueue(&ip->i_flags, __XFS_IPINNED_BIT); in __xfs_iunpin_wait()
2456 DEFINE_WAIT_BIT(wait, &ip->i_flags, __XFS_IPINNED_BIT); in __xfs_iunpin_wait()
2458 xfs_iunpin(ip); in __xfs_iunpin_wait()
2462 if (xfs_ipincount(ip)) in __xfs_iunpin_wait()
2464 } while (xfs_ipincount(ip)); in __xfs_iunpin_wait()
2470 struct xfs_inode *ip) in xfs_iunpin_wait() argument
2472 if (xfs_ipincount(ip)) in xfs_iunpin_wait()
2473 __xfs_iunpin_wait(ip); in xfs_iunpin_wait()
2507 xfs_inode_t *ip) in xfs_remove() argument
2511 int is_dir = S_ISDIR(VFS_I(ip)->i_mode); in xfs_remove()
2525 error = xfs_qm_dqattach(ip); in xfs_remove()
2541 error = xfs_trans_alloc_dir(dp, &M_RES(mp)->tr_remove, ip, &resblks, in xfs_remove()
2552 ASSERT(VFS_I(ip)->i_nlink >= 2); in xfs_remove()
2553 if (VFS_I(ip)->i_nlink != 2) { in xfs_remove()
2557 if (!xfs_dir_isempty(ip)) { in xfs_remove()
2568 error = xfs_droplink(tp, ip); in xfs_remove()
2579 error = xfs_dir_replace(tp, ip, &xfs_name_dotdot, in xfs_remove()
2595 error = xfs_droplink(tp, ip); in xfs_remove()
2599 error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); in xfs_remove()
2617 if (is_dir && xfs_inode_is_filestream(ip)) in xfs_remove()
2618 xfs_filestream_deassociate(ip); in xfs_remove()
3195 struct xfs_inode *ip, in xfs_iflush() argument
3198 struct xfs_inode_log_item *iip = ip->i_itemp; in xfs_iflush()
3200 struct xfs_mount *mp = ip->i_mount; in xfs_iflush()
3203 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL|XFS_ILOCK_SHARED)); in xfs_iflush()
3204 ASSERT(xfs_iflags_test(ip, XFS_IFLUSHING)); in xfs_iflush()
3205 ASSERT(ip->i_df.if_format != XFS_DINODE_FMT_BTREE || in xfs_iflush()
3206 ip->i_df.if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)); in xfs_iflush()
3209 dip = xfs_buf_offset(bp, ip->i_imap.im_boffset); in xfs_iflush()
3222 __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); in xfs_iflush()
3225 if (S_ISREG(VFS_I(ip)->i_mode)) { in xfs_iflush()
3227 ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS && in xfs_iflush()
3228 ip->i_df.if_format != XFS_DINODE_FMT_BTREE, in xfs_iflush()
3232 __func__, ip->i_ino, ip); in xfs_iflush()
3235 } else if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_iflush()
3237 ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS && in xfs_iflush()
3238 ip->i_df.if_format != XFS_DINODE_FMT_BTREE && in xfs_iflush()
3239 ip->i_df.if_format != XFS_DINODE_FMT_LOCAL, in xfs_iflush()
3243 __func__, ip->i_ino, ip); in xfs_iflush()
3247 if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af) > in xfs_iflush()
3248 ip->i_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) { in xfs_iflush()
3252 __func__, ip->i_ino, in xfs_iflush()
3253 ip->i_df.if_nextents + xfs_ifork_nextents(&ip->i_af), in xfs_iflush()
3254 ip->i_nblocks, ip); in xfs_iflush()
3257 if (XFS_TEST_ERROR(ip->i_forkoff > mp->m_sb.sb_inodesize, in xfs_iflush()
3261 __func__, ip->i_ino, ip->i_forkoff, ip); in xfs_iflush()
3274 ip->i_flushiter++; in xfs_iflush()
3280 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL && in xfs_iflush()
3281 xfs_ifork_verify_local_data(ip)) in xfs_iflush()
3283 if (xfs_inode_has_attr_fork(ip) && in xfs_iflush()
3284 ip->i_af.if_format == XFS_DINODE_FMT_LOCAL && in xfs_iflush()
3285 xfs_ifork_verify_local_attr(ip)) in xfs_iflush()
3293 xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn); in xfs_iflush()
3297 if (ip->i_flushiter == DI_MAX_FLUSH) in xfs_iflush()
3298 ip->i_flushiter = 0; in xfs_iflush()
3301 xfs_iflush_fork(ip, dip, iip, XFS_DATA_FORK); in xfs_iflush()
3302 if (xfs_inode_has_attr_fork(ip)) in xfs_iflush()
3303 xfs_iflush_fork(ip, dip, iip, XFS_ATTR_FORK); in xfs_iflush()
3360 struct xfs_inode *ip; in xfs_iflush_cluster() local
3371 ip = iip->ili_inode; in xfs_iflush_cluster()
3376 if (__xfs_iflags_test(ip, XFS_IRECLAIM | XFS_IFLUSHING)) in xfs_iflush_cluster()
3378 if (xfs_ipincount(ip)) in xfs_iflush_cluster()
3388 spin_lock(&ip->i_flags_lock); in xfs_iflush_cluster()
3389 ASSERT(!__xfs_iflags_test(ip, XFS_ISTALE)); in xfs_iflush_cluster()
3390 if (__xfs_iflags_test(ip, XFS_IRECLAIM | XFS_IFLUSHING)) { in xfs_iflush_cluster()
3391 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3401 if (!xfs_ilock_nowait(ip, XFS_ILOCK_SHARED)) { in xfs_iflush_cluster()
3402 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3405 __xfs_iflags_set(ip, XFS_IFLUSHING); in xfs_iflush_cluster()
3406 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3416 xfs_iunpin_wait(ip); in xfs_iflush_cluster()
3417 xfs_iflush_abort(ip); in xfs_iflush_cluster()
3418 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_iflush_cluster()
3424 if (xfs_ipincount(ip)) { in xfs_iflush_cluster()
3425 xfs_iflags_clear(ip, XFS_IFLUSHING); in xfs_iflush_cluster()
3426 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_iflush_cluster()
3430 if (!xfs_inode_clean(ip)) in xfs_iflush_cluster()
3431 error = xfs_iflush(ip, bp); in xfs_iflush_cluster()
3433 xfs_iflags_clear(ip, XFS_IFLUSHING); in xfs_iflush_cluster()
3434 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_iflush_cluster()
3469 struct xfs_inode *ip) in xfs_irele() argument
3471 trace_xfs_irele(ip, _RET_IP_); in xfs_irele()
3472 iput(VFS_I(ip)); in xfs_irele()
3480 struct xfs_inode *ip) in xfs_log_force_inode() argument
3484 xfs_ilock(ip, XFS_ILOCK_SHARED); in xfs_log_force_inode()
3485 if (xfs_ipincount(ip)) in xfs_log_force_inode()
3486 seq = ip->i_itemp->ili_commit_seq; in xfs_log_force_inode()
3487 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_log_force_inode()
3491 return xfs_log_force_seq(ip->i_mount, seq, XFS_LOG_SYNC, NULL); in xfs_log_force_inode()
3667 struct xfs_inode *ip) in xfs_inode_reload_unlinked_bucket() argument
3673 xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino); in xfs_inode_reload_unlinked_bucket()
3674 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_inode_reload_unlinked_bucket()
3692 if (!xfs_inode_unlinked_incomplete(ip)) { in xfs_inode_reload_unlinked_bucket()
3700 trace_xfs_inode_reload_unlinked_bucket(ip); in xfs_inode_reload_unlinked_bucket()
3713 next_ip = ip; in xfs_inode_reload_unlinked_bucket()
3755 struct xfs_inode *ip) in xfs_inode_reload_unlinked() argument
3760 error = xfs_trans_alloc_empty(ip->i_mount, &tp); in xfs_inode_reload_unlinked()
3764 xfs_ilock(ip, XFS_ILOCK_SHARED); in xfs_inode_reload_unlinked()
3765 if (xfs_inode_unlinked_incomplete(ip)) in xfs_inode_reload_unlinked()
3766 error = xfs_inode_reload_unlinked_bucket(tp, ip); in xfs_inode_reload_unlinked()
3767 xfs_iunlock(ip, XFS_ILOCK_SHARED); in xfs_inode_reload_unlinked()