From owner-freebsd-current@freebsd.org Tue May 10 20:46:31 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 8A780B36667 for ; Tue, 10 May 2016 20:46:31 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mx1.shrew.net (mx1.shrew.net [38.97.5.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4ECB61DA7 for ; Tue, 10 May 2016 20:46:30 +0000 (UTC) (envelope-from mgrooms@shrew.net) Received: from mail.shrew.net (mail.shrew.prv [10.24.10.20]) by mx1.shrew.net (8.14.7/8.14.7) with ESMTP id u4AKJYBt082606 for ; Tue, 10 May 2016 15:19:34 -0500 (CDT) (envelope-from mgrooms@shrew.net) Received: from [10.16.32.30] (unknown [172.126.77.65]) by mail.shrew.net (Postfix) with ESMTPSA id 1358E18CC6F for ; Tue, 10 May 2016 15:19:29 -0500 (CDT) From: Matthew Grooms Subject: Re: Resizing a zpool as a VMware ESXi guest ... To: freebsd-current@freebsd.org References: <543841B8.4070007@shrew.net> <20141016081016.GA4670@brick.home> <5657F135.6080902@shrew.net> <56581F5A.4010009@digiware.nl> <56589C1A.1020702@shrew.net> <5658A764.5030508@shrew.net> <565906E8.9060005@shrew.net> <565A425C.7020101@shrew.net> <565A7906.60106@shrew.net> Message-ID: <157c5d41-41c2-8812-79f1-3cab2c1eb8e5@shrew.net> Date: Tue, 10 May 2016 15:22:28 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <565A7906.60106@shrew.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (mx1.shrew.net [10.24.10.10]); Tue, 10 May 2016 15:19:34 -0500 (CDT) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2016 20:46:31 -0000 On 11/28/2015 10:03 PM, Matthew Grooms wrote: > On 11/28/2015 6:10 PM, Matthew Grooms wrote: >> On 11/27/2015 7:44 PM, Matthew Grooms wrote: >>> I spent the day looking over the FreeBSD cam and scsi_da source code. >>> After sprinkling a bunch of printf's around to see what code paths >>> were being called, It's obvious that Edward was correct in assuming >>> that ESXi doesn't return any 'Unit Attention' sense information in >>> response to a 'Read Capacity' request. This kinda makes sense as ESXi >>> emulates SCSI-2 disk devices and, as far as I can tell, the 0x2A/0x09 >>> ASC/ASCQ sense code that denotes 'Capacity Data Has Changed' wasn't >>> defined until the SCSCI-3 spec. It's frustrating that the only way to >>> get the scsci_da code to call reprobe() is by receiving a command >>> from the device. Would something like this work? ... >>> >>> 1) Register a callback using xpt_register_async( daasync, >>> AC_REPROBE_DEVICE, path ) that calls reprobe() >>> 2) Implement a new IOCTL in cam_xpt that camcontrol can call with the >>> bus:target:lun as the argument >>> 3) have cam_xpt capture the IOCTL request and call xpt_async( >>> AC_REPROBE_DEVICE, path ) as a result >>> >>> This way users would have the option of manually asking cam to >>> communicate the new size to geom. The only option now is one or more >>> reboots to gain access to the increased disk capacity. If this sounds >>> like a reasonable approach, I'll take a stab at implementing it. >>> >> >> Here is a proof of concept patch. I'm a complete noob when it comes to >> cam, scsi or freebsd kernel development for that matter, so I'm sure >> it could have been done a better way. In any case, I added a new >> command to camcontrol that allows you to specify a bus, target and lun >> as an argument. For example ... >> >> # camcontrol readcap da1 -h >> Device Size: 32 G, Block Length: 512 bytes >> >> # gpart show da1 >> => 40 58720176 da1 GPT (28G) >> 40 58720176 1 freebsd-ufs (28G) >> >> Note, I resized the VMDK disk in ESXi. The camcontrol output shows the >> size as 32G but geom thinks its 28G. >> >> # camcontrol devlist >> at scbus1 target 0 lun 0 (cd0,pass0) >> at scbus2 target 0 lun 0 (pass1,da0) >> at scbus2 target 1 lun 0 (pass2,da1) >> at scbus3 target 0 lun 0 (da2,pass3) >> >> # camcontrol reprobe 2:1:0 >> >> This generates an event that is captured by the scsci da device to >> forces a reprobe. The kernel output looks almost identical to when the >> 'Unit Attention' sense data is received ... >> >> Nov 28 17:46:13 iscsi-i kernel: (da1:mpt0:0:1:0): Re-probe requested >> Nov 28 17:46:13 iscsi-i kernel: GEOM_PART: da1 was automatically resized. >> Nov 28 17:46:13 iscsi-i kernel: Use `gpart commit da1` to save changes >> or `gpart undo da1` to revert them. >> >> Now that geom knows about the increased disk capacity, I can increase >> the partition size and grow the fs ... >> >> [root@iscsi-i /home/mgrooms]# gpart show da1 >> => 40 67108784 da1 GPT (32G) >> 40 58720176 1 freebsd-ufs (28G) >> 58720216 8388608 - free - (4.0G) >> >> # gpart resize -i 1 da1 >> da1p1 resized >> >> # growfs da1p1 >> Device is mounted read-write; resizing will result in temporary write >> suspension for /var/data1. >> It's strongly recommended to make a backup before growing the file >> system. >> OK to grow filesystem on /dev/da1p1, mounted on /var/data1, from 28GB >> to 32GB? [Yes/No] Yes >> super-block backups (for fsck_ffs -b #) at: >> 58983232, 60265472, 61547712, 62829952, 64112192, 65394432, 66676672 >> >> # df -h >> Filesystem Size Used Avail Capacity Mounted on >> /dev/da0p3 18G 5.3G 12G 31% / >> devfs 1.0K 1.0K 0B 100% /dev >> /dev/da1p1 31G 32M 28G 0% /var/data1 >> /dev/da2p1 15G 32M 14G 0% /var/data2 >> >> Sure would be nice to have something like this in the tree. It's >> really a drag to have to reboot production VMs to increase disk >> capacity when it could be easily avoided. I'm not sure what the >> correct IOCTL should look like. Maybe CAMIOCOMMAND is a better way to >> go? If someone with some experience with the cam/scsi subsystems was >> willing to give me some direction I'd be willing to try and rewrite >> the patch in a way that would be commit worthy. I just need some >> direction. >> > > Ok, last post until I get some feedback. Here's a new version of the > patch complete with man page updates. It communicates via CAMIOCOMMAND > instead of introducing a new ioctl value. I tried to model it after the > device reset option, hopefully with some degree of success. Functionally > it should be the same as the first patch. > The PR 204901 filed for this can be closed now that the author (ahem) has committed support for the camcontrol reprobe command ... https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204901 https://docs.freebsd.org/cgi/getmsg.cgi?fetch=866020+0+current/svn-src-head -Matthew