62
62
63
63
/* make sure inq_product_rev string corresponds to this version */
64
64
#define SDEBUG_VERSION "0188" /* format to fit INQUIRY revision field */
65
- static const char * sdebug_version_date = "20180128 " ;
65
+ static const char * sdebug_version_date = "20190125 " ;
66
66
67
67
#define MY_NAME "scsi_debug"
68
68
@@ -735,7 +735,7 @@ static inline bool scsi_debug_lbp(void)
735
735
(sdebug_lbpu || sdebug_lbpws || sdebug_lbpws10 );
736
736
}
737
737
738
- static void * fake_store (unsigned long long lba )
738
+ static void * lba2fake_store (unsigned long long lba )
739
739
{
740
740
lba = do_div (lba , sdebug_store_sectors );
741
741
@@ -2514,8 +2514,8 @@ static int do_device_access(struct scsi_cmnd *scmd, u32 sg_skip, u64 lba,
2514
2514
return ret ;
2515
2515
}
2516
2516
2517
- /* If fake_store (lba,num) compares equal to arr(num), then copy top half of
2518
- * arr into fake_store (lba,num) and return true. If comparison fails then
2517
+ /* If lba2fake_store (lba,num) compares equal to arr(num), then copy top half of
2518
+ * arr into lba2fake_store (lba,num) and return true. If comparison fails then
2519
2519
* return false. */
2520
2520
static bool comp_write_worker (u64 lba , u32 num , const u8 * arr )
2521
2521
{
@@ -2643,7 +2643,7 @@ static int prot_verify_read(struct scsi_cmnd *SCpnt, sector_t start_sec,
2643
2643
if (sdt -> app_tag == cpu_to_be16 (0xffff ))
2644
2644
continue ;
2645
2645
2646
- ret = dif_verify (sdt , fake_store (sector ), sector , ei_lba );
2646
+ ret = dif_verify (sdt , lba2fake_store (sector ), sector , ei_lba );
2647
2647
if (ret ) {
2648
2648
dif_errors ++ ;
2649
2649
return ret ;
@@ -3261,10 +3261,12 @@ static int resp_write_scat(struct scsi_cmnd *scp,
3261
3261
static int resp_write_same (struct scsi_cmnd * scp , u64 lba , u32 num ,
3262
3262
u32 ei_lba , bool unmap , bool ndob )
3263
3263
{
3264
+ int ret ;
3264
3265
unsigned long iflags ;
3265
3266
unsigned long long i ;
3266
- int ret ;
3267
- u64 lba_off ;
3267
+ u32 lb_size = sdebug_sector_size ;
3268
+ u64 block , lbaa ;
3269
+ u8 * fs1p ;
3268
3270
3269
3271
ret = check_device_access_params (scp , lba , num );
3270
3272
if (ret )
@@ -3276,31 +3278,30 @@ static int resp_write_same(struct scsi_cmnd *scp, u64 lba, u32 num,
3276
3278
unmap_region (lba , num );
3277
3279
goto out ;
3278
3280
}
3279
-
3280
- lba_off = lba * sdebug_sector_size ;
3281
+ lbaa = lba ;
3282
+ block = do_div ( lbaa , sdebug_store_sectors ) ;
3281
3283
/* if ndob then zero 1 logical block, else fetch 1 logical block */
3284
+ fs1p = fake_storep + (block * lb_size );
3282
3285
if (ndob ) {
3283
- memset (fake_storep + lba_off , 0 , sdebug_sector_size );
3286
+ memset (fs1p , 0 , lb_size );
3284
3287
ret = 0 ;
3285
3288
} else
3286
- ret = fetch_to_dev_buffer (scp , fake_storep + lba_off ,
3287
- sdebug_sector_size );
3289
+ ret = fetch_to_dev_buffer (scp , fs1p , lb_size );
3288
3290
3289
3291
if (-1 == ret ) {
3290
3292
write_unlock_irqrestore (& atomic_rw , iflags );
3291
3293
return DID_ERROR << 16 ;
3292
- } else if (sdebug_verbose && !ndob && (ret < sdebug_sector_size ))
3294
+ } else if (sdebug_verbose && !ndob && (ret < lb_size ))
3293
3295
sdev_printk (KERN_INFO , scp -> device ,
3294
3296
"%s: %s: lb size=%u, IO sent=%d bytes\n" ,
3295
- my_name , "write same" ,
3296
- sdebug_sector_size , ret );
3297
+ my_name , "write same" , lb_size , ret );
3297
3298
3298
3299
/* Copy first sector to remaining blocks */
3299
- for (i = 1 ; i < num ; i ++ )
3300
- memcpy ( fake_storep + (( lba + i ) * sdebug_sector_size ),
3301
- fake_storep + lba_off ,
3302
- sdebug_sector_size );
3303
-
3300
+ for (i = 1 ; i < num ; i ++ ) {
3301
+ lbaa = lba + i ;
3302
+ block = do_div ( lbaa , sdebug_store_sectors );
3303
+ memmove ( fake_storep + ( block * lb_size ), fs1p , lb_size );
3304
+ }
3304
3305
if (scsi_debug_lbp ())
3305
3306
map_region (lba , num );
3306
3307
out :
0 commit comments