@@ -165,6 +165,74 @@ xchk_setup_metapath_rtginode(
165165# define xchk_setup_metapath_rtginode (...) (-ENOENT)
166166#endif /* CONFIG_XFS_RT */
167167
168+ #ifdef CONFIG_XFS_QUOTA
169+ /* Scan the /quota directory itself. */
170+ static int
171+ xchk_setup_metapath_quotadir (
172+ struct xfs_scrub * sc )
173+ {
174+ struct xfs_trans * tp ;
175+ struct xfs_inode * dp = NULL ;
176+ int error ;
177+
178+ error = xfs_trans_alloc_empty (sc -> mp , & tp );
179+ if (error )
180+ return error ;
181+
182+ error = xfs_dqinode_load_parent (tp , & dp );
183+ xfs_trans_cancel (tp );
184+ if (error )
185+ return error ;
186+
187+ error = xchk_setup_metapath_scan (sc , sc -> mp -> m_metadirip ,
188+ kasprintf (GFP_KERNEL , "quota" ), dp );
189+ xfs_irele (dp );
190+ return error ;
191+ }
192+
193+ /* Scan a quota inode under the /quota directory. */
194+ static int
195+ xchk_setup_metapath_dqinode (
196+ struct xfs_scrub * sc ,
197+ xfs_dqtype_t type )
198+ {
199+ struct xfs_trans * tp = NULL ;
200+ struct xfs_inode * dp = NULL ;
201+ struct xfs_inode * ip = NULL ;
202+ const char * path ;
203+ int error ;
204+
205+ error = xfs_trans_alloc_empty (sc -> mp , & tp );
206+ if (error )
207+ return error ;
208+
209+ error = xfs_dqinode_load_parent (tp , & dp );
210+ if (error )
211+ goto out_cancel ;
212+
213+ error = xfs_dqinode_load (tp , dp , type , & ip );
214+ if (error )
215+ goto out_dp ;
216+
217+ xfs_trans_cancel (tp );
218+ tp = NULL ;
219+
220+ path = kasprintf (GFP_KERNEL , "%s" , xfs_dqinode_path (type ));
221+ error = xchk_setup_metapath_scan (sc , dp , path , ip );
222+
223+ xfs_irele (ip );
224+ out_dp :
225+ xfs_irele (dp );
226+ out_cancel :
227+ if (tp )
228+ xfs_trans_cancel (tp );
229+ return error ;
230+ }
231+ #else
232+ # define xchk_setup_metapath_quotadir (...) (-ENOENT)
233+ # define xchk_setup_metapath_dqinode (...) (-ENOENT)
234+ #endif /* CONFIG_XFS_QUOTA */
235+
168236int
169237xchk_setup_metapath (
170238 struct xfs_scrub * sc )
@@ -186,6 +254,14 @@ xchk_setup_metapath(
186254 return xchk_setup_metapath_rtginode (sc , XFS_RTGI_BITMAP );
187255 case XFS_SCRUB_METAPATH_RTSUMMARY :
188256 return xchk_setup_metapath_rtginode (sc , XFS_RTGI_SUMMARY );
257+ case XFS_SCRUB_METAPATH_QUOTADIR :
258+ return xchk_setup_metapath_quotadir (sc );
259+ case XFS_SCRUB_METAPATH_USRQUOTA :
260+ return xchk_setup_metapath_dqinode (sc , XFS_DQTYPE_USER );
261+ case XFS_SCRUB_METAPATH_GRPQUOTA :
262+ return xchk_setup_metapath_dqinode (sc , XFS_DQTYPE_GROUP );
263+ case XFS_SCRUB_METAPATH_PRJQUOTA :
264+ return xchk_setup_metapath_dqinode (sc , XFS_DQTYPE_PROJ );
189265 default :
190266 return - ENOENT ;
191267 }
0 commit comments