Lines Matching +full:tp +full:- +full:link
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2006 Silicon Graphics, Inc.
34 (ip->i_diflags & XFS_DIFLAG_PREALLOC); in xfs_flags2diflags()
50 if (S_ISDIR(VFS_I(ip)->i_mode)) { in xfs_flags2diflags()
59 } else if (S_ISREG(VFS_I(ip)->i_mode)) { in xfs_flags2diflags()
75 (ip->i_diflags2 & (XFS_DIFLAG2_REFLINK | in xfs_flags2diflags2()
93 if (ip->i_diflags & XFS_DIFLAG_ANY) { in xfs_ip2xflags()
94 if (ip->i_diflags & XFS_DIFLAG_REALTIME) in xfs_ip2xflags()
96 if (ip->i_diflags & XFS_DIFLAG_PREALLOC) in xfs_ip2xflags()
98 if (ip->i_diflags & XFS_DIFLAG_IMMUTABLE) in xfs_ip2xflags()
100 if (ip->i_diflags & XFS_DIFLAG_APPEND) in xfs_ip2xflags()
102 if (ip->i_diflags & XFS_DIFLAG_SYNC) in xfs_ip2xflags()
104 if (ip->i_diflags & XFS_DIFLAG_NOATIME) in xfs_ip2xflags()
106 if (ip->i_diflags & XFS_DIFLAG_NODUMP) in xfs_ip2xflags()
108 if (ip->i_diflags & XFS_DIFLAG_RTINHERIT) in xfs_ip2xflags()
110 if (ip->i_diflags & XFS_DIFLAG_PROJINHERIT) in xfs_ip2xflags()
112 if (ip->i_diflags & XFS_DIFLAG_NOSYMLINKS) in xfs_ip2xflags()
114 if (ip->i_diflags & XFS_DIFLAG_EXTSIZE) in xfs_ip2xflags()
116 if (ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) in xfs_ip2xflags()
118 if (ip->i_diflags & XFS_DIFLAG_NODEFRAG) in xfs_ip2xflags()
120 if (ip->i_diflags & XFS_DIFLAG_FILESTREAM) in xfs_ip2xflags()
124 if (ip->i_diflags2 & XFS_DIFLAG2_ANY) { in xfs_ip2xflags()
125 if (ip->i_diflags2 & XFS_DIFLAG2_DAX) in xfs_ip2xflags()
127 if (ip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) in xfs_ip2xflags()
139 if (dp->i_diflags & XFS_DIFLAG_PROJINHERIT) in xfs_get_initial_prid()
140 return dp->i_projid; in xfs_get_initial_prid()
154 umode_t mode = VFS_I(ip)->i_mode; in xfs_inode_inherit_flags()
157 if (pip->i_diflags & XFS_DIFLAG_RTINHERIT) in xfs_inode_inherit_flags()
159 if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) { in xfs_inode_inherit_flags()
161 ip->i_extsize = pip->i_extsize; in xfs_inode_inherit_flags()
163 if (pip->i_diflags & XFS_DIFLAG_PROJINHERIT) in xfs_inode_inherit_flags()
166 if ((pip->i_diflags & XFS_DIFLAG_RTINHERIT) && in xfs_inode_inherit_flags()
167 xfs_has_realtime(ip->i_mount)) in xfs_inode_inherit_flags()
169 if (pip->i_diflags & XFS_DIFLAG_EXTSZINHERIT) { in xfs_inode_inherit_flags()
171 ip->i_extsize = pip->i_extsize; in xfs_inode_inherit_flags()
174 if ((pip->i_diflags & XFS_DIFLAG_NOATIME) && in xfs_inode_inherit_flags()
177 if ((pip->i_diflags & XFS_DIFLAG_NODUMP) && in xfs_inode_inherit_flags()
180 if ((pip->i_diflags & XFS_DIFLAG_SYNC) && in xfs_inode_inherit_flags()
183 if ((pip->i_diflags & XFS_DIFLAG_NOSYMLINKS) && in xfs_inode_inherit_flags()
186 if ((pip->i_diflags & XFS_DIFLAG_NODEFRAG) && in xfs_inode_inherit_flags()
189 if (pip->i_diflags & XFS_DIFLAG_FILESTREAM) in xfs_inode_inherit_flags()
192 ip->i_diflags |= di_flags; in xfs_inode_inherit_flags()
204 failaddr = xfs_inode_validate_extsize(ip->i_mount, ip->i_extsize, in xfs_inode_inherit_flags()
205 VFS_I(ip)->i_mode, ip->i_diflags); in xfs_inode_inherit_flags()
207 ip->i_diflags &= ~(XFS_DIFLAG_EXTSIZE | in xfs_inode_inherit_flags()
209 ip->i_extsize = 0; in xfs_inode_inherit_flags()
221 if (pip->i_diflags2 & XFS_DIFLAG2_COWEXTSIZE) { in xfs_inode_inherit_flags2()
222 ip->i_diflags2 |= XFS_DIFLAG2_COWEXTSIZE; in xfs_inode_inherit_flags2()
223 ip->i_cowextsize = pip->i_cowextsize; in xfs_inode_inherit_flags2()
225 if (pip->i_diflags2 & XFS_DIFLAG2_DAX) in xfs_inode_inherit_flags2()
226 ip->i_diflags2 |= XFS_DIFLAG2_DAX; in xfs_inode_inherit_flags2()
229 failaddr = xfs_inode_validate_cowextsize(ip->i_mount, ip->i_cowextsize, in xfs_inode_inherit_flags2()
230 VFS_I(ip)->i_mode, ip->i_diflags, ip->i_diflags2); in xfs_inode_inherit_flags2()
232 ip->i_diflags2 &= ~XFS_DIFLAG2_COWEXTSIZE; in xfs_inode_inherit_flags2()
233 ip->i_cowextsize = 0; in xfs_inode_inherit_flags2()
253 if (args->flags & XFS_ICREATE_INIT_XATTRS) in xfs_icreate_want_attrfork()
256 if (!(args->flags & XFS_ICREATE_UNLINKABLE) && xfs_has_parent(mp)) in xfs_icreate_want_attrfork()
265 struct xfs_trans *tp, in xfs_inode_init() argument
269 struct xfs_inode *pip = args->pip; in xfs_inode_init()
271 struct xfs_mount *mp = tp->t_mountp; in xfs_inode_init()
277 if (args->flags & XFS_ICREATE_TMPFILE) in xfs_inode_init()
279 else if (S_ISDIR(args->mode)) in xfs_inode_init()
283 inode->i_rdev = args->rdev; in xfs_inode_init()
285 if (!args->idmap || pip == NULL) { in xfs_inode_init()
287 inode->i_uid = GLOBAL_ROOT_UID; in xfs_inode_init()
288 inode->i_gid = GLOBAL_ROOT_GID; in xfs_inode_init()
289 ip->i_projid = 0; in xfs_inode_init()
290 inode->i_mode = args->mode; in xfs_inode_init()
293 if (dir && !(dir->i_mode & S_ISGID) && xfs_has_grpid(mp)) { in xfs_inode_init()
294 inode_fsuid_set(inode, args->idmap); in xfs_inode_init()
295 inode->i_gid = dir->i_gid; in xfs_inode_init()
296 inode->i_mode = args->mode; in xfs_inode_init()
298 inode_init_owner(args->idmap, inode, dir, args->mode); in xfs_inode_init()
307 if (irix_sgid_inherit && (inode->i_mode & S_ISGID) && in xfs_inode_init()
308 !vfsgid_in_group_p(i_gid_into_vfsgid(args->idmap, inode))) in xfs_inode_init()
309 inode->i_mode &= ~S_ISGID; in xfs_inode_init()
311 ip->i_projid = xfs_get_initial_prid(pip); in xfs_inode_init()
314 ip->i_disk_size = 0; in xfs_inode_init()
315 ip->i_df.if_nextents = 0; in xfs_inode_init()
316 ASSERT(ip->i_nblocks == 0); in xfs_inode_init()
318 ip->i_extsize = 0; in xfs_inode_init()
319 ip->i_diflags = 0; in xfs_inode_init()
323 ip->i_cowextsize = 0; in xfs_inode_init()
327 xfs_trans_ichgtime(tp, ip, times); in xfs_inode_init()
330 switch (args->mode & S_IFMT) { in xfs_inode_init()
335 ip->i_df.if_format = XFS_DINODE_FMT_DEV; in xfs_inode_init()
340 if (pip && (pip->i_diflags & XFS_DIFLAG_ANY)) in xfs_inode_init()
342 if (pip && (pip->i_diflags2 & XFS_DIFLAG2_ANY)) in xfs_inode_init()
346 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_inode_init()
347 ip->i_df.if_bytes = 0; in xfs_inode_init()
348 ip->i_df.if_data = NULL; in xfs_inode_init()
355 ip->i_forkoff = xfs_default_attroffset(ip) >> 3; in xfs_inode_init()
359 spin_lock(&mp->m_sb_lock); in xfs_inode_init()
361 spin_unlock(&mp->m_sb_lock); in xfs_inode_init()
362 xfs_log_sb(tp); in xfs_inode_init()
366 xfs_trans_log_inode(tp, ip, flags); in xfs_inode_init()
370 * In-Core Unlinked List Lookups
375 * file descriptor but not linked from anywhere in the on-disk directory tree
377 * maintains links to these inodes so that on-disk metadata are consistent.
379 * XFS implements a per-AG on-disk hash table of unlinked inodes. The AGI
382 * singly-linked list causes scaling problems in the iunlink remove function
386 * Hence we keep an in-memory double linked list to link each inode on an
403 * Update the prev pointer of the next agino. Returns -ENOLINK if the inode
420 return -ENOLINK; in xfs_iunlink_update_backref()
422 ip->i_prev_unlinked = prev_agino; in xfs_iunlink_update_backref()
432 struct xfs_trans *tp, in xfs_iunlink_update_bucket() argument
438 struct xfs_agi *agi = agibp->b_addr; in xfs_iunlink_update_bucket()
444 old_value = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink_update_bucket()
445 trace_xfs_iunlink_update_bucket(tp->t_mountp, pag->pag_agno, bucket_index, in xfs_iunlink_update_bucket()
456 return -EFSCORRUPTED; in xfs_iunlink_update_bucket()
459 agi->agi_unlinked[bucket_index] = cpu_to_be32(new_agino); in xfs_iunlink_update_bucket()
462 xfs_trans_log_buf(tp, agibp, offset, offset + sizeof(xfs_agino_t) - 1); in xfs_iunlink_update_bucket()
468 struct xfs_trans *tp, in xfs_iunlink_insert_inode() argument
473 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_insert_inode()
474 struct xfs_agi *agi = agibp->b_addr; in xfs_iunlink_insert_inode()
476 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink_insert_inode()
485 next_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink_insert_inode()
490 return -EFSCORRUPTED; in xfs_iunlink_insert_inode()
498 if (error == -ENOLINK) in xfs_iunlink_insert_inode()
499 error = xfs_iunlink_reload_next(tp, agibp, agino, next_agino); in xfs_iunlink_insert_inode()
508 error = xfs_iunlink_log_inode(tp, ip, pag, next_agino); in xfs_iunlink_insert_inode()
511 ip->i_next_unlinked = next_agino; in xfs_iunlink_insert_inode()
515 ip->i_prev_unlinked = NULLAGINO; in xfs_iunlink_insert_inode()
516 return xfs_iunlink_update_bucket(tp, pag, agibp, bucket_index, agino); in xfs_iunlink_insert_inode()
520 * This is called when the inode's link count has gone to 0 or we are creating
523 * We place the on-disk inode on a list in the AGI. It will be pulled from this
528 struct xfs_trans *tp, in xfs_iunlink() argument
531 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink()
536 ASSERT(VFS_I(ip)->i_nlink == 0); in xfs_iunlink()
537 ASSERT(VFS_I(ip)->i_mode != 0); in xfs_iunlink()
540 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); in xfs_iunlink()
543 error = xfs_read_agi(pag, tp, 0, &agibp); in xfs_iunlink()
547 error = xfs_iunlink_insert_inode(tp, pag, agibp, ip); in xfs_iunlink()
555 struct xfs_trans *tp, in xfs_iunlink_remove_inode() argument
560 struct xfs_mount *mp = tp->t_mountp; in xfs_iunlink_remove_inode()
561 struct xfs_agi *agi = agibp->b_addr; in xfs_iunlink_remove_inode()
562 xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino); in xfs_iunlink_remove_inode()
573 head_agino = be32_to_cpu(agi->agi_unlinked[bucket_index]); in xfs_iunlink_remove_inode()
578 return -EFSCORRUPTED; in xfs_iunlink_remove_inode()
586 error = xfs_iunlink_log_inode(tp, ip, pag, NULLAGINO); in xfs_iunlink_remove_inode()
594 error = xfs_iunlink_update_backref(pag, ip->i_prev_unlinked, in xfs_iunlink_remove_inode()
595 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
596 if (error == -ENOLINK) in xfs_iunlink_remove_inode()
597 error = xfs_iunlink_reload_next(tp, agibp, ip->i_prev_unlinked, in xfs_iunlink_remove_inode()
598 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
605 prev_ip = xfs_iunlink_lookup(pag, ip->i_prev_unlinked); in xfs_iunlink_remove_inode()
608 return -EFSCORRUPTED; in xfs_iunlink_remove_inode()
611 error = xfs_iunlink_log_inode(tp, prev_ip, pag, in xfs_iunlink_remove_inode()
612 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
613 prev_ip->i_next_unlinked = ip->i_next_unlinked; in xfs_iunlink_remove_inode()
616 error = xfs_iunlink_update_bucket(tp, pag, agibp, bucket_index, in xfs_iunlink_remove_inode()
617 ip->i_next_unlinked); in xfs_iunlink_remove_inode()
620 ip->i_next_unlinked = NULLAGINO; in xfs_iunlink_remove_inode()
621 ip->i_prev_unlinked = 0; in xfs_iunlink_remove_inode()
626 * Pull the on-disk inode from the AGI unlinked list.
630 struct xfs_trans *tp, in xfs_iunlink_remove() argument
640 error = xfs_read_agi(pag, tp, 0, &agibp); in xfs_iunlink_remove()
644 return xfs_iunlink_remove_inode(tp, pag, agibp, ip); in xfs_iunlink_remove()
648 * Decrement the link count on an inode & log the change. If this causes the
649 * link count to go to zero, move the inode to AGI unlinked list so that it can
654 struct xfs_trans *tp, in xfs_droplink() argument
659 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); in xfs_droplink()
661 if (inode->i_nlink == 0) { in xfs_droplink()
662 xfs_info_ratelimited(tp->t_mountp, in xfs_droplink()
663 "Inode 0x%llx link count dropped below zero. Pinning link count.", in xfs_droplink()
664 ip->i_ino); in xfs_droplink()
667 if (inode->i_nlink != XFS_NLINK_PINNED) in xfs_droplink()
670 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_droplink()
672 if (inode->i_nlink) in xfs_droplink()
675 return xfs_iunlink(tp, ip); in xfs_droplink()
679 * Increment the link count on an inode & log the change.
683 struct xfs_trans *tp, in xfs_bumplink() argument
688 xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG); in xfs_bumplink()
690 if (inode->i_nlink == XFS_NLINK_PINNED - 1) in xfs_bumplink()
691 xfs_info_ratelimited(tp->t_mountp, in xfs_bumplink()
692 "Inode 0x%llx link count exceeded maximum. Pinning link count.", in xfs_bumplink()
693 ip->i_ino); in xfs_bumplink()
694 if (inode->i_nlink != XFS_NLINK_PINNED) in xfs_bumplink()
697 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_bumplink()
703 struct xfs_trans *tp, in xfs_inode_uninit() argument
708 struct xfs_mount *mp = ip->i_mount; in xfs_inode_uninit()
714 * makes the AGI lock -> unlinked list modification order the same as in xfs_inode_uninit()
717 error = xfs_difree(tp, pag, ip->i_ino, xic); in xfs_inode_uninit()
721 error = xfs_iunlink_remove(tp, pag, ip); in xfs_inode_uninit()
726 * Free any local-format data sitting around before we reset the in xfs_inode_uninit()
730 if (ip->i_df.if_format == XFS_DINODE_FMT_LOCAL) { in xfs_inode_uninit()
731 kfree(ip->i_df.if_data); in xfs_inode_uninit()
732 ip->i_df.if_data = NULL; in xfs_inode_uninit()
733 ip->i_df.if_bytes = 0; in xfs_inode_uninit()
736 VFS_I(ip)->i_mode = 0; /* mark incore inode as free */ in xfs_inode_uninit()
737 ip->i_diflags = 0; in xfs_inode_uninit()
738 ip->i_diflags2 = mp->m_ino_geo.new_diflags2; in xfs_inode_uninit()
739 ip->i_forkoff = 0; /* mark the attr fork not in use */ in xfs_inode_uninit()
740 ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS; in xfs_inode_uninit()
746 VFS_I(ip)->i_generation++; in xfs_inode_uninit()
747 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); in xfs_inode_uninit()