File tree Expand file tree Collapse file tree 8 files changed +53
-29
lines changed Expand file tree Collapse file tree 8 files changed +53
-29
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,7 @@ xchk_setup_inode_bmap(
38
38
if (error )
39
39
goto out ;
40
40
41
- sc -> ilock_flags = XFS_IOLOCK_EXCL ;
42
- xfs_ilock (sc -> ip , XFS_IOLOCK_EXCL );
41
+ xchk_ilock (sc , XFS_IOLOCK_EXCL );
43
42
44
43
/*
45
44
* We don't want any ephemeral data/cow fork updates sitting around
@@ -50,8 +49,7 @@ xchk_setup_inode_bmap(
50
49
sc -> sm -> sm_type != XFS_SCRUB_TYPE_BMBTA ) {
51
50
struct address_space * mapping = VFS_I (sc -> ip )-> i_mapping ;
52
51
53
- sc -> ilock_flags |= XFS_MMAPLOCK_EXCL ;
54
- xfs_ilock (sc -> ip , XFS_MMAPLOCK_EXCL );
52
+ xchk_ilock (sc , XFS_MMAPLOCK_EXCL );
55
53
56
54
inode_dio_wait (VFS_I (sc -> ip ));
57
55
@@ -79,9 +77,8 @@ xchk_setup_inode_bmap(
79
77
error = xchk_trans_alloc (sc , 0 );
80
78
if (error )
81
79
goto out ;
82
- sc -> ilock_flags |= XFS_ILOCK_EXCL ;
83
- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
84
80
81
+ xchk_ilock (sc , XFS_ILOCK_EXCL );
85
82
out :
86
83
/* scrub teardown will unlock and release the inode */
87
84
return error ;
Original file line number Diff line number Diff line change @@ -1022,20 +1022,48 @@ xchk_setup_inode_contents(
1022
1022
return error ;
1023
1023
1024
1024
/* 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 );
1027
1026
1028
1027
error = xchk_trans_alloc (sc , resblks );
1029
1028
if (error )
1030
1029
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 );
1034
1031
out :
1035
1032
/* scrub teardown will unlock and release the inode for us */
1036
1033
return error ;
1037
1034
}
1038
1035
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
+
1039
1067
/*
1040
1068
* Predicate that decides if we need to evaluate the cross-reference check.
1041
1069
* 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);
138
138
int xchk_iget_for_scrubbing (struct xfs_scrub * sc );
139
139
int xchk_setup_inode_contents (struct xfs_scrub * sc , unsigned int resblks );
140
140
int 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
+
141
146
void xchk_buffer_recheck (struct xfs_scrub * sc , struct xfs_buf * bp );
142
147
143
148
int 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(
32
32
{
33
33
int error ;
34
34
35
- sc -> ilock_flags = XFS_IOLOCK_EXCL ;
36
- xfs_ilock (sc -> ip , sc -> ilock_flags );
35
+ xchk_ilock (sc , XFS_IOLOCK_EXCL );
37
36
38
37
error = xchk_trans_alloc (sc , 0 );
39
38
if (error )
40
39
return error ;
41
40
42
- sc -> ilock_flags |= XFS_ILOCK_EXCL ;
43
- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
41
+ xchk_ilock (sc , XFS_ILOCK_EXCL );
44
42
return 0 ;
45
43
}
46
44
Original file line number Diff line number Diff line change @@ -150,8 +150,8 @@ xchk_parent_validate(
150
150
151
151
lock_mode = xchk_parent_ilock_dir (dp );
152
152
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 );
155
155
error = - EAGAIN ;
156
156
goto out_rele ;
157
157
}
Original file line number Diff line number Diff line change @@ -64,8 +64,7 @@ xchk_setup_quota(
64
64
if (error )
65
65
return error ;
66
66
67
- xfs_ilock (sc -> ip , XFS_ILOCK_EXCL );
68
- sc -> ilock_flags = XFS_ILOCK_EXCL ;
67
+ xchk_ilock (sc , XFS_ILOCK_EXCL );
69
68
return 0 ;
70
69
}
71
70
@@ -239,13 +238,11 @@ xchk_quota(
239
238
* data fork we have to drop ILOCK_EXCL to use the regular dquot
240
239
* functions.
241
240
*/
242
- xfs_iunlock (sc -> ip , sc -> ilock_flags );
243
- sc -> ilock_flags = 0 ;
241
+ xchk_iunlock (sc , sc -> ilock_flags );
244
242
sqi .sc = sc ;
245
243
sqi .last_id = 0 ;
246
244
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 );
249
246
if (error == - ECANCELED )
250
247
error = 0 ;
251
248
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(
32
32
if (error )
33
33
return error ;
34
34
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 );
37
36
return 0 ;
38
37
}
39
38
@@ -143,8 +142,8 @@ xchk_rtsummary(
143
142
* flags so that we don't mix up the inode state that @sc tracks.
144
143
*/
145
144
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 );
148
147
149
148
/* Invoke the fork scrubber. */
150
149
error = xchk_metadata_inode_forks (sc );
@@ -155,7 +154,7 @@ xchk_rtsummary(
155
154
xchk_set_incomplete (sc );
156
155
out :
157
156
/* 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 );
159
158
sc -> ilock_flags = old_ilock_flags ;
160
159
sc -> ip = old_ip ;
161
160
return error ;
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ xchk_teardown(
177
177
}
178
178
if (sc -> ip ) {
179
179
if (sc -> ilock_flags )
180
- xfs_iunlock (sc -> ip , sc -> ilock_flags );
180
+ xchk_iunlock (sc , sc -> ilock_flags );
181
181
xchk_irele (sc , sc -> ip );
182
182
sc -> ip = NULL ;
183
183
}
You can’t perform that action at this time.
0 commit comments