未验证 提交 c9003858 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!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: Jialin Zhang <zhangjialin11@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
...@@ -357,19 +357,36 @@ xfs_dinode_verify_fork( ...@@ -357,19 +357,36 @@ xfs_dinode_verify_fork(
int whichfork) int whichfork)
{ {
uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, 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)) { /*
* 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_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) > fork_size &&
fork_format == XFS_DINODE_FMT_LOCAL)
return __this_address;
}
switch (fork_format) {
case XFS_DINODE_FMT_LOCAL: case XFS_DINODE_FMT_LOCAL:
/* /*
* no local regular files yet * No local regular files yet.
*/ */
if (whichfork == XFS_DATA_FORK) { if (S_ISREG(mode) && whichfork == XFS_DATA_FORK)
if (S_ISREG(be16_to_cpu(dip->di_mode))) return __this_address;
return __this_address;
if (be64_to_cpu(dip->di_size) >
XFS_DFORK_SIZE(dip, mp, whichfork))
return __this_address;
}
if (di_nextents) if (di_nextents)
return __this_address; return __this_address;
break; break;
......
...@@ -2725,14 +2725,13 @@ xfs_ifree_cluster( ...@@ -2725,14 +2725,13 @@ xfs_ifree_cluster(
} }
/* /*
* This is called to return an inode to the inode free list. * This is called to return an inode to the inode free list. The inode should
* The inode should already be truncated to 0 length and have * already be truncated to 0 length and have no pages associated with it. This
* no pages associated with it. This routine also assumes that * routine also assumes that the inode is already a part of the transaction.
* the inode is already a part of the transaction.
* *
* The on-disk copy of the inode will have been added to the list * The on-disk copy of the inode will have been added to the list of unlinked
* of unlinked inodes in the AGI. We need to remove the inode from * inodes in the AGI. We need to remove the inode from that list atomically with
* that list atomically with respect to freeing it here. * respect to freeing it here.
*/ */
int int
xfs_ifree( xfs_ifree(
...@@ -2750,13 +2749,16 @@ xfs_ifree( ...@@ -2750,13 +2749,16 @@ xfs_ifree(
ASSERT(ip->i_d.di_nblocks == 0); 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) if (error)
return error; return error;
error = xfs_difree(tp, ip->i_ino, &xic); error = xfs_iunlink_remove(tp, ip);
if (error) if (error)
return error; return error;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册