From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 17/20] xfs: separate dquot repair into a separate function
Date: Fri, 22 Dec 2017 17:08:50 -0800 [thread overview]
Message-ID: <151399133030.23543.13471674725718289527.stgit@magnolia> (raw)
In-Reply-To: <151399122361.23543.15718507168231759645.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
Move the dquot repair code into a separate function and remove
XFS_QMOPT_DQREPAIR in favor of calling the helper directly. Remove
other dead code because quotacheck is the only caller of DQREPAIR.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/libxfs/xfs_dquot_buf.c | 22 +++++++++++-----
fs/xfs/libxfs/xfs_quota_defs.h | 3 +-
fs/xfs/xfs_dquot.c | 54 ----------------------------------------
fs/xfs/xfs_qm.c | 7 ++++-
4 files changed, 22 insertions(+), 64 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c
index f8b62fc..6b15c50 100644
--- a/fs/xfs/libxfs/xfs_dquot_buf.c
+++ b/fs/xfs/libxfs/xfs_dquot_buf.c
@@ -51,7 +51,6 @@ xfs_dqcheck(
uint flags,
const char *str)
{
- xfs_dqblk_t *d = (xfs_dqblk_t *)ddq;
int errs = 0;
/*
@@ -139,17 +138,26 @@ xfs_dqcheck(
}
}
- if (!errs || !(flags & XFS_QMOPT_DQREPAIR))
- return errs;
+ return errs;
+}
+
+/*
+ * Do some primitive error checking on ondisk dquot data structures.
+ */
+int
+xfs_dquot_repair(
+ struct xfs_mount *mp,
+ struct xfs_disk_dquot *ddq,
+ xfs_dqid_t id,
+ uint type)
+{
+ struct xfs_dqblk *d = (struct xfs_dqblk *)ddq;
- if (flags & XFS_QMOPT_DOWARN)
- xfs_notice(mp, "Re-initializing dquot ID 0x%x", id);
/*
* Typically, a repair is only requested by quotacheck.
*/
ASSERT(id != -1);
- ASSERT(flags & XFS_QMOPT_DQREPAIR);
memset(d, 0, sizeof(xfs_dqblk_t));
d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
@@ -163,7 +171,7 @@ xfs_dqcheck(
XFS_DQUOT_CRC_OFF);
}
- return errs;
+ return 0;
}
STATIC bool
diff --git a/fs/xfs/libxfs/xfs_quota_defs.h b/fs/xfs/libxfs/xfs_quota_defs.h
index d69c772..7187ec9 100644
--- a/fs/xfs/libxfs/xfs_quota_defs.h
+++ b/fs/xfs/libxfs/xfs_quota_defs.h
@@ -113,7 +113,6 @@ typedef uint16_t xfs_qwarncnt_t;
#define XFS_QMOPT_FORCE_RES 0x0000010 /* ignore quota limits */
#define XFS_QMOPT_SBVERSION 0x0000040 /* change superblock version num */
#define XFS_QMOPT_DOWARN 0x0000400 /* increase warning cnt if needed */
-#define XFS_QMOPT_DQREPAIR 0x0001000 /* repair dquot if damaged */
#define XFS_QMOPT_GQUOTA 0x0002000 /* group dquot requested */
#define XFS_QMOPT_ENOSPC 0x0004000 /* enospc instead of edquot (prj) */
#define XFS_QMOPT_DQNEXT 0x0008000 /* return next dquot >= this ID */
@@ -156,5 +155,7 @@ typedef uint16_t xfs_qwarncnt_t;
extern int xfs_dqcheck(struct xfs_mount *mp, xfs_disk_dquot_t *ddq,
xfs_dqid_t id, uint type, uint flags, const char *str);
extern int xfs_calc_dquots_per_chunk(unsigned int nbblks);
+extern int xfs_dquot_repair(struct xfs_mount *mp, struct xfs_disk_dquot *ddq,
+ xfs_dqid_t id, uint type);
#endif /* __XFS_QUOTA_H__ */
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index f248708..0d8c52b 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -399,52 +399,6 @@ xfs_qm_dqalloc(
return error;
}
-STATIC int
-xfs_qm_dqrepair(
- struct xfs_mount *mp,
- struct xfs_trans *tp,
- struct xfs_dquot *dqp,
- xfs_dqid_t firstid,
- struct xfs_buf **bpp)
-{
- int error;
- struct xfs_disk_dquot *ddq;
- struct xfs_dqblk *d;
- int i;
-
- /*
- * Read the buffer without verification so we get the corrupted
- * buffer returned to us. make sure we verify it on write, though.
- */
- error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, dqp->q_blkno,
- mp->m_quotainfo->qi_dqchunklen,
- 0, bpp, NULL);
-
- if (error) {
- ASSERT(*bpp == NULL);
- return error;
- }
- (*bpp)->b_ops = &xfs_dquot_buf_ops;
-
- ASSERT(xfs_buf_islocked(*bpp));
- d = (struct xfs_dqblk *)(*bpp)->b_addr;
-
- /* Do the actual repair of dquots in this buffer */
- for (i = 0; i < mp->m_quotainfo->qi_dqperchunk; i++) {
- ddq = &d[i].dd_diskdq;
- error = xfs_dqcheck(mp, ddq, firstid + i,
- dqp->dq_flags & XFS_DQ_ALLTYPES,
- XFS_QMOPT_DQREPAIR, "xfs_qm_dqrepair");
- if (error) {
- /* repair failed, we're screwed */
- xfs_trans_brelse(tp, *bpp);
- return -EIO;
- }
- }
-
- return 0;
-}
-
/*
* Maps a dquot to the buffer containing its on-disk version.
* This returns a ptr to the buffer containing the on-disk dquot
@@ -526,14 +480,6 @@ xfs_qm_dqtobp(
dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen,
0, &bp, &xfs_dquot_buf_ops);
-
- if (error == -EFSCORRUPTED && (flags & XFS_QMOPT_DQREPAIR)) {
- xfs_dqid_t firstid = (xfs_dqid_t)map.br_startoff *
- mp->m_quotainfo->qi_dqperchunk;
- ASSERT(bp == NULL);
- error = xfs_qm_dqrepair(mp, tp, dqp, firstid, &bp);
- }
-
if (error) {
ASSERT(bp == NULL);
return error;
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index ec952df..407a12b 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -847,6 +847,7 @@ xfs_qm_reset_dqcounts(
{
struct xfs_dqblk *dqb;
int j;
+ int error;
trace_xfs_reset_dqcounts(bp, _RET_IP_);
@@ -870,8 +871,10 @@ xfs_qm_reset_dqcounts(
* output any warnings because it's perfectly possible to
* find uninitialised dquot blks. See comment in xfs_dqcheck.
*/
- xfs_dqcheck(mp, ddq, id+j, type, XFS_QMOPT_DQREPAIR,
- "xfs_quotacheck");
+ error = xfs_dqcheck(mp, ddq, id+j, type, 0, "xfs_quotacheck");
+ if (error)
+ xfs_dquot_repair(mp, ddq, id + j, type);
+
/*
* Reset type in case we are reusing group quota file for
* project quotas or vice versa
next prev parent reply other threads:[~2017-12-23 1:14 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-23 1:07 [PATCH v3 00/20] xfs: more and better verifiers Darrick J. Wong
2017-12-23 1:07 ` [PATCH 01/20] xfs: remove XFS_FSB_SANITY_CHECK Darrick J. Wong
2018-01-02 23:11 ` Dave Chinner
2017-12-23 1:07 ` [PATCH 02/20] xfs: refactor long-format btree header verification routines Darrick J. Wong
2018-01-02 23:15 ` Dave Chinner
2017-12-23 1:07 ` [PATCH 03/20] xfs: refactor short form btree pointer verification Darrick J. Wong
2018-01-02 23:17 ` Dave Chinner
2017-12-23 1:07 ` [PATCH 04/20] xfs: remove XFS_WANT_CORRUPTED_RETURN from dir3 data verifiers Darrick J. Wong
2017-12-23 1:07 ` [PATCH 05/20] xfs: refactor xfs_verifier_error and xfs_buf_ioerror Darrick J. Wong
2018-01-02 23:22 ` Dave Chinner
2017-12-23 1:07 ` [PATCH 06/20] xfs: have buffer verifier functions report failing address Darrick J. Wong
2018-01-02 23:36 ` Dave Chinner
2017-12-23 1:07 ` [PATCH 07/20] xfs: refactor verifier callers to print address of failing check Darrick J. Wong
2018-01-02 23:44 ` Dave Chinner
2018-01-03 0:09 ` Darrick J. Wong
2017-12-23 1:07 ` [PATCH 08/20] xfs: verify dinode header first Darrick J. Wong
2017-12-23 1:08 ` [PATCH 09/20] xfs: move inode fork verifiers to xfs_dinode_verify Darrick J. Wong
2017-12-23 1:08 ` [PATCH 10/20] xfs: create structure verifier function for shortform xattrs Darrick J. Wong
2018-01-02 23:53 ` Dave Chinner
2017-12-23 1:08 ` [PATCH 11/20] xfs: create structure verifier function for short form symlinks Darrick J. Wong
2017-12-23 1:08 ` [PATCH 12/20] xfs: refactor short form directory structure verifier function Darrick J. Wong
2017-12-23 1:08 ` [PATCH 13/20] xfs: provide a centralized method for verifying inline fork data Darrick J. Wong
2018-01-03 0:32 ` Dave Chinner
2017-12-23 1:08 ` [PATCH 14/20] xfs: fail out of xfs_attr3_leaf_lookup_int if it looks corrupt Darrick J. Wong
2017-12-23 1:08 ` [PATCH 15/20] xfs: create a new buf_ops pointer to verify structure metadata Darrick J. Wong
2018-01-03 0:35 ` Dave Chinner
2017-12-23 1:08 ` [PATCH 16/20] xfs: scrub in-core metadata Darrick J. Wong
2017-12-23 1:08 ` Darrick J. Wong [this message]
2018-01-03 0:39 ` [PATCH 17/20] xfs: separate dquot repair into a separate function Dave Chinner
2017-12-23 1:08 ` [PATCH 18/20] xfs: standardize quota verification function outputs Darrick J. Wong
2018-01-03 0:44 ` Dave Chinner
2018-01-03 0:52 ` Darrick J. Wong
2017-12-23 1:09 ` [PATCH 19/20] xfs: teach error reporting functions to take xfs_failaddr_t Darrick J. Wong
2018-01-03 0:44 ` Dave Chinner
2017-12-23 1:09 ` [PATCH 20/20] xfs: dump the first 128 bytes of any corrupt buffer Darrick J. Wong
2018-01-03 0:49 ` Dave Chinner
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=151399133030.23543.13471674725718289527.stgit@magnolia \
--to=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).