From owner-freebsd-current@freebsd.org Wed May 11 07:12:24 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 7C611B36C99 for ; Wed, 11 May 2016 07:12:24 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 01FE41066 for ; Wed, 11 May 2016 07:12:24 +0000 (UTC) (envelope-from etnapierala@gmail.com) Received: by mail-wm0-x22f.google.com with SMTP id n129so206484413wmn.1 for ; Wed, 11 May 2016 00:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=QvtjcEhb2sh9BZrhb66gNEZIFmedMomUZylyMdnnj98=; b=WgbOrhWL/Cseu8KonxhvPQSnz2oAKRKZS8SZeqKmD7v0UnS3SQqw/cg/X8TQU4ckd9 oat4eek3WSIgtzgvyak0gpv59gDBTMTmYsg9/BZZ1RdKGdh2Y9le23o/2v8BBGrjdZ16 SDazSOwmOtRlRymsbXGXkryv8mXbhvqabmIe3yiPovwW282Tnppf93O2cTy3sOfanXCI j9CSXIWB2hkX2R9GO9xCXVELZcxAdn/FDJKRPvZTao7h1E5G064smn9zGcN0Ljk1ehhH 1wOJLxgqPuP3N7i9hNbp/07zH/yKc3iluf3CUWnCQw/uO532YuFPetnZR+QmFfaYdhM8 PawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=QvtjcEhb2sh9BZrhb66gNEZIFmedMomUZylyMdnnj98=; b=UJVnlbKKnZMtQWeHV6j0DIW7yUvLOAxgkzQ+qTMdL56jNAhHVXEX+JQpT5XVAJvPUb DUtROMmIQZC6cgI2XHfscjsVKhJ+I7xJ9jGurncSFdR2/rHVr1iA9Ln0jtJcwkQMpDrF yC1F0jC+lJV9Cl4ekXatWrKq7v4EGwFU51P8RMCPF4QV61/Pzch4yAQTFy/2yjydZaW4 8JNlq8O6GVYK/oDfMw+xutCuAZ3rz0uGNNiHmlS1B7V1iLLZfFoqQeTb9MnnYNyIRUjs BH+argZvgvKRYItWU0yFZZwbxSkN84R8gYvg6VYIMKej7VouLG5YXLJYo7TnfQtj4Az1 UTYA== X-Gm-Message-State: AOPr4FV2YKbBcW6164Q7zJqJsd4SA/xu32amiiKgxkneHPpa9uldBu2RQNN88CU4bQqUvA== X-Received: by 10.194.15.8 with SMTP id t8mr1752273wjc.177.1462950742380; Wed, 11 May 2016 00:12:22 -0700 (PDT) Received: from brick (aie67.neoplus.adsl.tpnet.pl. [83.25.212.67]) by smtp.gmail.com with ESMTPSA id jr8sm6421685wjb.15.2016.05.11.00.12.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 May 2016 00:12:21 -0700 (PDT) Sender: =?UTF-8?Q?Edward_Tomasz_Napiera=C5=82a?= Date: Wed, 11 May 2016 09:12:18 +0200 From: Edward Tomasz =?utf-8?Q?Napiera=C5=82a?= To: Matthew Grooms Cc: freebsd-current@freebsd.org Subject: Re: Resizing a zpool as a VMware ESXi guest ... Message-ID: <20160511071218.GC5193@brick> Mail-Followup-To: Matthew Grooms , 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> <157c5d41-41c2-8812-79f1-3cab2c1eb8e5@shrew.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <157c5d41-41c2-8812-79f1-3cab2c1eb8e5@shrew.net> User-Agent: Mutt/1.6.0 (2016-04-01) 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: Wed, 11 May 2016 07:12:24 -0000 On 0510T1522, Matthew Grooms wrote: > 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 Ugh. I honestly have no idea how did I manage to miss your patch. I did remember the discussion, I remember asking mav@ about what's the best way to hook it up to CAM, but until yesterday I just didn't know the patch (and the PR) existed. Sorry for that. Guess that's what happens when I try to keep up with too many unrelated subprojects at the same time.