OS-8136: Add DISCARD/TRIM support to bhyve

Details

Issue Type:Improvement
Priority:4 - Normal
Status:Resolved
Created at:2020-03-17T03:20:44.789Z
Updated at:2020-03-31T02:04:15.646Z

People

Created by:Former user
Reported by:Former user
Assigned to:Former user

Resolution

Fixed: A fix for this issue is checked into the tree and tested.
(Resolution Date: 2020-03-23T18:44:15.565Z)

Fix Versions

2020-03-26 Oh Henry (Release Date: 2020-03-26)

Related Links

Labels

bhyve

Description

. It uses the existing blockif delete functionality and essentially wires it up to the virtio block device.

To try to preserve the attribution of the work, his original change (w/ a few small tweaks) will be done as one PR, and a second PR will have the illumos-specific bits for blockif and the bhyve brand.

Comments

Comment by Former user
Created at 2020-03-17T03:28:59.422Z

For testing, I ran the zfs TRIM tests in an Ubuntu VM. The one failure was due to

ERROR: dd if=/dev/urandom of=/var/tmp/testdir/largefile conv=notrunc,nocreat seek=1024 bs=1048576 count=3072 exited 1

Likely due to / being too small on the test VM to create the test file. All the other TRIM tests passed. Additionally, I ran dtrace -n 'pid$target::ioctl:entry /arg1==1074/ {}' -p PID_OF_BHYVE_PROCESS to verify DKIOCFREE ioctls were being issued during the zfs trim tests.

I then added nodelete as an option to one of the test disks, rebooted, and used lsblk -D to verify that it no longer showed discard support:

(Before adding nodelete)

ubuntu@eb2dc436-64e7-6fe3-8c9f-89c4c1053fc8:~$ lsblk -D
NAME    DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
vda          512      512B      16M         0
├─vda1         0      512B      16M         0
├─vda2         0      512B      16M         0
├─vda14        0      512B      16M         0
└─vda15        0      512B      16M         0
vdb          512      512B      16M         0
vdc          512      512B      16M         0
├─vdc1         0      512B      16M         0
└─vdc9         0      512B      16M         0
vdd          512      512B      16M         0
├─vdd1         0      512B      16M         0
└─vdd9         0      512B      16M         0
vde          512      512B      16M         0
├─vde1         0      512B      16M         0
└─vde9         0      512B      16M         0

After

ubuntu@eb2dc436-64e7-6fe3-8c9f-89c4c1053fc8:~$ lsblk -D
NAME    DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
vda          512      512B      16M         0
├─vda1         0      512B      16M         0
├─vda2         0      512B      16M         0
├─vda14        0      512B      16M         0
└─vda15        0      512B      16M         0
vdb          512      512B      16M         0
vdc          512      512B      16M         0
├─vdc1         0      512B      16M         0
└─vdc9         0      512B      16M         0
vdd          512      512B      16M         0
├─vdd1         0      512B      16M         0
└─vdd9         0      512B      16M         0
vde            0        0B       0B         0
├─vde1         0        0B       0B         0
└─vde9         0        0B       0B         0

Comment by Former user
Created at 2020-03-18T20:55:25.879Z

Additionally, sjorge has tested the bits w/ Windows which also worked successfully (though requires newer virtio drivers for windows than what we publish).


Comment by Jira Bot
Created at 2020-03-18T21:05:21.825Z

illumos-joyent commit bfe191c490dc33e77e134e9bb5e2c8a3da737a29 (branch master, by Jason King)

OS-8136 Add DISCARD/TRIM support to bhyve (#268)

Contributed by: Allan Jude <allanjude@freebsd.org>
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Mike Zeller <mike.zeller.@joyent.com>
Approved by: Mike Zeller <mike.zeller@joyent.com>


Comment by Former user
Created at 2020-03-20T22:51:42.541Z

For the vmadm changes, I applied the following json to the same ubuntu vm that was used for the illumos-joyent testing:

{
  "update_disks": [
     {
         "path": "/dev/zvol/rdsk/zones/eb2dc436-64e7-6fe3-8c9f-89c4c1053fc8/disk4",
         "notrim": true
     }
  ]
}

Then ran vmadm get eb2dc436-64e7-6fe3-8c9f-89c4c1053fc8 to verify the notrim property showed up for the disk.

Then I used the following json to unset the value:

{
  "update_disks": [
     {
         "path": "/dev/zvol/rdsk/zones/eb2dc436-64e7-6fe3-8c9f-89c4c1053fc8/disk4",
         "notrim": false
     }
  ]
}

Started the VM, and verified that 'notrim' was not present for the disk entry.


Comment by Jira Bot
Created at 2020-03-23T18:43:05.358Z

illumos-joyent commit da036f5cbc2608d7100a682f9c91a938e76cefdc (branch master, by Jason King)

OS-8136 Add DISCARD/TRIM support to bhyve (illumos specific bits) (#270)

Reviewed by: Mike Zeller <mike.zeller@joyent.com>
Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Approved by: Mike Zeller <mike.zeller@joyent.com>


Comment by Jira Bot
Created at 2020-03-23T18:44:02.289Z

smartos-live commit eeb483134f3c082ddc260d3b3ca0174c35247d1f (branch master, by Jason King)

OS-8136 Add DISCARD/TRIM support to bhyve (#916)

Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Reviewed by: Mike Zeller <mike.zeller@joyent.com>
Approved by: Mike Zeller <mike.zeller@joyent.com>


Comment by Jira Bot
Created at 2020-03-24T18:29:25.614Z

illumos-joyent commit 8ea6e1e2b330e5f0cb4b3bc3f0ed46a6a385d79a (branch master, by Jason King)

OS-8136 Add DISCARD/TRIM support to bhyve (fix compiler warning) (#274)

Reviewed by: Mike Gerdts <mike.gerdts@joyent.com>
Approved by: Mike Gerdts <mike.gerdts@joyent.com>