summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_user.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 965f462eaa22..5d1daea51079 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -637,7 +637,7 @@ static void gather_data_area(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
637 637
638static inline size_t spc_bitmap_free(unsigned long *bitmap, uint32_t thresh) 638static inline size_t spc_bitmap_free(unsigned long *bitmap, uint32_t thresh)
639{ 639{
640 return DATA_BLOCK_SIZE * (thresh - bitmap_weight(bitmap, thresh)); 640 return thresh - bitmap_weight(bitmap, thresh);
641} 641}
642 642
643/* 643/*
@@ -677,8 +677,9 @@ static bool is_ring_space_avail(struct tcmu_dev *udev, struct tcmu_cmd *cmd,
677 677
678 /* try to check and get the data blocks as needed */ 678 /* try to check and get the data blocks as needed */
679 space = spc_bitmap_free(udev->data_bitmap, udev->dbi_thresh); 679 space = spc_bitmap_free(udev->data_bitmap, udev->dbi_thresh);
680 if (space < data_needed) { 680 if ((space * DATA_BLOCK_SIZE) < data_needed) {
681 unsigned long blocks_left = DATA_BLOCK_BITS - udev->dbi_thresh; 681 unsigned long blocks_left = DATA_BLOCK_BITS - udev->dbi_thresh +
682 space;
682 unsigned long grow; 683 unsigned long grow;
683 684
684 if (blocks_left < blocks_needed) { 685 if (blocks_left < blocks_needed) {