aboutsummaryrefslogtreecommitdiff
path: root/sys/cam/ctl/ctl_backend_block.c
diff options
context:
space:
mode:
authorAlexander Motin <mav@FreeBSD.org>2014-10-13 11:00:58 +0000
committerAlexander Motin <mav@FreeBSD.org>2014-10-13 11:00:58 +0000
commit20a28d6cee775cadf1e5a2ecbf02f6ba6f2b424b (patch)
treec3cf09030ed9bb8225ad9447360adebd3c1fed1d /sys/cam/ctl/ctl_backend_block.c
parent6ad1954bcb1e83d33892cc77b261fcf292f35c67 (diff)
downloadsrc-20a28d6cee775cadf1e5a2ecbf02f6ba6f2b424b.tar.gz
src-20a28d6cee775cadf1e5a2ecbf02f6ba6f2b424b.zip
Report physical block size for file-backed LUNs, using vattr.va_blocksize.
MFC after: 1 week
Notes
Notes: svn path=/head/; revision=273029
Diffstat (limited to 'sys/cam/ctl/ctl_backend_block.c')
-rw-r--r--sys/cam/ctl/ctl_backend_block.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c
index e9852348513c..2d3c368bf839 100644
--- a/sys/cam/ctl/ctl_backend_block.c
+++ b/sys/cam/ctl/ctl_backend_block.c
@@ -1542,6 +1542,7 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
struct ctl_be_block_filedata *file_data;
struct ctl_lun_create_params *params;
struct vattr vattr;
+ off_t pss;
int error;
error = 0;
@@ -1590,21 +1591,21 @@ ctl_be_block_open_file(struct ctl_be_block_lun *be_lun, struct ctl_lun_req *req)
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