@@ -397,16 +397,17 @@ static int bh_get(struct gfs2_quota_data *qd)
397
397
struct inode * inode = sdp -> sd_qc_inode ;
398
398
struct gfs2_inode * ip = GFS2_I (inode );
399
399
unsigned int block , offset ;
400
- struct buffer_head * bh ;
400
+ struct buffer_head * bh = NULL ;
401
401
struct iomap iomap = { };
402
402
int error ;
403
403
404
- mutex_lock ( & sdp -> sd_quota_mutex );
405
-
406
- if ( qd -> qd_bh_count ++ ) {
407
- mutex_unlock ( & sdp -> sd_quota_mutex );
404
+ spin_lock ( & qd -> qd_lockref . lock );
405
+ if ( qd -> qd_bh_count ) {
406
+ qd -> qd_bh_count ++ ;
407
+ spin_unlock ( & qd -> qd_lockref . lock );
408
408
return 0 ;
409
409
}
410
+ spin_unlock (& qd -> qd_lockref .lock );
410
411
411
412
block = qd -> qd_slot / sdp -> sd_qc_per_block ;
412
413
offset = qd -> qd_slot % sdp -> sd_qc_per_block ;
@@ -415,48 +416,50 @@ static int bh_get(struct gfs2_quota_data *qd)
415
416
(loff_t )block << inode -> i_blkbits ,
416
417
i_blocksize (inode ), & iomap );
417
418
if (error )
418
- goto fail ;
419
+ return error ;
419
420
error = - ENOENT ;
420
421
if (iomap .type != IOMAP_MAPPED )
421
- goto fail ;
422
+ return error ;
422
423
423
424
error = gfs2_meta_read (ip -> i_gl , iomap .addr >> inode -> i_blkbits ,
424
425
DIO_WAIT , 0 , & bh );
425
426
if (error )
426
- goto fail ;
427
+ return error ;
427
428
error = - EIO ;
428
429
if (gfs2_metatype_check (sdp , bh , GFS2_METATYPE_QC ))
429
- goto fail_brelse ;
430
-
431
- qd -> qd_bh = bh ;
432
- qd -> qd_bh_qc = (struct gfs2_quota_change * )
433
- (bh -> b_data + sizeof (struct gfs2_meta_header ) +
434
- offset * sizeof (struct gfs2_quota_change ));
435
-
436
- mutex_unlock (& sdp -> sd_quota_mutex );
430
+ goto out ;
437
431
438
- return 0 ;
432
+ spin_lock (& qd -> qd_lockref .lock );
433
+ if (qd -> qd_bh == NULL ) {
434
+ qd -> qd_bh = bh ;
435
+ qd -> qd_bh_qc = (struct gfs2_quota_change * )
436
+ (bh -> b_data + sizeof (struct gfs2_meta_header ) +
437
+ offset * sizeof (struct gfs2_quota_change ));
438
+ bh = NULL ;
439
+ }
440
+ qd -> qd_bh_count ++ ;
441
+ spin_unlock (& qd -> qd_lockref .lock );
442
+ error = 0 ;
439
443
440
- fail_brelse :
444
+ out :
441
445
brelse (bh );
442
- fail :
443
- qd -> qd_bh_count -- ;
444
- mutex_unlock (& sdp -> sd_quota_mutex );
445
446
return error ;
446
447
}
447
448
448
449
static void bh_put (struct gfs2_quota_data * qd )
449
450
{
450
451
struct gfs2_sbd * sdp = qd -> qd_sbd ;
452
+ struct buffer_head * bh = NULL ;
451
453
452
- mutex_lock ( & sdp -> sd_quota_mutex );
454
+ spin_lock ( & qd -> qd_lockref . lock );
453
455
gfs2_assert (sdp , qd -> qd_bh_count );
454
456
if (!-- qd -> qd_bh_count ) {
455
- brelse ( qd -> qd_bh ) ;
457
+ bh = qd -> qd_bh ;
456
458
qd -> qd_bh = NULL ;
457
459
qd -> qd_bh_qc = NULL ;
458
460
}
459
- mutex_unlock (& sdp -> sd_quota_mutex );
461
+ spin_unlock (& qd -> qd_lockref .lock );
462
+ brelse (bh );
460
463
}
461
464
462
465
static bool qd_grab_sync (struct gfs2_sbd * sdp , struct gfs2_quota_data * qd ,
@@ -676,7 +679,6 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
676
679
bool needs_put = false;
677
680
s64 x ;
678
681
679
- mutex_lock (& sdp -> sd_quota_mutex );
680
682
gfs2_trans_add_meta (ip -> i_gl , qd -> qd_bh );
681
683
682
684
/*
@@ -720,7 +722,6 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
720
722
}
721
723
if (change < 0 ) /* Reset quiet flag if we freed some blocks */
722
724
clear_bit (QDF_QMSG_QUIET , & qd -> qd_flags );
723
- mutex_unlock (& sdp -> sd_quota_mutex );
724
725
}
725
726
726
727
static int gfs2_write_buf_to_page (struct gfs2_sbd * sdp , unsigned long index ,
0 commit comments