Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Nov 2020 17:10:14 +0000 (UTC)
From:      Allan Jude <allanjude@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r367393 - head/usr.sbin/bhyve
Message-ID:  <202011051710.0A5HAE33010409@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: allanjude
Date: Thu Nov  5 17:10:14 2020
New Revision: 367393
URL: https://svnweb.freebsd.org/changeset/base/367393

Log:
  VirtIO: Make sure the guest knows the TRIM alignment requirements
  
  If bhyve is used to emulate 512e access in guest OS, then discard addresses should be properly aligned.
  Otherwise ioctl DIOCGDELETE fails for 512b requires on devices with 4K sector size.
  see g_dev_ioctl() in sys/geom/geom_dev.c
  
  Submitted by:	Vitaliy Gusev <gusev.vitaliy@gmail.com>
  MFC after:	1 week
  Sponsored by:	vStack.com
  Differential Revision:	https://reviews.freebsd.org/D27075

Modified:
  head/usr.sbin/bhyve/pci_virtio_block.c

Modified: head/usr.sbin/bhyve/pci_virtio_block.c
==============================================================================
--- head/usr.sbin/bhyve/pci_virtio_block.c	Thu Nov  5 16:47:23 2020	(r367392)
+++ head/usr.sbin/bhyve/pci_virtio_block.c	Thu Nov  5 17:10:14 2020	(r367393)
@@ -523,7 +523,7 @@ pci_vtblk_init(struct vmctx *ctx, struct pci_devinst *
 	sc->vbsc_cfg.vbc_writeback = 0;
 	sc->vbsc_cfg.max_discard_sectors = VTBLK_MAX_DISCARD_SECT;
 	sc->vbsc_cfg.max_discard_seg = VTBLK_MAX_DISCARD_SEG;
-	sc->vbsc_cfg.discard_sector_alignment = sectsz / VTBLK_BSIZE;
+	sc->vbsc_cfg.discard_sector_alignment = MAX(sectsz, sts) / VTBLK_BSIZE;
 
 	/*
 	 * Should we move some of this into virtio.c?  Could



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011051710.0A5HAE33010409>