libxfs: fix inode reservation space for removing transaction

Backport from 'libxfs' of xfs kernel git repository:
This fix has already been merged into xfs kernel git repository:
Link: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git/commit/?h=xfs-5.20-merge&id=031d166f968efba6e4f091ff75d0bb5206bb3918
And the original discussion for this patch can be found:
Link: https://marc.info/?l=linux-xfs&m=166053185303094&w=2

Signed-off-by: Xiaole He <hexiaole@kylinos.cn>
(cherry picked from commit a2813d23e18bd7033e13638598200b63ef2ac279)
This commit is contained in:
Xiaole He 2022-08-19 09:37:43 +08:00 committed by openeuler-sync-bot
parent 56c5d61d4c
commit 17e9fa3a6f
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From 7a9c0d2fb9361352d440740b798d69eb7294e9d8 Mon Sep 17 00:00:00 2001
From: hexiaole <hexiaole@kylinos.cn>
Date: Tue, 2 Aug 2022 11:08:47 +0800
Subject: [PATCH] libxfs: fix inode reservation space for removing transaction
In 'libxfs/xfs_trans_resv.c', the comment for transaction of removing a
directory entry mentions that there has 2 inode size of space to be
reserverd, but the actual code only count for 1 inode size:
/* libxfs/xfs_trans_resv.c begin */
/*
* For removing a directory entry we can modify:
* the parent directory inode: inode size
* the removed inode: inode size
...
xfs_calc_remove_reservation(
struct xfs_mount *mp)
{
return XFS_DQUOT_LOGRES(mp) +
xfs_calc_iunlink_add_reservation(mp) +
max((xfs_calc_inode_res(mp, 1) +
...
/* libxfs/xfs_trans_resv.c end */
Here only count for 1 inode size to be reserved in
'xfs_calc_inode_res(mp, 1)', rather than 2.
Signed-off-by: hexiaole <hexiaole@kylinos.cn>
---
libxfs/xfs_trans_resv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libxfs/xfs_trans_resv.c b/libxfs/xfs_trans_resv.c
index 5f3279d..330ec88 100644
--- a/libxfs/xfs_trans_resv.c
+++ b/libxfs/xfs_trans_resv.c
@@ -422,7 +422,7 @@ xfs_calc_remove_reservation(
{
return XFS_DQUOT_LOGRES(mp) +
xfs_calc_iunlink_add_reservation(mp) +
- max((xfs_calc_inode_res(mp, 1) +
+ max((xfs_calc_inode_res(mp, 2) +
xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
XFS_FSB_TO_B(mp, 1))),
(xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: xfsprogs
Version: 5.6.0
Release: 5
Release: 6
Summary: Administration and debugging tools for the XFS file system
License: GPL+ and LGPLv2+
URL: https://xfs.wiki.kernel.org
@ -19,6 +19,7 @@ Patch9: 0009-xfs-fix-off-by-one-in-inode-alloc-block-reservation-.patch
Patch10: 0010-xfs-fix-boundary-test-in-xfs_attr_shortform_verify.patch
Patch11: 0011-xfs-set-xefi_discard-when-creating-a-deferred-agfl-f.patch
Patch12: 0012-xfs-correct-nlink-printf-specifier-from-hd-to-PRIu32.patch
Patch13: 0013-libxfs-fix-inode-reservation-space-for-removing-tran.patch
BuildRequires: libtool libattr-devel libuuid-devel gcc git gettext
BuildRequires: readline-devel libblkid-devel >= 2.30 lvm2-devel libicu-devel >= 62.0
@ -111,6 +112,9 @@ rm -rf %{buildroot}%{_datadir}/doc/xfsprogs/
%changelog
* Thu Aug 18 2022 Xiaole He <hexiaole@kylinos.cn> - 5.6.0-6
- add Patch13: fix inode reservation space for removing transaction
* Tue Jul 19 2022 Xiaole He <hexiaole@kylinos.cn> - 5.6.0-5
- add Patch12: correct nlink printf specifier from hd to PRIu32