Re: [PATCH] scsi: Introduce a help function local_time_seconds() to simplify the getting time stamp operation

2013-05-29 Thread Gu Zheng
On 05/30/2013 11:00 AM, Libo Chen wrote:

> On 2013/5/29 17:33, Gu Zheng wrote:
>> >From 4d4caa16f3886ae910ad6dfe13353fc836f546cc Mon Sep 17 00:00:00 2001
>> From: Gu Zheng 
>> Date: Wed, 29 May 2013 17:34:22 +0900
>> Subject: [PATCH] driver/scsi: Introduce a help function local_time_seconds() 
>> to simplify the getting time stamp operation
>>
> hi gu,
> 
> next time, you can remove above info.

Ah~, I forgot to clean up the unnecessary title infos, thanks for your reminder.

Regards,
Gu

> 
> 
> thanks,
> 
> Libo
> 
> 
>> Signed-off-by: Gu Zheng 
>> ---
>>  drivers/scsi/3w-9xxx.c |   14 ++
>>  drivers/scsi/3w-sas.c  |   14 ++
>>  include/scsi/scsi.h|9 +
>>  3 files changed, 13 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
>> index 5e1e12c..44b3ea8 100644
>> --- a/drivers/scsi/3w-9xxx.c
>> +++ b/drivers/scsi/3w-9xxx.c
>> @@ -374,8 +374,6 @@ out:
>>  /* This function will queue an event */
>>  static void twa_aen_queue_event(TW_Device_Extension *tw_dev, 
>> TW_Command_Apache_Header *header)
>>  {
>> -u32 local_time;
>> -struct timeval time;
>>  TW_Event *event;
>>  unsigned short aen;
>>  char host[16];
>> @@ -398,9 +396,7 @@ static void twa_aen_queue_event(TW_Device_Extension 
>> *tw_dev, TW_Command_Apache_H
>>  memset(event, 0, sizeof(TW_Event));
>>  
>>  event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
>> -do_gettimeofday(&time);
>> -local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
>> -event->time_stamp_sec = local_time;
>> +event->time_stamp_sec = local_time_seconds();
>>  event->aen_code = aen;
>>  event->retrieved = TW_AEN_NOT_RETRIEVED;
>>  event->sequence_id = tw_dev->error_sequence_id;
>> @@ -479,11 +475,9 @@ out:
>>  static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>>  {
>>  u32 schedulertime;
>> -struct timeval utc;
>>  TW_Command_Full *full_command_packet;
>>  TW_Command *command_packet;
>>  TW_Param_Apache *param;
>> -u32 local_time;
>>  
>>  /* Fill out the command packet */
>>  full_command_packet = tw_dev->command_packet_virt[request_id];
>> @@ -503,11 +497,7 @@ static void twa_aen_sync_time(TW_Device_Extension 
>> *tw_dev, int request_id)
>>  param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
>>  param->parameter_size_bytes = cpu_to_le16(4);
>>  
>> -/* Convert system time in UTC to local time seconds since last 
>> -   Sunday 12:00AM */
>> -do_gettimeofday(&utc);
>> -local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
>> -schedulertime = local_time - (3 * 86400);
>> +schedulertime = local_time_seconds() - (3 * 86400);
>>  schedulertime = cpu_to_le32(schedulertime % 604800);
>>  
>>  memcpy(param->data, &schedulertime, sizeof(u32));
>> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
>> index c845bdb..69f1d8a 100644
>> --- a/drivers/scsi/3w-sas.c
>> +++ b/drivers/scsi/3w-sas.c
>> @@ -236,8 +236,6 @@ out:
>>  /* This function will queue an event */
>>  static void twl_aen_queue_event(TW_Device_Extension *tw_dev, 
>> TW_Command_Apache_Header *header)
>>  {
>> -u32 local_time;
>> -struct timeval time;
>>  TW_Event *event;
>>  unsigned short aen;
>>  char host[16];
>> @@ -256,9 +254,7 @@ static void twl_aen_queue_event(TW_Device_Extension 
>> *tw_dev, TW_Command_Apache_H
>>  memset(event, 0, sizeof(TW_Event));
>>  
>>  event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
>> -do_gettimeofday(&time);
>> -local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
>> -event->time_stamp_sec = local_time;
>> +event->time_stamp_sec = local_time_seconds();
>>  event->aen_code = aen;
>>  event->retrieved = TW_AEN_NOT_RETRIEVED;
>>  event->sequence_id = tw_dev->error_sequence_id;
>> @@ -444,11 +440,9 @@ out:
>>  static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>>  {
>>  u32 schedulertime;
>> -struct timeval utc;
>>  TW_Command_Full *full_command_packet;
>>  TW_Command *command_packet;
>>  TW_Param_Apache *param;
>> -u32 local_time;
>>  
>>  /* Fill out the command packet */
>>  full_command_packet = tw_dev->command_packet_virt[request_id];
>> @@ -468,11 +462,7 @@ static void twl_aen_sync_time(TW_Device_Extension 
>> *tw_dev, int request_id)
>>  param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
>>  param->parameter_size_bytes = cpu_to_le16(4);
>>  
>> -/* Convert system time in UTC to local time seconds since last 
>> -   Sunday 12:00AM */
>> -do_gettimeofday(&utc);
>> -local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
>> -schedulertime = local_time - (3 * 86400);
>> +schedulertime = local_time_seconds() - (3 * 86400);
>>  schedulertime = cpu_to_le32(schedulertime % 604800);
>>  
>>  memcpy(pa

Re: [PATCH] scsi: Introduce a help function local_time_seconds() to simplify the getting time stamp operation

2013-05-29 Thread Libo Chen
On 2013/5/29 17:33, Gu Zheng wrote:
>>From 4d4caa16f3886ae910ad6dfe13353fc836f546cc Mon Sep 17 00:00:00 2001
> From: Gu Zheng 
> Date: Wed, 29 May 2013 17:34:22 +0900
> Subject: [PATCH] driver/scsi: Introduce a help function local_time_seconds() 
> to simplify the getting time stamp operation
> 
hi gu,

next time, you can remove above info.


thanks,

Libo


> Signed-off-by: Gu Zheng 
> ---
>  drivers/scsi/3w-9xxx.c |   14 ++
>  drivers/scsi/3w-sas.c  |   14 ++
>  include/scsi/scsi.h|9 +
>  3 files changed, 13 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index 5e1e12c..44b3ea8 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -374,8 +374,6 @@ out:
>  /* This function will queue an event */
>  static void twa_aen_queue_event(TW_Device_Extension *tw_dev, 
> TW_Command_Apache_Header *header)
>  {
> - u32 local_time;
> - struct timeval time;
>   TW_Event *event;
>   unsigned short aen;
>   char host[16];
> @@ -398,9 +396,7 @@ static void twa_aen_queue_event(TW_Device_Extension 
> *tw_dev, TW_Command_Apache_H
>   memset(event, 0, sizeof(TW_Event));
>  
>   event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
> - do_gettimeofday(&time);
> - local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
> - event->time_stamp_sec = local_time;
> + event->time_stamp_sec = local_time_seconds();
>   event->aen_code = aen;
>   event->retrieved = TW_AEN_NOT_RETRIEVED;
>   event->sequence_id = tw_dev->error_sequence_id;
> @@ -479,11 +475,9 @@ out:
>  static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
>   u32 schedulertime;
> - struct timeval utc;
>   TW_Command_Full *full_command_packet;
>   TW_Command *command_packet;
>   TW_Param_Apache *param;
> - u32 local_time;
>  
>   /* Fill out the command packet */
>   full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -503,11 +497,7 @@ static void twa_aen_sync_time(TW_Device_Extension 
> *tw_dev, int request_id)
>   param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
>   param->parameter_size_bytes = cpu_to_le16(4);
>  
> - /* Convert system time in UTC to local time seconds since last 
> -   Sunday 12:00AM */
> - do_gettimeofday(&utc);
> - local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> - schedulertime = local_time - (3 * 86400);
> + schedulertime = local_time_seconds() - (3 * 86400);
>   schedulertime = cpu_to_le32(schedulertime % 604800);
>  
>   memcpy(param->data, &schedulertime, sizeof(u32));
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index c845bdb..69f1d8a 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -236,8 +236,6 @@ out:
>  /* This function will queue an event */
>  static void twl_aen_queue_event(TW_Device_Extension *tw_dev, 
> TW_Command_Apache_Header *header)
>  {
> - u32 local_time;
> - struct timeval time;
>   TW_Event *event;
>   unsigned short aen;
>   char host[16];
> @@ -256,9 +254,7 @@ static void twl_aen_queue_event(TW_Device_Extension 
> *tw_dev, TW_Command_Apache_H
>   memset(event, 0, sizeof(TW_Event));
>  
>   event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
> - do_gettimeofday(&time);
> - local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
> - event->time_stamp_sec = local_time;
> + event->time_stamp_sec = local_time_seconds();
>   event->aen_code = aen;
>   event->retrieved = TW_AEN_NOT_RETRIEVED;
>   event->sequence_id = tw_dev->error_sequence_id;
> @@ -444,11 +440,9 @@ out:
>  static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
>  {
>   u32 schedulertime;
> - struct timeval utc;
>   TW_Command_Full *full_command_packet;
>   TW_Command *command_packet;
>   TW_Param_Apache *param;
> - u32 local_time;
>  
>   /* Fill out the command packet */
>   full_command_packet = tw_dev->command_packet_virt[request_id];
> @@ -468,11 +462,7 @@ static void twl_aen_sync_time(TW_Device_Extension 
> *tw_dev, int request_id)
>   param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
>   param->parameter_size_bytes = cpu_to_le16(4);
>  
> - /* Convert system time in UTC to local time seconds since last 
> -   Sunday 12:00AM */
> - do_gettimeofday(&utc);
> - local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
> - schedulertime = local_time - (3 * 86400);
> + schedulertime = local_time_seconds() - (3 * 86400);
>   schedulertime = cpu_to_le32(schedulertime % 604800);
>  
>   memcpy(param->data, &schedulertime, sizeof(u32));
> diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
> index 66216c1..f3377ca 100644
> --- a/include/scsi/scsi.h
> +++ b/include/scsi/scsi.h
> @@ -574,4 +574,13 @@ stati

Re: [PATCH RESEND] scsi: megaraid: check kzalloc

2013-05-29 Thread Libo Chen
On 2013/5/30 9:38, Libo Chen wrote:
> On 2013/5/29 23:03, Tomas Henzl wrote:
>> On 05/24/2013 11:40 AM, Libo Chen wrote:
>>> we should check kzalloc, avoid to hit oops
>>>
>>> Signed-off-by: Libo Chen 
>>> ---
>>>  drivers/scsi/megaraid.c |4 
>>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>>
>>> instead of checking scmd->device, sdev is more appropriate.
>>>
>>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>>> index 846f475..6b623cb 100644
>>> --- a/drivers/scsi/megaraid.c
>>> +++ b/drivers/scsi/megaraid.c
>>> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t 
>>> *mc, mega_passthru *pthru)
>>> memset(scb, 0, sizeof(scb_t));
>>>
>>> sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
>>> +   if (sdev) {
>>> +   scsi_free_command(GFP_KERNEL, scmd);
>>
>> I think, that a mutex_unlock(&adapter->int_mtx); is also needed
>> Maybe just setting a rval = -ENOMEM and a jump to to some point below?
>>
>> tomash
> 
> thanks for catching this.
> 
> when kzalloc broken, fist unlock and then return.  I will update later.
> 

I think we can put kzalloc outside of mutex_lock(&adapter->int_mtx) ?
phase:

   mutex_lock  kzalloc
   kzalloc ->  mutex_lock


> 
> Libo
> 
>>
>>> +   return -ENOMEM;
>>> +   }
>>> scmd->device = sdev;
>>>
>>> memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
>>
>>
>> .
>>
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] scsi: megaraid: check kzalloc

2013-05-29 Thread Libo Chen
On 2013/5/29 23:03, Tomas Henzl wrote:
> On 05/24/2013 11:40 AM, Libo Chen wrote:
>> we should check kzalloc, avoid to hit oops
>>
>> Signed-off-by: Libo Chen 
>> ---
>>  drivers/scsi/megaraid.c |4 
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> instead of checking scmd->device, sdev is more appropriate.
>>
>> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
>> index 846f475..6b623cb 100644
>> --- a/drivers/scsi/megaraid.c
>> +++ b/drivers/scsi/megaraid.c
>> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t 
>> *mc, mega_passthru *pthru)
>>  memset(scb, 0, sizeof(scb_t));
>>
>>  sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
>> +if (sdev) {
>> +scsi_free_command(GFP_KERNEL, scmd);
> 
> I think, that a mutex_unlock(&adapter->int_mtx); is also needed
> Maybe just setting a rval = -ENOMEM and a jump to to some point below?
> 
> tomash

thanks for catching this.

when kzalloc broken, fist unlock and then return.  I will update later.


Libo

> 
>> +return -ENOMEM;
>> +}
>>  scmd->device = sdev;
>>
>>  memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));
> 
> 
> .
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] cxgb4i: add support for t5 adapter

2013-05-29 Thread kxie
[PATCH] cxgb4i: add support for T5 adapter

From: Karen Xie 

Adds support for Chelsio T5 adapter.

Signed-off-by: Karen Xie 
---
 drivers/scsi/cxgbi/cxgb4i/cxgb4i.c |  159 +---
 1 files changed, 128 insertions(+), 31 deletions(-)

diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c 
b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 3fecf35..e659feb 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 
+#include "t4_regs.h"
 #include "t4_msg.h"
 #include "cxgb4.h"
 #include "cxgb4_uld.h"
@@ -32,13 +33,12 @@ static unsigned int dbg_level;
 #include "../libcxgbi.h"
 
 #defineDRV_MODULE_NAME "cxgb4i"
-#define DRV_MODULE_DESC"Chelsio T4 iSCSI Driver"
-#defineDRV_MODULE_VERSION  "0.9.1"
-#defineDRV_MODULE_RELDATE  "Aug. 2010"
+#define DRV_MODULE_DESC"Chelsio T4/T5 iSCSI Driver"
+#defineDRV_MODULE_VERSION  "0.9.4"
 
 static char version[] =
DRV_MODULE_DESC " " DRV_MODULE_NAME
-   " v" DRV_MODULE_VERSION " (" DRV_MODULE_RELDATE ")\n";
+   " v" DRV_MODULE_VERSION "\n";
 
 MODULE_AUTHOR("Chelsio Communications, Inc.");
 MODULE_DESCRIPTION(DRV_MODULE_DESC);
@@ -175,10 +175,56 @@ static inline int is_ofld_imm(const struct sk_buff *skb)
sizeof(struct fw_ofld_tx_data_wr));
 }
 
+
+#define VLAN_NONE 0xfff
+#define FILTER_SEL_VLAN_NONE 0x
+#define FILTER_SEL_WIDTH_P_FC (3+1) /* port uses 3 bits, FCoE one bit */
+#define FILTER_SEL_WIDTH_VIN_P_FC \
+   (6 + 7 + FILTER_SEL_WIDTH_P_FC) /* 6 bits are unused, VF uses 7 bits*/
+#define FILTER_SEL_WIDTH_TAG_P_FC \
+   (3 + FILTER_SEL_WIDTH_VIN_P_FC) /* PF uses 3 bits */
+#define FILTER_SEL_WIDTH_VLD_TAG_P_FC (1 + FILTER_SEL_WIDTH_TAG_P_FC)
+
+static unsigned int select_ntuple(struct cxgbi_device *cdev,
+   struct l2t_entry *l2t)
+{
+   struct cxgb4_lld_info *lldi = cxgbi_cdev_priv(cdev);
+   unsigned int ntuple = 0;
+   u32 viid;
+
+   switch (lldi->filt_mode) {
+
+   /* default filter mode */
+   case HW_TPL_FR_MT_PR_IV_P_FC:
+   if (l2t->vlan == VLAN_NONE)
+   ntuple |= FILTER_SEL_VLAN_NONE << FILTER_SEL_WIDTH_P_FC;
+   else {
+   ntuple |= l2t->vlan << FILTER_SEL_WIDTH_P_FC;
+   ntuple |= 1 << FILTER_SEL_WIDTH_VLD_TAG_P_FC;
+   }
+   ntuple |= l2t->lport << S_PORT | IPPROTO_TCP <<
+ FILTER_SEL_WIDTH_VLD_TAG_P_FC;
+   break;
+   case HW_TPL_FR_MT_PR_OV_P_FC: {
+   viid = cxgb4_port_viid(l2t->neigh->dev);
+
+   ntuple |= FW_VIID_VIN_GET(viid) << FILTER_SEL_WIDTH_P_FC;
+   ntuple |= FW_VIID_PFN_GET(viid) << FILTER_SEL_WIDTH_VIN_P_FC;
+   ntuple |= FW_VIID_VIVLD_GET(viid) << FILTER_SEL_WIDTH_TAG_P_FC;
+   ntuple |= l2t->lport << S_PORT | IPPROTO_TCP <<
+ FILTER_SEL_WIDTH_VLD_TAG_P_FC;
+   break;
+   }
+   default:
+   break;
+   }
+   return ntuple;
+}
+
 static void send_act_open_req(struct cxgbi_sock *csk, struct sk_buff *skb,
struct l2t_entry *e)
 {
-   struct cpl_act_open_req *req;
+   struct cxgb4_lld_info *lldi = cxgbi_cdev_priv(csk->cdev);
int wscale = cxgbi_sock_compute_wscale(csk->mss_idx);
unsigned long long opt0;
unsigned int opt2;
@@ -195,29 +241,58 @@ static void send_act_open_req(struct cxgbi_sock *csk, 
struct sk_buff *skb,
RCV_BUFSIZ(cxgb4i_rcv_win >> 10);
opt2 = RX_CHANNEL(0) |
RSS_QUEUE_VALID |
-   (1 << 20) | (1 << 22) |
+   (1 << 20) |
RSS_QUEUE(csk->rss_qid);
 
-   set_wr_txq(skb, CPL_PRIORITY_SETUP, csk->port_id);
-   req = (struct cpl_act_open_req *)skb->head;
+   if (is_t4(lldi->adapter_type)) {
+   struct cpl_act_open_req *req =
+   (struct cpl_act_open_req *)skb->head;
 
-   INIT_TP_WR(req, 0);
-   OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
+   req = (struct cpl_act_open_req *)skb->head;
+
+   INIT_TP_WR(req, 0);
+   OPCODE_TID(req) = cpu_to_be32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ,
qid_atid));
-   req->local_port = csk->saddr.sin_port;
-   req->peer_port = csk->daddr.sin_port;
-   req->local_ip = csk->saddr.sin_addr.s_addr;
-   req->peer_ip = csk->daddr.sin_addr.s_addr;
-   req->opt0 = cpu_to_be64(opt0);
-   req->params = 0;
-   req->opt2 = cpu_to_be32(opt2);
+   req->local_port = csk->saddr.sin_port;
+   req->peer_port = csk->daddr.sin_port;
+   req->local_ip = csk->saddr.sin_addr.s_addr;
+   req->peer_ip = csk->daddr.sin_addr.s_addr;
+ 

Re: [PATCH RESEND] scsi: megaraid: check kzalloc

2013-05-29 Thread Tomas Henzl
On 05/24/2013 11:40 AM, Libo Chen wrote:
> we should check kzalloc, avoid to hit oops
>
> Signed-off-by: Libo Chen 
> ---
>  drivers/scsi/megaraid.c |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> instead of checking scmd->device, sdev is more appropriate.
>
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 846f475..6b623cb 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t 
> *mc, mega_passthru *pthru)
>   memset(scb, 0, sizeof(scb_t));
>
>   sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
> + if (sdev) {
> + scsi_free_command(GFP_KERNEL, scmd);

I think, that a mutex_unlock(&adapter->int_mtx); is also needed
Maybe just setting a rval = -ENOMEM and a jump to to some point below?

tomash

> + return -ENOMEM;
> + }
>   scmd->device = sdev;
>
>   memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Scattererd write support

2013-05-29 Thread Tony Aiello

There's T10 work describing scattered write operations and an evolving spec 
from SNIA about Non-Volatile Memory operations on flash of atomic multiwrite. 
These take advantage of the fact that flash has no locality and that writing to 
a vector of block addresses in an atomic manner is not all that different for a 
flash translation layer than processing any other write operation.

However, the expression of these writes - and the corresponding gathered reads, 
don't look like any other write/read operation.Writev, readv come close as they 
have a vector of memory addresses, but lack  a vector of block addresses as 
well.

Naturally this isn't just a storage stack problem. The expression of a vector 
of blocks in addition to a vector of memory addresses needs support thru the 
file operations definition to allow applications to access the methods. 

But for this I'm interested in knowing if there's any thoughts/work on the SCSI 
stack to support this write scattered operation. 

Thanks.

Tony

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH RESEND] scsi: megaraid: check kzalloc

2013-05-29 Thread Tomas Henzl
On 05/24/2013 11:40 AM, Libo Chen wrote:
> we should check kzalloc, avoid to hit oops
>
> Signed-off-by: Libo Chen 
> ---
>  drivers/scsi/megaraid.c |4 
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> instead of checking scmd->device, sdev is more appropriate.
>
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 846f475..6b623cb 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -4161,6 +4161,10 @@ mega_internal_command(adapter_t *adapter, megacmd_t 
> *mc, mega_passthru *pthru)
>   memset(scb, 0, sizeof(scb_t));
>
>   sdev = kzalloc(sizeof(struct scsi_device), GFP_KERNEL);
> + if (sdev) {
> + scsi_free_command(GFP_KERNEL, scmd);

I think, that a mutex_unlock(&adapter->int_mtx); is also needed
Maybe just setting a rval = -ENOMEM and a jump to to some point below?

tomash

> + return -ENOMEM;
> + }
>   scmd->device = sdev;
>
>   memset(adapter->int_cdb, 0, sizeof(adapter->int_cdb));

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] fix buffer leak after "scsi: saner replacements for ->proc_info()"

2013-05-29 Thread Jan Beulich
That patch failed to set proc_scsi_fops' .release method.

Signed-off-by: Jan Beulich 

---
 drivers/scsi/scsi_proc.c |1 +
 1 file changed, 1 insertion(+)

--- 3.10-rc3/drivers/scsi/scsi_proc.c
+++ 3.10-rc3-scsi-proc-leak/drivers/scsi/scsi_proc.c
@@ -84,6 +84,7 @@ static int proc_scsi_host_open(struct in
 
 static const struct file_operations proc_scsi_fops = {
.open = proc_scsi_host_open,
+   .release = single_release,
.read = seq_read,
.llseek = seq_lseek,
.write = proc_scsi_host_write



--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] scsi: Introduce a help function local_time_seconds() to simplify the getting time stamp operation

2013-05-29 Thread Gu Zheng
>From 4d4caa16f3886ae910ad6dfe13353fc836f546cc Mon Sep 17 00:00:00 2001
From: Gu Zheng 
Date: Wed, 29 May 2013 17:34:22 +0900
Subject: [PATCH] driver/scsi: Introduce a help function local_time_seconds() to 
simplify the getting time stamp operation

Signed-off-by: Gu Zheng 
---
 drivers/scsi/3w-9xxx.c |   14 ++
 drivers/scsi/3w-sas.c  |   14 ++
 include/scsi/scsi.h|9 +
 3 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 5e1e12c..44b3ea8 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -374,8 +374,6 @@ out:
 /* This function will queue an event */
 static void twa_aen_queue_event(TW_Device_Extension *tw_dev, 
TW_Command_Apache_Header *header)
 {
-   u32 local_time;
-   struct timeval time;
TW_Event *event;
unsigned short aen;
char host[16];
@@ -398,9 +396,7 @@ static void twa_aen_queue_event(TW_Device_Extension 
*tw_dev, TW_Command_Apache_H
memset(event, 0, sizeof(TW_Event));
 
event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
-   do_gettimeofday(&time);
-   local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
-   event->time_stamp_sec = local_time;
+   event->time_stamp_sec = local_time_seconds();
event->aen_code = aen;
event->retrieved = TW_AEN_NOT_RETRIEVED;
event->sequence_id = tw_dev->error_sequence_id;
@@ -479,11 +475,9 @@ out:
 static void twa_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
 {
u32 schedulertime;
-   struct timeval utc;
TW_Command_Full *full_command_packet;
TW_Command *command_packet;
TW_Param_Apache *param;
-   u32 local_time;
 
/* Fill out the command packet */
full_command_packet = tw_dev->command_packet_virt[request_id];
@@ -503,11 +497,7 @@ static void twa_aen_sync_time(TW_Device_Extension *tw_dev, 
int request_id)
param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
param->parameter_size_bytes = cpu_to_le16(4);
 
-   /* Convert system time in UTC to local time seconds since last 
-   Sunday 12:00AM */
-   do_gettimeofday(&utc);
-   local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
-   schedulertime = local_time - (3 * 86400);
+   schedulertime = local_time_seconds() - (3 * 86400);
schedulertime = cpu_to_le32(schedulertime % 604800);
 
memcpy(param->data, &schedulertime, sizeof(u32));
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index c845bdb..69f1d8a 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -236,8 +236,6 @@ out:
 /* This function will queue an event */
 static void twl_aen_queue_event(TW_Device_Extension *tw_dev, 
TW_Command_Apache_Header *header)
 {
-   u32 local_time;
-   struct timeval time;
TW_Event *event;
unsigned short aen;
char host[16];
@@ -256,9 +254,7 @@ static void twl_aen_queue_event(TW_Device_Extension 
*tw_dev, TW_Command_Apache_H
memset(event, 0, sizeof(TW_Event));
 
event->severity = TW_SEV_OUT(header->status_block.severity__reserved);
-   do_gettimeofday(&time);
-   local_time = (u32)(time.tv_sec - (sys_tz.tz_minuteswest * 60));
-   event->time_stamp_sec = local_time;
+   event->time_stamp_sec = local_time_seconds();
event->aen_code = aen;
event->retrieved = TW_AEN_NOT_RETRIEVED;
event->sequence_id = tw_dev->error_sequence_id;
@@ -444,11 +440,9 @@ out:
 static void twl_aen_sync_time(TW_Device_Extension *tw_dev, int request_id)
 {
u32 schedulertime;
-   struct timeval utc;
TW_Command_Full *full_command_packet;
TW_Command *command_packet;
TW_Param_Apache *param;
-   u32 local_time;
 
/* Fill out the command packet */
full_command_packet = tw_dev->command_packet_virt[request_id];
@@ -468,11 +462,7 @@ static void twl_aen_sync_time(TW_Device_Extension *tw_dev, 
int request_id)
param->parameter_id = cpu_to_le16(0x3); /* SchedulerTime */
param->parameter_size_bytes = cpu_to_le16(4);
 
-   /* Convert system time in UTC to local time seconds since last 
-   Sunday 12:00AM */
-   do_gettimeofday(&utc);
-   local_time = (u32)(utc.tv_sec - (sys_tz.tz_minuteswest * 60));
-   schedulertime = local_time - (3 * 86400);
+   schedulertime = local_time_seconds() - (3 * 86400);
schedulertime = cpu_to_le32(schedulertime % 604800);
 
memcpy(param->data, &schedulertime, sizeof(u32));
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 66216c1..f3377ca 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -574,4 +574,13 @@ static inline __u32 scsi_to_u32(__u8 *ptr)
return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
 }
 
+/*
+ * Convert system time in UTC to local time seconds.
+ */
+static inline u32 local_time_seconds(void)
+{