linux/drivers/scsi
Michael Kelley 11d9874c42 scsi: storvsc: Handle BlockSize change in Hyper-V VHD/VHDX file
Hyper-V uses a VHD or VHDX file on the host as the underlying storage for a
virtual disk.  The VHD/VHDX file format is a sparse format where real disk
space on the host is assigned in chunks that the VHD/VHDX file format calls
the BlockSize.  This BlockSize is not to be confused with the 512-byte (or
4096-byte) sector size of the underlying storage device.  The default block
size for a new VHD/VHDX file is 32 Mbytes.  When a guest VM touches any
disk space within a 32 Mbyte chunk of the VHD/VHDX file, Hyper-V allocates
32 Mbytes of real disk space for that section of the VHD/VHDX. Similarly,
if a discard operation is done that covers an entire 32 Mbyte chunk,
Hyper-V will free the real disk space for that portion of the VHD/VHDX.
This BlockSize is surfaced in Linux as the "discard_granularity" in
/sys/block/sd<x>/queue, which makes sense.

Hyper-V also has differencing disks that can overlay a VHD/VHDX file to
capture changes to the VHD/VHDX while preserving the original VHD/VHDX.
One example of this differencing functionality is for VM snapshots.  When a
snapshot is created, a differencing disk is created.  If the snapshot is
rolled back, Hyper-V can just delete the differencing disk, and the VM will
see the original disk contents at the time the snapshot was taken.
Differencing disks are used in other scenarios as well.

The BlockSize for a differencing disk defaults to 2 Mbytes, not 32 Mbytes.
The smaller default is used because changes to differencing disks are
typically scattered all over, and Hyper-V doesn't want to allocate 32
Mbytes of real disk space for a stray write here or there.  The smaller
BlockSize provides more efficient use of real disk space.

When a differencing disk is added to a VHD/VHDX, Hyper-V reports
UNIT_ATTENTION with a sense code indicating "Operating parameters have
changed", because the value of discard_granularity should be changed to 2
Mbytes. When the differencing disk is removed, discard_granularity should
be changed back to 32 Mbytes.  However, current code simply reports a
message from scsi_report_sense() and the value of
/sys/block/sd<x>/queue/discard_granularity is not updated. The message
isn't very actionable by a sysadmin.

Fix this by having the storvsc driver check for the sense code indicating
that the underly VHD/VHDX block size has changed, and do a rescan of the
device to pick up the new discard_granularity.  With this change the entire
transition to/from differencing disks is handled automatically and
transparently, with no confusing messages being output.

