Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: cxlflash: Fix vlun resize failure in the shrink path

The ioctl DK_CAPI_VLUN_RESIZE can fail if the allocated vlun size is
reduced from almost maximum capacity and then increased again.

The shrink_lxt() routine is currently using the SISL_ASTATUS_MASK to
mask the higher 48 bits of the lxt entry. This is unnecessary and
incorrect as it uses a mask designed for the asynchronous interrupt
status register. When the 4 port support was added to cxlflash, the
SISL_ASTATUS_MASK was updated to reflect the status bits for all 4
ports. This change indirectly affected the shrink_lxt() code path.

To extract the base, simply shift the bits without masking.

Fixes: 565180723294 ("scsi: cxlflash: SISlite updates to support 4 ports")
Signed-off-by: Uma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Uma Krishnan and committed by
Martin K. Petersen
07a191f7 1a9e3941

+1 -5
+1 -5
drivers/scsi/cxlflash/vlun.c
··· 694 694 /* Free LBAs allocated to freed chunks */ 695 695 mutex_lock(&blka->mutex); 696 696 for (i = delta - 1; i >= 0; i--) { 697 - /* Mask the higher 48 bits before shifting, even though 698 - * it is a noop 699 - */ 700 - aun = (lxt_old[my_new_size + i].rlba_base & SISL_ASTATUS_MASK); 701 - aun = (aun >> MC_CHUNK_SHIFT); 697 + aun = lxt_old[my_new_size + i].rlba_base >> MC_CHUNK_SHIFT; 702 698 if (needs_ws) 703 699 write_same16(sdev, aun, MC_CHUNK_SIZE); 704 700 ba_free(&blka->ba_lun, aun);