From 7e4a1d08c448ddbd6e20705cd2ea38b78f833401 Mon Sep 17 00:00:00 2001 Message-Id: <7e4a1d08c448ddbd6e20705cd2ea38b78f833401.1389014116.git.minovotn@redhat.com> In-Reply-To: References: From: Paolo Bonzini Date: Mon, 9 Dec 2013 14:09:33 +0100 Subject: [PATCH 45/50] block/iscsi: set bdi->cluster_size RH-Author: Paolo Bonzini Message-id: <1386598178-11845-48-git-send-email-pbonzini@redhat.com> Patchwork-id: 56083 O-Subject: [RHEL 7.0 qemu-kvm PATCH 47/52] block/iscsi: set bdi->cluster_size Bugzilla: 1007815 RH-Acked-by: Jeffrey Cody RH-Acked-by: Fam Zheng RH-Acked-by: Stefan Hajnoczi From: Peter Lieven this patch aims to set bdi->cluster_size to the internal page size of the iscsi target so that enabled callers can align requests properly. Reviewed-by: Paolo Bonzini Signed-off-by: Peter Lieven Signed-off-by: Stefan Hajnoczi (cherry picked from commit 1c0704a556dbb004a3b82791779760f418053951) --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) Signed-off-by: Michal Novotny --- block/iscsi.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index 8b82fe7..94c5af8 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1582,6 +1582,13 @@ static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) IscsiLun *iscsilun = bs->opaque; bdi->unallocated_blocks_are_zero = !!iscsilun->lbprz; bdi->can_write_zeroes_with_unmap = iscsilun->lbprz && iscsilun->lbp.lbpws; + /* Guess the internal cluster (page) size of the iscsi target by the means + * of opt_unmap_gran. Transfer the unmap granularity only if it has a + * reasonable size for bdi->cluster_size */ + if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 64 * 1024 && + iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) { + bdi->cluster_size = iscsilun->bl.opt_unmap_gran * iscsilun->block_size; + } return 0; } -- 1.7.11.7