From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 19/21] xfs: repair quotas
Date: Fri, 6 Jul 2018 11:50:25 +1000 [thread overview]
Message-ID: <20180706015025.GT2234@dastard> (raw)
In-Reply-To: <152986833543.3155.2878459585391745135.stgit@magnolia>
On Sun, Jun 24, 2018 at 12:25:35PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Fix anything that causes the quota verifiers to fail.
> +/* Fix anything the verifiers complain about. */
> +STATIC int
> +xfs_repair_quota_block(
> + struct xfs_scrub_context *sc,
> + struct xfs_buf *bp,
> + uint dqtype,
> + xfs_dqid_t id)
> +{
> + struct xfs_dqblk *d = (struct xfs_dqblk *)bp->b_addr;
> + struct xfs_disk_dquot *ddq;
> + struct xfs_quotainfo *qi = sc->mp->m_quotainfo;
> + enum xfs_blft buftype = 0;
> + int i;
> +
> + bp->b_ops = &xfs_dquot_buf_ops;
> + for (i = 0; i < qi->qi_dqperchunk; i++) {
> + ddq = &d[i].dd_diskdq;
> +
> + ddq->d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
> + ddq->d_version = XFS_DQUOT_VERSION;
> + ddq->d_flags = dqtype;
> + ddq->d_id = cpu_to_be32(id + i);
> +
> + xfs_repair_quota_fix_timer(ddq->d_blk_softlimit,
> + ddq->d_bcount, &ddq->d_btimer,
> + qi->qi_btimelimit);
> + xfs_repair_quota_fix_timer(ddq->d_ino_softlimit,
> + ddq->d_icount, &ddq->d_itimer,
> + qi->qi_itimelimit);
> + xfs_repair_quota_fix_timer(ddq->d_rtb_softlimit,
> + ddq->d_rtbcount, &ddq->d_rtbtimer,
> + qi->qi_rtbtimelimit);
> +
> + if (xfs_sb_version_hascrc(&sc->mp->m_sb)) {
> + uuid_copy(&d->dd_uuid, &sc->mp->m_sb.sb_meta_uuid);
> + xfs_update_cksum((char *)d, sizeof(struct xfs_dqblk),
> + XFS_DQUOT_CRC_OFF);
Hmmm - Do we need to reset the lsn here, too?
What makes me think - do we check that the lsn is valid in verifiers
and so catch/fix problems where the lsn is outside the valid range
of the current log LSNs?
> +STATIC int
> +xfs_repair_quota_data_fork(
> + struct xfs_scrub_context *sc,
> + uint dqtype)
> +{
> + struct xfs_bmbt_irec irec = { 0 };
> + struct xfs_iext_cursor icur;
> + struct xfs_quotainfo *qi = sc->mp->m_quotainfo;
> + struct xfs_ifork *ifp;
> + struct xfs_buf *bp;
> + struct xfs_dqblk *d;
> + xfs_dqid_t id;
> + xfs_fileoff_t max_dqid_off;
> + xfs_fileoff_t off;
> + xfs_fsblock_t fsbno;
> + bool truncate = false;
> + int error = 0;
> +
> + error = xfs_repair_metadata_inode_forks(sc);
> + if (error)
> + goto out;
> +
> + /* Check for data fork problems that apply only to quota files. */
> + max_dqid_off = ((xfs_dqid_t)-1) / qi->qi_dqperchunk;
> + ifp = XFS_IFORK_PTR(sc->ip, XFS_DATA_FORK);
> + for_each_xfs_iext(ifp, &icur, &irec) {
> + if (isnullstartblock(irec.br_startblock)) {
> + error = -EFSCORRUPTED;
> + goto out;
> + }
> +
> + if (irec.br_startoff > max_dqid_off ||
> + irec.br_startoff + irec.br_blockcount - 1 > max_dqid_off) {
> + truncate = true;
> + break;
> + }
> + }
> + if (truncate) {
> + error = xfs_itruncate_extents(&sc->tp, sc->ip, XFS_DATA_FORK,
> + max_dqid_off * sc->mp->m_sb.sb_blocksize);
> + if (error)
> + goto out;
> + }
> +
> + /* Now go fix anything that fails the verifiers. */
> + for_each_xfs_iext(ifp, &icur, &irec) {
> + for (fsbno = irec.br_startblock, off = irec.br_startoff;
> + fsbno < irec.br_startblock + irec.br_blockcount;
> + fsbno += XFS_DQUOT_CLUSTER_SIZE_FSB,
> + off += XFS_DQUOT_CLUSTER_SIZE_FSB) {
> + id = off * qi->qi_dqperchunk;
> + error = xfs_trans_read_buf(sc->mp, sc->tp,
> + sc->mp->m_ddev_targp,
> + XFS_FSB_TO_DADDR(sc->mp, fsbno),
> + qi->qi_dqchunklen,
> + 0, &bp, &xfs_dquot_buf_ops);
> + if (error == 0) {
> + d = (struct xfs_dqblk *)bp->b_addr;
> + if (id == be32_to_cpu(d->dd_diskdq.d_id))
> + continue;
Need to release the buffer here - it's clean and passes the
verifier, so no need to hold on to them as we may have thousands of
them to walk here.
Otherwise looks ok.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2018-07-06 1:50 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-24 19:23 [PATCH v16 00/21] xfs-4.19: online repair support Darrick J. Wong
2018-06-24 19:23 ` [PATCH 01/21] xfs: don't assume a left rmap when allocating a new rmap Darrick J. Wong
2018-06-27 0:54 ` Dave Chinner
2018-06-28 21:11 ` Allison Henderson
2018-06-29 14:39 ` Darrick J. Wong
2018-06-24 19:23 ` [PATCH 02/21] xfs: add helper to decide if an inode has allocated cow blocks Darrick J. Wong
2018-06-27 1:02 ` Dave Chinner
2018-06-28 21:12 ` Allison Henderson
2018-06-24 19:23 ` [PATCH 03/21] xfs: refactor part of xfs_free_eofblocks Darrick J. Wong
2018-06-28 21:13 ` Allison Henderson
2018-06-24 19:23 ` [PATCH 04/21] xfs: repair the AGF and AGFL Darrick J. Wong
2018-06-27 2:19 ` Dave Chinner
2018-06-27 16:44 ` Allison Henderson
2018-06-27 23:37 ` Dave Chinner
2018-06-29 15:14 ` Darrick J. Wong
2018-06-28 17:25 ` Allison Henderson
2018-06-29 15:08 ` Darrick J. Wong
2018-06-28 21:14 ` Allison Henderson
2018-06-28 23:21 ` Dave Chinner
2018-06-29 1:35 ` Allison Henderson
2018-06-29 14:55 ` Darrick J. Wong
2018-06-24 19:24 ` [PATCH 05/21] xfs: repair the AGI Darrick J. Wong
2018-06-27 2:22 ` Dave Chinner
2018-06-28 21:15 ` Allison Henderson
2018-06-24 19:24 ` [PATCH 06/21] xfs: repair free space btrees Darrick J. Wong
2018-06-27 3:21 ` Dave Chinner
2018-07-04 2:15 ` Darrick J. Wong
2018-07-04 2:25 ` Dave Chinner
2018-06-30 17:36 ` Allison Henderson
2018-06-24 19:24 ` [PATCH 07/21] xfs: repair inode btrees Darrick J. Wong
2018-06-28 0:55 ` Dave Chinner
2018-07-04 2:22 ` Darrick J. Wong
2018-06-30 17:36 ` Allison Henderson
2018-06-30 18:30 ` Darrick J. Wong
2018-07-01 0:45 ` Allison Henderson
2018-06-24 19:24 ` [PATCH 08/21] xfs: defer iput on certain inodes while scrub / repair are running Darrick J. Wong
2018-06-28 23:37 ` Dave Chinner
2018-06-29 14:49 ` Darrick J. Wong
2018-06-24 19:24 ` [PATCH 09/21] xfs: finish our set of inode get/put tracepoints for scrub Darrick J. Wong
2018-06-24 19:24 ` [PATCH 10/21] xfs: introduce online scrub freeze Darrick J. Wong
2018-06-24 19:24 ` [PATCH 11/21] xfs: repair the rmapbt Darrick J. Wong
2018-07-03 5:32 ` Dave Chinner
2018-07-03 23:59 ` Darrick J. Wong
2018-07-04 8:44 ` Carlos Maiolino
2018-07-04 18:40 ` Darrick J. Wong
2018-07-04 23:21 ` Dave Chinner
2018-07-05 3:48 ` Darrick J. Wong
2018-07-05 7:03 ` Dave Chinner
2018-07-06 0:47 ` Darrick J. Wong
2018-07-06 1:08 ` Dave Chinner
2018-06-24 19:24 ` [PATCH 12/21] xfs: repair refcount btrees Darrick J. Wong
2018-07-03 5:50 ` Dave Chinner
2018-07-04 2:23 ` Darrick J. Wong
2018-06-24 19:24 ` [PATCH 13/21] xfs: repair inode records Darrick J. Wong
2018-07-03 6:17 ` Dave Chinner
2018-07-04 0:16 ` Darrick J. Wong
2018-07-04 1:03 ` Dave Chinner
2018-07-04 1:30 ` Darrick J. Wong
2018-06-24 19:24 ` [PATCH 14/21] xfs: zap broken inode forks Darrick J. Wong
2018-07-04 2:07 ` Dave Chinner
2018-07-04 3:26 ` Darrick J. Wong
2018-06-24 19:25 ` [PATCH 15/21] xfs: repair inode block maps Darrick J. Wong
2018-07-04 3:00 ` Dave Chinner
2018-07-04 3:41 ` Darrick J. Wong
2018-06-24 19:25 ` [PATCH 16/21] xfs: repair damaged symlinks Darrick J. Wong
2018-07-04 5:45 ` Dave Chinner
2018-07-04 18:45 ` Darrick J. Wong
2018-06-24 19:25 ` [PATCH 17/21] xfs: repair extended attributes Darrick J. Wong
2018-07-06 1:03 ` Dave Chinner
2018-07-06 3:10 ` Darrick J. Wong
2018-06-24 19:25 ` [PATCH 18/21] xfs: scrub should set preen if attr leaf has holes Darrick J. Wong
2018-06-29 2:52 ` Dave Chinner
2018-06-24 19:25 ` [PATCH 19/21] xfs: repair quotas Darrick J. Wong
2018-07-06 1:50 ` Dave Chinner [this message]
2018-07-06 3:16 ` Darrick J. Wong
2018-06-24 19:25 ` [PATCH 20/21] xfs: implement live quotacheck as part of quota repair Darrick J. Wong
2018-06-24 19:25 ` [PATCH 21/21] xfs: add online scrub/repair for superblock counters Darrick J. Wong
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=20180706015025.GT2234@dastard \
--to=david@fromorbit.com \
--cc=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
/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).