From owner-svn-src-stable-10@FreeBSD.ORG Mon Oct 20 08:06:18 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 509C487C; Mon, 20 Oct 2014 08:06:18 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 228FABFA; Mon, 20 Oct 2014 08:06:18 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9K86I1h089041; Mon, 20 Oct 2014 08:06:18 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9K86IYm089040; Mon, 20 Oct 2014 08:06:18 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201410200806.s9K86IYm089040@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Mon, 20 Oct 2014 08:06:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273322 - stable/10/sys/cam/ctl X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Oct 2014 08:06:18 -0000 Author: mav Date: Mon Oct 20 08:06:17 2014 New Revision: 273322 URL: https://svnweb.freebsd.org/changeset/base/273322 Log: MFC r273029: Report physical block size for file-backed LUNs, using vattr.va_blocksize. Modified: stable/10/sys/cam/ctl/ctl_backend_block.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/cam/ctl/ctl_backend_block.c ============================================================================== --- stable/10/sys/cam/ctl/ctl_backend_block.c Mon Oct 20 08:04:46 2014 (r273321) +++ stable/10/sys/cam/ctl/ctl_backend_block.c Mon Oct 20 08:06:17 2014 (r273322) @@ -1545,6 +1545,7 @@ ctl_be_block_open_file(struct ctl_be_blo struct ctl_be_block_filedata *file_data; struct ctl_lun_create_params *params; struct vattr vattr; + off_t pss; int error; error = 0; @@ -1593,21 +1594,21 @@ ctl_be_block_open_file(struct ctl_be_blo be_lun->flags |= CTL_BE_BLOCK_LUN_MULTI_THREAD; /* - * XXX KDM vattr.va_blocksize may be larger than 512 bytes here. - * With ZFS, it is 131072 bytes. Block sizes that large don't work - * with disklabel and UFS on FreeBSD at least. Large block sizes - * may not work with other OSes as well. So just export a sector - * size of 512 bytes, which should work with any OS or - * application. Since our backing is a file, any block size will - * work fine for the backing store. + * For files we can use any logical block size. Prefer 512 bytes + * for compatibility reasons. If file's vattr.va_blocksize + * (preferred I/O block size) is bigger and multiple to chosen + * logical block size -- report it as physical block size. */ -#if 0 - be_lun->blocksize= vattr.va_blocksize; -#endif if (params->blocksize_bytes != 0) be_lun->blocksize = params->blocksize_bytes; else be_lun->blocksize = 512; + pss = vattr.va_blocksize / be_lun->blocksize; + if ((pss > 0) && (pss * be_lun->blocksize == vattr.va_blocksize) && + ((pss & (pss - 1)) == 0)) { + be_lun->pblockexp = fls(pss) - 1; + be_lun->pblockoff = 0; + } /* * Sanity check. The media size has to be at least one