linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jian Wen <wenjianhn@gmail.com>
To: linux-xfs@vger.kernel.org
Cc: Jian Wen <wenjianhn@gmail.com>,
	djwong@kernel.org, hch@lst.de, dchinner@redhat.com,
	Jian Wen <wenjian1@xiaomi.com>
Subject: [PATCH v2] xfs: improve handling of prjquot ENOSPC
Date: Sat, 16 Dec 2023 23:35:22 +0800	[thread overview]
Message-ID: <20231216153522.52767-1-wenjianhn@gmail.com> (raw)
In-Reply-To: <20231214150708.77586-1-wenjianhn@gmail.com>

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.

Changes since v1:
- use the want_blockgc_free_quota helper that written by Darrick

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

diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index e33e5e13b95f..7764697e7822 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>
@@ -761,6 +764,20 @@ xfs_file_dax_write(
 	return ret;
 }
 
+static inline bool want_blockgc_free_quota(struct xfs_inode *ip, int ret)
+{
+	if (ret == -EDQUOT)
+		return true;
+	if (ret != -ENOSPC)
+		return false;
+
+	if (XFS_IS_PQUOTA_ENFORCED(ip->i_mount) &&
+	    ip->i_pdquot && xfs_dquot_lowsp(ip->i_pdquot))
+		return true;
+
+	return false;
+}
+
 STATIC ssize_t
 xfs_file_buffered_write(
 	struct kiocb		*iocb,
@@ -796,7 +813,7 @@ xfs_file_buffered_write(
 	 * running at the same time.  Use a synchronous scan to increase the
 	 * effectiveness of the scan.
 	 */
-	if (ret == -EDQUOT && !cleared_space) {
+	if (want_blockgc_free_quota(ip, ret) && !cleared_space) {
 		xfs_iunlock(ip, iolock);
 		xfs_blockgc_free_quota(ip, XFS_ICWALK_FLAG_SYNC);
 		cleared_space = true;
-- 
2.34.1


  parent reply	other threads:[~2023-12-16 15:36 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Jian Wen [this message]
2023-12-18 22:00   ` [PATCH v2] " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231216153522.52767-1-wenjianhn@gmail.com \
    --to=wenjianhn@gmail.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=wenjian1@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).