From owner-freebsd-fs@FreeBSD.ORG Thu Apr 1 17:38:09 2010 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7B0FE106566B; Thu, 1 Apr 2010 17:38:09 +0000 (UTC) (envelope-from avg@freebsd.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 557AA8FC15; Thu, 1 Apr 2010 17:38:07 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id UAA17181; Thu, 01 Apr 2010 20:38:04 +0300 (EEST) (envelope-from avg@freebsd.org) Message-ID: <4BB4D9FB.3000706@freebsd.org> Date: Thu, 01 Apr 2010 20:38:03 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100319) MIME-Version: 1.0 To: freebsd-fs@freebsd.org, freebsd-geom@freebsd.org References: <201003261528.o2QFSAuI037251@chez.mckusick.com> In-Reply-To: <201003261528.o2QFSAuI037251@chez.mckusick.com> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Kirk McKusick , Bruce Evans Subject: Re: g_vfs_open and bread(devvp, ...) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2010 17:38:09 -0000 Some bad news. Apparently I missed the fact that in some places bo_bsize is used as sectorsize value of underlying provider. That is, there is code that assumes that devvp's bo_bsize == sectorsize. One such place is vnode_pager_generic_getpages() in sys/vm/vnode_pager.c. That code directly calls bstrategy() on bufobj of devvp and because of that it wants to round up read size to media sectorsize (there would be a KASSERT panic in GEOM if I/O size is not multiple of sectorsize). Thus the code needs to know sectorsize. The other possible place is ffs_rawread. I am not sure how to get sectorsize value in those places in a nice way, i.e. without kludges or violating logical layering. I.e. I could access bo_private->provider->sectorsize, but that seems to be too hack-ish. If anyone knows of a proper way to do this, please let me know. For now I am thinking about resorting to a different, slightly less kludgy (IMO) approach. Leave devvp's bo_bsize to mean provider's sectorsize, but instead in getblk() account for devvp's blkno being in units of DEV_BSIZE: --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -2700,7 +2700,7 @@ */ if (flags & GB_NOCREAT) return NULL; - bsize = bo->bo_bsize; + bsize = vn_isdisk(vp, NULL) ? DEV_BSIZE : bo->bo_bsize; offset = blkno * bsize; vmio = vp->v_object != NULL; maxsize = vmio ? size + (offset & PAGE_MASK) : size; -- Andriy Gapon