Unverified Commit c9003858 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!930 xfs: missing lts patchs

Merge Pull Request from: @ci-robot 
 
PR sync from:  Long Li <leo.lilong@huawei.com>
 https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/thread/4NT3HX6BJCACMKXGLIRDKTP7JBAVSSIO/ 
Dave Chinner (2):
  xfs: reorder iunlink remove operation in xfs_ifree
  xfs: validate inode fork size against fork format


-- 
2.31.1
 
 
Link:https://gitee.com/openeuler/kernel/pulls/930

 

Reviewed-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
parents 7aa9d7f3 382005dd
Loading
Loading
Loading
Loading
+26 −9
Original line number Diff line number Diff line
@@ -357,19 +357,36 @@ xfs_dinode_verify_fork(
	int			whichfork)
{
	uint32_t		di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork);
	mode_t			mode = be16_to_cpu(dip->di_mode);
	uint32_t		fork_size = XFS_DFORK_SIZE(dip, mp, whichfork);
	uint32_t		fork_format = XFS_DFORK_FORMAT(dip, whichfork);

	switch (XFS_DFORK_FORMAT(dip, whichfork)) {
	case XFS_DINODE_FMT_LOCAL:
	/*
		 * no local regular files yet
	 * For fork types that can contain local data, check that the fork
	 * format matches the size of local data contained within the fork.
	 *
	 * For all types, check that when the size says the should be in extent
	 * or btree format, the inode isn't claiming it is in local format.
	 */
	if (whichfork == XFS_DATA_FORK) {
			if (S_ISREG(be16_to_cpu(dip->di_mode)))
		if (S_ISDIR(mode) || S_ISLNK(mode)) {
			if (be64_to_cpu(dip->di_size) <= fork_size &&
			    fork_format != XFS_DINODE_FMT_LOCAL)
				return __this_address;
			if (be64_to_cpu(dip->di_size) >
					XFS_DFORK_SIZE(dip, mp, whichfork))
		}

		if (be64_to_cpu(dip->di_size) > fork_size &&
		    fork_format == XFS_DINODE_FMT_LOCAL)
			return __this_address;
	}

	switch (fork_format) {
	case XFS_DINODE_FMT_LOCAL:
		/*
		 * No local regular files yet.
		 */
		if (S_ISREG(mode) && whichfork == XFS_DATA_FORK)
			return __this_address;
		if (di_nextents)
			return __this_address;
		break;
+12 −10
Original line number Diff line number Diff line
@@ -2725,14 +2725,13 @@ xfs_ifree_cluster(
}

/*
 * This is called to return an inode to the inode free list.
 * The inode should already be truncated to 0 length and have
 * no pages associated with it.  This routine also assumes that
 * the inode is already a part of the transaction.
 * This is called to return an inode to the inode free list.  The inode should
 * already be truncated to 0 length and have no pages associated with it.  This
 * routine also assumes that the inode is already a part of the transaction.
 *
 * The on-disk copy of the inode will have been added to the list
 * of unlinked inodes in the AGI. We need to remove the inode from
 * that list atomically with respect to freeing it here.
 * The on-disk copy of the inode will have been added to the list of unlinked
 * inodes in the AGI. We need to remove the inode from that list atomically with
 * respect to freeing it here.
 */
int
xfs_ifree(
@@ -2750,13 +2749,16 @@ xfs_ifree(
	ASSERT(ip->i_d.di_nblocks == 0);

	/*
	 * Pull the on-disk inode from the AGI unlinked list.
	 * Free the inode first so that we guarantee that the AGI lock is going
	 * to be taken before we remove the inode from the unlinked list. This
	 * makes the AGI lock -> unlinked list modification order the same as
	 * used in O_TMPFILE creation.
	 */
	error = xfs_iunlink_remove(tp, ip);
	error = xfs_difree(tp, ip->i_ino, &xic);
	if (error)
		return error;

	error = xfs_difree(tp, ip->i_ino, &xic);
	error = xfs_iunlink_remove(tp, ip);
	if (error)
		return error;