On 08/07/2009 05:27 AM, Hannes Reinecke wrote:
> Before we're trying to send a PDU we have to check whether a TMF
> is active. If so and if the PDU will be affected by the TMF
> we should allow only Data-out PDUs to be sent, or, if
> fast_abort is set, no PDUs at all.
>
> Signed-off-by: Mike Christie<micha...@cs.wisc.edu>
> Signed-off-by: Hannes Reinecke<h...@suse.de>
> ---
>   drivers/scsi/libiscsi.c |  100 
> +++++++++++++++++++++++++++++++++++++++++------
>   1 files changed, 88 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
> index fc266e7..6123f97 100644
> --- a/drivers/scsi/libiscsi.c
> +++ b/drivers/scsi/libiscsi.c
> @@ -262,6 +262,76 @@ static int iscsi_prep_bidi_ahs(struct iscsi_task *task)
>       return 0;
>   }
>
> +static int iscsi_check_tmf_restrictions(struct iscsi_task *task, int opcode)
> +{
> +     struct iscsi_conn *conn = task->conn;
> +     struct iscsi_tm *tmf =&conn->tmhdr;
> +     unsigned int hdr_lun;
> +
> +     if (conn->tmf_state == TMF_INITIAL)
> +             return 0;
> +
> +     if ((tmf->opcode&  ISCSI_OPCODE_MASK) != ISCSI_OP_SCSI_TMFUNC)
> +             return 0;
> +
> +     switch (ISCSI_TM_FUNC_VALUE(tmf)) {
> +     case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET:
> +             /*
> +              * Allow PDUs for unrelated LUNs
> +              */
> +             hdr_lun = scsilun_to_int((struct scsi_lun *)tmf->lun);
> +             if (hdr_lun != task->sc->device->lun)
> +                     return 0;
> +
> +             /*
> +              * Fail all SCSI cmd PDUs
> +              */
> +             if (opcode != ISCSI_OP_SCSI_DATA_OUT) {
> +                     iscsi_conn_printk(KERN_INFO, conn,
> +                                       "task [op %x/%x itt "
> +                                       "0x%x/0x%x lun %u] "
> +                                       "rejected.\n",
> +                                       task->hdr->opcode, opcode,
> +                                       task->itt, task->hdr_itt, hdr_lun);
> +                     return -EACCES;
> +             }
> +             /*
> +              * And also all data-out PDUs in response to R2T
> +              * if fast_abort is set.
> +              */
> +             if (conn->session->fast_abort) {
> +                     iscsi_conn_printk(KERN_INFO, conn,
> +                                       "task [op %x/%x itt "
> +                                       "0x%x/0x%x lun %u] "
> +                                       "fast abort.\n",
> +                                       task->hdr->opcode, opcode,
> +                                       task->itt, task->hdr_itt, hdr_lun);
> +                     return -EACCES;
> +             }
> +             task->hdr->flags |= ISCSI_FLAG_CMD_FINAL;


The hdr flags will not get picked up. iscsi_prep_data_out_pdu sets the 
hdr to 0 or ISCSI_FLAG_CMD_FINAL and is called after this.

This could also cause problems because libiscsi_tcp could send multiple 
data-outs. If the flag setting did take affect on the first pdu sent, 
then when the target gets the other data-outs, I am not sure what would 
happen. The target would probably drop the session.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"open-iscsi" group.
To post to this group, send email to open-iscsi@googlegroups.com
To unsubscribe from this group, send email to 
open-iscsi+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/open-iscsi
-~----------~----~----~----~------~----~------~--~---

Reply via email to