summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2021-09-01 11:16:10 -0700
committerDarrick J. Wong <djwong@kernel.org>2021-10-22 16:41:01 -0700
commita16716dcd8f45ddf87f8944417693228171b8a21 (patch)
treefb3d080ac7592f81e416e60977b54395d90a3254
parentab76ea9c0089edc0ada07884e32cdea337a52f96 (diff)
xfs: attach dquots to rt metadata files when starting quota
Attach dquots to the realtime metadata files when starting up quotas, since the resources used by them are charged to the root dquot. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
-rw-r--r--fs/xfs/xfs_mount.c4
-rw-r--r--fs/xfs/xfs_qm.c20
-rw-r--r--fs/xfs/xfs_qm_bhv.c2
-rw-r--r--fs/xfs/xfs_quota.h4
-rw-r--r--fs/xfs/xfs_rtalloc.c19
-rw-r--r--fs/xfs/xfs_rtalloc.h3
6 files changed, 45 insertions, 7 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 4ca26703b4fb..e503f32615b1 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -938,7 +938,9 @@ xfs_mountfs(
ASSERT(mp->m_qflags == 0);
mp->m_qflags = quotaflags;
- xfs_qm_mount_quotas(mp);
+ error = xfs_qm_mount_quotas(mp);
+ if (error)
+ goto out_rtunmount;
}
/*
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 95f4ff3b4096..07f64506b81a 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -28,6 +28,7 @@
#include "xfs_health.h"
#include "xfs_imeta.h"
#include "xfs_da_format.h"
+#include "xfs_rtalloc.h"
/*
* The global quota manager. There is only one of these for the entire
@@ -1462,7 +1463,7 @@ xfs_qm_quotacheck(
* If we fail here, the mount will continue with quota turned off. We don't
* need to inidicate success or failure at all.
*/
-void
+int
xfs_qm_mount_quotas(
struct xfs_mount *mp)
{
@@ -1501,7 +1502,7 @@ xfs_qm_mount_quotas(
error = xfs_qm_quotacheck(mp);
if (error) {
/* Quotacheck failed and disabled quotas. */
- return;
+ return 0;
}
}
/*
@@ -1542,8 +1543,21 @@ xfs_qm_mount_quotas(
if (error) {
xfs_warn(mp, "Failed to initialize disk quotas.");
- return;
+ return 0;
+ }
+
+ /*
+ * Attach dquots to realtime metadata files before we do anything that
+ * could alter the resource usage of rt metadata (log recovery, normal
+ * operation, etc).
+ */
+ error = xfs_rtmount_dqattach(mp);
+ if (error) {
+ xfs_qm_unmount_quotas(mp);
+ return error;
}
+
+ return 0;
}
/*
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c
index b77673dd0558..0c23882c24c0 100644
--- a/fs/xfs/xfs_qm_bhv.c
+++ b/fs/xfs/xfs_qm_bhv.c
@@ -118,7 +118,7 @@ xfs_qm_newmount(
* mounting, and get on with the boring life
* without disk quotas.
*/
- xfs_qm_mount_quotas(mp);
+ return xfs_qm_mount_quotas(mp);
} else {
/*
* Clear the quota flags, but remember them. This
diff --git a/fs/xfs/xfs_quota.h b/fs/xfs/xfs_quota.h
index cff4512381dc..b6990ef26037 100644
--- a/fs/xfs/xfs_quota.h
+++ b/fs/xfs/xfs_quota.h
@@ -118,7 +118,7 @@ extern void xfs_qm_dqdetach(struct xfs_inode *);
extern void xfs_qm_dqrele(struct xfs_dquot *);
extern void xfs_qm_statvfs(struct xfs_inode *, struct kstatfs *);
extern int xfs_qm_newmount(struct xfs_mount *, uint *, uint *);
-extern void xfs_qm_mount_quotas(struct xfs_mount *);
+int xfs_qm_mount_quotas(struct xfs_mount *mp);
extern void xfs_qm_unmount(struct xfs_mount *);
extern void xfs_qm_unmount_quotas(struct xfs_mount *);
@@ -180,7 +180,7 @@ xfs_trans_reserve_quota_icreate(struct xfs_trans *tp, struct xfs_dquot *udqp,
#define xfs_qm_dqrele(d) do { (d) = (d); } while(0)
#define xfs_qm_statvfs(ip, s) do { } while(0)
#define xfs_qm_newmount(mp, a, b) (0)
-#define xfs_qm_mount_quotas(mp)
+#define xfs_qm_mount_quotas(mp) (0)
#define xfs_qm_unmount(mp)
#define xfs_qm_unmount_quotas(mp)
#define xfs_inode_near_dquot_enforcement(ip, type) (false)
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 0fa5dd8c6433..9f8f480368d0 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -23,6 +23,7 @@
#include "xfs_trace.h"
#include "xfs_da_format.h"
#include "xfs_imeta.h"
+#include "xfs_quota.h"
/*
* Read and return the summary information for a given extent size,
@@ -1366,6 +1367,24 @@ xfs_rtmount_inodes(
return 0;
}
+/* Attach dquots for realtime metadata files. */
+int
+xfs_rtmount_dqattach(
+ struct xfs_mount *mp)
+{
+ int error;
+
+ error = xfs_qm_dqattach(mp->m_rbmip);
+ if (error)
+ return error;
+
+ error = xfs_qm_dqattach(mp->m_rsumip);
+ if (error)
+ return error;
+
+ return 0;
+}
+
void
xfs_rtunmount_inodes(
struct xfs_mount *mp)
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 7a459c250aa6..326f13ef6890 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -71,6 +71,8 @@ void
xfs_rtunmount_inodes(
struct xfs_mount *mp);
+int xfs_rtmount_dqattach(struct xfs_mount *mp);
+
/*
* Get the bitmap and summary inodes into the mount structure
* at mount time.
@@ -174,6 +176,7 @@ xfs_rtmount_init(
# define xfs_rt_resv_free(mp) ((void)0)
# define xfs_rt_resv_init(mp) (0)
# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
+# define xfs_rtmount_dqattach(mp) (0)
# define xfs_rtunmount_inodes(m)
# define xfs_rtfile_convert_unwritten(ip, pos, len) (0)
# define xfs_rtlock(tp, mp, lock_flags) do { } while (0)