From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: target-devel@vger.kernel.org,
Nicholas Bellinger <nab@linux-iscsi.org>,
Sagi Grimberg <sagig@mellanox.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH v3 1/5] target: ensure se_cmd->t_prot_sg is allocated when required
Date: Mon, 27 Apr 2015 18:08:16 +0300 [thread overview]
Message-ID: <553E50E0.6080900@dev.mellanox.co.il> (raw)
In-Reply-To: <CAC5umyjPxmFVcW43iY0RCrQfGbuEx4k-owHUR3oM0Bg-DvzWoA@mail.gmail.com>
On 4/27/2015 3:57 PM, Akinobu Mita wrote:
> 2015-04-26 18:44 GMT+09:00 Sagi Grimberg <sagig@dev.mellanox.co.il>:
>>>> @@ -2181,6 +2182,12 @@ static inline void
>>>> transport_reset_sgl_orig(struct se_cmd *cmd)
>>>>
>>>> static inline void transport_free_pages(struct se_cmd *cmd)
>>>> {
>>>> + if (!(cmd->se_cmd_flags & SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC)) {
>>>> + transport_free_sgl(cmd->t_prot_sg, cmd->t_prot_nents);
>>>> + cmd->t_prot_sg = NULL;
>>>> + cmd->t_prot_nents = 0;
>>>> + }
>>>> +
>>>
>>>
>>> Hi Akinobu,
>>>
>>> Any reason why this changed it's location to the start of the function?
>
> Because when SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC is set, it will not
> reach the tail of the function. So when SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC
> is cleared and SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC is set,
> se_cmd->t_prot_sg leaks.
I see. That's fine...
>
>>>> if (cmd->se_cmd_flags & SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC) {
>>>> /*
>>>> * Release special case READ buffer payload required for
>>>> @@ -2204,10 +2211,6 @@ static inline void transport_free_pages(struct
>>>> se_cmd *cmd)
>>>> transport_free_sgl(cmd->t_bidi_data_sg, cmd->t_bidi_data_nents);
>>>> cmd->t_bidi_data_sg = NULL;
>>>> cmd->t_bidi_data_nents = 0;
>>>> -
>>>> - transport_free_sgl(cmd->t_prot_sg, cmd->t_prot_nents);
>>>> - cmd->t_prot_sg = NULL;
>>>> - cmd->t_prot_nents = 0;
>>>> }
>>>>
>>>> /**
>>>> @@ -2346,6 +2349,17 @@ transport_generic_new_cmd(struct se_cmd *cmd)
>>>> int ret = 0;
>>>> bool zero_flag = !(cmd->se_cmd_flags & SCF_SCSI_DATA_CDB);
>>>>
>>>> + if (!(cmd->se_cmd_flags & SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC)) {
>>>> + if (cmd->prot_op != TARGET_PROT_NORMAL) {
>>>
>>>
>>> This seems wrong,
>>>
>>> What will happen for transports that will actually to allocate
>>> protection SGLs? The allocation is unreachable since
>>> SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC is not set...
>>
>>
>> Umm, actually this is reachable... But I still think the condition
>> should be the other way around (saving a condition in some common
>> cases).
>
> Do you mean you prefer below?
>
> if (cmd->prot_op != TARGET_PROT_NORMAL &&
> !(cmd->se_cmd_flags & SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC)) {
> ...
>
I think it will be better.
next prev parent reply other threads:[~2015-04-27 15:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1429972410-7146-1-git-send-email-akinobu.mita@gmail.com>
2015-04-25 14:33 ` [PATCH v3 1/5] target: ensure se_cmd->t_prot_sg is allocated when required Akinobu Mita
2015-04-26 9:26 ` Sagi Grimberg
2015-04-26 9:44 ` Sagi Grimberg
2015-04-27 12:57 ` Akinobu Mita
2015-04-27 15:08 ` Sagi Grimberg [this message]
2015-04-25 14:33 ` [PATCH v3 3/5] target: handle odd SG mapping for data transfer memory Akinobu Mita
2015-04-26 10:07 ` Sagi Grimberg
2015-04-27 13:03 ` Akinobu Mita
2015-04-25 14:33 ` [PATCH v3 4/5] target: Fix sbc_dif_generate() and sbc_dif_verify() for WRITE SAME Akinobu Mita
2015-04-26 9:53 ` Sagi Grimberg
2015-04-27 12:58 ` Akinobu Mita
2015-04-25 14:33 ` [PATCH v3 5/5] target/file: enable WRITE SAME when protection info is enabled Akinobu Mita
2015-04-26 9:58 ` Sagi Grimberg
2015-04-27 13:02 ` Akinobu Mita
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=553E50E0.6080900@dev.mellanox.co.il \
--to=sagig@dev.mellanox.co.il \
--cc=James.Bottomley@hansenpartnership.com \
--cc=akinobu.mita@gmail.com \
--cc=hch@lst.de \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=nab@linux-iscsi.org \
--cc=sagig@mellanox.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox