Skip to content

Commit ed17f7d

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: clean up dqblk extraction
Since the introduction of xfs_dqblk in V5, xfs really ought to find the dqblk pointer from the dquot buffer, then compute the xfs_disk_dquot pointer from the dqblk pointer. Fix the open-coded xfs_buf_offset calls and do the type checking in the correct order. Note that this has made no practical difference since the start of the xfs_disk_dquot is coincident with the start of the xfs_dqblk. Signed-off-by: Darrick J. Wong <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 98b1cc8 commit ed17f7d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

fs/xfs/xfs_dquot.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,8 @@ xfs_dquot_from_disk(
562562
struct xfs_dquot *dqp,
563563
struct xfs_buf *bp)
564564
{
565-
struct xfs_disk_dquot *ddqp = bp->b_addr + dqp->q_bufoffset;
565+
struct xfs_dqblk *dqb = xfs_buf_offset(bp, dqp->q_bufoffset);
566+
struct xfs_disk_dquot *ddqp = &dqb->dd_diskdq;
566567

567568
/*
568569
* Ensure that we got the type and ID we were looking for.
@@ -1250,7 +1251,7 @@ xfs_qm_dqflush(
12501251
}
12511252

12521253
/* Flush the incore dquot to the ondisk buffer. */
1253-
dqblk = bp->b_addr + dqp->q_bufoffset;
1254+
dqblk = xfs_buf_offset(bp, dqp->q_bufoffset);
12541255
xfs_dquot_to_disk(&dqblk->dd_diskdq, dqp);
12551256

12561257
/*

fs/xfs/xfs_dquot_item_recover.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ xlog_recover_dquot_commit_pass2(
6565
{
6666
struct xfs_mount *mp = log->l_mp;
6767
struct xfs_buf *bp;
68+
struct xfs_dqblk *dqb;
6869
struct xfs_disk_dquot *ddq, *recddq;
6970
struct xfs_dq_logformat *dq_f;
7071
xfs_failaddr_t fa;
@@ -130,14 +131,14 @@ xlog_recover_dquot_commit_pass2(
130131
return error;
131132

132133
ASSERT(bp);
133-
ddq = xfs_buf_offset(bp, dq_f->qlf_boffset);
134+
dqb = xfs_buf_offset(bp, dq_f->qlf_boffset);
135+
ddq = &dqb->dd_diskdq;
134136

135137
/*
136138
* If the dquot has an LSN in it, recover the dquot only if it's less
137139
* than the lsn of the transaction we are replaying.
138140
*/
139141
if (xfs_has_crc(mp)) {
140-
struct xfs_dqblk *dqb = (struct xfs_dqblk *)ddq;
141142
xfs_lsn_t lsn = be64_to_cpu(dqb->dd_lsn);
142143

143144
if (lsn && lsn != -1 && XFS_LSN_CMP(lsn, current_lsn) >= 0) {
@@ -147,7 +148,7 @@ xlog_recover_dquot_commit_pass2(
147148

148149
memcpy(ddq, recddq, item->ri_buf[1].i_len);
149150
if (xfs_has_crc(mp)) {
150-
xfs_update_cksum((char *)ddq, sizeof(struct xfs_dqblk),
151+
xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
151152
XFS_DQUOT_CRC_OFF);
152153
}
153154

0 commit comments

Comments
 (0)