Skip to content

Commit 3ed1c68

Browse files
committed
Merge tag 'xfs-merge-6.19' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Carlos Maiolino: "There are no major changes in xfs. This contains mostly some code cleanups, a few bug fixes and documentation update. Highlights are: - Quota locking cleanup - Getting rid of old xlog_in_core_2_t type" * tag 'xfs-merge-6.19' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: (33 commits) docs: remove obsolete links in the xfs online repair documentation xfs: move some code out of xfs_iget_recycle xfs: use zi more in xfs_zone_gc_mount xfs: remove the unused bv field in struct xfs_gc_bio xfs: remove xarray mark for reclaimable zones xfs: remove the xlog_in_core_t typedef xfs: remove l_iclog_heads xfs: remove the xlog_rec_header_t typedef xfs: remove xlog_in_core_2_t xfs: remove a very outdated comment from xlog_alloc_log xfs: cleanup xlog_alloc_log a bit xfs: don't use xlog_in_core_2_t in struct xlog_in_core xfs: add a on-disk log header cycle array accessor xfs: add a XLOG_CYCLE_DATA_SIZE constant xfs: reduce ilock roundtrips in xfs_qm_vop_dqalloc xfs: move xfs_dquot_tree calls into xfs_qm_dqget_cache_{lookup,insert} xfs: move quota locking into xrep_quota_item xfs: move quota locking into xqcheck_commit_dquot xfs: move q_qlock locking into xqcheck_compare_dquot xfs: move q_qlock locking into xchk_quota_item ...
2 parents 477e31f + 69ceb8a commit 3ed1c68

29 files changed

Lines changed: 363 additions & 743 deletions

Documentation/filesystems/xfs/xfs-online-fsck-design.rst

Lines changed: 6 additions & 230 deletions
Large diffs are not rendered by default.

fs/xfs/libxfs/xfs_group.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,15 @@ xfs_group_max_blocks(
9898
return xg->xg_mount->m_groups[xg->xg_type].blocks;
9999
}
100100

101+
static inline xfs_rfsblock_t
102+
xfs_groups_to_rfsbs(
103+
struct xfs_mount *mp,
104+
uint32_t nr_groups,
105+
enum xfs_group_type type)
106+
{
107+
return (xfs_rfsblock_t)mp->m_groups[type].blocks * nr_groups;
108+
}
109+
101110
static inline xfs_fsblock_t
102111
xfs_group_start_fsb(
103112
struct xfs_group *xg)

