Lines Matching +full:ips +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
63 if ((ip->i_d.di_flags & XFS_DIFLAG_EXTSIZE) && ip->i_d.di_extsize) in xfs_get_extsz_hint()
64 return ip->i_d.di_extsize; in xfs_get_extsz_hint()
66 return ip->i_mount->m_sb.sb_rextsize; in xfs_get_extsz_hint()
83 if (ip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_get_cowextsz_hint()
84 a = ip->i_d.di_cowextsize; in xfs_get_cowextsz_hint()
98 * bringing in of the extents from disk for a file in b-tree format. If the
99 * inode is in b-tree format, then we need to lock the inode exclusively until
114 if (ip->i_df.if_format == XFS_DINODE_FMT_BTREE && in xfs_ilock_data_map_shared()
115 (ip->i_df.if_flags & XFS_IFEXTENTS) == 0) in xfs_ilock_data_map_shared()
127 if (ip->i_afp && in xfs_ilock_attr_map_shared()
128 ip->i_afp->if_format == XFS_DINODE_FMT_BTREE && in xfs_ilock_attr_map_shared()
129 (ip->i_afp->if_flags & XFS_IFEXTENTS) == 0) in xfs_ilock_attr_map_shared()
137 * multi-reader locks: i_mmap_lock and the i_lock. This routine allows
145 * i_rwsem -> i_mmap_lock -> page_lock -> i_ilock
149 * i_rwsem -> page lock -> mmap_lock
150 * mmap_lock -> i_mmap_lock -> page_lock
186 down_write_nested(&VFS_I(ip)->i_rwsem, in xfs_ilock()
189 down_read_nested(&VFS_I(ip)->i_rwsem, in xfs_ilock()
194 mrupdate_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags)); in xfs_ilock()
196 mraccess_nested(&ip->i_mmaplock, XFS_MMAPLOCK_DEP(lock_flags)); in xfs_ilock()
199 mrupdate_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); in xfs_ilock()
201 mraccess_nested(&ip->i_lock, XFS_ILOCK_DEP(lock_flags)); in xfs_ilock()
211 * ip -- the inode being locked
212 * lock_flags -- this parameter indicates the inode's locks to be
237 if (!down_write_trylock(&VFS_I(ip)->i_rwsem)) in xfs_ilock_nowait()
240 if (!down_read_trylock(&VFS_I(ip)->i_rwsem)) in xfs_ilock_nowait()
245 if (!mrtryupdate(&ip->i_mmaplock)) in xfs_ilock_nowait()
248 if (!mrtryaccess(&ip->i_mmaplock)) in xfs_ilock_nowait()
253 if (!mrtryupdate(&ip->i_lock)) in xfs_ilock_nowait()
256 if (!mrtryaccess(&ip->i_lock)) in xfs_ilock_nowait()
263 mrunlock_excl(&ip->i_mmaplock); in xfs_ilock_nowait()
265 mrunlock_shared(&ip->i_mmaplock); in xfs_ilock_nowait()
268 up_write(&VFS_I(ip)->i_rwsem); in xfs_ilock_nowait()
270 up_read(&VFS_I(ip)->i_rwsem); in xfs_ilock_nowait()
281 * ip -- the inode being unlocked
282 * lock_flags -- this parameter indicates the inode's locks to be
307 up_write(&VFS_I(ip)->i_rwsem); in xfs_iunlock()
309 up_read(&VFS_I(ip)->i_rwsem); in xfs_iunlock()
312 mrunlock_excl(&ip->i_mmaplock); in xfs_iunlock()
314 mrunlock_shared(&ip->i_mmaplock); in xfs_iunlock()
317 mrunlock_excl(&ip->i_lock); in xfs_iunlock()
319 mrunlock_shared(&ip->i_lock); in xfs_iunlock()
338 mrdemote(&ip->i_lock); in xfs_ilock_demote()
340 mrdemote(&ip->i_mmaplock); in xfs_ilock_demote()
342 downgrade_write(&VFS_I(ip)->i_rwsem); in xfs_ilock_demote()
355 return !!ip->i_lock.mr_writer; in xfs_isilocked()
356 return rwsem_is_locked(&ip->i_lock.mr_lock); in xfs_isilocked()
361 return !!ip->i_mmaplock.mr_writer; in xfs_isilocked()
362 return rwsem_is_locked(&ip->i_mmaplock.mr_lock); in xfs_isilocked()
368 lockdep_is_held_type(&VFS_I(ip)->i_rwsem, 0); in xfs_isilocked()
369 return rwsem_is_locked(&VFS_I(ip)->i_rwsem); in xfs_isilocked()
437 * xfs_lock_inodes() can only be used to lock one type of lock at a time -
444 struct xfs_inode **ips, in xfs_lock_inodes() argument
458 ASSERT(ips && inodes >= 2 && inodes <= 5); in xfs_lock_inodes()
477 ASSERT(ips[i]); in xfs_lock_inodes()
479 if (i && (ips[i] == ips[i - 1])) /* Already locked */ in xfs_lock_inodes()
487 for (j = (i - 1); j >= 0 && !try_lock; j--) { in xfs_lock_inodes()
488 lp = &ips[j]->i_itemp->ili_item; in xfs_lock_inodes()
489 if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags)) in xfs_lock_inodes()
501 xfs_ilock(ips[i], xfs_lock_inumorder(lock_mode, i)); in xfs_lock_inodes()
507 if (xfs_ilock_nowait(ips[i], xfs_lock_inumorder(lock_mode, i))) in xfs_lock_inodes()
515 for (j = i - 1; j >= 0; j--) { in xfs_lock_inodes()
521 if (j != (i - 1) && ips[j] == ips[j + 1]) in xfs_lock_inodes()
524 xfs_iunlock(ips[j], lock_mode); in xfs_lock_inodes()
537 * xfs_lock_two_inodes() can only be used to lock one type of lock at a time -
540 * violated locking orders. The iolock must be double-locked separately since
569 ASSERT(ip0->i_ino != ip1->i_ino); in xfs_lock_two_inodes()
571 if (ip0->i_ino > ip1->i_ino) { in xfs_lock_two_inodes()
588 lp = &ip0->i_itemp->ili_item; in xfs_lock_two_inodes()
589 if (lp && test_bit(XFS_LI_IN_AIL, &lp->li_flags)) { in xfs_lock_two_inodes()
657 struct xfs_icdinode *dic = &ip->i_d; in xfs_ip2xflags()
659 return _xfs_dic2xflags(dic->di_flags, dic->di_flags2, XFS_IFORK_Q(ip)); in xfs_ip2xflags()
665 * ci_name->name will point to a the actual name (caller must free) or
680 if (XFS_FORCED_SHUTDOWN(dp->i_mount)) in xfs_lookup()
681 return -EIO; in xfs_lookup()
687 error = xfs_iget(dp->i_mount, NULL, inum, 0, 0, ipp); in xfs_lookup()
695 kmem_free(ci_name->name); in xfs_lookup()
708 umode_t mode = VFS_I(ip)->i_mode; in xfs_inode_inherit_flags()
711 if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) in xfs_inode_inherit_flags()
713 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) { in xfs_inode_inherit_flags()
715 ip->i_d.di_extsize = pip->i_d.di_extsize; in xfs_inode_inherit_flags()
717 if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) in xfs_inode_inherit_flags()
720 if ((pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) && in xfs_inode_inherit_flags()
721 xfs_sb_version_hasrealtime(&ip->i_mount->m_sb)) in xfs_inode_inherit_flags()
723 if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) { in xfs_inode_inherit_flags()
725 ip->i_d.di_extsize = pip->i_d.di_extsize; in xfs_inode_inherit_flags()
728 if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) && in xfs_inode_inherit_flags()
731 if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) && in xfs_inode_inherit_flags()
734 if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) && in xfs_inode_inherit_flags()
737 if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) && in xfs_inode_inherit_flags()
740 if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) && in xfs_inode_inherit_flags()
743 if (pip->i_d.di_flags & XFS_DIFLAG_FILESTREAM) in xfs_inode_inherit_flags()
746 ip->i_d.di_flags |= di_flags; in xfs_inode_inherit_flags()
755 if (pip->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) { in xfs_inode_inherit_flags2()
756 ip->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; in xfs_inode_inherit_flags2()
757 ip->i_d.di_cowextsize = pip->i_d.di_cowextsize; in xfs_inode_inherit_flags2()
759 if (pip->i_d.di_flags2 & XFS_DIFLAG2_DAX) in xfs_inode_inherit_flags2()
760 ip->i_d.di_flags2 |= XFS_DIFLAG2_DAX; in xfs_inode_inherit_flags2()
764 * Allocate an inode on disk and return a copy of its in-core version.
765 * The in-core inode is locked exclusively. Set mode, nlink, and rdev
769 * Use xfs_dialloc() to allocate the on-disk inode. If xfs_dialloc()
770 * has a free inode available, call xfs_iget() to obtain the in-core
776 * its supply by doing an allocation. Since we can only do one
791 * are not linked into the directory structure - they are attached
792 * directly to the superblock - and so have no parent.
806 struct xfs_mount *mp = tp->t_mountp; in xfs_ialloc()
816 * the on-disk inode to be allocated. in xfs_ialloc()
818 error = xfs_dialloc(tp, pip ? pip->i_ino : 0, mode, in xfs_ialloc()
830 * xfs_iget checks will catch re-allocation of other active in-memory in xfs_ialloc()
831 * and on-disk inodes. If we don't catch reallocating the parent inode in xfs_ialloc()
835 if ((pip && ino == pip->i_ino) || !xfs_verify_dir_ino(mp, ino)) { in xfs_ialloc()
836 xfs_alert(mp, "Allocated a known in-use inode 0x%llx!", ino); in xfs_ialloc()
837 return -EFSCORRUPTED; in xfs_ialloc()
841 * Get the in-core inode with the lock held exclusively. in xfs_ialloc()
852 inode->i_rdev = rdev; in xfs_ialloc()
853 ip->i_d.di_projid = prid; in xfs_ialloc()
855 if (dir && !(dir->i_mode & S_ISGID) && in xfs_ialloc()
856 (mp->m_flags & XFS_MOUNT_GRPID)) { in xfs_ialloc()
857 inode->i_uid = current_fsuid(); in xfs_ialloc()
858 inode->i_gid = dir->i_gid; in xfs_ialloc()
859 inode->i_mode = mode; in xfs_ialloc()
870 (inode->i_mode & S_ISGID) && !in_group_p(inode->i_gid)) in xfs_ialloc()
871 inode->i_mode &= ~S_ISGID; in xfs_ialloc()
873 ip->i_d.di_size = 0; in xfs_ialloc()
874 ip->i_df.if_nextents = 0; in xfs_ialloc()
875 ASSERT(ip->i_d.di_nblocks == 0); in xfs_ialloc()
878 inode->i_mtime = tv; in xfs_ialloc()
879 inode->i_atime = tv; in xfs_ialloc()
880 inode->i_ctime = tv; in xfs_ialloc()
882 ip->i_d.di_extsize = 0; in xfs_ialloc()
883 ip->i_d.di_dmevmask = 0; in xfs_ialloc()
884 ip->i_d.di_dmstate = 0; in xfs_ialloc()
885 ip->i_d.di_flags = 0; in xfs_ialloc()
887 if (xfs_sb_version_has_v3inode(&mp->m_sb)) { in xfs_ialloc()
889 ip->i_d.di_flags2 = mp->m_ino_geo.new_diflags2; in xfs_ialloc()
890 ip->i_d.di_cowextsize = 0; in xfs_ialloc()
891 ip->i_d.di_crtime = tv; in xfs_ialloc()
900 ip->i_df.if_format = XFS_DINODE_FMT_DEV; in xfs_ialloc()
901 ip->i_df.if_flags = 0; in xfs_ialloc()
906 if (pip && (pip->i_d.di_flags & XFS_DIFLAG_ANY)) in xfs_ialloc()
908 if (pip && (pip->i_d.di_flags2 & XFS_DIFLAG2_ANY)) in xfs_ialloc()
912 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_ialloc()
913 ip->i_df.if_flags = XFS_IFEXTENTS; in xfs_ialloc()
914 ip->i_df.if_bytes = 0; in xfs_ialloc()
915 ip->i_df.if_u1.if_root = NULL; in xfs_ialloc()
938 * to do an allocation to replenish the inode free-list.
965 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_dir_ialloc()
996 return -ENOSPC; in xfs_dir_ialloc()
1000 * If the AGI buffer is non-NULL, then we were unable to get an in xfs_dir_ialloc()
1022 if (tp->t_dqinfo) { in xfs_dir_ialloc()
1023 dqinfo = (void *)tp->t_dqinfo; in xfs_dir_ialloc()
1024 tp->t_dqinfo = NULL; in xfs_dir_ialloc()
1025 tflags = tp->t_flags & XFS_TRANS_DQ_DIRTY; in xfs_dir_ialloc()
1026 tp->t_flags &= ~(XFS_TRANS_DQ_DIRTY); in xfs_dir_ialloc()
1032 * Re-attach the quota info that we detached from prev trx. in xfs_dir_ialloc()
1035 tp->t_dqinfo = dqinfo; in xfs_dir_ialloc()
1036 tp->t_flags |= tflags; in xfs_dir_ialloc()
1089 if (VFS_I(ip)->i_nlink) in xfs_droplink()
1118 struct xfs_mount *mp = dp->i_mount; in xfs_create()
1133 return -EIO; in xfs_create()
1147 resblks = XFS_MKDIR_SPACE_RES(mp, name->len); in xfs_create()
1148 tres = &M_RES(mp)->tr_mkdir; in xfs_create()
1150 resblks = XFS_CREATE_SPACE_RES(mp, name->len); in xfs_create()
1151 tres = &M_RES(mp)->tr_create; in xfs_create()
1161 if (error == -ENOSPC) { in xfs_create()
1199 error = xfs_dir_createname(tp, dp, name, ip->i_ino, in xfs_create()
1200 resblks - XFS_IALLOC_SPACE_RES(mp)); in xfs_create()
1202 ASSERT(error != -ENOSPC); in xfs_create()
1221 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) in xfs_create()
1270 struct xfs_mount *mp = dp->i_mount; in xfs_create_tmpfile()
1282 return -EIO; in xfs_create_tmpfile()
1296 tres = &M_RES(mp)->tr_create_tmpfile; in xfs_create_tmpfile()
1311 if (mp->m_flags & XFS_MOUNT_WSYNC) in xfs_create_tmpfile()
1362 xfs_mount_t *mp = tdp->i_mount; in xfs_link()
1369 ASSERT(!S_ISDIR(VFS_I(sip)->i_mode)); in xfs_link()
1372 return -EIO; in xfs_link()
1382 resblks = XFS_LINK_SPACE_RES(mp, target_name->len); in xfs_link()
1383 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_link, resblks, 0, 0, &tp); in xfs_link()
1384 if (error == -ENOSPC) { in xfs_link()
1386 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_link, 0, 0, 0, &tp); in xfs_link()
1401 if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && in xfs_link()
1402 tdp->i_d.di_projid != sip->i_d.di_projid)) { in xfs_link()
1403 error = -EXDEV; in xfs_link()
1416 if (VFS_I(sip)->i_nlink == 0) { in xfs_link()
1422 error = xfs_dir_createname(tp, tdp, target_name, sip->i_ino, in xfs_link()
1436 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) in xfs_link()
1459 if (dfork->if_bytes == 0 && cfork->if_bytes == 0) in xfs_itruncate_clear_reflink_flags()
1460 ip->i_d.di_flags2 &= ~XFS_DIFLAG2_REFLINK; in xfs_itruncate_clear_reflink_flags()
1461 if (cfork->if_bytes == 0) in xfs_itruncate_clear_reflink_flags()
1494 struct xfs_mount *mp = ip->i_mount; in xfs_itruncate_extents_flags()
1501 ASSERT(!atomic_read(&VFS_I(ip)->i_count) || in xfs_itruncate_extents_flags()
1504 ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); in xfs_itruncate_extents_flags()
1505 ASSERT(ip->i_itemp != NULL); in xfs_itruncate_extents_flags()
1506 ASSERT(ip->i_itemp->ili_lock_flags == 0); in xfs_itruncate_extents_flags()
1529 unmap_len = XFS_MAX_FILEOFF - first_unmap_block + 1; in xfs_itruncate_extents_flags()
1531 ASSERT(tp->t_firstblock == NULLFSBLOCK); in xfs_itruncate_extents_flags()
1554 * Always re-log the inode so that our permanent transaction can keep in xfs_itruncate_extents_flags()
1570 xfs_mount_t *mp = ip->i_mount; in xfs_release()
1573 if (!S_ISREG(VFS_I(ip)->i_mode) || (VFS_I(ip)->i_mode == 0)) in xfs_release()
1576 /* If this is a read-only mount, don't do this (would generate I/O) */ in xfs_release()
1577 if (mp->m_flags & XFS_MOUNT_RDONLY) in xfs_release()
1588 * truncate down, buffered (re-)write (delalloc), followed by in xfs_release()
1596 if (ip->i_delayed_blks > 0) { in xfs_release()
1597 error = filemap_flush(VFS_I(ip)->i_mapping); in xfs_release()
1604 if (VFS_I(ip)->i_nlink == 0) in xfs_release()
1640 if (ip->i_delayed_blks) in xfs_release()
1655 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_truncate()
1659 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); in xfs_inactive_truncate()
1672 ip->i_d.di_size = 0; in xfs_inactive_truncate()
1679 ASSERT(ip->i_df.if_nextents == 0); in xfs_inactive_truncate()
1704 struct xfs_mount *mp = ip->i_mount; in xfs_inactive_ifree()
1709 * We try to use a per-AG reservation for any block needed by the finobt in xfs_inactive_ifree()
1710 * tree, but as the finobt feature predates the per-AG reservation in xfs_inactive_ifree()
1719 if (unlikely(mp->m_finobt_nores)) { in xfs_inactive_ifree()
1720 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ifree, in xfs_inactive_ifree()
1724 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ifree, 0, 0, 0, &tp); in xfs_inactive_ifree()
1727 if (error == -ENOSPC) { in xfs_inactive_ifree()
1748 * operations - we freed the inode and hence reallocation is required in xfs_inactive_ifree()
1780 xfs_trans_mod_dquot_byino(tp, ip, XFS_TRANS_DQ_ICOUNT, -1); in xfs_inactive_ifree()
1799 * now be truncated. Also, we clear all of the read-ahead state
1814 if (VFS_I(ip)->i_mode == 0) { in xfs_inactive()
1815 ASSERT(ip->i_df.if_broot_bytes == 0); in xfs_inactive()
1819 mp = ip->i_mount; in xfs_inactive()
1822 /* If this is a read-only mount, don't do this (would generate I/O) */ in xfs_inactive()
1823 if (mp->m_flags & XFS_MOUNT_RDONLY) in xfs_inactive()
1830 if (VFS_I(ip)->i_nlink != 0) { in xfs_inactive()
1833 * cache. Post-eof blocks must be freed, lest we end up with in xfs_inactive()
1846 if (S_ISREG(VFS_I(ip)->i_mode) && in xfs_inactive()
1847 (ip->i_d.di_size != 0 || XFS_ISIZE(ip) != 0 || in xfs_inactive()
1848 ip->i_df.if_nextents > 0 || ip->i_delayed_blks > 0)) in xfs_inactive()
1855 if (S_ISLNK(VFS_I(ip)->i_mode)) in xfs_inactive()
1865 * attribute fork. If also blows away the in-core attribute fork. in xfs_inactive()
1873 ASSERT(!ip->i_afp); in xfs_inactive()
1874 ASSERT(ip->i_d.di_forkoff == 0); in xfs_inactive()
1890 * In-Core Unlinked List Lookups
1895 * file descriptor but not linked from anywhere in the on-disk directory tree
1897 * maintains links to these inodes so that on-disk metadata are consistent.
1899 * XFS implements a per-AG on-disk hash table of unlinked inodes. The AGI
1902 * singly-linked list causes scaling problems in the iunlink remove function
1909 * slow list walk. That's exactly what we do here (in-core) with a per-AG
1933 const xfs_agino_t *key = arg->key; in xfs_iunlink_obj_cmpfn()
1936 if (iu->iu_next_unlinked != *key) in xfs_iunlink_obj_cmpfn()
1962 iu = rhashtable_lookup_fast(&pag->pagi_unlinked_hash, &agino, in xfs_iunlink_lookup_backref()
1964 return iu ? iu->iu_agino : NULLAGINO; in xfs_iunlink_lookup_backref()
1979 error = rhashtable_insert_fast(&pag->pagi_unlinked_hash, in xfs_iunlink_insert_backref()
1980 &iu->iu_rhash_head, xfs_iunlink_hash_params); in xfs_iunlink_insert_backref()
1983 * corruption of in-memory data. Also fail loudly if we see an error in xfs_iunlink_insert_backref()
1988 WARN(error != -ENOMEM, "iunlink cache insert error %d", error); in xfs_iunlink_insert_backref()
1995 if (error != 0 && error != -EEXIST) in xfs_iunlink_insert_backref()
2009 if (XFS_TEST_ERROR(false, pag->pag_mount, XFS_ERRTAG_IUNLINK_FALLBACK)) in xfs_iunlink_add_backref()
2013 iu->iu_agino = prev_agino; in xfs_iunlink_add_backref()
2014 iu->iu_next_unlinked = this_agino; in xfs_iunlink_add_backref()
2034 iu = rhashtable_lookup_fast(&pag->pagi_unlinked_hash, &agino, in xfs_iunlink_change_backref()
2047 error = rhashtable_remove_fast(&pag->pagi_unlinked_hash, in xfs_iunlink_change_backref()
2048 &iu->iu_rhash_head, xfs_iunlink_hash_params); in xfs_iunlink_change_backref()
2058 /* Update the entry and re-add it to the hash table. */ in xfs_iunlink_change_backref()
2059 iu->iu_next_unlinked = next_unlinked; in xfs_iunlink_change_backref()
2063 /* Set up the in-core predecessor structures. */
2068 return rhashtable_init(&pag->pagi_unlinked_hash, in xfs_iunlink_init()
2072 /* Free the in-core predecessor structures. */
2091 rhashtable_free_and_destroy(&pag->pagi_unlinked_hash, in xfs_iunlink_destroy()
2094 ASSERT(freed_anything == false || XFS_FORCED_SHUTDOWN(pag->pag_mount)); in xfs_iunlink_destroy()
2109 struct xfs_agi *agi = agibp->b_addr; in xfs_iunlink_update_bucket()
2113 ASSERT(xfs_verify_agino_or_null(tp->t_mountp, agno, new_agino)); in xfs_iunlink_update_bucket()
2115 old_value = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink_update_bucket()
2116 trace_xfs_iunlink_update_bucket(tp->t_mountp, agno, bucket_index, in xfs_iunlink_update_bucket()
2126 return -EFSCORRUPTED; in xfs_iunlink_update_bucket()
2129 agi->agi_unlinked[bucket_index] = cpu_to_be32(new_agino); in xfs_iunlink_update_bucket()
2132 xfs_trans_log_buf(tp, agibp, offset, offset + sizeof(xfs_agino_t) - 1); in xfs_iunlink_update_bucket()
2136 /* Set an on-disk inode's next_unlinked pointer. */
2147 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_update_dinode()
2153 be32_to_cpu(dip->di_next_unlinked), next_agino); in xfs_iunlink_update_dinode()
2155 dip->di_next_unlinked = cpu_to_be32(next_agino); in xfs_iunlink_update_dinode()
2156 offset = imap->im_boffset + in xfs_iunlink_update_dinode()
2162 xfs_trans_log_buf(tp, ibp, offset, offset + sizeof(xfs_agino_t) - 1); in xfs_iunlink_update_dinode()
2165 /* Set an in-core inode's unlinked pointer and return the old value. */
2174 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_update_inode()
2182 error = xfs_imap_to_bp(mp, tp, &ip->i_imap, &dip, &ibp, 0); in xfs_iunlink_update_inode()
2187 old_value = be32_to_cpu(dip->di_next_unlinked); in xfs_iunlink_update_inode()
2189 xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, dip, in xfs_iunlink_update_inode()
2191 error = -EFSCORRUPTED; in xfs_iunlink_update_inode()
2203 xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, in xfs_iunlink_update_inode()
2205 error = -EFSCORRUPTED; in xfs_iunlink_update_inode()
2211 xfs_iunlink_update_dinode(tp, agno, XFS_INO_TO_AGINO(mp, ip->i_ino), in xfs_iunlink_update_inode()
2212 ibp, dip, &ip->i_imap, next_agino); in xfs_iunlink_update_inode()
2223 * We place the on-disk inode on a list in the AGI. It will be pulled from this
2231 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink()
2235 xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino); in xfs_iunlink()
2236 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink()
2240 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_iunlink()
2241 ASSERT(VFS_I(ip)->i_mode != 0); in xfs_iunlink()
2248 agi = agibp->b_addr; in xfs_iunlink()
2255 next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink()
2259 return -EFSCORRUPTED; in xfs_iunlink()
2279 error = xfs_iunlink_add_backref(agibp->b_pag, agino, next_agino); in xfs_iunlink()
2298 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_map_ino()
2301 imap->im_blkno = 0; in xfs_iunlink_map_ino()
2341 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_map_prev()
2355 if (be32_to_cpu((*dipp)->di_next_unlinked) == target_agino) in xfs_iunlink_map_prev()
2383 unlinked_agino = be32_to_cpu((*dipp)->di_next_unlinked); in xfs_iunlink_map_prev()
2393 error = -EFSCORRUPTED; in xfs_iunlink_map_prev()
2403 * Pull the on-disk inode from the AGI unlinked list.
2410 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_remove()
2415 xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino); in xfs_iunlink_remove()
2416 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink_remove()
2428 agi = agibp->b_addr; in xfs_iunlink_remove()
2434 head_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink_remove()
2438 return -EFSCORRUPTED; in xfs_iunlink_remove()
2458 error = xfs_iunlink_change_backref(agibp->b_pag, next_agino, in xfs_iunlink_remove()
2471 agibp->b_pag); in xfs_iunlink_remove()
2487 return xfs_iunlink_change_backref(agibp->b_pag, agino, in xfs_iunlink_remove()
2507 struct xfs_mount *mp = bp->b_mount; in xfs_ifree_mark_inode_stale()
2508 struct xfs_perag *pag = bp->b_pag; in xfs_ifree_mark_inode_stale()
2514 ip = radix_tree_lookup(&pag->pag_ici_root, XFS_INO_TO_AGINO(mp, inum)); in xfs_ifree_mark_inode_stale()
2528 spin_lock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2529 if (ip->i_ino != inum || __xfs_iflags_test(ip, XFS_ISTALE)) in xfs_ifree_mark_inode_stale()
2540 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2546 ip->i_flags |= XFS_ISTALE; in xfs_ifree_mark_inode_stale()
2553 iip = ip->i_itemp; in xfs_ifree_mark_inode_stale()
2555 ASSERT(!list_empty(&iip->ili_item.li_bio_list)); in xfs_ifree_mark_inode_stale()
2556 ASSERT(iip->ili_last_fields); in xfs_ifree_mark_inode_stale()
2566 if (!iip || list_empty(&iip->ili_item.li_bio_list)) in xfs_ifree_mark_inode_stale()
2570 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2574 spin_lock(&iip->ili_lock); in xfs_ifree_mark_inode_stale()
2575 iip->ili_last_fields = iip->ili_fields; in xfs_ifree_mark_inode_stale()
2576 iip->ili_fields = 0; in xfs_ifree_mark_inode_stale()
2577 iip->ili_fsync_fields = 0; in xfs_ifree_mark_inode_stale()
2578 spin_unlock(&iip->ili_lock); in xfs_ifree_mark_inode_stale()
2579 ASSERT(iip->ili_last_fields); in xfs_ifree_mark_inode_stale()
2589 spin_unlock(&ip->i_flags_lock); in xfs_ifree_mark_inode_stale()
2595 * inodes that are in memory - they all must be marked stale and attached to
2604 struct xfs_mount *mp = free_ip->i_mount; in xfs_ifree_cluster()
2608 xfs_ino_t inum = xic->first_ino; in xfs_ifree_cluster()
2614 nbufs = igeo->ialloc_blks / igeo->blocks_per_cluster; in xfs_ifree_cluster()
2616 for (j = 0; j < nbufs; j++, inum += igeo->inodes_per_cluster) { in xfs_ifree_cluster()
2622 ioffset = inum - xic->first_ino; in xfs_ifree_cluster()
2623 if ((xic->alloc & XFS_INOBT_MASK(ioffset)) == 0) { in xfs_ifree_cluster()
2624 ASSERT(ioffset % igeo->inodes_per_cluster == 0); in xfs_ifree_cluster()
2636 * If we scan the in-memory inodes first, then buffer IO can in xfs_ifree_cluster()
2640 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, in xfs_ifree_cluster()
2641 mp->m_bsize * igeo->blocks_per_cluster, in xfs_ifree_cluster()
2655 bp->b_ops = &xfs_inode_buf_ops; in xfs_ifree_cluster()
2662 for (i = 0; i < igeo->inodes_per_cluster; i++) in xfs_ifree_cluster()
2676 * The on-disk copy of the inode will have been added to the list of unlinked
2687 struct xfs_inode_log_item *iip = ip->i_itemp; in xfs_ifree()
2690 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_ifree()
2691 ASSERT(ip->i_df.if_nextents == 0); in xfs_ifree()
2692 ASSERT(ip->i_d.di_size == 0 || !S_ISREG(VFS_I(ip)->i_mode)); in xfs_ifree()
2693 ASSERT(ip->i_d.di_nblocks == 0); in xfs_ifree()
2698 * makes the AGI lock -> unlinked list modification order the same as in xfs_ifree()
2701 error = xfs_difree(tp, ip->i_ino, &xic); in xfs_ifree()
2710 * Free any local-format data sitting around before we reset the in xfs_ifree()
2714 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { in xfs_ifree()
2715 kmem_free(ip->i_df.if_u1.if_data); in xfs_ifree()
2716 ip->i_df.if_u1.if_data = NULL; in xfs_ifree()
2717 ip->i_df.if_bytes = 0; in xfs_ifree()
2720 VFS_I(ip)->i_mode = 0; /* mark incore inode as free */ in xfs_ifree()
2721 ip->i_d.di_flags = 0; in xfs_ifree()
2722 ip->i_d.di_flags2 = ip->i_mount->m_ino_geo.new_diflags2; in xfs_ifree()
2723 ip->i_d.di_dmevmask = 0; in xfs_ifree()
2724 ip->i_d.di_forkoff = 0; /* mark the attr fork not in use */ in xfs_ifree()
2725 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_ifree()
2728 spin_lock(&iip->ili_lock); in xfs_ifree()
2729 iip->ili_fields &= ~(XFS_ILOG_AOWNER | XFS_ILOG_DOWNER); in xfs_ifree()
2730 spin_unlock(&iip->ili_lock); in xfs_ifree()
2736 VFS_I(ip)->i_generation++; in xfs_ifree()
2759 xfs_log_force_seq(ip->i_mount, ip->i_itemp->ili_commit_seq, 0, NULL); in xfs_iunpin()
2767 wait_queue_head_t *wq = bit_waitqueue(&ip->i_flags, __XFS_IPINNED_BIT); in __xfs_iunpin_wait()
2768 DEFINE_WAIT_BIT(wait, &ip->i_flags, __XFS_IPINNED_BIT); in __xfs_iunpin_wait()
2796 * locking - inode allocation locks the AGI, then can allocate a new extent for
2809 * This is still safe from a transactional point of view - it is not until we
2821 xfs_mount_t *mp = dp->i_mount; in xfs_remove()
2823 int is_dir = S_ISDIR(VFS_I(ip)->i_mode); in xfs_remove()
2830 return -EIO; in xfs_remove()
2850 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_remove, resblks, 0, 0, &tp); in xfs_remove()
2851 if (error == -ENOSPC) { in xfs_remove()
2853 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_remove, 0, 0, 0, in xfs_remove()
2857 ASSERT(error != -ENOSPC); in xfs_remove()
2870 ASSERT(VFS_I(ip)->i_nlink >= 2); in xfs_remove()
2871 if (VFS_I(ip)->i_nlink != 2) { in xfs_remove()
2872 error = -ENOTEMPTY; in xfs_remove()
2876 error = -ENOTEMPTY; in xfs_remove()
2891 * When removing a non-directory we need to log the parent in xfs_remove()
2904 error = xfs_dir_removename(tp, dp, name, ip->i_ino, resblks); in xfs_remove()
2906 ASSERT(error != -ENOENT); in xfs_remove()
2915 if (mp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) in xfs_remove()
2975 if (i_tab[j]->i_ino < i_tab[j-1]->i_ino) { in xfs_sort_for_rename()
2977 i_tab[j] = i_tab[j-1]; in xfs_sort_for_rename()
2978 i_tab[j-1] = temp; in xfs_sort_for_rename()
2992 if (tp->t_mountp->m_flags & (XFS_MOUNT_WSYNC|XFS_MOUNT_DIRSYNC)) in xfs_finish_rename()
3020 error = xfs_dir_replace(tp, dp1, name1, ip2->i_ino, spaceres); in xfs_cross_rename()
3025 error = xfs_dir_replace(tp, dp2, name2, ip1->i_ino, spaceres); in xfs_cross_rename()
3037 if (S_ISDIR(VFS_I(ip2)->i_mode)) { in xfs_cross_rename()
3039 dp1->i_ino, spaceres); in xfs_cross_rename()
3044 if (!S_ISDIR(VFS_I(ip1)->i_mode)) { in xfs_cross_rename()
3061 if (S_ISDIR(VFS_I(ip1)->i_mode)) { in xfs_cross_rename()
3063 dp2->i_ino, spaceres); in xfs_cross_rename()
3068 if (!S_ISDIR(VFS_I(ip2)->i_mode)) { in xfs_cross_rename()
3134 VFS_I(tmpfile)->i_state |= I_LINKABLE; in xfs_rename_alloc_whiteout()
3153 struct xfs_mount *mp = src_dp->i_mount; in xfs_rename()
3160 bool src_is_directory = S_ISDIR(VFS_I(src_ip)->i_mode); in xfs_rename()
3167 return -EINVAL; in xfs_rename()
3180 src_name->type = XFS_DIR3_FT_CHRDEV; in xfs_rename()
3186 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); in xfs_rename()
3187 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, spaceres, 0, 0, &tp); in xfs_rename()
3188 if (error == -ENOSPC) { in xfs_rename()
3190 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_rename, 0, 0, 0, in xfs_rename()
3230 if (unlikely((target_dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) && in xfs_rename()
3231 target_dp->i_d.di_projid != src_ip->i_d.di_projid)) { in xfs_rename()
3232 error = -EXDEV; in xfs_rename()
3261 if (S_ISDIR(VFS_I(target_ip)->i_mode) && in xfs_rename()
3263 (VFS_I(target_ip)->i_nlink > 2))) { in xfs_rename()
3264 error = -EEXIST; in xfs_rename()
3282 (VFS_I(target_ip)->i_nlink == 1 || src_is_directory))) { in xfs_rename()
3286 agno = XFS_INO_TO_AGNO(mp, inodes[i]->i_ino); in xfs_rename()
3306 ASSERT(VFS_I(wip)->i_nlink == 0); in xfs_rename()
3312 VFS_I(wip)->i_state &= ~I_LINKABLE; in xfs_rename()
3325 src_ip->i_ino, spaceres); in xfs_rename()
3346 src_ip->i_ino, spaceres); in xfs_rename()
3380 target_dp->i_ino, spaceres); in xfs_rename()
3381 ASSERT(error != -EEXIST); in xfs_rename()
3418 error = xfs_dir_replace(tp, src_dp, src_name, wip->i_ino, in xfs_rename()
3421 error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino, in xfs_rename()
3449 struct xfs_inode_log_item *iip = ip->i_itemp; in xfs_iflush()
3451 struct xfs_mount *mp = ip->i_mount; in xfs_iflush()
3456 ASSERT(ip->i_df.if_format != XFS_DINODE_FMT_BTREE || in xfs_iflush()
3457 ip->i_df.if_nextents > XFS_IFORK_MAXEXT(ip, XFS_DATA_FORK)); in xfs_iflush()
3458 ASSERT(iip->ili_item.li_buf == bp); in xfs_iflush()
3460 dip = xfs_buf_offset(bp, ip->i_imap.im_boffset); in xfs_iflush()
3468 error = -EFSCORRUPTED; in xfs_iflush()
3469 if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC), in xfs_iflush()
3473 __func__, ip->i_ino, be16_to_cpu(dip->di_magic), dip); in xfs_iflush()
3476 if (S_ISREG(VFS_I(ip)->i_mode)) { in xfs_iflush()
3478 ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS && in xfs_iflush()
3479 ip->i_df.if_format != XFS_DINODE_FMT_BTREE, in xfs_iflush()
3483 __func__, ip->i_ino, ip); in xfs_iflush()
3486 } else if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_iflush()
3488 ip->i_df.if_format != XFS_DINODE_FMT_EXTENTS && in xfs_iflush()
3489 ip->i_df.if_format != XFS_DINODE_FMT_BTREE && in xfs_iflush()
3490 ip->i_df.if_format != XFS_DINODE_FMT_LOCAL, in xfs_iflush()
3494 __func__, ip->i_ino, ip); in xfs_iflush()
3498 if (XFS_TEST_ERROR(ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp) > in xfs_iflush()
3499 ip->i_d.di_nblocks, mp, XFS_ERRTAG_IFLUSH_5)) { in xfs_iflush()
3503 __func__, ip->i_ino, in xfs_iflush()
3504 ip->i_df.if_nextents + xfs_ifork_nextents(ip->i_afp), in xfs_iflush()
3505 ip->i_d.di_nblocks, ip); in xfs_iflush()
3508 if (XFS_TEST_ERROR(ip->i_d.di_forkoff > mp->m_sb.sb_inodesize, in xfs_iflush()
3512 __func__, ip->i_ino, ip->i_d.di_forkoff, ip); in xfs_iflush()
3525 if (!xfs_sb_version_has_v3inode(&mp->m_sb)) in xfs_iflush()
3526 ip->i_d.di_flushiter++; in xfs_iflush()
3532 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL && in xfs_iflush()
3535 if (ip->i_afp && ip->i_afp->if_format == XFS_DINODE_FMT_LOCAL && in xfs_iflush()
3540 * Copy the dirty parts of the inode into the on-disk inode. We always in xfs_iflush()
3544 xfs_inode_to_disk(ip, dip, iip->ili_item.li_lsn); in xfs_iflush()
3547 if (ip->i_d.di_flushiter == DI_MAX_FLUSH) in xfs_iflush()
3548 ip->i_d.di_flushiter = 0; in xfs_iflush()
3560 * after re-logging only part of it, and in the face of a crash we in xfs_iflush()
3572 spin_lock(&iip->ili_lock); in xfs_iflush()
3573 iip->ili_last_fields = iip->ili_fields; in xfs_iflush()
3574 iip->ili_fields = 0; in xfs_iflush()
3575 iip->ili_fsync_fields = 0; in xfs_iflush()
3576 spin_unlock(&iip->ili_lock); in xfs_iflush()
3582 xfs_trans_ail_copy_lsn(mp->m_ail, &iip->ili_flush_lsn, in xfs_iflush()
3583 &iip->ili_item.li_lsn); in xfs_iflush()
3591 * Non-blocking flush of dirty inode metadata into the backing buffer.
3598 * buffer and release it. If no inodes are flushed, -EAGAIN will be returned and
3607 struct xfs_mount *mp = bp->b_mount; in xfs_iflush_cluster()
3618 list_for_each_entry_safe(lip, n, &bp->b_li_list, li_bio_list) { in xfs_iflush_cluster()
3620 ip = iip->ili_inode; in xfs_iflush_cluster()
3637 spin_lock(&ip->i_flags_lock); in xfs_iflush_cluster()
3640 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3651 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3655 spin_unlock(&ip->i_flags_lock); in xfs_iflush_cluster()
3668 error = -EIO; in xfs_iflush_cluster()
3690 bp->b_flags |= XBF_ASYNC; in xfs_iflush_cluster()
3697 return -EAGAIN; in xfs_iflush_cluster()
3725 seq = ip->i_itemp->ili_commit_seq; in xfs_log_force_inode()
3730 return xfs_log_force_seq(ip->i_mount, seq, XFS_LOG_SYNC, NULL); in xfs_log_force_inode()
3766 if (error == -EWOULDBLOCK) in xfs_iolock_two_inodes_and_break_layout()
3780 if (error == -EWOULDBLOCK) in xfs_iolock_two_inodes_and_break_layout()