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

!10941 v2 xfs: fix file creation

Merge Pull Request from: @ci-robot 
 
PR sync from: Long Li <leo.lilong@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/YSZKX3FGFCHEGPSLDYIF33B5KA5IEMWW/ 
This patch set fix file create fail when get wrong longest extent. 


Zizhi Wo (2):
  xfs: Fix file creation failure
  xfs: Fix agf_longest update error


-- 
2.39.2
 
https://gitee.com/openeuler/kernel/issues/I9TDTA 
 
Link:https://gitee.com/openeuler/kernel/pulls/10941

 

Reviewed-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents 67ac0f13 032f2f90
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -543,6 +543,13 @@ xfs_alloc_fixup_trees(
		nfbno2 = rbno + rlen;
		nflen2 = (fbno + flen) - nfbno2;
	}

	/*
	 * Record the potential maximum free length in advance.
	 */
	if (nfbno1 != NULLAGBLOCK || nfbno2 != NULLAGBLOCK)
		cnt_cur->bc_free_longest = max_t(xfs_extlen_t, nflen1, nflen2);

	/*
	 * Delete the entry from the by-size btree.
	 */
@@ -2039,6 +2046,13 @@ xfs_free_ag_extent(
	 * Now allocate and initialize a cursor for the by-size tree.
	 */
	cnt_cur = xfs_allocbt_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT);
	/*
	 * Record the potential maximum free length in advance.
	 */
	if (haveleft)
		cnt_cur->bc_free_longest = ltlen;
	if (haveright)
		cnt_cur->bc_free_longest = gtlen;
	/*
	 * Have both left and right contiguous neighbors.
	 * Merge all three into a single free block.
+10 −3
Original line number Diff line number Diff line
@@ -141,13 +141,20 @@ xfs_allocbt_update_lastrec(
			return;
		ASSERT(ptr == numrecs + 1);

		/*
		 * Update in advance to prevent file creation failure
		 * for concurrent processes even though there is no
		 * numrec currently.
		 * And there's no need to worry as the value that not
		 * less than bc_free_longest will be inserted later.
		 */
		len = cpu_to_be32(cur->bc_free_longest);
		if (numrecs) {
			xfs_alloc_rec_t *rrp;

			rrp = XFS_ALLOC_REC_ADDR(cur->bc_mp, block, numrecs);
			len = rrp->ar_blockcount;
		} else {
			len = 0;
			len = cpu_to_be32(max_t(xfs_extlen_t, cur->bc_free_longest,
						be32_to_cpu(rrp->ar_blockcount)));
		}

		break;
+1 −0
Original line number Diff line number Diff line
@@ -235,6 +235,7 @@ typedef struct xfs_btree_cur
		struct xfs_btree_cur_ag	bc_ag;
		struct xfs_btree_cur_ino bc_ino;
	};
	xfs_extlen_t	bc_free_longest;	/* the actual longest free extent */
} xfs_btree_cur_t;

/* cursor flags */