File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ xchk_setup_inode_bmap(
3838 if (error )
3939 goto out ;
4040
41- sc -> ilock_flags = XFS_IOLOCK_EXCL ;
42- xfs_ilock (sc -> ip , XFS_IOLOCK_EXCL );
41+ xchk_ilock (sc , XFS_IOLOCK_EXCL );
4342
4443 /*
4544 * We don't want any ephemeral data/cow fork updates sitting around
@@ -50,8 +49,7 @@ xchk_setup_inode_bmap(
5049 sc -> sm -> sm_type != XFS_SCRUB_TYPE_BMBTA ) {
5150 struct address_space * mapping = VFS_I (sc -> ip )-> i_mapping ;
5251
53- sc -> ilock_flags |= XFS_MMAPLOCK_EXCL ;
54- xfs_ilock (sc -> ip , XFS_MMAPLOCK_EXCL );
52+ xchk_ilock (sc , XFS_MMAPLOCK_EXCL );
5553
5654 inode_dio_wait (VFS_I (sc -> ip ));
5755
@@ -79,9 +77,8 @@ xchk_setup_inode_bmap(
7977 error = xchk_trans_alloc (sc , 0 );
8078 if (error )
8179 goto out ;
82- sc -> ilock_flags |= XFS_ILOCK_EXCL ;
83- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
8480
81+ xchk_ilock (sc , XFS_ILOCK_EXCL );
8582out :
8683 /* scrub teardown will unlock and release the inode */
8784 return error ;
Original file line number Diff line number Diff line change @@ -1022,20 +1022,48 @@ xchk_setup_inode_contents(
10221022 return error ;
10231023
10241024 /* Lock the inode so the VFS cannot touch this file. */
1025- sc -> ilock_flags = XFS_IOLOCK_EXCL ;
1026- xfs_ilock (sc -> ip , sc -> ilock_flags );
1025+ xchk_ilock (sc , XFS_IOLOCK_EXCL );
10271026
10281027 error = xchk_trans_alloc (sc , resblks );
10291028 if (error )
10301029 goto out ;
1031- sc -> ilock_flags |= XFS_ILOCK_EXCL ;
1032- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
1033-
1030+ xchk_ilock (sc , XFS_ILOCK_EXCL );
10341031out :
10351032 /* scrub teardown will unlock and release the inode for us */
10361033 return error ;
10371034}
10381035
1036+ void
1037+ xchk_ilock (
1038+ struct xfs_scrub * sc ,
1039+ unsigned int ilock_flags )
1040+ {
1041+ xfs_ilock (sc -> ip , ilock_flags );
1042+ sc -> ilock_flags |= ilock_flags ;
1043+ }
1044+
1045+ bool
1046+ xchk_ilock_nowait (
1047+ struct xfs_scrub * sc ,
1048+ unsigned int ilock_flags )
1049+ {
1050+ if (xfs_ilock_nowait (sc -> ip , ilock_flags )) {
1051+ sc -> ilock_flags |= ilock_flags ;
1052+ return true;
1053+ }
1054+
1055+ return false;
1056+ }
1057+
1058+ void
1059+ xchk_iunlock (
1060+ struct xfs_scrub * sc ,
1061+ unsigned int ilock_flags )
1062+ {
1063+ sc -> ilock_flags &= ~ilock_flags ;
1064+ xfs_iunlock (sc -> ip , ilock_flags );
1065+ }
1066+
10391067/*
10401068 * Predicate that decides if we need to evaluate the cross-reference check.
10411069 * If there was an error accessing the cross-reference btree, just delete
Original file line number Diff line number Diff line change @@ -138,6 +138,11 @@ int xchk_setup_ag_btree(struct xfs_scrub *sc, bool force_log);
138138int xchk_iget_for_scrubbing (struct xfs_scrub * sc );
139139int xchk_setup_inode_contents (struct xfs_scrub * sc , unsigned int resblks );
140140int xchk_install_live_inode (struct xfs_scrub * sc , struct xfs_inode * ip );
141+
142+ void xchk_ilock (struct xfs_scrub * sc , unsigned int ilock_flags );
143+ bool xchk_ilock_nowait (struct xfs_scrub * sc , unsigned int ilock_flags );
144+ void xchk_iunlock (struct xfs_scrub * sc , unsigned int ilock_flags );
145+
141146void xchk_buffer_recheck (struct xfs_scrub * sc , struct xfs_buf * bp );
142147
143148int xchk_iget (struct xfs_scrub * sc , xfs_ino_t inum , struct xfs_inode * * ipp );
Original file line number Diff line number Diff line change @@ -32,15 +32,13 @@ xchk_prepare_iscrub(
3232{
3333 int error ;
3434
35- sc -> ilock_flags = XFS_IOLOCK_EXCL ;
36- xfs_ilock (sc -> ip , sc -> ilock_flags );
35+ xchk_ilock (sc , XFS_IOLOCK_EXCL );
3736
3837 error = xchk_trans_alloc (sc , 0 );
3938 if (error )
4039 return error ;
4140
42- sc -> ilock_flags |= XFS_ILOCK_EXCL ;
43- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
41+ xchk_ilock (sc , XFS_ILOCK_EXCL );
4442 return 0 ;
4543}
4644
Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ xchk_parent_validate(
150150
151151 lock_mode = xchk_parent_ilock_dir (dp );
152152 if (!lock_mode ) {
153- xfs_iunlock (sc -> ip , XFS_ILOCK_EXCL );
154- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
153+ xchk_iunlock (sc , XFS_ILOCK_EXCL );
154+ xchk_ilock (sc , XFS_ILOCK_EXCL );
155155 error = - EAGAIN ;
156156 goto out_rele ;
157157 }
Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ xchk_setup_quota(
6464 if (error )
6565 return error ;
6666
67- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
68- sc -> ilock_flags = XFS_ILOCK_EXCL ;
67+ xchk_ilock (sc , XFS_ILOCK_EXCL );
6968 return 0 ;
7069}
7170
@@ -239,13 +238,11 @@ xchk_quota(
239238 * data fork we have to drop ILOCK_EXCL to use the regular dquot
240239 * functions.
241240 */
242- xfs_iunlock (sc -> ip , sc -> ilock_flags );
243- sc -> ilock_flags = 0 ;
241+ xchk_iunlock (sc , sc -> ilock_flags );
244242 sqi .sc = sc ;
245243 sqi .last_id = 0 ;
246244 error = xfs_qm_dqiterate (mp , dqtype , xchk_quota_item , & sqi );
247- sc -> ilock_flags = XFS_ILOCK_EXCL ;
248- xfs_ilock (sc -> ip , sc -> ilock_flags );
245+ xchk_ilock (sc , XFS_ILOCK_EXCL );
249246 if (error == - ECANCELED )
250247 error = 0 ;
251248 if (!xchk_fblock_process_error (sc , XFS_DATA_FORK ,
Original file line number Diff line number Diff line change @@ -32,8 +32,7 @@ xchk_setup_rt(
3232 if (error )
3333 return error ;
3434
35- sc -> ilock_flags = XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP ;
36- xfs_ilock (sc -> ip , sc -> ilock_flags );
35+ xchk_ilock (sc , XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP );
3736 return 0 ;
3837}
3938
@@ -143,8 +142,8 @@ xchk_rtsummary(
143142 * flags so that we don't mix up the inode state that @sc tracks.
144143 */
145144 sc -> ip = rsumip ;
146- sc -> ilock_flags = XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM ;
147- xfs_ilock (sc -> ip , sc -> ilock_flags );
145+ sc -> ilock_flags = 0 ;
146+ xchk_ilock (sc , XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM );
148147
149148 /* Invoke the fork scrubber. */
150149 error = xchk_metadata_inode_forks (sc );
@@ -155,7 +154,7 @@ xchk_rtsummary(
155154 xchk_set_incomplete (sc );
156155out :
157156 /* Switch back to the rtbitmap inode and lock flags. */
158- xfs_iunlock (sc -> ip , sc -> ilock_flags );
157+ xchk_iunlock (sc , XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM );
159158 sc -> ilock_flags = old_ilock_flags ;
160159 sc -> ip = old_ip ;
161160 return error ;
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ xchk_teardown(
177177 }
178178 if (sc -> ip ) {
179179 if (sc -> ilock_flags )
180- xfs_iunlock (sc -> ip , sc -> ilock_flags );
180+ xchk_iunlock (sc , sc -> ilock_flags );
181181 xchk_irele (sc , sc -> ip );
182182 sc -> ip = NULL ;
183183 }
You can’t perform that action at this time.
0 commit comments