fs/xfs/libxfs/xfs_log_format.h

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef uint32_t xlog_tid_t;
3131
#define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */
3232
#define XLOG_MAX_RECORD_BSIZE (256*1024)
3333
#define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */
34+
#define XLOG_CYCLE_DATA_SIZE (XLOG_HEADER_CYCLE_SIZE / BBSIZE)
3435
#define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */
3536
#define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */
3637
#define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */
@@ -125,7 +126,17 @@ struct xlog_op_header {
125126
#define XLOG_FMT XLOG_FMT_LINUX_LE
126127
#endif
127128

128-
typedef struct xlog_rec_header {
129+
struct xlog_rec_ext_header {
130+
__be32 xh_cycle; /* write cycle of log */
131+
__be32 xh_cycle_data[XLOG_CYCLE_DATA_SIZE];
132+
__u8 xh_reserved[252];
133+
};
134+
135+
/* actual ext header payload size for checksumming */
136+
#define XLOG_REC_EXT_SIZE \
137+
offsetofend(struct xlog_rec_ext_header, xh_cycle_data)
138+
139+
struct xlog_rec_header {
129140
__be32 h_magicno; /* log record (LR) identifier : 4 */
130141
__be32 h_cycle; /* write cycle of log : 4 */
131142
__be32 h_version; /* LR version : 4 */
@@ -135,7 +146,7 @@ typedef struct xlog_rec_header {
135146
__le32 h_crc; /* crc of log record : 4 */
136147
__be32 h_prev_block; /* block number to previous LR : 4 */
137148
__be32 h_num_logops; /* number of log operations in this LR : 4 */
138-
__be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
149+
__be32 h_cycle_data[XLOG_CYCLE_DATA_SIZE];
139150

140151
/* fields added by the Linux port: */
141152
__be32 h_fmt; /* format of log record : 4 */
@@ -160,30 +171,19 @@ typedef struct xlog_rec_header {
160171
* (little-endian) architectures.
161172
*/
162173
__u32 h_pad0;
163-
} xlog_rec_header_t;
174+
175+
__u8 h_reserved[184];
176+
struct xlog_rec_ext_header h_ext[];
177+
};
164178

165179
#ifdef __i386__
166180
#define XLOG_REC_SIZE offsetofend(struct xlog_rec_header, h_size)
167-
#define XLOG_REC_SIZE_OTHER sizeof(struct xlog_rec_header)
181+
#define XLOG_REC_SIZE_OTHER offsetofend(struct xlog_rec_header, h_pad0)
168182
#else
169-
#define XLOG_REC_SIZE sizeof(struct xlog_rec_header)
183+
#define XLOG_REC_SIZE offsetofend(struct xlog_rec_header, h_pad0)
170184
#define XLOG_REC_SIZE_OTHER offsetofend(struct xlog_rec_header, h_size)
171185
#endif /* __i386__ */
172186

173-
typedef struct xlog_rec_ext_header {
174-
__be32 xh_cycle; /* write cycle of log : 4 */
175-
__be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
176-
} xlog_rec_ext_header_t;
177-
178-
/*
179-
* Quite misnamed, because this union lays out the actual on-disk log buffer.
180-
*/
181-
typedef union xlog_in_core2 {
182-
xlog_rec_header_t hic_header;
183-
xlog_rec_ext_header_t hic_xheader;
184-
char hic_sector[XLOG_HEADER_SIZE];
185-
} xlog_in_core_2_t;
186-
187187
/* not an on-disk structure, but needed by log recovery in userspace */
188188
struct xfs_log_iovec {
189189
void *i_addr; /* beginning address of region */

fs/xfs/libxfs/xfs_ondisk.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,11 @@ xfs_check_ondisk_structs(void)
174174
XFS_CHECK_STRUCT_SIZE(struct xfs_rud_log_format, 16);
175175
XFS_CHECK_STRUCT_SIZE(struct xfs_map_extent, 32);
176176
XFS_CHECK_STRUCT_SIZE(struct xfs_phys_extent, 16);
177-
XFS_CHECK_STRUCT_SIZE(struct xlog_rec_header, 328);
178-
XFS_CHECK_STRUCT_SIZE(struct xlog_rec_ext_header, 260);
177+
XFS_CHECK_STRUCT_SIZE(struct xlog_rec_header, 512);
178+
XFS_CHECK_STRUCT_SIZE(struct xlog_rec_ext_header, 512);
179179

180+
XFS_CHECK_OFFSET(struct xlog_rec_header, h_reserved, 328);
181+
XFS_CHECK_OFFSET(struct xlog_rec_ext_header, xh_reserved, 260);
180182
XFS_CHECK_OFFSET(struct xfs_bui_log_format, bui_extents, 16);
181183
XFS_CHECK_OFFSET(struct xfs_cui_log_format, cui_extents, 16);
182184
XFS_CHECK_OFFSET(struct xfs_rui_log_format, rui_extents, 16);

fs/xfs/libxfs/xfs_quota_defs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ typedef uint8_t xfs_dqtype_t;
2929
* flags for q_flags field in the dquot.
3030
*/
3131
#define XFS_DQFLAG_DIRTY (1u << 0) /* dquot is dirty */
32-
#define XFS_DQFLAG_FREEING (1u << 1) /* dquot is being torn down */
3332

3433
#define XFS_DQFLAG_STRINGS \
35-
{ XFS_DQFLAG_DIRTY, "DIRTY" }, \
36-
{ XFS_DQFLAG_FREEING, "FREEING" }
34+
{ XFS_DQFLAG_DIRTY, "DIRTY" }
3735

3836
/*
3937
* We have the possibility of all three quota types being active at once, and

fs/xfs/libxfs/xfs_rtgroup.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,6 @@ struct xfs_rtgroup {
6464
*/
6565
#define XFS_RTG_FREE XA_MARK_0
6666

67-
/*
68-
* For zoned RT devices this is set on groups that are fully written and that
69-
* have unused blocks. Used by the garbage collection to pick targets.
70-
*/
71-
#define XFS_RTG_RECLAIMABLE XA_MARK_1
72-
7367
static inline struct xfs_rtgroup *to_rtg(struct xfs_group *xg)
7468
{
7569
return container_of(xg, struct xfs_rtgroup, rtg_group);
@@ -371,4 +365,12 @@ static inline int xfs_initialize_rtgroups(struct xfs_mount *mp,
371365
# define xfs_rtgroup_get_geometry(rtg, rgeo) (-EOPNOTSUPP)
372366
#endif /* CONFIG_XFS_RT */
373367

368+
static inline xfs_rfsblock_t
369+
xfs_rtgs_to_rfsbs(
370+
struct xfs_mount *mp,
371+
uint32_t nr_groups)
372+
{
373+
return xfs_groups_to_rfsbs(mp, nr_groups, XG_TYPE_RTG);
374+
}
375+
374376
#endif /* __LIBXFS_RTGROUP_H */

fs/xfs/scrub/quota.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,9 @@ xchk_quota_item(
155155
* We want to validate the bmap record for the storage backing this
156156
* dquot, so we need to lock the dquot and the quota file. For quota
157157
* operations, the locking order is first the ILOCK and then the dquot.
158-
* However, dqiterate gave us a locked dquot, so drop the dquot lock to
159-
* get the ILOCK.
160158
*/
161-
xfs_dqunlock(dq);
162159
xchk_ilock(sc, XFS_ILOCK_SHARED);
163-
xfs_dqlock(dq);
160+
mutex_lock(&dq->q_qlock);
164161

165162
/*
166163
* Except for the root dquot, the actual dquot we got must either have
@@ -251,6 +248,7 @@ xchk_quota_item(
251248
xchk_quota_item_timer(sc, offset, &dq->q_rtb);
252249

253250
out:
251+
mutex_unlock(&dq->q_qlock);
254252
if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
255253
return -ECANCELED;
256254

@@ -330,7 +328,7 @@ xchk_quota(
330328
xchk_dqiter_init(&cursor, sc, dqtype);
331329
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
332330
error = xchk_quota_item(&sqi, dq);
333-
xfs_qm_dqput(dq);
331+
xfs_qm_dqrele(dq);
334332
if (error)
335333
break;
336334
}

fs/xfs/scrub/quota_repair.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,13 @@ xrep_quota_item(
184184
/*
185185
* We might need to fix holes in the bmap record for the storage
186186
* backing this dquot, so we need to lock the dquot and the quota file.
187-
* dqiterate gave us a locked dquot, so drop the dquot lock to get the
188-
* ILOCK_EXCL.
189187
*/
190-
xfs_dqunlock(dq);
191188
xchk_ilock(sc, XFS_ILOCK_EXCL);
192-
xfs_dqlock(dq);
193-
189+
mutex_lock(&dq->q_qlock);
194190
error = xrep_quota_item_bmap(sc, dq, &dirty);
195191
xchk_iunlock(sc, XFS_ILOCK_EXCL);
196192
if (error)
197-
return error;
193+
goto out_unlock_dquot;
198194

199195
/* Check the limits. */
200196
if (dq->q_blk.softlimit > dq->q_blk.hardlimit) {
@@ -246,7 +242,7 @@ xrep_quota_item(
246242
xrep_quota_item_timer(sc, &dq->q_rtb, &dirty);
247243

248244
if (!dirty)
249-
return 0;
245+
goto out_unlock_dquot;
250246

251247
trace_xrep_dquot_item(sc->mp, dq->q_type, dq->q_id);
252248

@@ -257,8 +253,10 @@ xrep_quota_item(
257253
xfs_qm_adjust_dqtimers(dq);
258254
}
259255
xfs_trans_log_dquot(sc->tp, dq);
260-
error = xfs_trans_roll(&sc->tp);
261-
xfs_dqlock(dq);
256+
return xfs_trans_roll(&sc->tp);
257+
258+
out_unlock_dquot:
259+
mutex_unlock(&dq->q_qlock);
262260
return error;
263261
}
264262

@@ -513,7 +511,7 @@ xrep_quota_problems(
513511
xchk_dqiter_init(&cursor, sc, dqtype);
514512
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
515513
error = xrep_quota_item(&rqi, dq);
516-
xfs_qm_dqput(dq);
514+
xfs_qm_dqrele(dq);
517515
if (error)
518516
break;
519517
}

fs/xfs/scrub/quotacheck.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ xqcheck_compare_dquot(
563563
return -ECANCELED;
564564
}
565565

566+
mutex_lock(&dq->q_qlock);
566567
mutex_lock(&xqc->lock);
567568
error = xfarray_load_sparse(counts, dq->q_id, &xcdq);
568569
if (error)
@@ -589,18 +590,16 @@ xqcheck_compare_dquot(
589590
xchk_set_incomplete(xqc->sc);
590591
error = -ECANCELED;
591592
}
593+
out_unlock:
592594
mutex_unlock(&xqc->lock);
595+
mutex_unlock(&dq->q_qlock);
593596
if (error)
594597
return error;
595598

596599
if (xqc->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
597600
return -ECANCELED;
598601

599602
return 0;
600-
601-
out_unlock:
602-
mutex_unlock(&xqc->lock);
603-
return error;
604603
}
605604

606605
/*
@@ -636,7 +635,7 @@ xqcheck_walk_observations(
636635
return error;
637636

638637
error = xqcheck_compare_dquot(xqc, dqtype, dq);
639-
xfs_qm_dqput(dq);
638+
xfs_qm_dqrele(dq);
640639
if (error)
641640
return error;
642641

@@ -674,7 +673,7 @@ xqcheck_compare_dqtype(
674673
xchk_dqiter_init(&cursor, sc, dqtype);
675674
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
676675
error = xqcheck_compare_dquot(xqc, dqtype, dq);
677-
xfs_qm_dqput(dq);
676+
xfs_qm_dqrele(dq);
678677
if (error)
679678
break;
680679
}

fs/xfs/scrub/quotacheck_repair.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,11 @@ xqcheck_commit_dquot(
5252
bool dirty = false;
5353
int error = 0;
5454

55-
/* Unlock the dquot just long enough to allocate a transaction. */
56-
xfs_dqunlock(dq);
5755
error = xchk_trans_alloc(xqc->sc, 0);
58-
xfs_dqlock(dq);
5956
if (error)
6057
return error;
6158

59+
mutex_lock(&dq->q_qlock);
6260
xfs_trans_dqjoin(xqc->sc->tp, dq);
6361

6462
if (xchk_iscan_aborted(&xqc->iscan)) {
@@ -115,23 +113,12 @@ xqcheck_commit_dquot(
115113
if (dq->q_id)
116114
xfs_qm_adjust_dqtimers(dq);
117115
xfs_trans_log_dquot(xqc->sc->tp, dq);
118-
119-
/*
120-
* Transaction commit unlocks the dquot, so we must re-lock it so that
121-
* the caller can put the reference (which apparently requires a locked
122-
* dquot).
123-
*/
124-
error = xrep_trans_commit(xqc->sc);
125-
xfs_dqlock(dq);
126-
return error;
116+
return xrep_trans_commit(xqc->sc);
127117

128118
out_unlock:
129119
mutex_unlock(&xqc->lock);
130120
out_cancel:
131121
xchk_trans_cancel(xqc->sc);
132-
133-
/* Re-lock the dquot so the caller can put the reference. */
134-
xfs_dqlock(dq);
135122
return error;
136123
}
137124

@@ -156,7 +143,7 @@ xqcheck_commit_dqtype(
156143
xchk_dqiter_init(&cursor, sc, dqtype);
157144
while ((error = xchk_dquot_iter(&cursor, &dq)) == 1) {
158145
error = xqcheck_commit_dquot(xqc, dqtype, dq);
159-
xfs_qm_dqput(dq);
146+
xfs_qm_dqrele(dq);
160147
if (error)
161148
break;
162149
}
@@ -187,7 +174,7 @@ xqcheck_commit_dqtype(
187174
return error;
188175

189176
error = xqcheck_commit_dquot(xqc, dqtype, dq);
190-
xfs_qm_dqput(dq);
177+
xfs_qm_dqrele(dq);
191178
if (error)
192179
return error;
193180

0 commit comments

Comments
 (0)