···0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001Release Date : Mon Apr 11 12:27:22 EST 2006 - Seokmann Ju <sju@lsil.com>2Current Version : 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)3Older Version : 2.20.4.7 (scsi module), 2.20.2.6 (cmm module)
···1+Release Date : Fri May 19 09:31:45 EST 2006 - Seokmann Ju <sju@lsil.com>2+Current Version : 2.20.4.9 (scsi module), 2.20.2.6 (cmm module)3+Older Version : 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)4+5+1. Fixed a bug in megaraid_init_mbox().6+ Customer reported "garbage in file on x86_64 platform".7+ Root Cause: the driver registered controllers as 64-bit DMA capable8+ for those which are not support it.9+ Fix: Made change in the function inserting identification machanism10+ identifying 64-bit DMA capable controllers.11+12+ > -----Original Message-----13+ > From: Vasily Averin [mailto:vvs@sw.ru]14+ > Sent: Thursday, May 04, 2006 2:49 PM15+ > To: linux-scsi@vger.kernel.org; Kolli, Neela; Mukker, Atul;16+ > Ju, Seokmann; Bagalkote, Sreenivas;17+ > James.Bottomley@SteelEye.com; devel@openvz.org18+ > Subject: megaraid_mbox: garbage in file19+ >20+ > Hello all,21+ >22+ > I've investigated customers claim on the unstable work of23+ > their node and found a24+ > strange effect: reading from some files leads to the25+ > "attempt to access beyond end of device" messages.26+ >27+ > I've checked filesystem, memory on the node, motherboard BIOS28+ > version, but it29+ > does not help and issue still has been reproduced by simple30+ > file reading.31+ >32+ > Reproducer is simple:33+ >34+ > echo 0xffffffff >/proc/sys/dev/scsi/logging_level ;35+ > cat /vz/private/101/root/etc/ld.so.cache >/tmp/ttt ;36+ > echo 0 >/proc/sys/dev/scsi/logging37+ >38+ > It leads to the following messages in dmesg39+ >40+ > sd_init_command: disk=sda, block=871769260, count=2641+ > sda : block=87176926042+ > sda : reading 26/26 512 byte blocks.43+ > scsi_add_timer: scmd: f79ed980, time: 7500, (c02b1420)44+ > sd 0:1:0:0: send 0xf79ed980 sd 0:1:0:0:45+ > command: Read (10): 28 00 33 f6 24 ac 00 00 1a 0046+ > buffer = 0xf7cfb540, bufflen = 13312, done = 0xc0366b40,47+ > queuecommand 0xc034401048+ > leaving scsi_dispatch_cmnd()49+ > scsi_delete_timer: scmd: f79ed980, rtn: 150+ > sd 0:1:0:0: done 0xf79ed980 SUCCESS 0 sd 0:1:0:0:51+ > command: Read (10): 28 00 33 f6 24 ac 00 00 1a 0052+ > scsi host busy 1 failed 053+ > sd 0:1:0:0: Notifying upper driver of completion (result 0)54+ > sd_rw_intr: sda: res=0x055+ > 26 sectors total, 13312 bytes done.56+ > use_sg is 457+ > attempt to access beyond end of device58+ > sda6: rw=0, want=1044134458, limit=95140136759+ > Buffer I/O error on device sda6, logical block 52206722860+ > attempt to access beyond end of device61+62+2. When INQUIRY with EVPD bit set issued to the MegaRAID controller,63+ system memory gets corrupted.64+ Root Cause: MegaRAID F/W handle the INQUIRY with EVPD bit set65+ incorrectly.66+ Fix: MegaRAID F/W has fixed the problem and being process of release,67+ soon. Meanwhile, driver will filter out the request.68+69+3. One of member in the data structure of the driver leads unaligne70+ issue on 64-bit platform.71+ Customer reporeted "kernel unaligned access addrss" issue when72+ application communicates with MegaRAID HBA driver.73+ Root Cause: in uioc_t structure, one of member had misaligned and it74+ led system to display the error message.75+ Fix: A patch submitted to community from following folk.76+77+ > -----Original Message-----78+ > From: linux-scsi-owner@vger.kernel.org79+ > [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Sakurai Hiroomi80+ > Sent: Wednesday, July 12, 2006 4:20 AM81+ > To: linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org82+ > Subject: Re: Help: strange messages from kernel on IA64 platform83+ >84+ > Hi,85+ >86+ > I saw same message.87+ >88+ > When GAM(Global Array Manager) is started, The following89+ > message output.90+ > kernel: kernel unaligned access to 0xe0000001fe1080d4,91+ > ip=0xa00000020005337192+ >93+ > The uioc structure used by ioctl is defined by packed,94+ > the allignment of each member are disturbed.95+ > In a 64 bit structure, the allignment of member doesn't fit 64 bit96+ > boundary. this causes this messages.97+ > In a 32 bit structure, we don't see the message because the allinment98+ > of member fit 32 bit boundary even if packed is specified.99+ >100+ > patch101+ > I Add 32 bit dummy member to fit 64 bit boundary. I tested.102+ > We confirmed this patch fix the problem by IA64 server.103+ >104+ > **************************************************************105+ > ****************106+ > --- linux-2.6.9/drivers/scsi/megaraid/megaraid_ioctl.h.orig107+ > 2006-04-03 17:13:03.000000000 +0900108+ > +++ linux-2.6.9/drivers/scsi/megaraid/megaraid_ioctl.h109+ > 2006-04-03 17:14:09.000000000 +0900110+ > @@ -132,6 +132,10 @@111+ > /* Driver Data: */112+ > void __user * user_data;113+ > uint32_t user_data_len;114+ > +115+ > + /* 64bit alignment */116+ > + uint32_t pad_0xBC;117+ > +118+ > mraid_passthru_t __user *user_pthru;119+ >120+ > mraid_passthru_t *pthru32;121+ > **************************************************************122+ > ****************123+124Release Date : Mon Apr 11 12:27:22 EST 2006 - Seokmann Ju <sju@lsil.com>125Current Version : 2.20.4.8 (scsi module), 2.20.2.6 (cmm module)126Older Version : 2.20.4.7 (scsi module), 2.20.2.6 (cmm module)
···669 * if still doing discovery,670 * hang loose a while until finished671 */672- if (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) {000673 if (count-- > 0) {674 msleep(100);675 goto try_again;···898{899 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;900 int ii;901- int work_to_do;902 u64 pn;903- unsigned long flags;904 struct mptfc_rport_info *ri;905906- do {907- /* start by tagging all ports as missing */908- list_for_each_entry(ri, &ioc->fc_rports, list) {909- if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {910- ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;911- }912 }0913914- /*915- * now rescan devices known to adapter,916- * will reregister existing rports917- */918- for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {919- (void) mptfc_GetFcPortPage0(ioc, ii);920- mptfc_init_host_attr(ioc,ii); /* refresh */921- mptfc_GetFcDevPage0(ioc,ii,mptfc_register_dev);0000000000000000000922 }923-924- /* delete devices still missing */925- list_for_each_entry(ri, &ioc->fc_rports, list) {926- /* if newly missing, delete it */927- if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) {928-929- ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|930- MPT_RPORT_INFO_FLAGS_MISSING);931- fc_remote_port_delete(ri->rport); /* won't sleep */932- ri->rport = NULL;933-934- pn = (u64)ri->pg0.WWPN.High << 32 |935- (u64)ri->pg0.WWPN.Low;936- dfcprintk ((MYIOC_s_INFO_FMT937- "mptfc_rescan.%d: %llx deleted\n",938- ioc->name,939- ioc->sh->host_no,940- (unsigned long long)pn));941- }942- }943-944- /*945- * allow multiple passes as target state946- * might have changed during scan947- */948- spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);949- if (ioc->fc_rescan_work_count > 2) /* only need one more */950- ioc->fc_rescan_work_count = 2;951- work_to_do = --ioc->fc_rescan_work_count;952- spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);953- } while (work_to_do);954}955956static int···1148 * by doing it via the workqueue, some locking is eliminated1149 */11501151- ioc->fc_rescan_work_count = 1;1152 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work);1153 flush_workqueue(ioc->fc_rescan_work_q);1154···1190 case MPI_EVENT_RESCAN:1191 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);1192 if (ioc->fc_rescan_work_q) {1193- if (ioc->fc_rescan_work_count++ == 0) {1194- queue_work(ioc->fc_rescan_work_q,1195- &ioc->fc_rescan_work);1196- }1197 }1198 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);1199 break;···1234 mptfc_SetFcPortPage1_defaults(ioc);1235 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);1236 if (ioc->fc_rescan_work_q) {1237- if (ioc->fc_rescan_work_count++ == 0) {1238- queue_work(ioc->fc_rescan_work_q,1239- &ioc->fc_rescan_work);1240- }1241 }1242 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);1243 }
···669 * if still doing discovery,670 * hang loose a while until finished671 */672+ if ((pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_UNKNOWN) ||673+ (pp0dest->PortState == MPI_FCPORTPAGE0_PORTSTATE_ONLINE &&674+ (pp0dest->Flags & MPI_FCPORTPAGE0_FLAGS_ATTACH_TYPE_MASK)675+ == MPI_FCPORTPAGE0_FLAGS_ATTACH_NO_INIT)) {676 if (count-- > 0) {677 msleep(100);678 goto try_again;···895{896 MPT_ADAPTER *ioc = (MPT_ADAPTER *)arg;897 int ii;0898 u64 pn;0899 struct mptfc_rport_info *ri;900901+ /* start by tagging all ports as missing */902+ list_for_each_entry(ri, &ioc->fc_rports, list) {903+ if (ri->flags & MPT_RPORT_INFO_FLAGS_REGISTERED) {904+ ri->flags |= MPT_RPORT_INFO_FLAGS_MISSING;00905 }906+ }907908+ /*909+ * now rescan devices known to adapter,910+ * will reregister existing rports911+ */912+ for (ii=0; ii < ioc->facts.NumberOfPorts; ii++) {913+ (void) mptfc_GetFcPortPage0(ioc, ii);914+ mptfc_init_host_attr(ioc, ii); /* refresh */915+ mptfc_GetFcDevPage0(ioc, ii, mptfc_register_dev);916+ }917+918+ /* delete devices still missing */919+ list_for_each_entry(ri, &ioc->fc_rports, list) {920+ /* if newly missing, delete it */921+ if (ri->flags & MPT_RPORT_INFO_FLAGS_MISSING) {922+923+ ri->flags &= ~(MPT_RPORT_INFO_FLAGS_REGISTERED|924+ MPT_RPORT_INFO_FLAGS_MISSING);925+ fc_remote_port_delete(ri->rport); /* won't sleep */926+ ri->rport = NULL;927+928+ pn = (u64)ri->pg0.WWPN.High << 32 |929+ (u64)ri->pg0.WWPN.Low;930+ dfcprintk ((MYIOC_s_INFO_FMT931+ "mptfc_rescan.%d: %llx deleted\n",932+ ioc->name,933+ ioc->sh->host_no,934+ (unsigned long long)pn));935 }936+ }000000000000000000000000000000937}938939static int···1159 * by doing it via the workqueue, some locking is eliminated1160 */116101162 queue_work(ioc->fc_rescan_work_q, &ioc->fc_rescan_work);1163 flush_workqueue(ioc->fc_rescan_work_q);1164···1202 case MPI_EVENT_RESCAN:1203 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);1204 if (ioc->fc_rescan_work_q) {1205+ queue_work(ioc->fc_rescan_work_q,1206+ &ioc->fc_rescan_work);001207 }1208 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);1209 break;···1248 mptfc_SetFcPortPage1_defaults(ioc);1249 spin_lock_irqsave(&ioc->fc_rescan_work_lock, flags);1250 if (ioc->fc_rescan_work_q) {1251+ queue_work(ioc->fc_rescan_work_q,1252+ &ioc->fc_rescan_work);001253 }1254 spin_unlock_irqrestore(&ioc->fc_rescan_work_lock, flags);1255 }
+111-9
drivers/s390/scsi/zfcp_aux.c
···112 printk("\n");113}114000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000115/****************************************************************/116/************** Uncategorised Functions *************************/117/****************************************************************/···1060 INIT_LIST_HEAD(&adapter->port_remove_lh);10611062 /* initialize list of fsf requests */1063- spin_lock_init(&adapter->fsf_req_list_lock);1064- INIT_LIST_HEAD(&adapter->fsf_req_list_head);000010651066 /* initialize debug locks */1067···1144 * !0 - struct zfcp_adapter data structure could not be removed1145 * (e.g. still used)1146 * locks: adapter list write lock is assumed to be held by caller1147- * adapter->fsf_req_list_lock is taken and released within this 1148- * function and must not be held on entry1149 */1150void1151zfcp_adapter_dequeue(struct zfcp_adapter *adapter)···1155 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);1156 dev_set_drvdata(&adapter->ccw_device->dev, NULL);1157 /* sanity check: no pending FSF requests */1158- spin_lock_irqsave(&adapter->fsf_req_list_lock, flags);1159- retval = !list_empty(&adapter->fsf_req_list_head);1160- spin_unlock_irqrestore(&adapter->fsf_req_list_lock, flags);1161- if (retval) {1162 ZFCP_LOG_NORMAL("bug: adapter %s (%p) still in use, "1163 "%i requests outstanding\n",1164 zfcp_get_busid_by_adapter(adapter), adapter,1165- atomic_read(&adapter->fsf_reqs_active));1166 retval = -EBUSY;1167 goto out;1168 }···1188 zfcp_free_low_mem_buffers(adapter);1189 /* free memory of adapter data structure and queues */1190 zfcp_qdio_free_queues(adapter);01191 kfree(adapter->fc_stats);1192 kfree(adapter->stats_reset_data);1193 ZFCP_LOG_TRACE("freeing adapter structure\n");
···112 printk("\n");113}114115+116+/****************************************************************/117+/****** Functions to handle the request ID hash table ********/118+/****************************************************************/119+120+#define ZFCP_LOG_AREA ZFCP_LOG_AREA_FSF121+122+static int zfcp_reqlist_init(struct zfcp_adapter *adapter)123+{124+ int i;125+126+ adapter->req_list = kcalloc(REQUEST_LIST_SIZE, sizeof(struct list_head),127+ GFP_KERNEL);128+129+ if (!adapter->req_list)130+ return -ENOMEM;131+132+ for (i=0; i<REQUEST_LIST_SIZE; i++)133+ INIT_LIST_HEAD(&adapter->req_list[i]);134+135+ return 0;136+}137+138+static void zfcp_reqlist_free(struct zfcp_adapter *adapter)139+{140+ struct zfcp_fsf_req *request, *tmp;141+ unsigned int i;142+143+ for (i=0; i<REQUEST_LIST_SIZE; i++) {144+ if (list_empty(&adapter->req_list[i]))145+ continue;146+147+ list_for_each_entry_safe(request, tmp,148+ &adapter->req_list[i], list)149+ list_del(&request->list);150+ }151+152+ kfree(adapter->req_list);153+}154+155+void zfcp_reqlist_add(struct zfcp_adapter *adapter,156+ struct zfcp_fsf_req *fsf_req)157+{158+ unsigned int i;159+160+ i = fsf_req->req_id % REQUEST_LIST_SIZE;161+ list_add_tail(&fsf_req->list, &adapter->req_list[i]);162+}163+164+void zfcp_reqlist_remove(struct zfcp_adapter *adapter, unsigned long req_id)165+{166+ struct zfcp_fsf_req *request, *tmp;167+ unsigned int i, counter;168+ u64 dbg_tmp[2];169+170+ i = req_id % REQUEST_LIST_SIZE;171+ BUG_ON(list_empty(&adapter->req_list[i]));172+173+ counter = 0;174+ list_for_each_entry_safe(request, tmp, &adapter->req_list[i], list) {175+ if (request->req_id == req_id) {176+ dbg_tmp[0] = (u64) atomic_read(&adapter->reqs_active);177+ dbg_tmp[1] = (u64) counter;178+ debug_event(adapter->erp_dbf, 4, (void *) dbg_tmp, 16);179+ list_del(&request->list);180+ break;181+ }182+ counter++;183+ }184+}185+186+struct zfcp_fsf_req *zfcp_reqlist_ismember(struct zfcp_adapter *adapter,187+ unsigned long req_id)188+{189+ struct zfcp_fsf_req *request, *tmp;190+ unsigned int i;191+192+ i = req_id % REQUEST_LIST_SIZE;193+194+ list_for_each_entry_safe(request, tmp, &adapter->req_list[i], list)195+ if (request->req_id == req_id)196+ return request;197+198+ return NULL;199+}200+201+int zfcp_reqlist_isempty(struct zfcp_adapter *adapter)202+{203+ unsigned int i;204+205+ for (i=0; i<REQUEST_LIST_SIZE; i++)206+ if (!list_empty(&adapter->req_list[i]))207+ return 0;208+209+ return 1;210+}211+212+#undef ZFCP_LOG_AREA213+214/****************************************************************/215/************** Uncategorised Functions *************************/216/****************************************************************/···961 INIT_LIST_HEAD(&adapter->port_remove_lh);962963 /* initialize list of fsf requests */964+ spin_lock_init(&adapter->req_list_lock);965+ retval = zfcp_reqlist_init(adapter);966+ if (retval) {967+ ZFCP_LOG_INFO("request list initialization failed\n");968+ goto failed_low_mem_buffers;969+ }970971 /* initialize debug locks */972···1041 * !0 - struct zfcp_adapter data structure could not be removed1042 * (e.g. still used)1043 * locks: adapter list write lock is assumed to be held by caller001044 */1045void1046zfcp_adapter_dequeue(struct zfcp_adapter *adapter)···1054 zfcp_sysfs_adapter_remove_files(&adapter->ccw_device->dev);1055 dev_set_drvdata(&adapter->ccw_device->dev, NULL);1056 /* sanity check: no pending FSF requests */1057+ spin_lock_irqsave(&adapter->req_list_lock, flags);1058+ retval = zfcp_reqlist_isempty(adapter);1059+ spin_unlock_irqrestore(&adapter->req_list_lock, flags);1060+ if (!retval) {1061 ZFCP_LOG_NORMAL("bug: adapter %s (%p) still in use, "1062 "%i requests outstanding\n",1063 zfcp_get_busid_by_adapter(adapter), adapter,1064+ atomic_read(&adapter->reqs_active));1065 retval = -EBUSY;1066 goto out;1067 }···1087 zfcp_free_low_mem_buffers(adapter);1088 /* free memory of adapter data structure and queues */1089 zfcp_qdio_free_queues(adapter);1090+ zfcp_reqlist_free(adapter);1091 kfree(adapter->fc_stats);1092 kfree(adapter->stats_reset_data);1093 ZFCP_LOG_TRACE("freeing adapter structure\n");
···52/********************* GENERAL DEFINES *********************************/5354/* zfcp version number, it consists of major, minor, and patch-level number */55-#define ZFCP_VERSION "4.7.0"5657/**58 * zfcp_sg_to_address - determine kernel address from struct scatterlist···80#define REQUEST_LIST_SIZE 1288182/********************* SCSI SPECIFIC DEFINES *********************************/83-#define ZFCP_SCSI_ER_TIMEOUT (100*HZ)8485/********************* CIO/QDIO SPECIFIC DEFINES *****************************/86···886 struct list_head port_remove_lh; /* head of ports to be887 removed */888 u32 ports; /* number of remote ports */889- struct timer_list scsi_er_timer; /* SCSI err recovery watch */890- struct list_head fsf_req_list_head; /* head of FSF req list */891- spinlock_t fsf_req_list_lock; /* lock for ops on list of892- FSF requests */893- atomic_t fsf_reqs_active; /* # active FSF reqs */894 struct zfcp_qdio_queue request_queue; /* request queue */895 u32 fsf_req_seq_no; /* FSF cmnd seq number */896 wait_queue_head_t request_wq; /* can be used to wait for···986/* FSF request */987struct zfcp_fsf_req {988 struct list_head list; /* list of FSF requests */0989 struct zfcp_adapter *adapter; /* adapter request belongs to */990 u8 sbal_number; /* nr of SBALs free for use */991 u8 sbal_first; /* first SBAL for this request */
···52/********************* GENERAL DEFINES *********************************/5354/* zfcp version number, it consists of major, minor, and patch-level number */55+#define ZFCP_VERSION "4.8.0"5657/**58 * zfcp_sg_to_address - determine kernel address from struct scatterlist···80#define REQUEST_LIST_SIZE 1288182/********************* SCSI SPECIFIC DEFINES *********************************/83+#define ZFCP_SCSI_ER_TIMEOUT (10*HZ)8485/********************* CIO/QDIO SPECIFIC DEFINES *****************************/86···886 struct list_head port_remove_lh; /* head of ports to be887 removed */888 u32 ports; /* number of remote ports */889+ struct timer_list scsi_er_timer; /* SCSI err recovery watch */890+ atomic_t reqs_active; /* # active FSF reqs */891+ unsigned long req_no; /* unique FSF req number */892+ struct list_head *req_list; /* list of pending reqs */893+ spinlock_t req_list_lock; /* request list lock */894 struct zfcp_qdio_queue request_queue; /* request queue */895 u32 fsf_req_seq_no; /* FSF cmnd seq number */896 wait_queue_head_t request_wq; /* can be used to wait for···986/* FSF request */987struct zfcp_fsf_req {988 struct list_head list; /* list of FSF requests */989+ unsigned long req_id; /* unique request ID */990 struct zfcp_adapter *adapter; /* adapter request belongs to */991 u8 sbal_number; /* nr of SBALs free for use */992 u8 sbal_first; /* first SBAL for this request */
+73-137
drivers/s390/scsi/zfcp_erp.c
···64static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);65static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);66static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);67-static int zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);68-static int zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);69static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);70static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);71static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);···93static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *);94static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *);9596-static int zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *);97-static int zfcp_erp_action_dismiss_port(struct zfcp_port *);98-static int zfcp_erp_action_dismiss_unit(struct zfcp_unit *);99-static int zfcp_erp_action_dismiss(struct zfcp_erp_action *);100101static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,102 struct zfcp_port *, struct zfcp_unit *);···134 zfcp_erp_adapter_reopen(adapter, 0);135}136137-/*138- * function: zfcp_fsf_scsi_er_timeout_handler139 *140- * purpose: This function needs to be called whenever a SCSI error recovery141- * action (abort/reset) does not return.142- * Re-opening the adapter means that the command can be returned143- * by zfcp (it is guarranteed that it does not return via the144- * adapter anymore). The buffer can then be used again.145- * 146- * returns: sod all147 */148-void149-zfcp_fsf_scsi_er_timeout_handler(unsigned long data)150{151 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;0152153 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "154 "Restarting all operations on the adapter %s\n",155 zfcp_get_busid_by_adapter(adapter));156 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout");157- zfcp_erp_adapter_reopen(adapter, 0);158159- return;0000000000000160}161162/*···679 return retval;680}681682-/*683- * function: 684- *685- * purpose: disable I/O,686- * return any open requests and clean them up,687- * aim: no pending and incoming I/O688- *689- * returns:690 */691-static void692-zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)693{694 debug_text_event(adapter->erp_dbf, 6, "a_bl");695 zfcp_erp_modify_adapter_status(adapter,···690 clear_mask, ZFCP_CLEAR);691}692693-/*694- * function: 695- *696- * purpose: enable I/O697- *698- * returns:699 */700-static void701-zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)702{703 debug_text_event(adapter->erp_dbf, 6, "a_ubl");704 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);···845 struct zfcp_adapter *adapter = erp_action->adapter;846847 if (erp_action->fsf_req) {848- /* take lock to ensure that request is not being deleted meanwhile */849- spin_lock(&adapter->fsf_req_list_lock);850- /* check whether fsf req does still exist */851- list_for_each_entry(fsf_req, &adapter->fsf_req_list_head, list)852- if (fsf_req == erp_action->fsf_req)853- break;854- if (fsf_req && (fsf_req->erp_action == erp_action)) {855 /* fsf_req still exists */856 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");857 debug_event(adapter->erp_dbf, 3, &fsf_req,858 sizeof (unsigned long));859- /* dismiss fsf_req of timed out or dismissed erp_action */860 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |861 ZFCP_STATUS_ERP_TIMEDOUT)) {862 debug_text_event(adapter->erp_dbf, 3,···887 */888 erp_action->fsf_req = NULL;889 }890- spin_unlock(&adapter->fsf_req_list_lock);891 } else892 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");893894 return retval;895}896897-/*898- * purpose: generic handler for asynchronous events related to erp_action events899- * (normal completion, time-out, dismissing, retry after900- * low memory condition)901 *902- * note: deletion of timer is not required (e.g. in case of a time-out),903- * but a second try does no harm,904- * we leave it in here to allow for greater simplification905- *906- * returns: 0 - there was an action to handle907- * !0 - otherwise908 */909-static int910-zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,911- unsigned long set_mask)912{913- int retval;914 struct zfcp_adapter *adapter = erp_action->adapter;915916 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {···913 del_timer(&erp_action->timer);914 erp_action->status |= set_mask;915 zfcp_erp_action_ready(erp_action);916- retval = 0;917 } else {918 /* action is ready or gone - nothing to do */919 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");920 debug_event(adapter->erp_dbf, 3, &erp_action->action,921 sizeof (int));922- retval = 1;923 }924-925- return retval;926}927928-/*929- * purpose: generic handler for asynchronous events related to erp_action930- * events (normal completion, time-out, dismissing, retry after931- * low memory condition)932- *933- * note: deletion of timer is not required (e.g. in case of a time-out),934- * but a second try does no harm,935- * we leave it in here to allow for greater simplification936- *937- * returns: 0 - there was an action to handle938- * !0 - otherwise939 */940-int941-zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,942- unsigned long set_mask)943{944 struct zfcp_adapter *adapter = erp_action->adapter;945 unsigned long flags;946- int retval;947948 write_lock_irqsave(&adapter->erp_lock, flags);949- retval = zfcp_erp_async_handler_nolock(erp_action, set_mask);950 write_unlock_irqrestore(&adapter->erp_lock, flags);951-952- return retval;953}954955/*···969 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);970}971972-/*973- * purpose: is called for an erp_action which needs to be ended974- * though not being done,975- * this is usually required if an higher is generated,976- * action gets an appropriate flag and will be processed977- * accordingly978 *979- * locks: erp_lock held (thus we need to call another handler variant)000980 */981-static int982-zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)983{984 struct zfcp_adapter *adapter = erp_action->adapter;985···985 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));986987 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);988-989- return 0;990}991992int···2040 return retval;2041}20422043-/*2044- * function: zfcp_qdio_cleanup2045- *2046- * purpose: cleans up QDIO operation for the specified adapter2047- *2048- * returns: 0 - successful cleanup2049- * !0 - failed cleanup2050 */2051-int2052zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)2053{2054- int retval = ZFCP_ERP_SUCCEEDED;2055 int first_used;2056 int used_count;2057 struct zfcp_adapter *adapter = erp_action->adapter;···2054 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "2055 "queues on adapter %s\n",2056 zfcp_get_busid_by_adapter(adapter));2057- retval = ZFCP_ERP_FAILED;2058- goto out;2059 }20602061 /*2062 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that2063 * do_QDIO won't be called while qdio_shutdown is in progress.2064 */2065-2066 write_lock_irq(&adapter->request_queue.queue_lock);2067 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);2068 write_unlock_irq(&adapter->request_queue.queue_lock);···2092 adapter->request_queue.free_index = 0;2093 atomic_set(&adapter->request_queue.free_count, 0);2094 adapter->request_queue.distance_from_int = 0;2095- out:2096- return retval;2097}20982099static int···2214 "%s)\n", zfcp_get_busid_by_adapter(adapter));2215 ret = ZFCP_ERP_FAILED;2216 }2217- if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status)) {2218- ZFCP_LOG_INFO("error: exchange port data failed (adapter "002219 "%s\n", zfcp_get_busid_by_adapter(adapter));2220- ret = ZFCP_ERP_FAILED;2221- }22222223 return ret;2224}···2248 return retval;2249}22502251-/*2252- * function: zfcp_fsf_cleanup2253- *2254- * purpose: cleanup FSF operation for specified adapter2255- *2256- * returns: 0 - FSF operation successfully cleaned up2257- * !0 - failed to cleanup FSF operation for this adapter2258 */2259-static int2260zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)2261{2262- int retval = ZFCP_ERP_SUCCEEDED;2263 struct zfcp_adapter *adapter = erp_action->adapter;22642265 /*···2267 /* all ports and units are closed */2268 zfcp_erp_modify_adapter_status(adapter,2269 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);2270-2271- return retval;2272}22732274/*···3241}324232433244-static int3245-zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)3246{3247- int retval = 0;3248 struct zfcp_port *port;32493250 debug_text_event(adapter->erp_dbf, 5, "a_actab");···3251 else3252 list_for_each_entry(port, &adapter->port_list_head, list)3253 zfcp_erp_action_dismiss_port(port);3254-3255- return retval;3256}32573258-static int3259-zfcp_erp_action_dismiss_port(struct zfcp_port *port)3260{3261- int retval = 0;3262 struct zfcp_unit *unit;3263 struct zfcp_adapter *adapter = port->adapter;3264···3265 else3266 list_for_each_entry(unit, &port->unit_list_head, list)3267 zfcp_erp_action_dismiss_unit(unit);3268-3269- return retval;3270}32713272-static int3273-zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)3274{3275- int retval = 0;3276 struct zfcp_adapter *adapter = unit->port->adapter;32773278 debug_text_event(adapter->erp_dbf, 5, "u_actab");3279 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));3280 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))3281 zfcp_erp_action_dismiss(&unit->erp_action);3282-3283- return retval;3284}32853286static inline void
···64static int zfcp_erp_adapter_strategy(struct zfcp_erp_action *);65static int zfcp_erp_adapter_strategy_generic(struct zfcp_erp_action *, int);66static int zfcp_erp_adapter_strategy_close(struct zfcp_erp_action *);67+static void zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *);68+static void zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *);69static int zfcp_erp_adapter_strategy_open(struct zfcp_erp_action *);70static int zfcp_erp_adapter_strategy_open_qdio(struct zfcp_erp_action *);71static int zfcp_erp_adapter_strategy_open_fsf(struct zfcp_erp_action *);···93static int zfcp_erp_unit_strategy_close(struct zfcp_erp_action *);94static int zfcp_erp_unit_strategy_open(struct zfcp_erp_action *);9596+static void zfcp_erp_action_dismiss_port(struct zfcp_port *);97+static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *);98+static void zfcp_erp_action_dismiss(struct zfcp_erp_action *);099100static int zfcp_erp_action_enqueue(int, struct zfcp_adapter *,101 struct zfcp_port *, struct zfcp_unit *);···135 zfcp_erp_adapter_reopen(adapter, 0);136}137138+/**139+ * zfcp_fsf_scsi_er_timeout_handler - timeout handler for scsi eh tasks140 *141+ * This function needs to be called whenever a SCSI error recovery142+ * action (abort/reset) does not return. Re-opening the adapter means143+ * that the abort/reset command can be returned by zfcp. It won't complete144+ * via the adapter anymore (because qdio queues are closed). If ERP is145+ * already running on this adapter it will be stopped.00146 */147+void zfcp_fsf_scsi_er_timeout_handler(unsigned long data)0148{149 struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;150+ unsigned long flags;151152 ZFCP_LOG_NORMAL("warning: SCSI error recovery timed out. "153 "Restarting all operations on the adapter %s\n",154 zfcp_get_busid_by_adapter(adapter));155 debug_text_event(adapter->erp_dbf, 1, "eh_lmem_tout");0156157+ write_lock_irqsave(&adapter->erp_lock, flags);158+ if (atomic_test_mask(ZFCP_STATUS_ADAPTER_ERP_PENDING,159+ &adapter->status)) {160+ zfcp_erp_modify_adapter_status(adapter,161+ ZFCP_STATUS_COMMON_UNBLOCKED|ZFCP_STATUS_COMMON_OPEN,162+ ZFCP_CLEAR);163+ zfcp_erp_action_dismiss_adapter(adapter);164+ write_unlock_irqrestore(&adapter->erp_lock, flags);165+ /* dismiss all pending requests including requests for ERP */166+ zfcp_fsf_req_dismiss_all(adapter);167+ adapter->fsf_req_seq_no = 0;168+ } else169+ write_unlock_irqrestore(&adapter->erp_lock, flags);170+ zfcp_erp_adapter_reopen(adapter, 0);171}172173/*···670 return retval;671}672673+/**674+ * zfcp_erp_adapter_block - mark adapter as blocked, block scsi requests000000675 */676+static void zfcp_erp_adapter_block(struct zfcp_adapter *adapter, int clear_mask)0677{678 debug_text_event(adapter->erp_dbf, 6, "a_bl");679 zfcp_erp_modify_adapter_status(adapter,···688 clear_mask, ZFCP_CLEAR);689}690691+/**692+ * zfcp_erp_adapter_unblock - mark adapter as unblocked, allow scsi requests0000693 */694+static void zfcp_erp_adapter_unblock(struct zfcp_adapter *adapter)0695{696 debug_text_event(adapter->erp_dbf, 6, "a_ubl");697 atomic_set_mask(ZFCP_STATUS_COMMON_UNBLOCKED, &adapter->status);···848 struct zfcp_adapter *adapter = erp_action->adapter;849850 if (erp_action->fsf_req) {851+ /* take lock to ensure that request is not deleted meanwhile */852+ spin_lock(&adapter->req_list_lock);853+ if ((!zfcp_reqlist_ismember(adapter,854+ erp_action->fsf_req->req_id)) &&855+ (fsf_req->erp_action == erp_action)) {00856 /* fsf_req still exists */857 debug_text_event(adapter->erp_dbf, 3, "a_ca_req");858 debug_event(adapter->erp_dbf, 3, &fsf_req,859 sizeof (unsigned long));860+ /* dismiss fsf_req of timed out/dismissed erp_action */861 if (erp_action->status & (ZFCP_STATUS_ERP_DISMISSED |862 ZFCP_STATUS_ERP_TIMEDOUT)) {863 debug_text_event(adapter->erp_dbf, 3,···892 */893 erp_action->fsf_req = NULL;894 }895+ spin_unlock(&adapter->req_list_lock);896 } else897 debug_text_event(adapter->erp_dbf, 3, "a_ca_noreq");898899 return retval;900}901902+/**903+ * zfcp_erp_async_handler_nolock - complete erp_action00904 *905+ * Used for normal completion, time-out, dismissal and failure after906+ * low memory condition.0000907 */908+static void zfcp_erp_async_handler_nolock(struct zfcp_erp_action *erp_action,909+ unsigned long set_mask)0910{0911 struct zfcp_adapter *adapter = erp_action->adapter;912913 if (zfcp_erp_action_exists(erp_action) == ZFCP_ERP_ACTION_RUNNING) {···926 del_timer(&erp_action->timer);927 erp_action->status |= set_mask;928 zfcp_erp_action_ready(erp_action);0929 } else {930 /* action is ready or gone - nothing to do */931 debug_text_event(adapter->erp_dbf, 3, "a_asyh_gone");932 debug_event(adapter->erp_dbf, 3, &erp_action->action,933 sizeof (int));0934 }00935}936937+/**938+ * zfcp_erp_async_handler - wrapper for erp_async_handler_nolock w/ locking000000000939 */940+void zfcp_erp_async_handler(struct zfcp_erp_action *erp_action,941+ unsigned long set_mask)0942{943 struct zfcp_adapter *adapter = erp_action->adapter;944 unsigned long flags;0945946 write_lock_irqsave(&adapter->erp_lock, flags);947+ zfcp_erp_async_handler_nolock(erp_action, set_mask);948 write_unlock_irqrestore(&adapter->erp_lock, flags);00949}950951/*···999 zfcp_erp_async_handler(erp_action, ZFCP_STATUS_ERP_TIMEDOUT);1000}10011002+/**1003+ * zfcp_erp_action_dismiss - dismiss an erp_action00001004 *1005+ * adapter->erp_lock must be held1006+ * 1007+ * Dismissal of an erp_action is usually required if an erp_action of1008+ * higher priority is generated.1009 */1010+static void zfcp_erp_action_dismiss(struct zfcp_erp_action *erp_action)01011{1012 struct zfcp_adapter *adapter = erp_action->adapter;1013···1017 debug_event(adapter->erp_dbf, 2, &erp_action->action, sizeof (int));10181019 zfcp_erp_async_handler_nolock(erp_action, ZFCP_STATUS_ERP_DISMISSED);001020}10211022int···2074 return retval;2075}20762077+/**2078+ * zfcp_erp_adapter_strategy_close_qdio - close qdio queues for an adapter000002079 */2080+static void2081zfcp_erp_adapter_strategy_close_qdio(struct zfcp_erp_action *erp_action)2082{02083 int first_used;2084 int used_count;2085 struct zfcp_adapter *adapter = erp_action->adapter;···2094 ZFCP_LOG_DEBUG("error: attempt to shut down inactive QDIO "2095 "queues on adapter %s\n",2096 zfcp_get_busid_by_adapter(adapter));2097+ return;02098 }20992100 /*2101 * Get queue_lock and clear QDIOUP flag. Thus it's guaranteed that2102 * do_QDIO won't be called while qdio_shutdown is in progress.2103 */02104 write_lock_irq(&adapter->request_queue.queue_lock);2105 atomic_clear_mask(ZFCP_STATUS_ADAPTER_QDIOUP, &adapter->status);2106 write_unlock_irq(&adapter->request_queue.queue_lock);···2134 adapter->request_queue.free_index = 0;2135 atomic_set(&adapter->request_queue.free_count, 0);2136 adapter->request_queue.distance_from_int = 0;002137}21382139static int···2258 "%s)\n", zfcp_get_busid_by_adapter(adapter));2259 ret = ZFCP_ERP_FAILED;2260 }2261+2262+ /* don't treat as error for the sake of compatibility */2263+ if (!atomic_test_mask(ZFCP_STATUS_ADAPTER_XPORT_OK, &adapter->status))2264+ ZFCP_LOG_INFO("warning: exchange port data failed (adapter "2265 "%s\n", zfcp_get_busid_by_adapter(adapter));0022662267 return ret;2268}···2292 return retval;2293}22942295+/**2296+ * zfcp_erp_adapter_strategy_close_fsf - stop FSF operations for an adapter000002297 */2298+static void2299zfcp_erp_adapter_strategy_close_fsf(struct zfcp_erp_action *erp_action)2300{02301 struct zfcp_adapter *adapter = erp_action->adapter;23022303 /*···2317 /* all ports and units are closed */2318 zfcp_erp_modify_adapter_status(adapter,2319 ZFCP_STATUS_COMMON_OPEN, ZFCP_CLEAR);002320}23212322/*···3293}329432953296+void zfcp_erp_action_dismiss_adapter(struct zfcp_adapter *adapter)03297{03298 struct zfcp_port *port;32993300 debug_text_event(adapter->erp_dbf, 5, "a_actab");···3305 else3306 list_for_each_entry(port, &adapter->port_list_head, list)3307 zfcp_erp_action_dismiss_port(port);003308}33093310+static void zfcp_erp_action_dismiss_port(struct zfcp_port *port)03311{03312 struct zfcp_unit *unit;3313 struct zfcp_adapter *adapter = port->adapter;3314···3323 else3324 list_for_each_entry(unit, &port->unit_list_head, list)3325 zfcp_erp_action_dismiss_unit(unit);003326}33273328+static void zfcp_erp_action_dismiss_unit(struct zfcp_unit *unit)03329{03330 struct zfcp_adapter *adapter = unit->port->adapter;33313332 debug_text_event(adapter->erp_dbf, 5, "u_actab");3333 debug_event(adapter->erp_dbf, 5, &unit->fcp_lun, sizeof (fcp_lun_t));3334 if (atomic_test_mask(ZFCP_STATUS_COMMON_ERP_INUSE, &unit->status))3335 zfcp_erp_action_dismiss(&unit->erp_action);003336}33373338static inline void
+7-2
drivers/s390/scsi/zfcp_ext.h
···63extern void zfcp_qdio_free_queues(struct zfcp_adapter *);64extern int zfcp_qdio_determine_pci(struct zfcp_qdio_queue *,65 struct zfcp_fsf_req *);66-extern int zfcp_qdio_reqid_check(struct zfcp_adapter *, void *);6768extern volatile struct qdio_buffer_element *zfcp_qdio_sbale_req69 (struct zfcp_fsf_req *, int, int);···139extern int zfcp_erp_adapter_reopen(struct zfcp_adapter *, int);140extern int zfcp_erp_adapter_shutdown(struct zfcp_adapter *, int);141extern void zfcp_erp_adapter_failed(struct zfcp_adapter *);0142143extern void zfcp_erp_modify_port_status(struct zfcp_port *, u32, int);144extern int zfcp_erp_port_reopen(struct zfcp_port *, int);···156extern int zfcp_erp_thread_setup(struct zfcp_adapter *);157extern int zfcp_erp_thread_kill(struct zfcp_adapter *);158extern int zfcp_erp_wait(struct zfcp_adapter *);159-extern int zfcp_erp_async_handler(struct zfcp_erp_action *, unsigned long);160161extern int zfcp_test_link(struct zfcp_port *);162···190 struct zfcp_fsf_req *);191extern void zfcp_scsi_dbf_event_devreset(const char *, u8, struct zfcp_unit *,192 struct scsi_cmnd *);00000193194#endif /* ZFCP_EXT_H */
···4344#include "iscsi_tcp.h"4546-#define ISCSI_TCP_VERSION "1.0-595"47-48MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, "49 "Alex Aizman <itn780@yahoo.com>");50MODULE_DESCRIPTION("iSCSI/TCP data-path");51MODULE_LICENSE("GPL");52-MODULE_VERSION(ISCSI_TCP_VERSION);53/* #define DEBUG_TCP */54#define DEBUG_ASSERT55···182 * must be called with session lock183 */184static void185-__iscsi_ctask_cleanup(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)186{187 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;0188 struct scsi_cmnd *sc;0000000189190 sc = ctask->sc;191 if (unlikely(!sc))···379 spin_unlock(&session->lock);380 return 0;381 }0382 rc = __kfifo_get(tcp_ctask->r2tpool.queue, (void*)&r2t, sizeof(void*));383 BUG_ON(!rc);384···405 tcp_ctask->exp_r2tsn = r2tsn + 1;406 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;407 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));408- __kfifo_put(conn->xmitqueue, (void*)&ctask, sizeof(void*));409410 scsi_queue_work(session->host, &conn->xmitwork);411 conn->r2t_pdus_cnt++;···483 case ISCSI_OP_SCSI_DATA_IN:484 tcp_conn->in.ctask = session->cmds[itt];485 rc = iscsi_data_rsp(conn, tcp_conn->in.ctask);00486 /* fall through */487 case ISCSI_OP_SCSI_CMD_RSP:488 tcp_conn->in.ctask = session->cmds[itt];···492 goto copy_hdr;493494 spin_lock(&session->lock);495- __iscsi_ctask_cleanup(conn, tcp_conn->in.ctask);496 rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);497 spin_unlock(&session->lock);498 break;···508 break;509 case ISCSI_OP_LOGIN_RSP:510 case ISCSI_OP_TEXT_RSP:511- case ISCSI_OP_LOGOUT_RSP:512- case ISCSI_OP_NOOP_IN:513 case ISCSI_OP_REJECT:514 case ISCSI_OP_ASYNC_EVENT:000000000000000515 if (tcp_conn->in.datalen)516 goto copy_hdr;517 /* fall through */00518 case ISCSI_OP_SCSI_TMFUNC_RSP:519 rc = iscsi_complete_pdu(conn, hdr, NULL, 0);520 break;···546 * skbs to complete the command then we have to copy the header547 * for later use548 */549- if (tcp_conn->in.zero_copy_hdr && tcp_conn->in.copy <550 (tcp_conn->in.datalen + tcp_conn->in.padding +551 (conn->datadgst_en ? 4 : 0))) {552 debug_tcp("Copying header for later use. in.copy %d in.datalen"···637 * byte counters.638 **/639static inline int640-iscsi_tcp_copy(struct iscsi_tcp_conn *tcp_conn)641{642- void *buf = tcp_conn->data;643 int buf_size = tcp_conn->in.datalen;644 int buf_left = buf_size - tcp_conn->data_copied;645 int size = min(tcp_conn->in.copy, buf_left);···650 BUG_ON(size <= 0);651652 rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,653- (char*)buf + tcp_conn->data_copied, size);654 BUG_ON(rc);655656 tcp_conn->in.offset += size;···768done:769 /* check for non-exceptional status */770 if (tcp_conn->in.hdr->flags & ISCSI_FLAG_DATA_STATUS) {771- debug_scsi("done [sc %lx res %d itt 0x%x]\n",772- (long)sc, sc->result, ctask->itt);0773 spin_lock(&conn->session->lock);774- __iscsi_ctask_cleanup(conn, ctask);775 __iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);776 spin_unlock(&conn->session->lock);777 }···793 break;794 case ISCSI_OP_SCSI_CMD_RSP:795 spin_lock(&conn->session->lock);796- __iscsi_ctask_cleanup(conn, tcp_conn->in.ctask);797 spin_unlock(&conn->session->lock);798 case ISCSI_OP_TEXT_RSP:799 case ISCSI_OP_LOGIN_RSP:800- case ISCSI_OP_NOOP_IN:801 case ISCSI_OP_ASYNC_EVENT:802 case ISCSI_OP_REJECT:803 /*804 * Collect data segment to the connection's data805 * placeholder806 */807- if (iscsi_tcp_copy(tcp_conn)) {808 rc = -EAGAIN;809 goto exit;810 }811812- rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, tcp_conn->data,813 tcp_conn->in.datalen);814 if (!rc && conn->datadgst_en && opcode != ISCSI_OP_LOGIN_RSP)815- iscsi_recv_digest_update(tcp_conn, tcp_conn->data,816 tcp_conn->in.datalen);817 break;818 default:···866 if (rc == -EAGAIN)867 goto nomore;868 else {869- iscsi_conn_failure(conn, rc);870 return 0;871 }872 }···920 if (rc) {921 if (rc == -EAGAIN)922 goto again;923- iscsi_conn_failure(conn, rc);924 return 0;925 }926 tcp_conn->in.copy -= tcp_conn->in.padding;···1051}10521053static void1054-iscsi_conn_restore_callbacks(struct iscsi_conn *conn)1055{1056- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;1057 struct sock *sk = tcp_conn->sock->sk;10581059 /* restore socket callbacks, see also: iscsi_conn_set_callbacks() */···1330 ctask->imm_count -1331 ctask->unsol_count;13321333- debug_scsi("cmd [itt %x total %d imm %d imm_data %d "1334 "r2t_data %d]\n",1335 ctask->itt, ctask->total_length, ctask->imm_count,1336 ctask->unsol_count, tcp_ctask->r2t_data_count);···1658 }1659solicit_again:1660 /*1661- * send Data-Out whitnin this R2T sequence.1662 */1663 if (!r2t->data_count)1664 goto data_out_done;···1753 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1754 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;1755 struct iscsi_data_task *dtask = tcp_ctask->dtask;1756- int sent, rc;17571758 tcp_ctask->xmstate &= ~XMSTATE_W_PAD;1759 iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,···1922 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;1923 /* initial operational parameters */1924 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);1925- tcp_conn->data_size = DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH;1926-1927- /* allocate initial PDU receive place holder */1928- if (tcp_conn->data_size <= PAGE_SIZE)1929- tcp_conn->data = kmalloc(tcp_conn->data_size, GFP_KERNEL);1930- else1931- tcp_conn->data = (void*)__get_free_pages(GFP_KERNEL,1932- get_order(tcp_conn->data_size));1933- if (!tcp_conn->data)1934- goto max_recv_dlenght_alloc_fail;19351936 return cls_conn;19371938-max_recv_dlenght_alloc_fail:1939- kfree(tcp_conn);1940tcp_conn_alloc_fail:1941 iscsi_conn_teardown(cls_conn);1942 return NULL;000000000000000001943}19441945static void···1957 if (conn->hdrdgst_en || conn->datadgst_en)1958 digest = 1;195901960 iscsi_conn_teardown(cls_conn);19611962 /* now free tcp_conn */···1972 crypto_free_tfm(tcp_conn->data_rx_tfm);1973 }19741975- /* free conn->data, size = MaxRecvDataSegmentLength */1976- if (tcp_conn->data_size <= PAGE_SIZE)1977- kfree(tcp_conn->data);1978- else1979- free_pages((unsigned long)tcp_conn->data,1980- get_order(tcp_conn->data_size));1981 kfree(tcp_conn);0000000001982}19831984static int···2032 return 0;2033}20342035-static void2036-iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)2037-{2038- struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;2039- struct iscsi_r2t_info *r2t;2040-2041- /* flush ctask's r2t queues */2042- while (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*)))2043- __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,2044- sizeof(void*));2045-2046- __iscsi_ctask_cleanup(conn, ctask);2047-}2048-2049-static void2050-iscsi_tcp_suspend_conn_rx(struct iscsi_conn *conn)2051-{2052- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;2053- struct sock *sk;2054-2055- if (!tcp_conn->sock)2056- return;2057-2058- sk = tcp_conn->sock->sk;2059- write_lock_bh(&sk->sk_callback_lock);2060- set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);2061- write_unlock_bh(&sk->sk_callback_lock);2062-}2063-2064-static void2065-iscsi_tcp_terminate_conn(struct iscsi_conn *conn)2066-{2067- struct iscsi_tcp_conn *tcp_conn = conn->dd_data;2068-2069- if (!tcp_conn->sock)2070- return;2071-2072- sock_hold(tcp_conn->sock->sk);2073- iscsi_conn_restore_callbacks(conn);2074- sock_put(tcp_conn->sock->sk);2075-2076- sock_release(tcp_conn->sock);2077- tcp_conn->sock = NULL;2078- conn->recv_lock = NULL;2079-}2080-2081/* called with host lock */2082static void2083iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask,···2042 iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr,2043 sizeof(struct iscsi_hdr));2044 tcp_mtask->xmstate = XMSTATE_IMM_HDR;020452046 if (mtask->data_count)2047 iscsi_buf_init_iov(&tcp_mtask->sendbuf, (char*)mtask->data,···2124 int value;21252126 switch(param) {2127- case ISCSI_PARAM_MAX_RECV_DLENGTH: {2128- char *saveptr = tcp_conn->data;2129- gfp_t flags = GFP_KERNEL;2130-2131- sscanf(buf, "%d", &value);2132- if (tcp_conn->data_size >= value) {2133- iscsi_set_param(cls_conn, param, buf, buflen);2134- break;2135- }2136-2137- spin_lock_bh(&session->lock);2138- if (conn->stop_stage == STOP_CONN_RECOVER)2139- flags = GFP_ATOMIC;2140- spin_unlock_bh(&session->lock);2141-2142- if (value <= PAGE_SIZE)2143- tcp_conn->data = kmalloc(value, flags);2144- else2145- tcp_conn->data = (void*)__get_free_pages(flags,2146- get_order(value));2147- if (tcp_conn->data == NULL) {2148- tcp_conn->data = saveptr;2149- return -ENOMEM;2150- }2151- if (tcp_conn->data_size <= PAGE_SIZE)2152- kfree(saveptr);2153- else2154- free_pages((unsigned long)saveptr,2155- get_order(tcp_conn->data_size));2156- iscsi_set_param(cls_conn, param, buf, buflen);2157- tcp_conn->data_size = value;2158- break;2159- }2160 case ISCSI_PARAM_HDRDGST_EN:2161 iscsi_set_param(cls_conn, param, buf, buflen);2162 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);···2314}23152316static struct scsi_host_template iscsi_sht = {2317- .name = "iSCSI Initiator over TCP/IP, v"2318- ISCSI_TCP_VERSION,2319 .queuecommand = iscsi_queuecommand,2320 .change_queue_depth = iscsi_change_queue_depth,2321 .can_queue = ISCSI_XMIT_CMDS_MAX - 1,···2366 .get_conn_param = iscsi_tcp_conn_get_param,2367 .get_session_param = iscsi_session_get_param,2368 .start_conn = iscsi_conn_start,2369- .stop_conn = iscsi_conn_stop,2370- /* these are called as part of conn recovery */2371- .suspend_conn_recv = iscsi_tcp_suspend_conn_rx,2372- .terminate_conn = iscsi_tcp_terminate_conn,2373 /* IO */2374 .send_pdu = iscsi_conn_send_pdu,2375 .get_stats = iscsi_conn_get_stats,
···4344#include "iscsi_tcp.h"450046MODULE_AUTHOR("Dmitry Yusupov <dmitry_yus@yahoo.com>, "47 "Alex Aizman <itn780@yahoo.com>");48MODULE_DESCRIPTION("iSCSI/TCP data-path");49MODULE_LICENSE("GPL");050/* #define DEBUG_TCP */51#define DEBUG_ASSERT52···185 * must be called with session lock186 */187static void188+iscsi_tcp_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask)189{190 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;191+ struct iscsi_r2t_info *r2t;192 struct scsi_cmnd *sc;193+194+ /* flush ctask's r2t queues */195+ while (__kfifo_get(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*))) {196+ __kfifo_put(tcp_ctask->r2tpool.queue, (void*)&r2t,197+ sizeof(void*));198+ debug_scsi("iscsi_tcp_cleanup_ctask pending r2t dropped\n");199+ }200201 sc = ctask->sc;202 if (unlikely(!sc))···374 spin_unlock(&session->lock);375 return 0;376 }377+378 rc = __kfifo_get(tcp_ctask->r2tpool.queue, (void*)&r2t, sizeof(void*));379 BUG_ON(!rc);380···399 tcp_ctask->exp_r2tsn = r2tsn + 1;400 tcp_ctask->xmstate |= XMSTATE_SOL_HDR;401 __kfifo_put(tcp_ctask->r2tqueue, (void*)&r2t, sizeof(void*));402+ list_move_tail(&ctask->running, &conn->xmitqueue);403404 scsi_queue_work(session->host, &conn->xmitwork);405 conn->r2t_pdus_cnt++;···477 case ISCSI_OP_SCSI_DATA_IN:478 tcp_conn->in.ctask = session->cmds[itt];479 rc = iscsi_data_rsp(conn, tcp_conn->in.ctask);480+ if (rc)481+ return rc;482 /* fall through */483 case ISCSI_OP_SCSI_CMD_RSP:484 tcp_conn->in.ctask = session->cmds[itt];···484 goto copy_hdr;485486 spin_lock(&session->lock);487+ iscsi_tcp_cleanup_ctask(conn, tcp_conn->in.ctask);488 rc = __iscsi_complete_pdu(conn, hdr, NULL, 0);489 spin_unlock(&session->lock);490 break;···500 break;501 case ISCSI_OP_LOGIN_RSP:502 case ISCSI_OP_TEXT_RSP:00503 case ISCSI_OP_REJECT:504 case ISCSI_OP_ASYNC_EVENT:505+ /*506+ * It is possible that we could get a PDU with a buffer larger507+ * than 8K, but there are no targets that currently do this.508+ * For now we fail until we find a vendor that needs it509+ */510+ if (DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH <511+ tcp_conn->in.datalen) {512+ printk(KERN_ERR "iscsi_tcp: received buffer of len %u "513+ "but conn buffer is only %u (opcode %0x)\n",514+ tcp_conn->in.datalen,515+ DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, opcode);516+ rc = ISCSI_ERR_PROTO;517+ break;518+ }519+520 if (tcp_conn->in.datalen)521 goto copy_hdr;522 /* fall through */523+ case ISCSI_OP_LOGOUT_RSP:524+ case ISCSI_OP_NOOP_IN:525 case ISCSI_OP_SCSI_TMFUNC_RSP:526 rc = iscsi_complete_pdu(conn, hdr, NULL, 0);527 break;···523 * skbs to complete the command then we have to copy the header524 * for later use525 */526+ if (tcp_conn->in.zero_copy_hdr && tcp_conn->in.copy <=527 (tcp_conn->in.datalen + tcp_conn->in.padding +528 (conn->datadgst_en ? 4 : 0))) {529 debug_tcp("Copying header for later use. in.copy %d in.datalen"···614 * byte counters.615 **/616static inline int617+iscsi_tcp_copy(struct iscsi_conn *conn)618{619+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;620 int buf_size = tcp_conn->in.datalen;621 int buf_left = buf_size - tcp_conn->data_copied;622 int size = min(tcp_conn->in.copy, buf_left);···627 BUG_ON(size <= 0);628629 rc = skb_copy_bits(tcp_conn->in.skb, tcp_conn->in.offset,630+ (char*)conn->data + tcp_conn->data_copied, size);631 BUG_ON(rc);632633 tcp_conn->in.offset += size;···745done:746 /* check for non-exceptional status */747 if (tcp_conn->in.hdr->flags & ISCSI_FLAG_DATA_STATUS) {748+ debug_scsi("done [sc %lx res %d itt 0x%x flags 0x%x]\n",749+ (long)sc, sc->result, ctask->itt,750+ tcp_conn->in.hdr->flags);751 spin_lock(&conn->session->lock);752+ iscsi_tcp_cleanup_ctask(conn, ctask);753 __iscsi_complete_pdu(conn, tcp_conn->in.hdr, NULL, 0);754 spin_unlock(&conn->session->lock);755 }···769 break;770 case ISCSI_OP_SCSI_CMD_RSP:771 spin_lock(&conn->session->lock);772+ iscsi_tcp_cleanup_ctask(conn, tcp_conn->in.ctask);773 spin_unlock(&conn->session->lock);774 case ISCSI_OP_TEXT_RSP:775 case ISCSI_OP_LOGIN_RSP:0776 case ISCSI_OP_ASYNC_EVENT:777 case ISCSI_OP_REJECT:778 /*779 * Collect data segment to the connection's data780 * placeholder781 */782+ if (iscsi_tcp_copy(conn)) {783 rc = -EAGAIN;784 goto exit;785 }786787+ rc = iscsi_complete_pdu(conn, tcp_conn->in.hdr, conn->data,788 tcp_conn->in.datalen);789 if (!rc && conn->datadgst_en && opcode != ISCSI_OP_LOGIN_RSP)790+ iscsi_recv_digest_update(tcp_conn, conn->data,791 tcp_conn->in.datalen);792 break;793 default:···843 if (rc == -EAGAIN)844 goto nomore;845 else {846+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);847 return 0;848 }849 }···897 if (rc) {898 if (rc == -EAGAIN)899 goto again;900+ iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);901 return 0;902 }903 tcp_conn->in.copy -= tcp_conn->in.padding;···1028}10291030static void1031+iscsi_conn_restore_callbacks(struct iscsi_tcp_conn *tcp_conn)1032{01033 struct sock *sk = tcp_conn->sock->sk;10341035 /* restore socket callbacks, see also: iscsi_conn_set_callbacks() */···1308 ctask->imm_count -1309 ctask->unsol_count;13101311+ debug_scsi("cmd [itt 0x%x total %d imm %d imm_data %d "1312 "r2t_data %d]\n",1313 ctask->itt, ctask->total_length, ctask->imm_count,1314 ctask->unsol_count, tcp_ctask->r2t_data_count);···1636 }1637solicit_again:1638 /*1639+ * send Data-Out within this R2T sequence.1640 */1641 if (!r2t->data_count)1642 goto data_out_done;···1731 struct iscsi_tcp_cmd_task *tcp_ctask = ctask->dd_data;1732 struct iscsi_tcp_conn *tcp_conn = conn->dd_data;1733 struct iscsi_data_task *dtask = tcp_ctask->dtask;1734+ int sent = 0, rc;17351736 tcp_ctask->xmstate &= ~XMSTATE_W_PAD;1737 iscsi_buf_init_iov(&tcp_ctask->sendbuf, (char*)&tcp_ctask->pad,···1900 tcp_conn->in_progress = IN_PROGRESS_WAIT_HEADER;1901 /* initial operational parameters */1902 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);000000000019031904 return cls_conn;1905001906tcp_conn_alloc_fail:1907 iscsi_conn_teardown(cls_conn);1908 return NULL;1909+}1910+1911+static void1912+iscsi_tcp_release_conn(struct iscsi_conn *conn)1913+{1914+ struct iscsi_tcp_conn *tcp_conn = conn->dd_data;1915+1916+ if (!tcp_conn->sock)1917+ return;1918+1919+ sock_hold(tcp_conn->sock->sk);1920+ iscsi_conn_restore_callbacks(tcp_conn);1921+ sock_put(tcp_conn->sock->sk);1922+1923+ sock_release(tcp_conn->sock);1924+ tcp_conn->sock = NULL;1925+ conn->recv_lock = NULL;1926}19271928static void···1930 if (conn->hdrdgst_en || conn->datadgst_en)1931 digest = 1;19321933+ iscsi_tcp_release_conn(conn);1934 iscsi_conn_teardown(cls_conn);19351936 /* now free tcp_conn */···1944 crypto_free_tfm(tcp_conn->data_rx_tfm);1945 }19460000001947 kfree(tcp_conn);1948+}1949+1950+static void1951+iscsi_tcp_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)1952+{1953+ struct iscsi_conn *conn = cls_conn->dd_data;1954+1955+ iscsi_conn_stop(cls_conn, flag);1956+ iscsi_tcp_release_conn(conn);1957}19581959static int···2001 return 0;2002}200300000000000000000000000000000000000000000000002004/* called with host lock */2005static void2006iscsi_tcp_mgmt_init(struct iscsi_conn *conn, struct iscsi_mgmt_task *mtask,···2057 iscsi_buf_init_iov(&tcp_mtask->headbuf, (char*)mtask->hdr,2058 sizeof(struct iscsi_hdr));2059 tcp_mtask->xmstate = XMSTATE_IMM_HDR;2060+ tcp_mtask->sent = 0;20612062 if (mtask->data_count)2063 iscsi_buf_init_iov(&tcp_mtask->sendbuf, (char*)mtask->data,···2138 int value;21392140 switch(param) {0000000000000000000000000000000002141 case ISCSI_PARAM_HDRDGST_EN:2142 iscsi_set_param(cls_conn, param, buf, buflen);2143 tcp_conn->hdr_size = sizeof(struct iscsi_hdr);···2361}23622363static struct scsi_host_template iscsi_sht = {2364+ .name = "iSCSI Initiator over TCP/IP",02365 .queuecommand = iscsi_queuecommand,2366 .change_queue_depth = iscsi_change_queue_depth,2367 .can_queue = ISCSI_XMIT_CMDS_MAX - 1,···2414 .get_conn_param = iscsi_tcp_conn_get_param,2415 .get_session_param = iscsi_session_get_param,2416 .start_conn = iscsi_conn_start,2417+ .stop_conn = iscsi_tcp_conn_stop,0002418 /* IO */2419 .send_pdu = iscsi_conn_send_pdu,2420 .get_stats = iscsi_conn_get_stats,
-2
drivers/scsi/iscsi_tcp.h
···78 char hdrext[4*sizeof(__u16) +79 sizeof(__u32)];80 int data_copied;81- char *data; /* data placeholder */82- int data_size; /* actual recv_dlength */83 int stop_stage; /* conn_stop() flag: *84 * stop to recover, *85 * stop to terminate */
···78 char hdrext[4*sizeof(__u16) +79 sizeof(__u32)];80 int data_copied;0081 int stop_stage; /* conn_stop() flag: *82 * stop to recover, *83 * stop to terminate */
+116-98
drivers/scsi/libiscsi.c
···189{190 struct scsi_cmnd *sc = ctask->sc;1910192 ctask->sc = NULL;193 list_del_init(&ctask->running);194 __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*));···276 return rc;277}2780000000000000000000279/**280 * __iscsi_complete_pdu - complete pdu281 * @conn: iscsi conn···360361 switch(opcode) {362 case ISCSI_OP_LOGOUT_RSP:0000363 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;364 /* fall through */365 case ISCSI_OP_LOGIN_RSP:···372 * login related PDU's exp_statsn is handled in373 * userspace374 */375- rc = iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen);0376 list_del(&mtask->running);377 if (conn->login_mtask != mtask)378 __kfifo_put(session->mgmtpool.queue,···385 break;386 }387388- conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;389- conn->tmfrsp_pdus_cnt++;390- if (conn->tmabort_state == TMABORT_INITIAL) {391- conn->tmabort_state =392- ((struct iscsi_tm_rsp *)hdr)->393- response == ISCSI_TMF_RSP_COMPLETE ?394- TMABORT_SUCCESS:TMABORT_FAILED;395- /* unblock eh_abort() */396- wake_up(&conn->ehwait);397- }398 break;399 case ISCSI_OP_NOOP_IN:400- if (hdr->ttt != ISCSI_RESERVED_TAG) {401 rc = ISCSI_ERR_PROTO;402 break;403 }404 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;405406- rc = iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen);0407 list_del(&mtask->running);408 if (conn->login_mtask != mtask)409 __kfifo_put(session->mgmtpool.queue,···408 } else if (itt == ISCSI_RESERVED_TAG) {409 switch(opcode) {410 case ISCSI_OP_NOOP_IN:411- if (!datalen) {412- rc = iscsi_check_assign_cmdsn(session,413- (struct iscsi_nopin*)hdr);414- if (!rc && hdr->ttt != ISCSI_RESERVED_TAG)415- rc = iscsi_recv_pdu(conn->cls_conn,416- hdr, NULL, 0);417- } else418 rc = ISCSI_ERR_PROTO;0000000000000419 break;420 case ISCSI_OP_REJECT:421 /* we need sth like iscsi_reject_rsp()*/···592 }593594 /* process command queue */595- while (__kfifo_get(conn->xmitqueue, (void*)&conn->ctask,596- sizeof(void*))) {597 /*598 * iscsi tcp may readd the task to the xmitqueue to send599 * write data600 */601- spin_lock_bh(&conn->session->lock);602- if (list_empty(&conn->ctask->running))603- list_add_tail(&conn->ctask->running, &conn->run_list);0604 spin_unlock_bh(&conn->session->lock);0605 rc = tt->xmit_cmd_task(conn, conn->ctask);606 if (rc)607 goto again;0608 }0609 /* done with this ctask */610 conn->ctask = NULL;611···719 sc->SCp.phase = session->age;720 sc->SCp.ptr = (char *)ctask;7210722 ctask->mtask = NULL;723 ctask->conn = conn;724 ctask->sc = sc;···729730 session->tt->init_cmd_task(ctask);731732- __kfifo_put(conn->xmitqueue, (void*)&ctask, sizeof(void*));733 debug_scsi(734 "ctask enq [%s cid %d sc %lx itt 0x%x len %d cmdsn %d win %d]\n",735 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",···1006/*1007 * xmit mutex and session lock must be held1008 */1009-#define iscsi_remove_task(tasktype) \1010-static struct iscsi_##tasktype * \1011-iscsi_remove_##tasktype(struct kfifo *fifo, uint32_t itt) \1012-{ \1013- int i, nr_tasks = __kfifo_len(fifo) / sizeof(void*); \1014- struct iscsi_##tasktype *task; \1015- \1016- debug_scsi("searching %d tasks\n", nr_tasks); \1017- \1018- for (i = 0; i < nr_tasks; i++) { \1019- __kfifo_get(fifo, (void*)&task, sizeof(void*)); \1020- debug_scsi("check task %u\n", task->itt); \1021- \1022- if (task->itt == itt) { \1023- debug_scsi("matched task\n"); \1024- return task; \1025- } \1026- \1027- __kfifo_put(fifo, (void*)&task, sizeof(void*)); \1028- } \1029- return NULL; \1030-}10311032-iscsi_remove_task(mgmt_task);1033-iscsi_remove_task(cmd_task);000000000000010341035static int iscsi_ctask_mtask_cleanup(struct iscsi_cmd_task *ctask)1036{···1052{1053 struct scsi_cmnd *sc;10541055- conn->session->tt->cleanup_cmd_task(conn, ctask);1056- iscsi_ctask_mtask_cleanup(ctask);1057-1058 sc = ctask->sc;1059 if (!sc)1060 return;00001061 sc->result = err;1062 sc->resid = sc->request_bufflen;1063 iscsi_complete_command(conn->session, ctask);···1069 struct iscsi_cmd_task *ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;1070 struct iscsi_conn *conn = ctask->conn;1071 struct iscsi_session *session = conn->session;1072- struct iscsi_cmd_task *pending_ctask;1073 int rc;10741075 conn->eh_abort_cnt++;···1086 goto failed;10871088 /* ctask completed before time out */1089- if (!ctask->sc)1090- goto success;00010911092 /* what should we do here ? */1093 if (conn->ctask == ctask) {···1099 goto failed;1100 }11011102- /* check for the easy pending cmd abort */1103- pending_ctask = iscsi_remove_cmd_task(conn->xmitqueue, ctask->itt);1104- if (pending_ctask) {1105- /* iscsi_tcp queues write transfers on the xmitqueue */1106- if (list_empty(&pending_ctask->running)) {1107- debug_scsi("found pending task\n");1108- goto success;1109- } else1110- __kfifo_put(conn->xmitqueue, (void*)&pending_ctask,1111- sizeof(void*));1112- }11131114 conn->tmabort_state = TMABORT_INITIAL;1115···1108 rc = iscsi_exec_abort_task(sc, ctask);1109 spin_lock_bh(&session->lock);11101111- iscsi_ctask_mtask_cleanup(ctask);1112 if (rc || sc->SCp.phase != session->age ||1113 session->state != ISCSI_STATE_LOGGED_IN)1114 goto failed;011151116- /* ctask completed before tmf abort response */1117- if (!ctask->sc) {1118- debug_scsi("sc completed while abort in progress\n");1119- goto success;1120- }1121-1122- if (conn->tmabort_state != TMABORT_SUCCESS) {0000001123 spin_unlock_bh(&session->lock);1124 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);1125 spin_lock_bh(&session->lock);1126 goto failed;1127 }11281129-success:1130 debug_scsi("abort success [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);1131 spin_unlock_bh(&session->lock);1132···1146 spin_unlock(&session->lock);1147 write_unlock_bh(conn->recv_lock);114801149 mutex_unlock(&conn->xmitmutex);1150 return SUCCESS;1151···1289 if (cmd_task_size)1290 ctask->dd_data = &ctask[1];1291 ctask->itt = cmd_i;01292 }12931294 spin_lock_init(&session->lock);···1309 if (mgmt_task_size)1310 mtask->dd_data = &mtask[1];1311 mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i;01312 }13131314 if (scsi_add_host(shost, NULL))···1350{1351 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);1352 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);013531354 scsi_remove_host(shost);13551356 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);1357 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);1358001359 iscsi_destroy_session(cls_session);1360 scsi_host_put(shost);1361- module_put(cls_session->transport->owner);1362}1363EXPORT_SYMBOL_GPL(iscsi_session_teardown);1364···1392 conn->tmabort_state = TMABORT_INITIAL;1393 INIT_LIST_HEAD(&conn->run_list);1394 INIT_LIST_HEAD(&conn->mgmt_run_list);1395-1396- /* initialize general xmit PDU commands queue */1397- conn->xmitqueue = kfifo_alloc(session->cmds_max * sizeof(void*),1398- GFP_KERNEL, NULL);1399- if (conn->xmitqueue == ERR_PTR(-ENOMEM))1400- goto xmitqueue_alloc_fail;14011402 /* initialize general immediate & non-immediate PDU commands queue */1403 conn->immqueue = kfifo_alloc(session->mgmtpool_max * sizeof(void*),···1420 data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL);1421 if (!data)1422 goto login_mtask_data_alloc_fail;1423- conn->login_mtask->data = data;14241425 init_timer(&conn->tmabort_timer);1426 mutex_init(&conn->xmitmutex);···1436mgmtqueue_alloc_fail:1437 kfifo_free(conn->immqueue);1438immqueue_alloc_fail:1439- kfifo_free(conn->xmitqueue);1440-xmitqueue_alloc_fail:1441 iscsi_destroy_conn(cls_conn);1442 return NULL;1443}···14561457 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1458 mutex_lock(&conn->xmitmutex);1459- if (conn->c_stage == ISCSI_CONN_INITIAL_STAGE) {1460- if (session->tt->suspend_conn_recv)1461- session->tt->suspend_conn_recv(conn);1462-1463- session->tt->terminate_conn(conn);1464- }14651466 spin_lock_bh(&session->lock);1467 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;···1492 }14931494 spin_lock_bh(&session->lock);1495- kfree(conn->login_mtask->data);01496 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,1497 sizeof(void*));1498 list_del(&conn->item);···1508 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;1509 spin_unlock_bh(&session->lock);15101511- kfifo_free(conn->xmitqueue);1512 kfifo_free(conn->immqueue);1513 kfifo_free(conn->mgmtqueue);1514···1590 struct iscsi_cmd_task *ctask, *tmp;15911592 /* flush pending */1593- while (__kfifo_get(conn->xmitqueue, (void*)&ctask, sizeof(void*))) {1594 debug_scsi("failing pending sc %p itt 0x%x\n", ctask->sc,1595 ctask->itt);1596 fail_command(conn, ctask, DID_BUS_BUSY << 16);···1633 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1634 spin_unlock_bh(&session->lock);16351636- if (session->tt->suspend_conn_recv)1637- session->tt->suspend_conn_recv(conn);016381639 mutex_lock(&conn->xmitmutex);1640 /*···1654 }1655 }16561657- session->tt->terminate_conn(conn);1658 /*1659 * flush queues.1660 */
···189{190 struct scsi_cmnd *sc = ctask->sc;191192+ ctask->state = ISCSI_TASK_COMPLETED;193 ctask->sc = NULL;194 list_del_init(&ctask->running);195 __kfifo_put(session->cmdpool.queue, (void*)&ctask, sizeof(void*));···275 return rc;276}277278+static void iscsi_tmf_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr)279+{280+ struct iscsi_tm_rsp *tmf = (struct iscsi_tm_rsp *)hdr;281+282+ conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;283+ conn->tmfrsp_pdus_cnt++;284+285+ if (conn->tmabort_state != TMABORT_INITIAL)286+ return;287+288+ if (tmf->response == ISCSI_TMF_RSP_COMPLETE)289+ conn->tmabort_state = TMABORT_SUCCESS;290+ else if (tmf->response == ISCSI_TMF_RSP_NO_TASK)291+ conn->tmabort_state = TMABORT_NOT_FOUND;292+ else293+ conn->tmabort_state = TMABORT_FAILED;294+ wake_up(&conn->ehwait);295+}296+297/**298 * __iscsi_complete_pdu - complete pdu299 * @conn: iscsi conn···340341 switch(opcode) {342 case ISCSI_OP_LOGOUT_RSP:343+ if (datalen) {344+ rc = ISCSI_ERR_PROTO;345+ break;346+ }347 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;348 /* fall through */349 case ISCSI_OP_LOGIN_RSP:···348 * login related PDU's exp_statsn is handled in349 * userspace350 */351+ if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))352+ rc = ISCSI_ERR_CONN_FAILED;353 list_del(&mtask->running);354 if (conn->login_mtask != mtask)355 __kfifo_put(session->mgmtpool.queue,···360 break;361 }362363+ iscsi_tmf_rsp(conn, hdr);000000000364 break;365 case ISCSI_OP_NOOP_IN:366+ if (hdr->ttt != ISCSI_RESERVED_TAG || datalen) {367 rc = ISCSI_ERR_PROTO;368 break;369 }370 conn->exp_statsn = be32_to_cpu(hdr->statsn) + 1;371372+ if (iscsi_recv_pdu(conn->cls_conn, hdr, data, datalen))373+ rc = ISCSI_ERR_CONN_FAILED;374 list_del(&mtask->running);375 if (conn->login_mtask != mtask)376 __kfifo_put(session->mgmtpool.queue,···391 } else if (itt == ISCSI_RESERVED_TAG) {392 switch(opcode) {393 case ISCSI_OP_NOOP_IN:394+ if (datalen) {000000395 rc = ISCSI_ERR_PROTO;396+ break;397+ }398+399+ rc = iscsi_check_assign_cmdsn(session,400+ (struct iscsi_nopin*)hdr);401+ if (rc)402+ break;403+404+ if (hdr->ttt == ISCSI_RESERVED_TAG)405+ break;406+407+ if (iscsi_recv_pdu(conn->cls_conn, hdr, NULL, 0))408+ rc = ISCSI_ERR_CONN_FAILED;409 break;410 case ISCSI_OP_REJECT:411 /* we need sth like iscsi_reject_rsp()*/···568 }569570 /* process command queue */571+ spin_lock_bh(&conn->session->lock);572+ while (!list_empty(&conn->xmitqueue)) {573 /*574 * iscsi tcp may readd the task to the xmitqueue to send575 * write data576 */577+ conn->ctask = list_entry(conn->xmitqueue.next,578+ struct iscsi_cmd_task, running);579+ conn->ctask->state = ISCSI_TASK_RUNNING;580+ list_move_tail(conn->xmitqueue.next, &conn->run_list);581 spin_unlock_bh(&conn->session->lock);582+583 rc = tt->xmit_cmd_task(conn, conn->ctask);584 if (rc)585 goto again;586+ spin_lock_bh(&conn->session->lock);587 }588+ spin_unlock_bh(&conn->session->lock);589 /* done with this ctask */590 conn->ctask = NULL;591···691 sc->SCp.phase = session->age;692 sc->SCp.ptr = (char *)ctask;693694+ ctask->state = ISCSI_TASK_PENDING;695 ctask->mtask = NULL;696 ctask->conn = conn;697 ctask->sc = sc;···700701 session->tt->init_cmd_task(ctask);702703+ list_add_tail(&ctask->running, &conn->xmitqueue);704 debug_scsi(705 "ctask enq [%s cid %d sc %lx itt 0x%x len %d cmdsn %d win %d]\n",706 sc->sc_data_direction == DMA_TO_DEVICE ? "write" : "read",···977/*978 * xmit mutex and session lock must be held979 */980+static struct iscsi_mgmt_task *981+iscsi_remove_mgmt_task(struct kfifo *fifo, uint32_t itt)982+{983+ int i, nr_tasks = __kfifo_len(fifo) / sizeof(void*);984+ struct iscsi_mgmt_task *task;00000000000000000985986+ debug_scsi("searching %d tasks\n", nr_tasks);987+988+ for (i = 0; i < nr_tasks; i++) {989+ __kfifo_get(fifo, (void*)&task, sizeof(void*));990+ debug_scsi("check task %u\n", task->itt);991+992+ if (task->itt == itt) {993+ debug_scsi("matched task\n");994+ return task;995+ }996+997+ __kfifo_put(fifo, (void*)&task, sizeof(void*));998+ }999+ return NULL;1000+}10011002static int iscsi_ctask_mtask_cleanup(struct iscsi_cmd_task *ctask)1003{···1027{1028 struct scsi_cmnd *sc;10290001030 sc = ctask->sc;1031 if (!sc)1032 return;1033+1034+ conn->session->tt->cleanup_cmd_task(conn, ctask);1035+ iscsi_ctask_mtask_cleanup(ctask);1036+1037 sc->result = err;1038 sc->resid = sc->request_bufflen;1039 iscsi_complete_command(conn->session, ctask);···1043 struct iscsi_cmd_task *ctask = (struct iscsi_cmd_task *)sc->SCp.ptr;1044 struct iscsi_conn *conn = ctask->conn;1045 struct iscsi_session *session = conn->session;01046 int rc;10471048 conn->eh_abort_cnt++;···1061 goto failed;10621063 /* ctask completed before time out */1064+ if (!ctask->sc) {1065+ spin_unlock_bh(&session->lock);1066+ debug_scsi("sc completed while abort in progress\n");1067+ goto success_rel_mutex;1068+ }10691070 /* what should we do here ? */1071 if (conn->ctask == ctask) {···1071 goto failed;1072 }10731074+ if (ctask->state == ISCSI_TASK_PENDING)1075+ goto success_cleanup;00000000010761077 conn->tmabort_state = TMABORT_INITIAL;1078···1089 rc = iscsi_exec_abort_task(sc, ctask);1090 spin_lock_bh(&session->lock);109101092 if (rc || sc->SCp.phase != session->age ||1093 session->state != ISCSI_STATE_LOGGED_IN)1094 goto failed;1095+ iscsi_ctask_mtask_cleanup(ctask);10961097+ switch (conn->tmabort_state) {1098+ case TMABORT_SUCCESS:1099+ goto success_cleanup;1100+ case TMABORT_NOT_FOUND:1101+ if (!ctask->sc) {1102+ /* ctask completed before tmf abort response */1103+ spin_unlock_bh(&session->lock);1104+ debug_scsi("sc completed while abort in progress\n");1105+ goto success_rel_mutex;1106+ }1107+ /* fall through */1108+ default:1109+ /* timedout or failed */1110 spin_unlock_bh(&session->lock);1111 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);1112 spin_lock_bh(&session->lock);1113 goto failed;1114 }11151116+success_cleanup:1117 debug_scsi("abort success [sc %lx itt 0x%x]\n", (long)sc, ctask->itt);1118 spin_unlock_bh(&session->lock);1119···1121 spin_unlock(&session->lock);1122 write_unlock_bh(conn->recv_lock);11231124+success_rel_mutex:1125 mutex_unlock(&conn->xmitmutex);1126 return SUCCESS;1127···1263 if (cmd_task_size)1264 ctask->dd_data = &ctask[1];1265 ctask->itt = cmd_i;1266+ INIT_LIST_HEAD(&ctask->running);1267 }12681269 spin_lock_init(&session->lock);···1282 if (mgmt_task_size)1283 mtask->dd_data = &mtask[1];1284 mtask->itt = ISCSI_MGMT_ITT_OFFSET + cmd_i;1285+ INIT_LIST_HEAD(&mtask->running);1286 }12871288 if (scsi_add_host(shost, NULL))···1322{1323 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);1324 struct iscsi_session *session = iscsi_hostdata(shost->hostdata);1325+ struct module *owner = cls_session->transport->owner;13261327 scsi_remove_host(shost);13281329 iscsi_pool_free(&session->mgmtpool, (void**)session->mgmt_cmds);1330 iscsi_pool_free(&session->cmdpool, (void**)session->cmds);13311332+ kfree(session->targetname);1333+1334 iscsi_destroy_session(cls_session);1335 scsi_host_put(shost);1336+ module_put(owner);1337}1338EXPORT_SYMBOL_GPL(iscsi_session_teardown);1339···1361 conn->tmabort_state = TMABORT_INITIAL;1362 INIT_LIST_HEAD(&conn->run_list);1363 INIT_LIST_HEAD(&conn->mgmt_run_list);1364+ INIT_LIST_HEAD(&conn->xmitqueue);0000013651366 /* initialize general immediate & non-immediate PDU commands queue */1367 conn->immqueue = kfifo_alloc(session->mgmtpool_max * sizeof(void*),···1394 data = kmalloc(DEFAULT_MAX_RECV_DATA_SEGMENT_LENGTH, GFP_KERNEL);1395 if (!data)1396 goto login_mtask_data_alloc_fail;1397+ conn->login_mtask->data = conn->data = data;13981399 init_timer(&conn->tmabort_timer);1400 mutex_init(&conn->xmitmutex);···1410mgmtqueue_alloc_fail:1411 kfifo_free(conn->immqueue);1412immqueue_alloc_fail:001413 iscsi_destroy_conn(cls_conn);1414 return NULL;1415}···14321433 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1434 mutex_lock(&conn->xmitmutex);00000014351436 spin_lock_bh(&session->lock);1437 conn->c_stage = ISCSI_CONN_CLEANUP_WAIT;···1474 }14751476 spin_lock_bh(&session->lock);1477+ kfree(conn->data);1478+ kfree(conn->persistent_address);1479 __kfifo_put(session->mgmtpool.queue, (void*)&conn->login_mtask,1480 sizeof(void*));1481 list_del(&conn->item);···1489 session->cmdsn = session->max_cmdsn = session->exp_cmdsn = 1;1490 spin_unlock_bh(&session->lock);149101492 kfifo_free(conn->immqueue);1493 kfifo_free(conn->mgmtqueue);1494···1572 struct iscsi_cmd_task *ctask, *tmp;15731574 /* flush pending */1575+ list_for_each_entry_safe(ctask, tmp, &conn->xmitqueue, running) {1576 debug_scsi("failing pending sc %p itt 0x%x\n", ctask->sc,1577 ctask->itt);1578 fail_command(conn, ctask, DID_BUS_BUSY << 16);···1615 set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_tx);1616 spin_unlock_bh(&session->lock);16171618+ write_lock_bh(conn->recv_lock);1619+ set_bit(ISCSI_SUSPEND_BIT, &conn->suspend_rx);1620+ write_unlock_bh(conn->recv_lock);16211622 mutex_lock(&conn->xmitmutex);1623 /*···1635 }1636 }163701638 /*1639 * flush queues.1640 */
···1379 /* stop all timers associated with this hba */1380 lpfc_stop_timer(phba);1381 phba->work_hba_events = 0;013821383 lpfc_printf_log(phba,1384 KERN_WARNING,···1617 goto out_free_iocbq;1618 }16191620- /* We can rely on a queue depth attribute only after SLI HBA setup */00001621 host->can_queue = phba->cfg_hba_queue_depth - 10;16221623 /* Tell the midlayer we support 16 byte commands */···1660 error = -ENODEV;1661 goto out_free_irq;1662 }00000016631664 lpfc_discovery_wait(phba);1665
···1379 /* stop all timers associated with this hba */1380 lpfc_stop_timer(phba);1381 phba->work_hba_events = 0;1382+ phba->work_ha = 0;13831384 lpfc_printf_log(phba,1385 KERN_WARNING,···1616 goto out_free_iocbq;1617 }16181619+ /*1620+ * Set initial can_queue value since 0 is no longer supported and1621+ * scsi_add_host will fail. This will be adjusted later based on the1622+ * max xri value determined in hba setup.1623+ */1624 host->can_queue = phba->cfg_hba_queue_depth - 10;16251626 /* Tell the midlayer we support 16 byte commands */···1655 error = -ENODEV;1656 goto out_free_irq;1657 }1658+1659+ /*1660+ * hba setup may have changed the hba_queue_depth so we need to adjust1661+ * the value of can_queue.1662+ */1663+ host->can_queue = phba->cfg_hba_queue_depth - 10;16641665 lpfc_discovery_wait(phba);1666
···179180 /* Abort outstanding I/O on NPort <nlp_DID> */181 lpfc_printf_log(phba, KERN_INFO, LOG_DISCOVERY,182+ "%d:0205 Abort outstanding I/O on NPort x%x "183 "Data: x%x x%x x%x\n",184 phba->brd_no, ndlp->nlp_DID, ndlp->nlp_flag,185 ndlp->nlp_state, ndlp->nlp_rpi);···392 mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;393 mbox->context2 = ndlp;394 ndlp->nlp_flag |= (NLP_ACC_REGLOGIN | NLP_RCV_PLOGI);395+396+ /*397+ * If there is an outstanding PLOGI issued, abort it before398+ * sending ACC rsp for received PLOGI. If pending plogi399+ * is not canceled here, the plogi will be rejected by400+ * remote port and will be retried. On a configuration with401+ * single discovery thread, this will cause a huge delay in402+ * discovery. Also this will cause multiple state machines403+ * running in parallel for this node.404+ */405+ if (ndlp->nlp_state == NLP_STE_PLOGI_ISSUE) {406+ /* software abort outstanding PLOGI */407+ lpfc_els_abort(phba, ndlp, 1);408+ }409410 lpfc_els_rsp_acc(phba, ELS_CMD_PLOGI, cmdiocb, ndlp, mbox, 0);411 return 1;···16011602 lpfc_rcv_padisc(phba, ndlp, cmdiocb);16031604+ /*1605+ * Do not start discovery if discovery is about to start1606+ * or discovery in progress for this node. Starting discovery1607+ * here will affect the counting of discovery threads.1608+ */1609+ if ((!(ndlp->nlp_flag & NLP_DELAY_TMO)) &&1610+ (ndlp->nlp_flag & NLP_NPR_2B_DISC)){1611 if (ndlp->nlp_flag & NLP_NPR_ADISC) {1612 ndlp->nlp_prev_state = NLP_STE_NPR_NODE;1613 ndlp->nlp_state = NLP_STE_ADISC_ISSUE;
+20-1
drivers/scsi/lpfc/lpfc_scsi.c
···2122#include <linux/pci.h>23#include <linux/interrupt.h>02425#include <scsi/scsi.h>26#include <scsi/scsi_device.h>···842 return 0;843}844000000000000000845846static int847lpfc_abort_handler(struct scsi_cmnd *cmnd)···871 unsigned int loop_count = 0;872 int ret = SUCCESS;8730874 spin_lock_irq(shost->host_lock);875876 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;···974 int ret = FAILED;975 int cnt, loopcnt;9760977 spin_lock_irq(shost->host_lock);978 /*979 * If target is not in a MAPPED state, delay the reset until···1091 int cnt, loopcnt;1092 struct lpfc_scsi_buf * lpfc_cmd;109301094 spin_lock_irq(shost->host_lock);10951096 lpfc_cmd = lpfc_get_scsi_buf(phba);···1123 ndlp->rport->dd_data);1124 if (ret != SUCCESS) {1125 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,1126- "%d:0713 Bus Reset on target %d failed\n",1127 phba->brd_no, i);1128 err_count++;1129 }
···2122#include <linux/pci.h>23#include <linux/interrupt.h>24+#include <linux/delay.h>2526#include <scsi/scsi.h>27#include <scsi/scsi_device.h>···841 return 0;842}843844+static void845+lpfc_block_error_handler(struct scsi_cmnd *cmnd)846+{847+ struct Scsi_Host *shost = cmnd->device->host;848+ struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));849+850+ spin_lock_irq(shost->host_lock);851+ while (rport->port_state == FC_PORTSTATE_BLOCKED) {852+ spin_unlock_irq(shost->host_lock);853+ msleep(1000);854+ spin_lock_irq(shost->host_lock);855+ }856+ spin_unlock_irq(shost->host_lock);857+ return;858+}859860static int861lpfc_abort_handler(struct scsi_cmnd *cmnd)···855 unsigned int loop_count = 0;856 int ret = SUCCESS;857858+ lpfc_block_error_handler(cmnd);859 spin_lock_irq(shost->host_lock);860861 lpfc_cmd = (struct lpfc_scsi_buf *)cmnd->host_scribble;···957 int ret = FAILED;958 int cnt, loopcnt;959960+ lpfc_block_error_handler(cmnd);961 spin_lock_irq(shost->host_lock);962 /*963 * If target is not in a MAPPED state, delay the reset until···1073 int cnt, loopcnt;1074 struct lpfc_scsi_buf * lpfc_cmd;10751076+ lpfc_block_error_handler(cmnd);1077 spin_lock_irq(shost->host_lock);10781079 lpfc_cmd = lpfc_get_scsi_buf(phba);···1104 ndlp->rport->dd_data);1105 if (ret != SUCCESS) {1106 lpfc_printf_log(phba, KERN_ERR, LOG_FCP,1107+ "%d:0700 Bus Reset on target %d failed\n",1108 phba->brd_no, i);1109 err_count++;1110 }
+36-21
drivers/scsi/lpfc/lpfc_sli.c
···320 kfree(old_arr);321 return iotag;322 }323- }0324325 lpfc_printf_log(phba, KERN_ERR,LOG_SLI,326 "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n",···970 * resources need to be recovered.971 */972 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {973- printk(KERN_INFO "%s: IOCB cmd 0x%x processed."974- " Skipping completion\n", __FUNCTION__,975- irsp->ulpCommand);00976 break;977 }978···1107 if (unlikely(irsp->ulpStatus)) {1108 /* Rsp ring <ringno> error: IOCB */1109 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,1110- "%d:0326 Rsp Ring %d error: IOCB Data: "1111 "x%x x%x x%x x%x x%x x%x x%x x%x\n",1112 phba->brd_no, pring->ringno,1113 irsp->un.ulpWord[0], irsp->un.ulpWord[1],···1125 * resources need to be recovered.1126 */1127 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {1128- printk(KERN_INFO "%s: IOCB cmd 0x%x processed. "1129- "Skipping completion\n", __FUNCTION__,1130- irsp->ulpCommand);001131 break;1132 }1133···1160 } else {1161 /* Unknown IOCB command */1162 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,1163- "%d:0321 Unknown IOCB command "1164 "Data: x%x, x%x x%x x%x x%x\n",1165 phba->brd_no, type, irsp->ulpCommand,1166 irsp->ulpStatus, irsp->ulpIoTag,···1243 lpfc_printf_log(phba,1244 KERN_ERR,1245 LOG_SLI,1246- "%d:0312 Ring %d handler: portRspPut %d "1247 "is bigger then rsp ring %d\n",1248 phba->brd_no,1249 pring->ringno, portRspPut, portRspMax);···1388 lpfc_printf_log(phba,1389 KERN_ERR,1390 LOG_SLI,1391- "%d:0321 Unknown IOCB command "1392 "Data: x%x x%x x%x x%x\n",1393 phba->brd_no,1394 irsp->ulpCommand,···1404 next_iocb,1405 &saveq->list,1406 list) {01407 lpfc_sli_release_iocbq(phba,1408 rspiocbp);1409 }1410 }1411-1412 lpfc_sli_release_iocbq(phba, saveq);1413 }1414 }···1716 phba->fc_myDID = 0;1717 phba->fc_prevDID = 0;17181719- psli->sli_flag = 0;1720-1721 /* Turn off parity checking and serr during the physical reset */1722 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value);1723 pci_write_config_word(phba->pcidev, PCI_COMMAND,1724 (cfg_value &1725 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR)));17261727- psli->sli_flag &= ~LPFC_SLI2_ACTIVE;1728 /* Now toggle INITFF bit in the Host Control Register */1729 writel(HC_INITFF, phba->HCregaddr);1730 mdelay(1);···17631764 /* Restart HBA */1765 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,1766- "%d:0328 Restart HBA Data: x%x x%x\n", phba->brd_no,1767 phba->hba_state, psli->sli_flag);17681769 word0 = 0;···1794 phba->hba_state = LPFC_INIT_START;17951796 spin_unlock_irq(phba->host->host_lock);00017971798 if (skip_post)1799 mdelay(100);···1908 }19091910 while (resetcount < 2 && !done) {0001911 phba->hba_state = LPFC_STATE_UNKNOWN;1912 lpfc_sli_brdrestart(phba);1913 msleep(2500);···1918 if (rc)1919 break;19200001921 resetcount++;19221923 /* Call pre CONFIG_PORT mailbox command initialization. A value of 0···2206 return (MBX_NOT_FINISHED);2207 }2208 /* timeout active mbox command */2209- mod_timer(&psli->mbox_tmo, jiffies + HZ * LPFC_MBOX_TMO);02210 }22112212 /* Mailbox cmd <cmd> issue */···2267 break;22682269 case MBX_POLL:2270- i = 0;2271 psli->mbox_active = NULL;2272 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {2273 /* First read mbox status word */···2280 /* Read the HBA Host Attention Register */2281 ha_copy = readl(phba->HAregaddr);22820002283 /* Wait for command to complete */2284 while (((word0 & OWN_CHIP) == OWN_CHIP) ||2285 (!(ha_copy & HA_MBATT) &&2286 (phba->hba_state > LPFC_WARM_START))) {2287- if (i++ >= 100) {2288 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;2289 spin_unlock_irqrestore(phba->host->host_lock,2290 drvr_flag);···23052306 /* Can be in interrupt context, do not sleep */2307 /* (or might be called with interrupts disabled) */2308- mdelay(i);23092310 spin_lock_irqsave(phba->host->host_lock, drvr_flag);2311···30203021 if (timeleft == 0) {3022 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,3023- "%d:0329 IOCB wait timeout error - no "3024 "wake response Data x%x\n",3025 phba->brd_no, timeout);3026 retval = IOCB_TIMEDOUT;
···320 kfree(old_arr);321 return iotag;322 }323+ } else324+ spin_unlock_irq(phba->host->host_lock);325326 lpfc_printf_log(phba, KERN_ERR,LOG_SLI,327 "%d:0318 Failed to allocate IOTAG.last IOTAG is %d\n",···969 * resources need to be recovered.970 */971 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {972+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,973+ "%d:0314 IOCB cmd 0x%x"974+ " processed. Skipping"975+ " completion", phba->brd_no,976+ irsp->ulpCommand);977 break;978 }979···1104 if (unlikely(irsp->ulpStatus)) {1105 /* Rsp ring <ringno> error: IOCB */1106 lpfc_printf_log(phba, KERN_WARNING, LOG_SLI,1107+ "%d:0336 Rsp Ring %d error: IOCB Data: "1108 "x%x x%x x%x x%x x%x x%x x%x x%x\n",1109 phba->brd_no, pring->ringno,1110 irsp->un.ulpWord[0], irsp->un.ulpWord[1],···1122 * resources need to be recovered.1123 */1124 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) {1125+ lpfc_printf_log(phba, KERN_INFO, LOG_SLI,1126+ "%d:0333 IOCB cmd 0x%x"1127+ " processed. Skipping"1128+ " completion\n", phba->brd_no,1129+ irsp->ulpCommand);1130 break;1131 }1132···1155 } else {1156 /* Unknown IOCB command */1157 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,1158+ "%d:0334 Unknown IOCB command "1159 "Data: x%x, x%x x%x x%x x%x\n",1160 phba->brd_no, type, irsp->ulpCommand,1161 irsp->ulpStatus, irsp->ulpIoTag,···1238 lpfc_printf_log(phba,1239 KERN_ERR,1240 LOG_SLI,1241+ "%d:0303 Ring %d handler: portRspPut %d "1242 "is bigger then rsp ring %d\n",1243 phba->brd_no,1244 pring->ringno, portRspPut, portRspMax);···1383 lpfc_printf_log(phba,1384 KERN_ERR,1385 LOG_SLI,1386+ "%d:0335 Unknown IOCB command "1387 "Data: x%x x%x x%x x%x\n",1388 phba->brd_no,1389 irsp->ulpCommand,···1399 next_iocb,1400 &saveq->list,1401 list) {1402+ list_del(&rspiocbp->list);1403 lpfc_sli_release_iocbq(phba,1404 rspiocbp);1405 }1406 }01407 lpfc_sli_release_iocbq(phba, saveq);1408 }1409 }···1711 phba->fc_myDID = 0;1712 phba->fc_prevDID = 0;1713001714 /* Turn off parity checking and serr during the physical reset */1715 pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value);1716 pci_write_config_word(phba->pcidev, PCI_COMMAND,1717 (cfg_value &1718 ~(PCI_COMMAND_PARITY | PCI_COMMAND_SERR)));17191720+ psli->sli_flag &= ~(LPFC_SLI2_ACTIVE | LPFC_PROCESS_LA);1721 /* Now toggle INITFF bit in the Host Control Register */1722 writel(HC_INITFF, phba->HCregaddr);1723 mdelay(1);···17601761 /* Restart HBA */1762 lpfc_printf_log(phba, KERN_INFO, LOG_SLI,1763+ "%d:0337 Restart HBA Data: x%x x%x\n", phba->brd_no,1764 phba->hba_state, psli->sli_flag);17651766 word0 = 0;···1791 phba->hba_state = LPFC_INIT_START;17921793 spin_unlock_irq(phba->host->host_lock);1794+1795+ memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets));1796+ psli->stats_start = get_seconds();17971798 if (skip_post)1799 mdelay(100);···1902 }19031904 while (resetcount < 2 && !done) {1905+ spin_lock_irq(phba->host->host_lock);1906+ phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE;1907+ spin_unlock_irq(phba->host->host_lock);1908 phba->hba_state = LPFC_STATE_UNKNOWN;1909 lpfc_sli_brdrestart(phba);1910 msleep(2500);···1909 if (rc)1910 break;19111912+ spin_lock_irq(phba->host->host_lock);1913+ phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;1914+ spin_unlock_irq(phba->host->host_lock);1915 resetcount++;19161917 /* Call pre CONFIG_PORT mailbox command initialization. A value of 0···2194 return (MBX_NOT_FINISHED);2195 }2196 /* timeout active mbox command */2197+ mod_timer(&psli->mbox_tmo, (jiffies +2198+ (HZ * lpfc_mbox_tmo_val(phba, mb->mbxCommand))));2199 }22002201 /* Mailbox cmd <cmd> issue */···2254 break;22552256 case MBX_POLL:02257 psli->mbox_active = NULL;2258 if (psli->sli_flag & LPFC_SLI2_ACTIVE) {2259 /* First read mbox status word */···2268 /* Read the HBA Host Attention Register */2269 ha_copy = readl(phba->HAregaddr);22702271+ i = lpfc_mbox_tmo_val(phba, mb->mbxCommand);2272+ i *= 1000; /* Convert to ms */2273+2274 /* Wait for command to complete */2275 while (((word0 & OWN_CHIP) == OWN_CHIP) ||2276 (!(ha_copy & HA_MBATT) &&2277 (phba->hba_state > LPFC_WARM_START))) {2278+ if (i-- <= 0) {2279 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE;2280 spin_unlock_irqrestore(phba->host->host_lock,2281 drvr_flag);···22902291 /* Can be in interrupt context, do not sleep */2292 /* (or might be called with interrupts disabled) */2293+ mdelay(1);22942295 spin_lock_irqsave(phba->host->host_lock, drvr_flag);2296···30053006 if (timeleft == 0) {3007 lpfc_printf_log(phba, KERN_ERR, LOG_SLI,3008+ "%d:0338 IOCB wait timeout error - no "3009 "wake response Data x%x\n",3010 phba->brd_no, timeout);3011 retval = IOCB_TIMEDOUT;
+20
drivers/scsi/lpfc/lpfc_sli.h
···172 uint32_t mbox_busy; /* Mailbox cmd busy */173};174000000000000175/* Structure used to hold SLI information */176struct lpfc_sli {177 uint32_t num_rings;···213 struct lpfc_iocbq ** iocbq_lookup; /* array to lookup IOCB by IOTAG */214 size_t iocbq_lookup_len; /* current lengs of the array */215 uint16_t last_iotag; /* last allocated IOTAG */00216};217218/* Given a pointer to the start of the ring, and the slot number of···225226#define LPFC_MBOX_TMO 30 /* Sec tmo for outstanding mbox227 command */000000
···172 uint32_t mbox_busy; /* Mailbox cmd busy */173};174175+/* Structure to store link status values when port stats are reset */176+struct lpfc_lnk_stat {177+ uint32_t link_failure_count;178+ uint32_t loss_of_sync_count;179+ uint32_t loss_of_signal_count;180+ uint32_t prim_seq_protocol_err_count;181+ uint32_t invalid_tx_word_count;182+ uint32_t invalid_crc_count;183+ uint32_t error_frames;184+ uint32_t link_events;185+};186+187/* Structure used to hold SLI information */188struct lpfc_sli {189 uint32_t num_rings;···201 struct lpfc_iocbq ** iocbq_lookup; /* array to lookup IOCB by IOTAG */202 size_t iocbq_lookup_len; /* current lengs of the array */203 uint16_t last_iotag; /* last allocated IOTAG */204+ unsigned long stats_start; /* in seconds */205+ struct lpfc_lnk_stat lnk_stat_offsets;206};207208/* Given a pointer to the start of the ring, and the slot number of···211212#define LPFC_MBOX_TMO 30 /* Sec tmo for outstanding mbox213 command */214+#define LPFC_MBOX_TMO_FLASH_CMD 300 /* Sec tmo for outstanding FLASH write215+ * or erase cmds. This is especially216+ * long because of the potential of217+ * multiple flash erases that can be218+ * spawned.219+ */
+1-1
drivers/scsi/lpfc/lpfc_version.h
···18 * included with this package. *19 *******************************************************************/2021-#define LPFC_DRIVER_VERSION "8.1.7"2223#define LPFC_DRIVER_NAME "lpfc"24
···18 * included with this package. *19 *******************************************************************/2021+#define LPFC_DRIVER_VERSION "8.1.9"2223#define LPFC_DRIVER_NAME "lpfc"24
···10 * 2 of the License, or (at your option) any later version.11 *12 * FILE : megaraid_mbox.c13- * Version : v2.20.4.8 (Apr 11 2006)14 *15 * Authors:16 * Atul Mukker <Atul.Mukker@lsil.com>···720 struct pci_dev *pdev;721 mraid_device_t *raid_dev;722 int i;0723724725 adapter->ito = MBOX_TIMEOUT;···864865 // Set the DMA mask to 64-bit. All supported controllers as capable of866 // DMA in this range867- if (pci_set_dma_mask(adapter->pdev, DMA_64BIT_MASK) != 0) {868869- con_log(CL_ANN, (KERN_WARNING870- "megaraid: could not set DMA mask for 64-bit.\n"));0000000000000000871872- goto out_free_sysfs_res;00000873 }874875 // setup tasklet for DPC···1642 " [virtual] for logical drives\n"));16431644 rdev->last_disp |= (1L << SCP2CHANNEL(scp));000000001645 }16461647 /* Fall through */
···10 * 2 of the License, or (at your option) any later version.11 *12 * FILE : megaraid_mbox.c13+ * Version : v2.20.4.9 (Jul 16 2006)14 *15 * Authors:16 * Atul Mukker <Atul.Mukker@lsil.com>···720 struct pci_dev *pdev;721 mraid_device_t *raid_dev;722 int i;723+ uint32_t magic64;724725726 adapter->ito = MBOX_TIMEOUT;···863864 // Set the DMA mask to 64-bit. All supported controllers as capable of865 // DMA in this range866+ pci_read_config_dword(adapter->pdev, PCI_CONF_AMISIG64, &magic64);867868+ if (((magic64 == HBA_SIGNATURE_64_BIT) &&869+ ((adapter->pdev->subsystem_device !=870+ PCI_SUBSYS_ID_MEGARAID_SATA_150_6) ||871+ (adapter->pdev->subsystem_device !=872+ PCI_SUBSYS_ID_MEGARAID_SATA_150_4))) ||873+ (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&874+ adapter->pdev->device == PCI_DEVICE_ID_VERDE) ||875+ (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&876+ adapter->pdev->device == PCI_DEVICE_ID_DOBSON) ||877+ (adapter->pdev->vendor == PCI_VENDOR_ID_LSI_LOGIC &&878+ adapter->pdev->device == PCI_DEVICE_ID_LINDSAY) ||879+ (adapter->pdev->vendor == PCI_VENDOR_ID_DELL &&880+ adapter->pdev->device == PCI_DEVICE_ID_PERC4_DI_EVERGLADES) ||881+ (adapter->pdev->vendor == PCI_VENDOR_ID_DELL &&882+ adapter->pdev->device == PCI_DEVICE_ID_PERC4E_DI_KOBUK)) {883+ if (pci_set_dma_mask(adapter->pdev, DMA_64BIT_MASK)) {884+ con_log(CL_ANN, (KERN_WARNING885+ "megaraid: DMA mask for 64-bit failed\n"));886887+ if (pci_set_dma_mask (adapter->pdev, DMA_32BIT_MASK)) {888+ con_log(CL_ANN, (KERN_WARNING889+ "megaraid: 32-bit DMA mask failed\n"));890+ goto out_free_sysfs_res;891+ }892+ }893 }894895 // setup tasklet for DPC···1620 " [virtual] for logical drives\n"));16211622 rdev->last_disp |= (1L << SCP2CHANNEL(scp));1623+ }1624+1625+ if (scp->cmnd[1] & MEGA_SCSI_INQ_EVPD) {1626+ scp->sense_buffer[0] = 0x70;1627+ scp->sense_buffer[2] = ILLEGAL_REQUEST;1628+ scp->sense_buffer[12] = MEGA_INVALID_FIELD_IN_CDB;1629+ scp->result = CHECK_CONDITION << 1;1630+ return NULL;1631 }16321633 /* Fall through */
···21#include "megaraid_ioctl.h"222324+#define MEGARAID_VERSION "2.20.4.9"25+#define MEGARAID_EXT_VERSION "(Release Date: Sun Jul 16 12:27:22 EST 2006)"262728/*
+1-1
drivers/scsi/megaraid/megaraid_mm.c
···10 * 2 of the License, or (at your option) any later version.11 *12 * FILE : megaraid_mm.c13- * Version : v2.20.2.6 (Mar 7 2005)14 *15 * Common management module16 */
···10 * 2 of the License, or (at your option) any later version.11 *12 * FILE : megaraid_mm.c13+ * Version : v2.20.2.7 (Jul 16 2006)14 *15 * Common management module16 */
+2-2
drivers/scsi/megaraid/megaraid_mm.h
···27#include "megaraid_ioctl.h"282930-#define LSI_COMMON_MOD_VERSION "2.20.2.6"31#define LSI_COMMON_MOD_EXT_VERSION \32- "(Release Date: Mon Mar 7 00:01:03 EST 2005)"333435#define LSI_DBGLVL dbglevel
···27#include "megaraid_ioctl.h"282930+#define LSI_COMMON_MOD_VERSION "2.20.2.7"31#define LSI_COMMON_MOD_EXT_VERSION \32+ "(Release Date: Sun Jul 16 00:01:03 EST 2006)"333435#define LSI_DBGLVL dbglevel
+1
drivers/scsi/qla2xxx/qla_def.h
···487#define MBA_IP_RCV_BUFFER_EMPTY 0x8026 /* IP receive buffer queue empty. */488#define MBA_IP_HDR_DATA_SPLIT 0x8027 /* IP header/data splitting feature */489 /* used. */0490#define MBA_POINT_TO_POINT 0x8030 /* Point to point mode. */491#define MBA_CMPLT_1_16BIT 0x8031 /* Completion 1 16bit IOSB. */492#define MBA_CMPLT_2_16BIT 0x8032 /* Completion 2 16bit IOSB. */
···744{745 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);746 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;747- srb_t *sp;748 int ret;749 unsigned int id, lun;750 unsigned long serial;···754 lun = cmd->device->lun;755 serial = cmd->serial_number;756757- sp = (srb_t *) CMD_SP(cmd);758- if (!sp || !fcport)759 return ret;760761 qla_printk(KERN_INFO, ha,···873{874 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);875 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;876- srb_t *sp;877 int ret;878 unsigned int id, lun;879 unsigned long serial;···883 lun = cmd->device->lun;884 serial = cmd->serial_number;885886- sp = (srb_t *) CMD_SP(cmd);887- if (!sp || !fcport)888 return ret;889890 qla_printk(KERN_INFO, ha,···932{933 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);934 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;935- srb_t *sp;936 int ret;937 unsigned int id, lun;938 unsigned long serial;···942 lun = cmd->device->lun;943 serial = cmd->serial_number;944945- sp = (srb_t *) CMD_SP(cmd);946- if (!sp || !fcport)947 return ret;948949 qla_printk(KERN_INFO, ha,···22382239 next_loopid = 0;2240 list_for_each_entry(fcport, &ha->fcports, list) {2241- if (fcport->port_type != FCT_TARGET)2242- continue;2243-2244 /*2245 * If the port is not ONLINE then try to login2246 * to it if we haven't run out of retries.
···744{745 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);746 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;0747 int ret;748 unsigned int id, lun;749 unsigned long serial;···755 lun = cmd->device->lun;756 serial = cmd->serial_number;757758+ if (!fcport)0759 return ret;760761 qla_printk(KERN_INFO, ha,···875{876 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);877 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;0878 int ret;879 unsigned int id, lun;880 unsigned long serial;···886 lun = cmd->device->lun;887 serial = cmd->serial_number;888889+ if (!fcport)0890 return ret;891892 qla_printk(KERN_INFO, ha,···936{937 scsi_qla_host_t *ha = to_qla_host(cmd->device->host);938 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;0939 int ret;940 unsigned int id, lun;941 unsigned long serial;···947 lun = cmd->device->lun;948 serial = cmd->serial_number;949950+ if (!fcport)0951 return ret;952953 qla_printk(KERN_INFO, ha,···22442245 next_loopid = 0;2246 list_for_each_entry(fcport, &ha->fcports, list) {0002247 /*2248 * If the port is not ONLINE then try to login2249 * to it if we haven't run out of retries.
···460 * Return value:461 * SUCCESS or FAILED or NEEDS_RETRY462 **/463-static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, int timeout, int copy_sense)0464{465 struct scsi_device *sdev = scmd->device;466 struct Scsi_Host *shost = sdev->host;···490 old_data_direction = scmd->sc_data_direction;491 old_cmd_len = scmd->cmd_len;492 old_use_sg = scmd->use_sg;000493494 if (copy_sense) {495 int gfp_mask = GFP_ATOMIC;···614 static unsigned char generic_sense[6] =615 {REQUEST_SENSE, 0, 0, 0, 252, 0};616617- memcpy(scmd->cmnd, generic_sense, sizeof(generic_sense));618- return scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT, 1);619}620621/**···739 int retry_cnt = 1, rtn;740741retry_tur:742- memcpy(scmd->cmnd, tur_command, sizeof(tur_command));743-744-745- rtn = scsi_send_eh_cmnd(scmd, SENSE_TIMEOUT, 0);746747 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",748 __FUNCTION__, scmd, rtn));···839 if (scmd->device->allow_restart) {840 int rtn;841842- memcpy(scmd->cmnd, stu_command, sizeof(stu_command));843- rtn = scsi_send_eh_cmnd(scmd, START_UNIT_TIMEOUT, 0);844 if (rtn == SUCCESS)845 return 0;846 }
···460 * Return value:461 * SUCCESS or FAILED or NEEDS_RETRY462 **/463+static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,464+ int cmnd_size, int timeout, int copy_sense)465{466 struct scsi_device *sdev = scmd->device;467 struct Scsi_Host *shost = sdev->host;···489 old_data_direction = scmd->sc_data_direction;490 old_cmd_len = scmd->cmd_len;491 old_use_sg = scmd->use_sg;492+493+ memset(scmd->cmnd, 0, sizeof(scmd->cmnd));494+ memcpy(scmd->cmnd, cmnd, cmnd_size);495496 if (copy_sense) {497 int gfp_mask = GFP_ATOMIC;···610 static unsigned char generic_sense[6] =611 {REQUEST_SENSE, 0, 0, 0, 252, 0};612613+ return scsi_send_eh_cmnd(scmd, generic_sense, 6, SENSE_TIMEOUT, 1);0614}615616/**···736 int retry_cnt = 1, rtn;737738retry_tur:739+ rtn = scsi_send_eh_cmnd(scmd, tur_command, 6, SENSE_TIMEOUT, 0);000740741 SCSI_LOG_ERROR_RECOVERY(3, printk("%s: scmd %p rtn %x\n",742 __FUNCTION__, scmd, rtn));···839 if (scmd->device->allow_restart) {840 int rtn;841842+ rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,843+ START_UNIT_TIMEOUT, 0);844 if (rtn == SUCCESS)845 return 0;846 }
+10-5
drivers/scsi/scsi_transport_iscsi.c
···34#define ISCSI_SESSION_ATTRS 1135#define ISCSI_CONN_ATTRS 1136#define ISCSI_HOST_ATTRS 003738struct iscsi_internal {39 int daemon_pid;···635}636637static int638-iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb)639{640 unsigned long flags;641 int rc;642643 skb_get(skb);644- rc = netlink_broadcast(nls, skb, 0, 1, GFP_KERNEL);645 if (rc < 0) {646 mempool_free(skb, zone->pool);647 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);···750 ev->r.connerror.cid = conn->cid;751 ev->r.connerror.sid = iscsi_conn_get_sid(conn);752753- iscsi_broadcast_skb(conn->z_error, skb);754755 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",756 error);···896 * this will occur if the daemon is not up, so we just warn897 * the user and when the daemon is restarted it will handle it898 */899- rc = iscsi_broadcast_skb(conn->z_pdu, skb);900 if (rc < 0)901 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "902 "session destruction event. Check iscsi daemon\n");···959 * this will occur if the daemon is not up, so we just warn960 * the user and when the daemon is restarted it will handle it961 */962- rc = iscsi_broadcast_skb(conn->z_pdu, skb);963 if (rc < 0)964 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "965 "session creation event. Check iscsi daemon\n");···1614{1615 int err;16160001617 err = class_register(&iscsi_transport_class);1618 if (err)1619 return err;···1682 "Alex Aizman <itn780@yahoo.com>");1683MODULE_DESCRIPTION("iSCSI Transport Interface");1684MODULE_LICENSE("GPL");0
···34#define ISCSI_SESSION_ATTRS 1135#define ISCSI_CONN_ATTRS 1136#define ISCSI_HOST_ATTRS 037+#define ISCSI_TRANSPORT_VERSION "1.1-646"3839struct iscsi_internal {40 int daemon_pid;···634}635636static int637+iscsi_broadcast_skb(struct mempool_zone *zone, struct sk_buff *skb, gfp_t gfp)638{639 unsigned long flags;640 int rc;641642 skb_get(skb);643+ rc = netlink_broadcast(nls, skb, 0, 1, gfp);644 if (rc < 0) {645 mempool_free(skb, zone->pool);646 printk(KERN_ERR "iscsi: can not broadcast skb (%d)\n", rc);···749 ev->r.connerror.cid = conn->cid;750 ev->r.connerror.sid = iscsi_conn_get_sid(conn);751752+ iscsi_broadcast_skb(conn->z_error, skb, GFP_ATOMIC);753754 dev_printk(KERN_INFO, &conn->dev, "iscsi: detected conn error (%d)\n",755 error);···895 * this will occur if the daemon is not up, so we just warn896 * the user and when the daemon is restarted it will handle it897 */898+ rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL);899 if (rc < 0)900 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "901 "session destruction event. Check iscsi daemon\n");···958 * this will occur if the daemon is not up, so we just warn959 * the user and when the daemon is restarted it will handle it960 */961+ rc = iscsi_broadcast_skb(conn->z_pdu, skb, GFP_KERNEL);962 if (rc < 0)963 dev_printk(KERN_ERR, &conn->dev, "Cannot notify userspace of "964 "session creation event. Check iscsi daemon\n");···1613{1614 int err;16151616+ printk(KERN_INFO "Loading iSCSI transport class v%s.",1617+ ISCSI_TRANSPORT_VERSION);1618+1619 err = class_register(&iscsi_transport_class);1620 if (err)1621 return err;···1678 "Alex Aizman <itn780@yahoo.com>");1679MODULE_DESCRIPTION("iSCSI Transport Interface");1680MODULE_LICENSE("GPL");1681+MODULE_VERSION(ISCSI_TRANSPORT_VERSION);
+4-4
drivers/scsi/sg.c
···18 *19 */2021-static int sg_version_num = 30533; /* 2 digits for each component */22-#define SG_VERSION_STR "3.5.33"2324/*25 * D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au), notes:···6061#ifdef CONFIG_SCSI_PROC_FS62#include <linux/proc_fs.h>63-static char *sg_version_date = "20050908";6465static int sg_proc_init(void);66static void sg_proc_cleanup(void);···1164 len = vma->vm_end - sa;1165 len = (len < sg->length) ? len : sg->length;1166 if (offset < len) {1167- page = sg->page;1168 get_page(page); /* increment page count */1169 break;1170 }
···18 *19 */2021+static int sg_version_num = 30534; /* 2 digits for each component */22+#define SG_VERSION_STR "3.5.34"2324/*25 * D. P. Gilbert (dgilbert@interlog.com, dougg@triode.net.au), notes:···6061#ifdef CONFIG_SCSI_PROC_FS62#include <linux/proc_fs.h>63+static char *sg_version_date = "20060818";6465static int sg_proc_init(void);66static void sg_proc_cleanup(void);···1164 len = vma->vm_end - sa;1165 len = (len < sg->length) ? len : sg->length;1166 if (offset < len) {1167+ page = virt_to_page(page_address(sg->page) + offset);1168 get_page(page); /* increment page count */1169 break;1170 }
···60#define TMABORT_SUCCESS 0x161#define TMABORT_FAILED 0x262#define TMABORT_TIMEDOUT 0x306364/* Connection suspend "bit" */65#define ISCSI_SUSPEND_BIT 1···84 struct list_head running;85};8600000087struct iscsi_cmd_task {88 /*89 * Becuae LLDs allocate their hdr differently, this is a pointer to···108 struct iscsi_conn *conn; /* used connection */109 struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */11000111 struct list_head running; /* running cmd list */112 void *dd_data; /* driver/transport data */113};···135 int id; /* CID */136 struct list_head item; /* maintains list of conns */137 int c_stage; /* connection state */00000000138 struct iscsi_mgmt_task *login_mtask; /* mtask used for login/text */139 struct iscsi_mgmt_task *mtask; /* xmit mtask in progress */140 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */···151 struct kfifo *immqueue; /* immediate xmit queue */152 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */153 struct list_head mgmt_run_list; /* list of control tasks */154- struct kfifo *xmitqueue; /* data-path cmd queue */155 struct list_head run_list; /* list of cmds in progress */156 struct work_struct xmitwork; /* per-conn. xmit workqueue */157 /*
···60#define TMABORT_SUCCESS 0x161#define TMABORT_FAILED 0x262#define TMABORT_TIMEDOUT 0x363+#define TMABORT_NOT_FOUND 0x46465/* Connection suspend "bit" */66#define ISCSI_SUSPEND_BIT 1···83 struct list_head running;84};8586+enum {87+ ISCSI_TASK_COMPLETED,88+ ISCSI_TASK_PENDING,89+ ISCSI_TASK_RUNNING,90+};91+92struct iscsi_cmd_task {93 /*94 * Becuae LLDs allocate their hdr differently, this is a pointer to···101 struct iscsi_conn *conn; /* used connection */102 struct iscsi_mgmt_task *mtask; /* tmf mtask in progr */103104+ /* state set/tested under session->lock */105+ int state;106 struct list_head running; /* running cmd list */107 void *dd_data; /* driver/transport data */108};···126 int id; /* CID */127 struct list_head item; /* maintains list of conns */128 int c_stage; /* connection state */129+ /*130+ * Preallocated buffer for pdus that have data but do not131+ * originate from scsi-ml. We never have two pdus using the132+ * buffer at the same time. It is only allocated to133+ * the default max recv size because the pdus we support134+ * should always fit in this buffer135+ */136+ char *data;137 struct iscsi_mgmt_task *login_mtask; /* mtask used for login/text */138 struct iscsi_mgmt_task *mtask; /* xmit mtask in progress */139 struct iscsi_cmd_task *ctask; /* xmit ctask in progress */···134 struct kfifo *immqueue; /* immediate xmit queue */135 struct kfifo *mgmtqueue; /* mgmt (control) xmit queue */136 struct list_head mgmt_run_list; /* list of control tasks */137+ struct list_head xmitqueue; /* data-path cmd queue */138 struct list_head run_list; /* list of cmds in progress */139 struct work_struct xmitwork; /* per-conn. xmit workqueue */140 /*
-4
include/scsi/scsi_transport_iscsi.h
···57 * @stop_conn: suspend/recover/terminate connection58 * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text.59 * @session_recovery_timedout: notify LLD a block during recovery timed out60- * @suspend_conn_recv: susepend the recv side of the connection61- * @termincate_conn: destroy socket connection. Called with mutex lock.62 * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs.63 * Called from queuecommand with session lock held.64 * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs.···110 char *data, uint32_t data_size);111 void (*get_stats) (struct iscsi_cls_conn *conn,112 struct iscsi_stats *stats);113- void (*suspend_conn_recv) (struct iscsi_conn *conn);114- void (*terminate_conn) (struct iscsi_conn *conn);115 void (*init_cmd_task) (struct iscsi_cmd_task *ctask);116 void (*init_mgmt_task) (struct iscsi_conn *conn,117 struct iscsi_mgmt_task *mtask,
···57 * @stop_conn: suspend/recover/terminate connection58 * @send_pdu: send iSCSI PDU, Login, Logout, NOP-Out, Reject, Text.59 * @session_recovery_timedout: notify LLD a block during recovery timed out0060 * @init_cmd_task: Initialize a iscsi_cmd_task and any internal structs.61 * Called from queuecommand with session lock held.62 * @init_mgmt_task: Initialize a iscsi_mgmt_task and any internal structs.···112 char *data, uint32_t data_size);113 void (*get_stats) (struct iscsi_cls_conn *conn,114 struct iscsi_stats *stats);00115 void (*init_cmd_task) (struct iscsi_cmd_task *ctask);116 void (*init_mgmt_task) (struct iscsi_conn *conn,117 struct iscsi_mgmt_task *mtask,