Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Oracle. All Rights Reserved. |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 5 | */ |
| 6 | #include "xfs.h" |
| 7 | #include "xfs_fs.h" |
| 8 | #include "xfs_shared.h" |
| 9 | #include "xfs_format.h" |
| 10 | #include "xfs_trans_resv.h" |
| 11 | #include "xfs_mount.h" |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 12 | #include "xfs_log_format.h" |
| 13 | #include "xfs_trans.h" |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 14 | #include "xfs_inode.h" |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 15 | #include "xfs_quota.h" |
| 16 | #include "xfs_qm.h" |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 17 | #include "scrub/scrub.h" |
| 18 | #include "scrub/common.h" |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 19 | |
| 20 | /* Convert a scrub type code to a DQ flag, or return 0 if error. */ |
Darrick J. Wong | 1a7ed27 | 2020-07-15 17:53:43 -0700 | [diff] [blame] | 21 | static inline xfs_dqtype_t |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 22 | xchk_quota_to_dqtype( |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 23 | struct xfs_scrub *sc) |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 24 | { |
| 25 | switch (sc->sm->sm_type) { |
| 26 | case XFS_SCRUB_TYPE_UQUOTA: |
Darrick J. Wong | 8cd4901 | 2020-07-15 17:42:36 -0700 | [diff] [blame] | 27 | return XFS_DQTYPE_USER; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 28 | case XFS_SCRUB_TYPE_GQUOTA: |
Darrick J. Wong | 8cd4901 | 2020-07-15 17:42:36 -0700 | [diff] [blame] | 29 | return XFS_DQTYPE_GROUP; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 30 | case XFS_SCRUB_TYPE_PQUOTA: |
Darrick J. Wong | 8cd4901 | 2020-07-15 17:42:36 -0700 | [diff] [blame] | 31 | return XFS_DQTYPE_PROJ; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 32 | default: |
| 33 | return 0; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | /* Set us up to scrub a quota. */ |
| 38 | int |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 39 | xchk_setup_quota( |
Darrick J. Wong | 026f57e | 2021-04-07 17:59:39 -0700 | [diff] [blame] | 40 | struct xfs_scrub *sc) |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 41 | { |
Darrick J. Wong | 1a7ed27 | 2020-07-15 17:53:43 -0700 | [diff] [blame] | 42 | xfs_dqtype_t dqtype; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 43 | int error; |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 44 | |
Christoph Hellwig | 149e53a | 2021-08-06 11:05:37 -0700 | [diff] [blame] | 45 | if (!XFS_IS_QUOTA_ON(sc->mp)) |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 46 | return -ENOENT; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 47 | |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 48 | dqtype = xchk_quota_to_dqtype(sc); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 49 | if (dqtype == 0) |
| 50 | return -EINVAL; |
Darrick J. Wong | 59d7fab | 2021-12-15 11:53:16 -0800 | [diff] [blame] | 51 | |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 52 | if (!xfs_this_quota_on(sc->mp, dqtype)) |
| 53 | return -ENOENT; |
Darrick J. Wong | 59d7fab | 2021-12-15 11:53:16 -0800 | [diff] [blame] | 54 | |
Darrick J. Wong | 026f57e | 2021-04-07 17:59:39 -0700 | [diff] [blame] | 55 | error = xchk_setup_fs(sc); |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 56 | if (error) |
| 57 | return error; |
| 58 | sc->ip = xfs_quota_inode(sc->mp, dqtype); |
| 59 | xfs_ilock(sc->ip, XFS_ILOCK_EXCL); |
| 60 | sc->ilock_flags = XFS_ILOCK_EXCL; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | /* Quotas. */ |
| 65 | |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 66 | struct xchk_quota_info { |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 67 | struct xfs_scrub *sc; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 68 | xfs_dqid_t last_id; |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 69 | }; |
| 70 | |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 71 | /* Scrub the fields in an individual quota item. */ |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 72 | STATIC int |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 73 | xchk_quota_item( |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 74 | struct xfs_dquot *dq, |
Darrick J. Wong | 1a7ed27 | 2020-07-15 17:53:43 -0700 | [diff] [blame] | 75 | xfs_dqtype_t dqtype, |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 76 | void *priv) |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 77 | { |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 78 | struct xchk_quota_info *sqi = priv; |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 79 | struct xfs_scrub *sc = sqi->sc; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 80 | struct xfs_mount *mp = sc->mp; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 81 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
| 82 | xfs_fileoff_t offset; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 83 | xfs_ino_t fs_icount; |
Darrick J. Wong | 8ef34723 | 2019-11-05 15:33:56 -0800 | [diff] [blame] | 84 | int error = 0; |
| 85 | |
| 86 | if (xchk_should_terminate(sc, &error)) |
Darrick J. Wong | 0523703 | 2021-03-22 09:51:52 -0700 | [diff] [blame] | 87 | return -ECANCELED; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 88 | |
| 89 | /* |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 90 | * Except for the root dquot, the actual dquot we got must either have |
| 91 | * the same or higher id as we saw before. |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 92 | */ |
Darrick J. Wong | c51df73 | 2020-07-14 10:37:30 -0700 | [diff] [blame] | 93 | offset = dq->q_id / qi->qi_dqperchunk; |
| 94 | if (dq->q_id && dq->q_id <= sqi->last_id) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 95 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 96 | |
Darrick J. Wong | c51df73 | 2020-07-14 10:37:30 -0700 | [diff] [blame] | 97 | sqi->last_id = dq->q_id; |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 98 | |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 99 | /* |
| 100 | * Warn if the hard limits are larger than the fs. |
| 101 | * Administrators can do this, though in production this seems |
| 102 | * suspect, which is why we flag it for review. |
| 103 | * |
| 104 | * Complain about corruption if the soft limit is greater than |
| 105 | * the hard limit. |
| 106 | */ |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 107 | if (dq->q_blk.hardlimit > mp->m_sb.sb_dblocks) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 108 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 109 | if (dq->q_blk.softlimit > dq->q_blk.hardlimit) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 110 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 111 | |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 112 | if (dq->q_ino.hardlimit > M_IGEO(mp)->maxicount) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 113 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 114 | if (dq->q_ino.softlimit > dq->q_ino.hardlimit) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 115 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 116 | |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 117 | if (dq->q_rtb.hardlimit > mp->m_sb.sb_rblocks) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 118 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 119 | if (dq->q_rtb.softlimit > dq->q_rtb.hardlimit) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 120 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 121 | |
| 122 | /* Check the resource counts. */ |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 123 | fs_icount = percpu_counter_sum(&mp->m_icount); |
| 124 | |
| 125 | /* |
| 126 | * Check that usage doesn't exceed physical limits. However, on |
| 127 | * a reflink filesystem we're allowed to exceed physical space |
| 128 | * if there are no quota limits. |
| 129 | */ |
Dave Chinner | ebd9027 | 2021-08-18 18:46:55 -0700 | [diff] [blame] | 130 | if (xfs_has_reflink(mp)) { |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 131 | if (mp->m_sb.sb_dblocks < dq->q_blk.count) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 132 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 133 | offset); |
| 134 | } else { |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 135 | if (mp->m_sb.sb_dblocks < dq->q_blk.count) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 136 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 137 | offset); |
| 138 | } |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 139 | if (dq->q_ino.count > fs_icount || dq->q_rtb.count > mp->m_sb.sb_rblocks) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 140 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 141 | |
| 142 | /* |
| 143 | * We can violate the hard limits if the admin suddenly sets a |
| 144 | * lower limit than the actual usage. However, we flag it for |
| 145 | * admin review. |
| 146 | */ |
Darrick J. Wong | c51df73 | 2020-07-14 10:37:30 -0700 | [diff] [blame] | 147 | if (dq->q_id == 0) |
| 148 | goto out; |
| 149 | |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 150 | if (dq->q_blk.hardlimit != 0 && |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 151 | dq->q_blk.count > dq->q_blk.hardlimit) |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 152 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 153 | |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 154 | if (dq->q_ino.hardlimit != 0 && |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 155 | dq->q_ino.count > dq->q_ino.hardlimit) |
Darrick J. Wong | c51df73 | 2020-07-14 10:37:30 -0700 | [diff] [blame] | 156 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
| 157 | |
Darrick J. Wong | d3537cf | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 158 | if (dq->q_rtb.hardlimit != 0 && |
Darrick J. Wong | be37d40 | 2020-07-14 10:37:31 -0700 | [diff] [blame] | 159 | dq->q_rtb.count > dq->q_rtb.hardlimit) |
Darrick J. Wong | c51df73 | 2020-07-14 10:37:30 -0700 | [diff] [blame] | 160 | xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); |
| 161 | |
| 162 | out: |
Darrick J. Wong | 8ef34723 | 2019-11-05 15:33:56 -0800 | [diff] [blame] | 163 | if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) |
Darrick J. Wong | 0523703 | 2021-03-22 09:51:52 -0700 | [diff] [blame] | 164 | return -ECANCELED; |
Darrick J. Wong | 8ef34723 | 2019-11-05 15:33:56 -0800 | [diff] [blame] | 165 | |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 166 | return 0; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 167 | } |
| 168 | |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 169 | /* Check the quota's data fork. */ |
| 170 | STATIC int |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 171 | xchk_quota_data_fork( |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 172 | struct xfs_scrub *sc) |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 173 | { |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 174 | struct xfs_bmbt_irec irec = { 0 }; |
| 175 | struct xfs_iext_cursor icur; |
| 176 | struct xfs_quotainfo *qi = sc->mp->m_quotainfo; |
| 177 | struct xfs_ifork *ifp; |
| 178 | xfs_fileoff_t max_dqid_off; |
| 179 | int error = 0; |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 180 | |
| 181 | /* Invoke the fork scrubber. */ |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 182 | error = xchk_metadata_inode_forks(sc); |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 183 | if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) |
| 184 | return error; |
| 185 | |
| 186 | /* Check for data fork problems that apply only to quota files. */ |
| 187 | max_dqid_off = ((xfs_dqid_t)-1) / qi->qi_dqperchunk; |
| 188 | ifp = XFS_IFORK_PTR(sc->ip, XFS_DATA_FORK); |
| 189 | for_each_xfs_iext(ifp, &icur, &irec) { |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 190 | if (xchk_should_terminate(sc, &error)) |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 191 | break; |
| 192 | /* |
| 193 | * delalloc extents or blocks mapped above the highest |
| 194 | * quota id shouldn't happen. |
| 195 | */ |
| 196 | if (isnullstartblock(irec.br_startblock) || |
| 197 | irec.br_startoff > max_dqid_off || |
| 198 | irec.br_startoff + irec.br_blockcount - 1 > max_dqid_off) { |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 199 | xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 200 | irec.br_startoff); |
| 201 | break; |
| 202 | } |
| 203 | } |
| 204 | |
| 205 | return error; |
| 206 | } |
| 207 | |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 208 | /* Scrub all of a quota type's items. */ |
| 209 | int |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 210 | xchk_quota( |
Darrick J. Wong | 1d8a748 | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 211 | struct xfs_scrub *sc) |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 212 | { |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 213 | struct xchk_quota_info sqi; |
| 214 | struct xfs_mount *mp = sc->mp; |
| 215 | struct xfs_quotainfo *qi = mp->m_quotainfo; |
Darrick J. Wong | 1a7ed27 | 2020-07-15 17:53:43 -0700 | [diff] [blame] | 216 | xfs_dqtype_t dqtype; |
Darrick J. Wong | 032d91f | 2018-07-19 12:29:12 -0700 | [diff] [blame] | 217 | int error = 0; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 218 | |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 219 | dqtype = xchk_quota_to_dqtype(sc); |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 220 | |
| 221 | /* Look for problem extents. */ |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 222 | error = xchk_quota_data_fork(sc); |
Darrick J. Wong | 87d9d60 | 2018-05-14 06:34:33 -0700 | [diff] [blame] | 223 | if (error) |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 224 | goto out; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 225 | if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) |
| 226 | goto out; |
| 227 | |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 228 | /* |
| 229 | * Check all the quota items. Now that we've checked the quota inode |
| 230 | * data fork we have to drop ILOCK_EXCL to use the regular dquot |
| 231 | * functions. |
| 232 | */ |
| 233 | xfs_iunlock(sc->ip, sc->ilock_flags); |
| 234 | sc->ilock_flags = 0; |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 235 | sqi.sc = sc; |
| 236 | sqi.last_id = 0; |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 237 | error = xfs_qm_dqiterate(mp, dqtype, xchk_quota_item, &sqi); |
Darrick J. Wong | eb41c93 | 2018-05-09 10:02:00 -0700 | [diff] [blame] | 238 | sc->ilock_flags = XFS_ILOCK_EXCL; |
| 239 | xfs_ilock(sc->ip, sc->ilock_flags); |
Darrick J. Wong | 0523703 | 2021-03-22 09:51:52 -0700 | [diff] [blame] | 240 | if (error == -ECANCELED) |
| 241 | error = 0; |
Darrick J. Wong | c517b3a | 2018-07-19 12:29:11 -0700 | [diff] [blame] | 242 | if (!xchk_fblock_process_error(sc, XFS_DATA_FORK, |
Darrick J. Wong | 554ba96 | 2018-05-04 15:31:21 -0700 | [diff] [blame] | 243 | sqi.last_id * qi->qi_dqperchunk, &error)) |
| 244 | goto out; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 245 | |
| 246 | out: |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 247 | return error; |
Darrick J. Wong | c2fc338 | 2017-10-17 21:37:47 -0700 | [diff] [blame] | 248 | } |