From: Ilias Tsitsimpis <iliastsi@arrikto.com>
To: lixiubo@cmss.chinamobile.com
Cc: agrover@redhat.com, nab@linux-iscsi.org, mchristi@redhat.com,
shli@kernel.org, sheng@yasker.org, linux-scsi@vger.kernel.org,
target-devel@vger.kernel.org, namei.unix@gmail.com,
bryantly@linux.vnet.ibm.com
Subject: Re: [PATCHv4 0/4] tcmu: bug fix and dynamic growing data area support
Date: Thu, 23 Mar 2017 18:02:37 +0200 [thread overview]
Message-ID: <20170323160237.qqofpc7v7aoazfqd@iliastsi-m.arr> (raw)
In-Reply-To: <1490085382-28658-1-git-send-email-lixiubo@cmss.chinamobile.com>
Hi Xiubo,
On Tue, Mar 21, 2017 at 04:36PM, lixiubo@cmss.chinamobile.com wrote:
> [...]
> tcmu: Fix possible overwrite of t_data_sg's last iov[]
> tcmu: Fix wrongly calculating of the base_command_size
I tested these two patches, which try to fix the broken support for
BIDI commands in target/user.
Both look good to me, but unfortunately, there is also another
regression which got introduced with the use of the data_bitmap. More
specifically, in case of BIDI commands, the data bitmap records both the
Data-Out and the Data-In buffer, and so when gathering the data in the
tcmu_handle_completion() function, care should be taken in order to
discard the Data-Out buffer before gathering the Data-In buffer.
Something like this should do the trick:
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 1108bf5..7075161 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -610,10 +610,22 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
se_cmd->scsi_sense_length);
free_data_area(udev, cmd);
} else if (se_cmd->se_cmd_flags & SCF_BIDI) {
+ struct scatterlist *sg;
+ int n, block, sg_remaining = 0;
DECLARE_BITMAP(bitmap, DATA_BLOCK_BITS);
- /* Get Data-In buffer before clean up */
bitmap_copy(bitmap, cmd->data_bitmap, DATA_BLOCK_BITS);
+
+ /* Discard Data-Out buffer */
+ for_each_sg(se_cmd->t_data_sg, sg, se_cmd->t_data_nents, n) {
+ sg_remaining += sg->length;
+ while (sg_remaining > 0) {
+ block = find_first_bit(bitmap, DATA_BLOCK_BITS);
+ clear_bit(block, bitmap);
+ sg_remaining -= DATA_BLOCK_SIZE;
+ }
+ }
+
+ /* Get Data-In buffer before clean up */
gather_data_area(udev, bitmap,
se_cmd->t_bidi_data_sg, se_cmd->t_bidi_data_nents);
free_data_area(udev, cmd);
With your patches, and the above diff, support for BIDI commands in the
target/user seems to be working again.
Could you please validate the above snippet, and update your patches to
include it?
--
Ilias
next prev parent reply other threads:[~2017-03-23 16:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-21 8:36 [PATCHv4 0/4] tcmu: bug fix and dynamic growing data area support lixiubo
2017-03-21 8:36 ` [PATCHv4 1/4] tcmu: Fix possible overwrite of t_data_sg's last iov[] lixiubo
2017-03-21 19:39 ` Mike Christie
2017-03-21 8:36 ` [PATCHv4 2/4] tcmu: Fix wrongly calculating of the base_command_size lixiubo
2017-03-21 19:53 ` Mike Christie
2017-03-21 8:36 ` [PATCHv4 3/4] tcmu: Add dynamic growing data area feature support lixiubo
2017-03-21 8:36 ` [PATCHv4 4/4] tcmu: Add global data block pool support lixiubo
2017-03-21 19:12 ` [PATCHv4 0/4] tcmu: bug fix and dynamic growing data area support Bryant G. Ly
2017-03-23 16:02 ` Ilias Tsitsimpis [this message]
[not found] ` <c28c75c3-0ab8-4320-9716-b36fc027ff50@email.android.com>
2017-03-25 8:57 ` Ilias Tsitsimpis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170323160237.qqofpc7v7aoazfqd@iliastsi-m.arr \
--to=iliastsi@arrikto.com \
--cc=agrover@redhat.com \
--cc=bryantly@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=lixiubo@cmss.chinamobile.com \
--cc=mchristi@redhat.com \
--cc=nab@linux-iscsi.org \
--cc=namei.unix@gmail.com \
--cc=sheng@yasker.org \
--cc=shli@kernel.org \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.