@@ -462,13 +462,13 @@ static void bh_put(struct gfs2_quota_data *qd)
462
462
mutex_unlock (& sdp -> sd_quota_mutex );
463
463
}
464
464
465
- static int qd_check_sync (struct gfs2_sbd * sdp , struct gfs2_quota_data * qd ,
466
- u64 * sync_gen )
465
+ static bool qd_grab_sync (struct gfs2_sbd * sdp , struct gfs2_quota_data * qd ,
466
+ u64 sync_gen )
467
467
{
468
468
if (test_bit (QDF_LOCKED , & qd -> qd_flags ) ||
469
469
!test_bit (QDF_CHANGE , & qd -> qd_flags ) ||
470
- ( sync_gen && ( qd -> qd_sync_gen >= * sync_gen )) )
471
- return 0 ;
470
+ qd -> qd_sync_gen >= sync_gen )
471
+ return false ;
472
472
473
473
/*
474
474
* If qd_change is 0 it means a pending quota change was negated.
@@ -478,17 +478,24 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd,
478
478
if (!qd -> qd_change && test_and_clear_bit (QDF_CHANGE , & qd -> qd_flags )) {
479
479
slot_put (qd );
480
480
qd_put (qd );
481
- return 0 ;
481
+ return false ;
482
482
}
483
483
484
484
if (!lockref_get_not_dead (& qd -> qd_lockref ))
485
- return 0 ;
485
+ return false ;
486
486
487
487
list_move_tail (& qd -> qd_list , & sdp -> sd_quota_list );
488
488
set_bit (QDF_LOCKED , & qd -> qd_flags );
489
489
qd -> qd_change_sync = qd -> qd_change ;
490
490
slot_hold (qd );
491
- return 1 ;
491
+ return true;
492
+ }
493
+
494
+ static void qd_ungrab_sync (struct gfs2_quota_data * qd )
495
+ {
496
+ clear_bit (QDF_LOCKED , & qd -> qd_flags );
497
+ slot_put (qd );
498
+ qd_put (qd );
492
499
}
493
500
494
501
static int qd_fish (struct gfs2_sbd * sdp , struct gfs2_quota_data * * qdp )
@@ -504,7 +511,7 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
504
511
spin_lock (& qd_lock );
505
512
506
513
list_for_each_entry (iter , & sdp -> sd_quota_list , qd_list ) {
507
- if (qd_check_sync (sdp , iter , & sdp -> sd_quota_sync_gen )) {
514
+ if (qd_grab_sync (sdp , iter , sdp -> sd_quota_sync_gen )) {
508
515
qd = iter ;
509
516
break ;
510
517
}
@@ -515,9 +522,7 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp)
515
522
if (qd ) {
516
523
error = bh_get (qd );
517
524
if (error ) {
518
- clear_bit (QDF_LOCKED , & qd -> qd_flags );
519
- slot_put (qd );
520
- qd_put (qd );
525
+ qd_ungrab_sync (qd );
521
526
return error ;
522
527
}
523
528
}
@@ -1157,14 +1162,14 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
1157
1162
struct gfs2_quota_data * qda [2 * GFS2_MAXQUOTAS ];
1158
1163
unsigned int count = 0 ;
1159
1164
u32 x ;
1160
- int found ;
1161
1165
1162
1166
if (!test_and_clear_bit (GIF_QD_LOCKED , & ip -> i_flags ))
1163
1167
return ;
1164
1168
1165
1169
for (x = 0 ; x < ip -> i_qadata -> qa_qd_num ; x ++ ) {
1166
1170
struct gfs2_quota_data * qd ;
1167
1171
bool sync ;
1172
+ int error ;
1168
1173
1169
1174
qd = ip -> i_qadata -> qa_qd [x ];
1170
1175
sync = need_sync (qd );
@@ -1174,17 +1179,16 @@ void gfs2_quota_unlock(struct gfs2_inode *ip)
1174
1179
continue ;
1175
1180
1176
1181
spin_lock (& qd_lock );
1177
- found = qd_check_sync (sdp , qd , NULL );
1182
+ sync = qd_grab_sync (sdp , qd , U64_MAX );
1178
1183
spin_unlock (& qd_lock );
1179
1184
1180
- if (!found )
1185
+ if (!sync )
1181
1186
continue ;
1182
1187
1183
1188
gfs2_assert_warn (sdp , qd -> qd_change_sync );
1184
- if (bh_get (qd )) {
1185
- clear_bit (QDF_LOCKED , & qd -> qd_flags );
1186
- slot_put (qd );
1187
- qd_put (qd );
1189
+ error = bh_get (qd );
1190
+ if (error ) {
1191
+ qd_ungrab_sync (qd );
1188
1192
continue ;
1189
1193
}
1190
1194
0 commit comments