diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index cfe6bd154e8d..a922c8318a2f 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -4052,24 +4052,27 @@ static inline struct sdeb_store_info *devip2sip(struct sdebug_dev_info *devip, static inline void sdeb_read_lock(rwlock_t *lock) + __acquires_shared(lock) { if (sdebug_no_rwlock) - __acquire(lock); + __acquire_shared(lock); else read_lock(lock); } static inline void sdeb_read_unlock(rwlock_t *lock) + __releases_shared(lock) { if (sdebug_no_rwlock) - __release(lock); + __release_shared(lock); else read_unlock(lock); } static inline void sdeb_write_lock(rwlock_t *lock) + __acquires(lock) { if (sdebug_no_rwlock) __acquire(lock); @@ -4079,6 +4082,7 @@ sdeb_write_lock(rwlock_t *lock) static inline void sdeb_write_unlock(rwlock_t *lock) + __releases(lock) { if (sdebug_no_rwlock) __release(lock); @@ -4088,6 +4092,7 @@ sdeb_write_unlock(rwlock_t *lock) static inline void sdeb_data_read_lock(struct sdeb_store_info *sip) + __acquires_shared(&sip->macc_data_lck) { BUG_ON(!sip); @@ -4096,6 +4101,7 @@ sdeb_data_read_lock(struct sdeb_store_info *sip) static inline void sdeb_data_read_unlock(struct sdeb_store_info *sip) + __releases_shared(&sip->macc_data_lck) { BUG_ON(!sip); @@ -4104,6 +4110,7 @@ sdeb_data_read_unlock(struct sdeb_store_info *sip) static inline void sdeb_data_write_lock(struct sdeb_store_info *sip) + __acquires(&sip->macc_data_lck) { BUG_ON(!sip); @@ -4112,6 +4119,7 @@ sdeb_data_write_lock(struct sdeb_store_info *sip) static inline void sdeb_data_write_unlock(struct sdeb_store_info *sip) + __releases(&sip->macc_data_lck) { BUG_ON(!sip); @@ -4120,6 +4128,7 @@ sdeb_data_write_unlock(struct sdeb_store_info *sip) static inline void sdeb_data_sector_read_lock(struct sdeb_store_info *sip) + __acquires_shared(&sip->macc_sector_lck) { BUG_ON(!sip); @@ -4128,6 +4137,7 @@ sdeb_data_sector_read_lock(struct sdeb_store_info *sip) static inline void sdeb_data_sector_read_unlock(struct sdeb_store_info *sip) + __releases_shared(&sip->macc_sector_lck) { BUG_ON(!sip); @@ -4136,6 +4146,7 @@ sdeb_data_sector_read_unlock(struct sdeb_store_info *sip) static inline void sdeb_data_sector_write_lock(struct sdeb_store_info *sip) + __acquires(&sip->macc_sector_lck) { BUG_ON(!sip); @@ -4144,6 +4155,7 @@ sdeb_data_sector_write_lock(struct sdeb_store_info *sip) static inline void sdeb_data_sector_write_unlock(struct sdeb_store_info *sip) + __releases(&sip->macc_sector_lck) { BUG_ON(!sip); @@ -4165,50 +4177,67 @@ sdeb_data_sector_write_unlock(struct sdeb_store_info *sip) static inline void sdeb_data_lock(struct sdeb_store_info *sip, bool atomic) + __acquires(&sip->macc_data_lck) { - if (atomic) + if (atomic) { sdeb_data_write_lock(sip); - else + } else { sdeb_data_read_lock(sip); + __release_shared(&sip->macc_data_lck); + __acquire(&sip->macc_data_lck); + } } static inline void sdeb_data_unlock(struct sdeb_store_info *sip, bool atomic) + __releases(&sip->macc_data_lck) { - if (atomic) + if (atomic) { sdeb_data_write_unlock(sip); - else + } else { + __release(&sip->macc_data_lck); + __acquire_shared(&sip->macc_data_lck); sdeb_data_read_unlock(sip); + } } /* Allow many reads but only 1x write per sector */ static inline void sdeb_data_sector_lock(struct sdeb_store_info *sip, bool do_write) + __acquires(&sip->macc_sector_lck) { - if (do_write) + if (do_write) { sdeb_data_sector_write_lock(sip); - else + } else { sdeb_data_sector_read_lock(sip); + __release_shared(&sip->macc_sector_lck); + __acquire(&sip->macc_sector_lck); + } } static inline void sdeb_data_sector_unlock(struct sdeb_store_info *sip, bool do_write) + __releases(&sip->macc_sector_lck) { - if (do_write) + if (do_write) { sdeb_data_sector_write_unlock(sip); - else + } else { + __release(&sip->macc_sector_lck); + __acquire_shared(&sip->macc_sector_lck); sdeb_data_sector_read_unlock(sip); + } } static inline void sdeb_meta_read_lock(struct sdeb_store_info *sip) + __acquires_shared(&sip->macc_meta_lck) + __context_unsafe(/* + * Can't be annotated with + * __{acquire,release}(,_shared}() without triggering + * undefined behavior. + */) { - if (sdebug_no_rwlock) { - if (sip) - __acquire(&sip->macc_meta_lck); - else - __acquire(&sdeb_fake_rw_lck); - } else { + if (!sdebug_no_rwlock) { if (sip) read_lock(&sip->macc_meta_lck); else @@ -4218,13 +4247,14 @@ sdeb_meta_read_lock(struct sdeb_store_info *sip) static inline void sdeb_meta_read_unlock(struct sdeb_store_info *sip) + __releases_shared(&sip->macc_meta_lck) + __context_unsafe(/* + * Can't be annotated with + * __{acquire,release}(,_shared}() without triggering + * undefined behavior. + */) { - if (sdebug_no_rwlock) { - if (sip) - __release(&sip->macc_meta_lck); - else - __release(&sdeb_fake_rw_lck); - } else { + if (!sdebug_no_rwlock) { if (sip) read_unlock(&sip->macc_meta_lck); else @@ -4234,13 +4264,14 @@ sdeb_meta_read_unlock(struct sdeb_store_info *sip) static inline void sdeb_meta_write_lock(struct sdeb_store_info *sip) + __acquires(&sip->macc_meta_lck) + __context_unsafe(/* + * Can't be annotated with + * __{acquire,release}(,_shared}() without triggering + * undefined behavior. + */) { - if (sdebug_no_rwlock) { - if (sip) - __acquire(&sip->macc_meta_lck); - else - __acquire(&sdeb_fake_rw_lck); - } else { + if (!sdebug_no_rwlock) { if (sip) write_lock(&sip->macc_meta_lck); else @@ -4250,13 +4281,14 @@ sdeb_meta_write_lock(struct sdeb_store_info *sip) static inline void sdeb_meta_write_unlock(struct sdeb_store_info *sip) + __releases(&sip->macc_meta_lck) + __context_unsafe(/* + * Can't be annotated with + * __{acquire,release}(,_shared}() without triggering + * undefined behavior. + */) { - if (sdebug_no_rwlock) { - if (sip) - __release(&sip->macc_meta_lck); - else - __release(&sdeb_fake_rw_lck); - } else { + if (!sdebug_no_rwlock) { if (sip) write_unlock(&sip->macc_meta_lck); else