hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/xfs/libxfs/xfs_dquot_buf.c
....@@ -16,8 +16,6 @@
1616 #include "xfs_trans.h"
1717 #include "xfs_qm.h"
1818 #include "xfs_error.h"
19
-#include "xfs_cksum.h"
20
-#include "xfs_trace.h"
2119
2220 int
2321 xfs_calc_dquots_per_chunk(
....@@ -37,11 +35,12 @@
3735
3836 xfs_failaddr_t
3937 xfs_dquot_verify(
40
- struct xfs_mount *mp,
41
- xfs_disk_dquot_t *ddq,
42
- xfs_dqid_t id,
43
- uint type) /* used only during quotacheck */
38
+ struct xfs_mount *mp,
39
+ struct xfs_disk_dquot *ddq,
40
+ xfs_dqid_t id) /* used only during quotacheck */
4441 {
42
+ __u8 ddq_type;
43
+
4544 /*
4645 * We can encounter an uninitialized dquot buffer for 2 reasons:
4746 * 1. If we crash while deleting the quotainode(s), and those blks got
....@@ -62,11 +61,19 @@
6261 if (ddq->d_version != XFS_DQUOT_VERSION)
6362 return __this_address;
6463
65
- if (type && ddq->d_flags != type)
64
+ if (ddq->d_type & ~XFS_DQTYPE_ANY)
6665 return __this_address;
67
- if (ddq->d_flags != XFS_DQ_USER &&
68
- ddq->d_flags != XFS_DQ_PROJ &&
69
- ddq->d_flags != XFS_DQ_GROUP)
66
+ ddq_type = ddq->d_type & XFS_DQTYPE_REC_MASK;
67
+ if (ddq_type != XFS_DQTYPE_USER &&
68
+ ddq_type != XFS_DQTYPE_PROJ &&
69
+ ddq_type != XFS_DQTYPE_GROUP)
70
+ return __this_address;
71
+
72
+ if ((ddq->d_type & XFS_DQTYPE_BIGTIME) &&
73
+ !xfs_sb_version_hasbigtime(&mp->m_sb))
74
+ return __this_address;
75
+
76
+ if ((ddq->d_type & XFS_DQTYPE_BIGTIME) && !ddq->d_id)
7077 return __this_address;
7178
7279 if (id != -1 && id != be32_to_cpu(ddq->d_id))
....@@ -97,25 +104,24 @@
97104 xfs_dqblk_verify(
98105 struct xfs_mount *mp,
99106 struct xfs_dqblk *dqb,
100
- xfs_dqid_t id,
101
- uint type) /* used only during quotacheck */
107
+ xfs_dqid_t id) /* used only during quotacheck */
102108 {
103109 if (xfs_sb_version_hascrc(&mp->m_sb) &&
104110 !uuid_equal(&dqb->dd_uuid, &mp->m_sb.sb_meta_uuid))
105111 return __this_address;
106112
107
- return xfs_dquot_verify(mp, &dqb->dd_diskdq, id, type);
113
+ return xfs_dquot_verify(mp, &dqb->dd_diskdq, id);
108114 }
109115
110116 /*
111117 * Do some primitive error checking on ondisk dquot data structures.
112118 */
113
-int
119
+void
114120 xfs_dqblk_repair(
115121 struct xfs_mount *mp,
116122 struct xfs_dqblk *dqb,
117123 xfs_dqid_t id,
118
- uint type)
124
+ xfs_dqtype_t type)
119125 {
120126 /*
121127 * Typically, a repair is only requested by quotacheck.
....@@ -125,7 +131,7 @@
125131
126132 dqb->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
127133 dqb->dd_diskdq.d_version = XFS_DQUOT_VERSION;
128
- dqb->dd_diskdq.d_flags = type;
134
+ dqb->dd_diskdq.d_type = type;
129135 dqb->dd_diskdq.d_id = cpu_to_be32(id);
130136
131137 if (xfs_sb_version_hascrc(&mp->m_sb)) {
....@@ -133,8 +139,6 @@
133139 xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
134140 XFS_DQUOT_CRC_OFF);
135141 }
136
-
137
- return 0;
138142 }
139143
140144 STATIC bool
....@@ -209,7 +213,7 @@
209213 if (i == 0)
210214 id = be32_to_cpu(ddq->d_id);
211215
212
- fa = xfs_dqblk_verify(mp, &dqb[i], id + i, 0);
216
+ fa = xfs_dqblk_verify(mp, &dqb[i], id + i);
213217 if (fa) {
214218 if (!readahead)
215219 xfs_buf_verifier_error(bp, -EFSCORRUPTED,
....@@ -226,7 +230,7 @@
226230 xfs_dquot_buf_verify_struct(
227231 struct xfs_buf *bp)
228232 {
229
- struct xfs_mount *mp = bp->b_target->bt_mount;
233
+ struct xfs_mount *mp = bp->b_mount;
230234
231235 return xfs_dquot_buf_verify(mp, bp, false);
232236 }
....@@ -235,7 +239,7 @@
235239 xfs_dquot_buf_read_verify(
236240 struct xfs_buf *bp)
237241 {
238
- struct xfs_mount *mp = bp->b_target->bt_mount;
242
+ struct xfs_mount *mp = bp->b_mount;
239243
240244 if (!xfs_dquot_buf_verify_crc(mp, bp, false))
241245 return;
....@@ -252,7 +256,7 @@
252256 xfs_dquot_buf_readahead_verify(
253257 struct xfs_buf *bp)
254258 {
255
- struct xfs_mount *mp = bp->b_target->bt_mount;
259
+ struct xfs_mount *mp = bp->b_mount;
256260
257261 if (!xfs_dquot_buf_verify_crc(mp, bp, true) ||
258262 xfs_dquot_buf_verify(mp, bp, true) != NULL) {
....@@ -270,13 +274,15 @@
270274 xfs_dquot_buf_write_verify(
271275 struct xfs_buf *bp)
272276 {
273
- struct xfs_mount *mp = bp->b_target->bt_mount;
277
+ struct xfs_mount *mp = bp->b_mount;
274278
275279 xfs_dquot_buf_verify(mp, bp, false);
276280 }
277281
278282 const struct xfs_buf_ops xfs_dquot_buf_ops = {
279283 .name = "xfs_dquot",
284
+ .magic16 = { cpu_to_be16(XFS_DQUOT_MAGIC),
285
+ cpu_to_be16(XFS_DQUOT_MAGIC) },
280286 .verify_read = xfs_dquot_buf_read_verify,
281287 .verify_write = xfs_dquot_buf_write_verify,
282288 .verify_struct = xfs_dquot_buf_verify_struct,
....@@ -284,6 +290,36 @@
284290
285291 const struct xfs_buf_ops xfs_dquot_buf_ra_ops = {
286292 .name = "xfs_dquot_ra",
293
+ .magic16 = { cpu_to_be16(XFS_DQUOT_MAGIC),
294
+ cpu_to_be16(XFS_DQUOT_MAGIC) },
287295 .verify_read = xfs_dquot_buf_readahead_verify,
288296 .verify_write = xfs_dquot_buf_write_verify,
289297 };
298
+
299
+/* Convert an on-disk timer value into an incore timer value. */
300
+time64_t
301
+xfs_dquot_from_disk_ts(
302
+ struct xfs_disk_dquot *ddq,
303
+ __be32 dtimer)
304
+{
305
+ uint32_t t = be32_to_cpu(dtimer);
306
+
307
+ if (t != 0 && (ddq->d_type & XFS_DQTYPE_BIGTIME))
308
+ return xfs_dq_bigtime_to_unix(t);
309
+
310
+ return t;
311
+}
312
+
313
+/* Convert an incore timer value into an on-disk timer value. */
314
+__be32
315
+xfs_dquot_to_disk_ts(
316
+ struct xfs_dquot *dqp,
317
+ time64_t timer)
318
+{
319
+ uint32_t t = timer;
320
+
321
+ if (timer != 0 && (dqp->q_type & XFS_DQTYPE_BIGTIME))
322
+ t = xfs_dq_unix_to_bigtime(timer);
323
+
324
+ return cpu_to_be32(t);
325
+}