linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfs: improve handling of prjquot ENOSPC
@ 2023-12-14 15:07 Jian Wen
  2023-12-14 15:29 ` Christoph Hellwig
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Jian Wen @ 2023-12-14 15:07 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jian Wen, djwong, Jian Wen

Don't clear space of the whole fs when the project quota limit is
reached, since it affects the writing performance of files of
the directories that are under quota.

Only run cow/eofblocks scans on the quota attached to the inode.

Signed-off-by: Jian Wen <wenjian1@xiaomi.com>
---
 fs/xfs/xfs_file.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index e33e5e13b95f..4fbe262d33cc 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -24,6 +24,9 @@
 #include "xfs_pnfs.h"
 #include "xfs_iomap.h"
 #include "xfs_reflink.h"
+#include "xfs_quota.h"
+#include "xfs_dquot_item.h"
+#include "xfs_dquot.h"
 
 #include <linux/dax.h>
 #include <linux/falloc.h>
@@ -803,8 +806,18 @@ xfs_file_buffered_write(
 		goto write_retry;
 	} else if (ret == -ENOSPC && !cleared_space) {
 		struct xfs_icwalk	icw = {0};
+		struct xfs_dquot	*pdqp = ip->i_pdquot;
 
 		cleared_space = true;
+		if (XFS_IS_PQUOTA_ENFORCED(ip->i_mount) &&
+			pdqp && xfs_dquot_lowsp(pdqp)) {
+			xfs_iunlock(ip, iolock);
+			icw.icw_prid = pdqp->q_id;
+			icw.icw_flags |= XFS_ICWALK_FLAG_PRID;
+			xfs_blockgc_free_space(ip->i_mount, &icw);
+			goto write_retry;
+		}
+
 		xfs_flush_inodes(ip->i_mount);
 
 		xfs_iunlock(ip, iolock);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-01-11  7:24 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-14 15:07 [PATCH] xfs: improve handling of prjquot ENOSPC Jian Wen
2023-12-14 15:29 ` Christoph Hellwig
2023-12-14 17:06 ` Darrick J. Wong
2023-12-14 21:13 ` Dave Chinner
2023-12-16 15:49   ` Jian Wen
2023-12-16 15:35 ` [PATCH v2] " Jian Wen
2023-12-18 22:00   ` Dave Chinner
2023-12-19  5:47     ` Christoph Hellwig
2023-12-19 13:50     ` Jian Wen
2023-12-23 11:00     ` Jian Wen
2024-01-04  6:22   ` [PATCH v4] " Jian Wen
2024-01-08  0:35     ` Dave Chinner
2024-01-09  6:14       ` Darrick J. Wong
2024-01-09  6:38         ` Dave Chinner
2024-01-11  1:42           ` Darrick J. Wong
2024-01-11  7:24             ` Dave Chinner
2024-01-10 14:08     ` kernel test robot
2023-12-23 10:56 ` [PATCH v3] " Jian Wen
2024-01-03  1:42   ` Darrick J. Wong
2024-01-03  3:45     ` Jian Wen
2024-01-04  1:46       ` Darrick J. Wong
2024-01-04  3:36         ` Jian Wen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).