Link: https://lore.kernel.org/r/1677516514-86060-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2023-03-06 18:33:13 -05:00
..
aacraid scsi: aacraid: Allocate cmd_priv with scsicmd 2023-02-08 18:49:48 -05:00
aic7xxx scsi: aic79xx: Use __ro_after_init explicitly 2022-09-15 22:01:24 -04:00
aic94xx scsi: aic94xx: Add missing check for dma_map_single() 2023-02-08 19:12:25 -05:00
arcmsr
arm scsi: arm: Move the SCSI pointer to private command data 2022-02-22 21:11:03 -05:00
be2iscsi scsi: iscsi: Remove iscsi_get_task back_lock requirement 2022-06-21 21:19:23 -04:00
bfa scsi: bfa: Replace one-element array with flexible-array member 2022-11-17 18:15:45 +00:00
bnx2fc scsi: bnx2fc: Avoid using get_cpu() in bnx2fc_cmd_alloc() 2022-05-16 21:26:50 -04:00
bnx2i scsi: iscsi: Fix session removal on shutdown 2022-06-21 21:14:54 -04:00
csiostor scsi: csiostor: Remove unused variable 'n' 2022-11-08 03:40:54 +00:00
cxgbi scsi: cxgbi: Remove unneeded version.h include 2023-02-21 22:00:51 -05:00
cxlflash - Daniel Verkamp has contributed a memfd series ("mm/memfd: add 2023-02-23 17:09:35 -08:00
device_handler SCSI misc on 20230222 2023-02-22 13:41:41 -08:00
elx scsi: elx: libefc_sli: Use "/*" for non-kernel-doc comment 2023-01-23 20:53:43 -05:00
esas2r scsi: esas2r: Introduce scsi_template_proc_dir() 2022-10-18 03:17:09 +00:00
fcoe SCSI misc on 20221213 2022-12-14 08:58:51 -08:00
fnic SCSI misc on 20220804 2022-08-04 19:47:37 -07:00
hisi_sas scsi: hisi_sas: Check devm_add_action() return value 2023-03-06 18:33:12 -05:00
ibmvscsi scsi: ibmvfc: Avoid path failures during live migration 2022-11-07 18:57:39 +00:00
ibmvscsi_tgt scsi: ibmvscsi_tgt: Fix repeated words in comment 2022-09-15 22:30:26 -04:00
isci scsi: isci: Fix typo in comment 2022-05-23 23:24:10 -04:00
libfc scsi: libfc: Include the correct header 2022-12-01 03:03:36 +00:00
libsas SCSI misc on 20230222 2023-02-22 13:41:41 -08:00
lpfc scsi: lpfc: Avoid usage of list iterator variable after loop 2023-03-06 18:33:12 -05:00
megaraid scsi: megaraid_sas: Driver version update to 07.725.01.00-rc1 2023-03-06 18:33:13 -05:00
mpi3mr scsi: mpi3mr: Bad drive in topology results kernel crash 2023-03-06 18:33:13 -05:00
mpt3sas SCSI misc on 20230222 2023-02-22 13:41:41 -08:00
mvsas scsi: mvsas: Use sas_task_find_rq() for tagging 2022-10-22 03:02:52 +00:00
pcmcia scsi: pcmcia: nsp_cs: Remove unused variable i 2022-10-27 02:15:46 +00:00
pm8001 scsi: pm8001: Use sysfs_emit() in show function callbacks 2023-01-11 21:53:34 -05:00
qedf scsi: qedf: Remove set but unused variable 'page' 2022-10-22 03:09:45 +00:00
qedi scsi: qedi: Remove unneeded version.h include 2023-02-21 22:00:51 -05:00
qla2xxx scsi: qla2xxx: Add option to disable FC2 Target support 2023-03-06 17:06:39 -05:00
qla4xxx scsi: core: Change the return type of .eh_timed_out() 2022-10-22 03:25:59 +00:00
smartpqi scsi: smartpqi: Replace one-element array with flexible-array member 2023-02-08 19:03:43 -05:00
snic scsi: snic: Fix memory leak with using debugfs_lookup() 2023-02-08 18:49:59 -05:00
sym53c8xx_2 scsi: sym53c8xx_2: Remove redundant "with" 2022-06-21 21:41:19 -04:00
.gitignore
3w-9xxx.c scsi: 3w-9xxx: Avoid disabling device if failing to enable it 2022-09-06 22:22:24 -04:00
3w-9xxx.h
3w-sas.c scsi: 3w-sas: Replace 1-element arrays with flexible array members 2023-01-12 00:09:52 -05:00
3w-sas.h scsi: 3w-sas: Replace 1-element arrays with flexible array members 2023-01-12 00:09:52 -05:00
3w-xxxx.c scsi: 3w-xxxx: Replace one-element array with flexible-array member 2022-09-25 13:06:00 -04:00
3w-xxxx.h scsi: 3w-xxxx: Replace one-element array with flexible-array member 2022-09-25 13:06:00 -04:00
53c700_d.h_shipped
53c700.c scsi: 53c700: Stop clearing SCSI pointer fields 2022-02-22 21:11:03 -05:00
53c700.h
53c700.scr
a100u2w.c scsi: a100u2w: Fix a kernel-doc warning 2021-11-29 23:02:13 -05:00
a100u2w.h
a2091.c scsi: a2091: Convert m68k WD33C93 drivers to DMA API 2022-07-07 17:01:22 -04:00
a2091.h
a3000.c scsi: a3000: Convert m68k WD33C93 drivers to DMA API 2022-07-07 17:01:22 -04:00
a3000.h
a4000t.c
advansys.c scsi: advansys: Move the SCSI pointer to private command data 2022-02-22 21:11:03 -05:00
aha152x.c scsi: aha152x: Stop using struct scsi_pointer 2022-03-29 23:42:18 -04:00
aha152x.h
aha1542.c scsi: aha1542: Remove unneeded semicolon 2022-04-25 23:25:11 -04:00
aha1542.h
aha1740.c scsi: Remove drivers/scsi/scsi.h 2022-02-22 21:11:02 -05:00
aha1740.h
am53c974.c
atari_scsi.c scsi: NCR5380: Add SCp members to struct NCR5380_cmd 2022-02-22 21:11:03 -05:00
atp870u.c scsi: atp870u: Fix a kernel-doc warning 2021-11-29 23:02:13 -05:00
atp870u.h
BusLogic.c scsi: BusLogic: Remove variable 'adapter_count' 2022-11-08 03:01:12 +00:00
BusLogic.h
bvme6000_scsi.c
ch.c scsi: ch: Convert to scsi_execute_cmd() 2023-01-13 21:34:08 -05:00
constants.c
dc395x.c scsi: dc395x: Fix a missing check on list iterator 2022-04-26 08:51:56 -04:00
dc395x.h
dmx3191d.c scsi: NCR5380: Remove the NCR5380_CMD_SIZE macro 2022-02-22 21:11:03 -05:00
esp_scsi.c scsi: esp_scsi: Stop using the SCSI pointer 2022-02-22 21:11:04 -05:00
esp_scsi.h scsi: esp_scsi: Stop using the SCSI pointer 2022-02-22 21:11:04 -05:00
fdomain_isa.c
fdomain_pci.c
fdomain.c scsi: fdomain: Move the SCSI pointer to private command data 2022-02-22 21:11:04 -05:00
fdomain.h
FlashPoint.c scsi: FlashPoint: Remove redundant variable bm_int_st 2022-08-01 19:52:03 -04:00
g_NCR5380.c scsi: NCR5380: Add SCp members to struct NCR5380_cmd 2022-02-22 21:11:03 -05:00
gvp11.c scsi: gvp11.c: Fix DMA mask calculation error 2022-07-13 23:18:26 -04:00
gvp11.h
hosts.c scsi: core: Remove the /proc/scsi/${proc_name} directory earlier 2023-02-21 22:00:51 -05:00
hpsa_cmd.h
hpsa.c scsi: hpsa: Fix allocation size for scsi_host_alloc() 2023-01-18 18:59:46 -05:00
hpsa.h
hptiop.c scsi: hptiop: Use struct_size() helper in code related to struct hpt_iop_request_scsi_command 2022-09-25 13:02:23 -04:00
hptiop.h scsi: hptiop: Replace one-element array with flexible-array member in struct hpt_iop_request_ioctl_command() 2022-09-25 13:04:17 -04:00
imm.c scsi: imm: Move the SCSI pointer to private command data 2022-02-22 21:11:04 -05:00
imm.h scsi: imm: Move the SCSI pointer to private command data 2022-02-22 21:11:04 -05:00
initio.c scsi: initio: Remove redundant assignment to pointer scb 2022-08-31 23:39:57 -04:00
initio.h scsi: initio: Stop using the SCSI pointer 2022-02-22 21:11:05 -05:00
ipr.c SCSI misc on 20230303 2023-03-03 14:41:50 -08:00
ipr.h
ips.c scsi: ips: Replace kmap_atomic() with kmap_local_page() 2023-01-18 18:41:12 -05:00
ips.h
iscsi_boot_sysfs.c
iscsi_tcp.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-01-27 22:56:18 -08:00
iscsi_tcp.h scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername() 2022-09-25 14:27:47 -04:00
jazz_esp.c
Kconfig scsi: core: Make SCSI_MOD depend on BLOCK for cleaner .config files 2022-09-25 12:46:59 -04:00
lasi700.c
libiscsi_tcp.c scsi: iscsi: Remove iscsi_get_task back_lock requirement 2022-06-21 21:19:23 -04:00
libiscsi.c scsi: iscsi_tcp: Fix UAF during logout when accessing the shost ipaddress 2023-01-18 19:14:56 -05:00
mac_esp.c
mac_scsi.c scsi: NCR5380: Add SCp members to struct NCR5380_cmd 2022-02-22 21:11:03 -05:00
mac53c94.c scsi: mac53c94: Fix warning comparing pointer to 0 2022-04-25 23:23:05 -04:00
mac53c94.h scsi: mac53c94: Stop using struct scsi_pointer 2022-02-27 21:35:30 -05:00
Makefile scsi: dpt_i2o: Remove obsolete driver 2022-06-27 22:56:21 -04:00
megaraid.c scsi: megaraid: Fix error check return value of register_chrdev() 2022-04-26 09:02:44 -04:00
megaraid.h scsi: megaraid: Stop using the SCSI pointer 2022-02-22 21:11:05 -05:00
mesh.c powerpc/powermac: Remove empty function note_scsi_host() 2022-06-26 10:29:44 +10:00
mesh.h scsi: mesh: Stop using struct scsi_pointer 2022-02-27 21:34:02 -05:00
mvme16x_scsi.c
mvme147.c scsi: wd33c93: Move the SCSI pointer to private command data 2022-02-22 21:11:07 -05:00
mvme147.h
mvumi.c scsi: mvumi: Replace 1-element arrays with flexible array members 2023-01-12 00:11:11 -05:00
mvumi.h scsi: mvumi: Replace 1-element arrays with flexible array members 2023-01-12 00:11:11 -05:00
myrb.c scsi: myrb: Fix up null pointer access on myrb_cleanup() 2022-05-23 23:24:10 -04:00
myrb.h
myrs.c scsi: myrs: Fix crash in error case 2022-01-25 00:09:41 -05:00
myrs.h
ncr53c8xx.c scsi: zalon: Stop using the SCSI pointer 2022-02-22 21:11:07 -05:00
ncr53c8xx.h scsi: zalon: Stop using the SCSI pointer 2022-02-22 21:11:07 -05:00
NCR5380.c scsi: NCR5380: Fix repeated words in comment 2022-11-08 02:57:01 +00:00
NCR5380.h scsi: NCR5380: Add SCp members to struct NCR5380_cmd 2022-02-22 21:11:03 -05:00
nsp32_debug.c
nsp32_io.h
nsp32.c scsi: nsp32: Stop using the SCSI pointer 2022-02-22 21:11:06 -05:00
nsp32.h scsi: nsp32: Stop using the SCSI pointer 2022-02-22 21:11:06 -05:00
pmcraid.c scsi: pmcraid: Fix missing resource cleanup in error case 2022-06-07 22:05:14 -04:00
pmcraid.h scsi: pmcraid: Remove the PMCRAID_PASSTHROUGH_IOCTL ioctl implementation 2022-03-29 23:32:26 -04:00
ppa.c scsi: ppa: Move the SCSI pointer to private command data 2022-02-22 21:11:06 -05:00
ppa.h
ps3rom.c
qla1280.c scsi: qla1280: Remove redundant variable 2022-05-19 20:26:21 -04:00
qla1280.h scsi: qla1280: Move the SCSI pointer to private command data 2022-02-22 21:11:06 -05:00
qlogicfas.c scsi: Remove drivers/scsi/scsi.h 2022-02-22 21:11:02 -05:00
qlogicfas408.c scsi: Remove drivers/scsi/scsi.h 2022-02-22 21:11:02 -05:00
qlogicfas408.h
qlogicpti.c scsi: qlogicpti: Fix dma_map_sg() check 2022-09-06 22:14:14 -04:00
qlogicpti.h
raid_class.c
script_asm.pl
scsi_bsg.c scsi: bsg: Drop needless assignment in scsi_bsg_sg_io_fn() 2022-03-15 14:05:02 -04:00
scsi_common.c
scsi_debug.c Merge branch '6.2/scsi-queue' into 6.2/scsi-fixes 2022-12-30 16:29:34 +00:00
scsi_debugfs.c scsi: core: Remove struct scsi_request 2022-03-01 22:21:50 -05:00
scsi_debugfs.h
scsi_devinfo.c
scsi_dh.c
scsi_error.c Merge branch '6.2/scsi-queue' into 6.2/scsi-fixes 2022-12-30 16:29:34 +00:00
scsi_ioctl.c scsi: core: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
scsi_lib_dma.c
scsi_lib.c scsi: core: Extend struct scsi_exec_args 2023-02-21 22:00:51 -05:00
scsi_logging.c scsi: core: scsi_logging: Fix a BUG 2022-03-29 23:29:19 -04:00
scsi_logging.h
scsi_netlink.c
scsi_pm.c scsi: block: pm: Always set request queue runtime active in blk_post_runtime_resume() 2021-12-22 23:38:29 -05:00
scsi_priv.h scsi: core: Introduce a new list for SCSI proc directory entries 2022-10-18 03:17:09 +00:00
scsi_proc.c scsi: core: Introduce a new list for SCSI proc directory entries 2022-10-18 03:17:09 +00:00
scsi_sas_internal.h
scsi_scan.c SCSI misc on 20230222 2023-02-22 13:41:41 -08:00
scsi_sysctl.c
scsi_sysfs.c Driver core changes for 6.3-rc1 2023-02-24 12:58:55 -08:00
scsi_trace.c
scsi_transport_api.h
scsi_transport_fc.c scsi: scsi_transport_fc: Add an additional flag to fc_host_fpin_rcv() 2023-02-21 18:03:29 -05:00
scsi_transport_iscsi.c Merge branch '6.2/scsi-queue' into 6.2/scsi-fixes 2022-12-30 16:29:34 +00:00
scsi_transport_sas.c scsi: scsi_transport_sas: Fix error handling in sas_phy_add() 2022-11-08 01:52:52 +00:00
scsi_transport_spi.c scsi: spi: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
scsi_transport_srp.c scsi: core: Change the return type of .eh_timed_out() 2022-10-22 03:25:59 +00:00
scsi.c SCSI misc on 20230222 2023-02-22 13:41:41 -08:00
scsicam.c scsicam: Fix use of page cache 2022-05-08 14:28:18 -04:00
sd_dif.c scsi: sd: Update DIX config every time sd_revalidate_disk() is called 2023-02-21 22:00:32 -05:00
sd_trace.h scsi: sd: sd_zbc: Trace zone append emulation 2022-12-01 03:13:55 +00:00
sd_zbc.c scsi: zbc: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
sd.c SCSI misc on 20230303 2023-03-03 14:41:50 -08:00
sd.h scsi: sd: Revert "Rework asynchronous resume support" 2022-08-22 22:45:25 -04:00
sense_codes.h
ses.c scsi: ses: Don't attach if enclosure has no components 2023-02-21 17:44:06 -05:00
sg.c mm: replace vma->vm_flags direct modifications with modifier calls 2023-02-09 16:51:39 -08:00
sgiwd93.c scsi: wd33c93: Move the SCSI pointer to private command data 2022-02-22 21:11:07 -05:00
sim710.c
sni_53c710.c
sr_ioctl.c scsi: sr: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
sr_vendor.c scsi: sr: Don't use GFP_DMA 2021-12-22 23:41:13 -05:00
sr.c scsi: sr: Convert to scsi_execute_cmd() 2023-01-13 21:34:09 -05:00
sr.h sr: implement ->free_disk to simplify refcounting 2022-03-08 19:40:01 -07:00
st_options.h
st.c SCSI misc on 20221007 2022-10-07 12:33:18 -07:00
st.h scsi: don't use disk->private_data to find the scsi_driver 2022-03-08 19:40:00 -07:00
stex.c scsi: stex: Properly zero out the passthrough command structure 2022-09-25 14:15:03 -04:00
storvsc_drv.c scsi: storvsc: Handle BlockSize change in Hyper-V VHD/VHDX file 2023-03-06 18:33:13 -05:00
sun_esp.c
sun3_scsi_vme.c
sun3_scsi.c scsi: NCR5380: Add SCp members to struct NCR5380_cmd 2022-02-22 21:11:03 -05:00
sun3x_esp.c
virtio_scsi.c virtio,vhost,vdpa: features, fixes 2023-02-25 11:48:02 -08:00
vmw_pvscsi.c scsi: vmw_pvscsi: No need to clear memory after a dma_alloc_coherent() call 2022-04-06 23:01:54 -04:00
vmw_pvscsi.h scsi: vmw_pvscsi: Expand vcpuHint to 16 bits 2022-06-07 21:30:56 -04:00
wd33c93.c scsi: wd33c93: Remove dead code related to the long-gone config WD33C93_PIO 2022-09-25 13:29:53 -04:00
wd33c93.h scsi: wd33c93: Remove dead code related to the long-gone config WD33C93_PIO 2022-09-25 13:29:53 -04:00
wd719x.c scsi: wd719x: Return proper error code when dma_set_mask() fails 2022-03-01 23:56:28 -05:00
wd719x.h scsi: wd719x: Stop using the SCSI pointer 2022-02-22 21:11:07 -05:00
xen-scsifront.c xen: make remove callback of xen driver void returned 2022-12-15 16:06:10 +01:00
zalon.c scsi: zalon: Stop using the SCSI pointer 2022-02-22 21:11:07 -05:00
zorro_esp.c
zorro7xx.c scsi: zorro7xx: Fix a resource leak in zorro7xx_remove_one() 2022-03-30 00:05:42 -04:00