Commit f890f579 authored by Mike Christie's avatar Mike Christie Committed by Nicholas Bellinger

tcmu: simplify dbi thresh handling

We do not really save a lot by trying to increase thresh
a multiple of the existing value. This just simplifies the
code by increasing it to whatever is needed for the command
being executed.
Signed-off-by: default avatarMike Christie <mchristi@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 6fd0ce79
...@@ -79,7 +79,6 @@ ...@@ -79,7 +79,6 @@
#define DATA_BLOCK_SIZE PAGE_SIZE #define DATA_BLOCK_SIZE PAGE_SIZE
#define DATA_BLOCK_BITS (256 * 1024) #define DATA_BLOCK_BITS (256 * 1024)
#define DATA_SIZE (DATA_BLOCK_BITS * DATA_BLOCK_SIZE) #define DATA_SIZE (DATA_BLOCK_BITS * DATA_BLOCK_SIZE)
#define DATA_BLOCK_INIT_BITS 128
/* The total size of the ring is 8M + 256K * PAGE_SIZE */ /* The total size of the ring is 8M + 256K * PAGE_SIZE */
#define TCMU_RING_SIZE (CMDR_SIZE + DATA_SIZE) #define TCMU_RING_SIZE (CMDR_SIZE + DATA_SIZE)
...@@ -700,7 +699,6 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd, ...@@ -700,7 +699,6 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
if ((space * DATA_BLOCK_SIZE) < data_needed) { if ((space * DATA_BLOCK_SIZE) < data_needed) {
unsigned long blocks_left = DATA_BLOCK_BITS - udev->dbi_thresh + unsigned long blocks_left = DATA_BLOCK_BITS - udev->dbi_thresh +
space; space;
unsigned long grow;
if (blocks_left < blocks_needed) { if (blocks_left < blocks_needed) {
pr_debug("no data space: only %lu available, but ask for %zu\n", pr_debug("no data space: only %lu available, but ask for %zu\n",
...@@ -709,23 +707,9 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd, ...@@ -709,23 +707,9 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
return false; return false;
} }
/* Try to expand the thresh */ udev->dbi_thresh += blocks_needed;
if (!udev->dbi_thresh) { if (udev->dbi_thresh > DATA_BLOCK_BITS)
/* From idle state */ udev->dbi_thresh = DATA_BLOCK_BITS;
uint32_t init_thresh = DATA_BLOCK_INIT_BITS;
udev->dbi_thresh = max(blocks_needed, init_thresh);
} else {
/*
* Grow the data area by max(blocks needed,
* dbi_thresh / 2), but limited to the max
* DATA_BLOCK_BITS size.
*/
grow = max(blocks_needed, udev->dbi_thresh / 2);
udev->dbi_thresh += grow;
if (udev->dbi_thresh > DATA_BLOCK_BITS)
udev->dbi_thresh = DATA_BLOCK_BITS;
}
} }
return tcmu_get_empty_blocks(udev, cmd); return tcmu_get_empty_blocks(udev, cmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment