Skip to content

Commit a9e583d

Browse files
author
Darrick J. Wong
committed
xfs: hoist xfs_{bump,drop}link to libxfs
Move xfs_bumplink and xfs_droplink to libxfs. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent b8a6107 commit a9e583d

File tree

4 files changed

+55
-55
lines changed

4 files changed

+55
-55
lines changed

fs/xfs/libxfs/xfs_inode_util.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,3 +626,56 @@ xfs_iunlink_remove(
626626

627627
return xfs_iunlink_remove_inode(tp, pag, agibp, ip);
628628
}
629+
630+
/*
631+
* Decrement the link count on an inode & log the change. If this causes the
632+
* link count to go to zero, move the inode to AGI unlinked list so that it can
633+
* be freed when the last active reference goes away via xfs_inactive().
634+
*/
635+
int
636+
xfs_droplink(
637+
struct xfs_trans *tp,
638+
struct xfs_inode *ip)
639+
{
640+
struct inode *inode = VFS_I(ip);
641+
642+
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
643+
644+
if (inode->i_nlink == 0) {
645+
xfs_info_ratelimited(tp->t_mountp,
646+
"Inode 0x%llx link count dropped below zero. Pinning link count.",
647+
ip->i_ino);
648+
set_nlink(inode, XFS_NLINK_PINNED);
649+
}
650+
if (inode->i_nlink != XFS_NLINK_PINNED)
651+
drop_nlink(inode);
652+
653+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
654+
655+
if (inode->i_nlink)
656+
return 0;
657+
658+
return xfs_iunlink(tp, ip);
659+
}
660+
661+
/*
662+
* Increment the link count on an inode & log the change.
663+
*/
664+
void
665+
xfs_bumplink(
666+
struct xfs_trans *tp,
667+
struct xfs_inode *ip)
668+
{
669+
struct inode *inode = VFS_I(ip);
670+
671+
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
672+
673+
if (inode->i_nlink == XFS_NLINK_PINNED - 1)
674+
xfs_info_ratelimited(tp->t_mountp,
675+
"Inode 0x%llx link count exceeded maximum. Pinning link count.",
676+
ip->i_ino);
677+
if (inode->i_nlink != XFS_NLINK_PINNED)
678+
inc_nlink(inode);
679+
680+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
681+
}

fs/xfs/libxfs/xfs_inode_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ void xfs_inode_init(struct xfs_trans *tp, const struct xfs_icreate_args *args,
5050
int xfs_iunlink(struct xfs_trans *tp, struct xfs_inode *ip);
5151
int xfs_iunlink_remove(struct xfs_trans *tp, struct xfs_perag *pag,
5252
struct xfs_inode *ip);
53+
int xfs_droplink(struct xfs_trans *tp, struct xfs_inode *ip);
54+
void xfs_bumplink(struct xfs_trans *tp, struct xfs_inode *ip);
5355

5456
#endif /* __XFS_INODE_UTIL_H__ */

fs/xfs/xfs_inode.c

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -600,59 +600,6 @@ xfs_icreate(
600600
return 0;
601601
}
602602

603-
/*
604-
* Decrement the link count on an inode & log the change. If this causes the
605-
* link count to go to zero, move the inode to AGI unlinked list so that it can
606-
* be freed when the last active reference goes away via xfs_inactive().
607-
*/
608-
int
609-
xfs_droplink(
610-
struct xfs_trans *tp,
611-
struct xfs_inode *ip)
612-
{
613-
struct inode *inode = VFS_I(ip);
614-
615-
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
616-
617-
if (inode->i_nlink == 0) {
618-
xfs_info_ratelimited(tp->t_mountp,
619-
"Inode 0x%llx link count dropped below zero. Pinning link count.",
620-
ip->i_ino);
621-
set_nlink(inode, XFS_NLINK_PINNED);
622-
}
623-
if (inode->i_nlink != XFS_NLINK_PINNED)
624-
drop_nlink(inode);
625-
626-
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
627-
628-
if (inode->i_nlink)
629-
return 0;
630-
631-
return xfs_iunlink(tp, ip);
632-
}
633-
634-
/*
635-
* Increment the link count on an inode & log the change.
636-
*/
637-
void
638-
xfs_bumplink(
639-
struct xfs_trans *tp,
640-
struct xfs_inode *ip)
641-
{
642-
struct inode *inode = VFS_I(ip);
643-
644-
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
645-
646-
if (inode->i_nlink == XFS_NLINK_PINNED - 1)
647-
xfs_info_ratelimited(tp->t_mountp,
648-
"Inode 0x%llx link count exceeded maximum. Pinning link count.",
649-
ip->i_ino);
650-
if (inode->i_nlink != XFS_NLINK_PINNED)
651-
inc_nlink(inode);
652-
653-
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
654-
}
655-
656603
#ifdef CONFIG_XFS_LIVE_HOOKS
657604
/*
658605
* Use a static key here to reduce the overhead of directory live update hooks.

fs/xfs/xfs_inode.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,6 @@ void xfs_end_io(struct work_struct *work);
615615
int xfs_ilock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
616616
void xfs_iunlock2_io_mmap(struct xfs_inode *ip1, struct xfs_inode *ip2);
617617
void xfs_iunlock2_remapping(struct xfs_inode *ip1, struct xfs_inode *ip2);
618-
int xfs_droplink(struct xfs_trans *tp, struct xfs_inode *ip);
619-
void xfs_bumplink(struct xfs_trans *tp, struct xfs_inode *ip);
620618
void xfs_lock_inodes(struct xfs_inode **ips, int inodes, uint lock_mode);
621619
void xfs_sort_inodes(struct xfs_inode **i_tab, unsigned int num_inodes);
622620

0 commit comments

Comments
 (0)