cam_xpt.c (190677) | cam_xpt.c (190878) |
---|---|
1/*- 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 190677 2009-04-03 19:49:33Z thompsa $"); | 31__FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 190878 2009-04-10 04:08:34Z thompsa $"); |
32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/systm.h> 36#include <sys/types.h> 37#include <sys/malloc.h> 38#include <sys/kernel.h> 39#include <sys/time.h> --- 5094 unchanged lines hidden (view full) --- 5134 } 5135 } 5136 return (device); 5137} 5138 5139typedef struct { 5140 union ccb *request_ccb; 5141 struct ccb_pathinq *cpi; | 32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/systm.h> 36#include <sys/types.h> 37#include <sys/malloc.h> 38#include <sys/kernel.h> 39#include <sys/time.h> --- 5094 unchanged lines hidden (view full) --- 5134 } 5135 } 5136 return (device); 5137} 5138 5139typedef struct { 5140 union ccb *request_ccb; 5141 struct ccb_pathinq *cpi; |
5142 struct root_hold_token *roothold; | |
5143 int counter; 5144} xpt_scan_bus_info; 5145 5146/* 5147 * To start a scan, request_ccb is an XPT_SCAN_BUS ccb. 5148 * As the scan progresses, xpt_scan_bus is used as the 5149 * callback on completion function. 5150 */ --- 46 unchanged lines hidden (view full) --- 5197 malloc(sizeof(xpt_scan_bus_info), M_CAMXPT, M_NOWAIT); 5198 if (scan_info == NULL) { 5199 request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 5200 xpt_done(request_ccb); 5201 return; 5202 } 5203 scan_info->request_ccb = request_ccb; 5204 scan_info->cpi = &work_ccb->cpi; | 5142 int counter; 5143} xpt_scan_bus_info; 5144 5145/* 5146 * To start a scan, request_ccb is an XPT_SCAN_BUS ccb. 5147 * As the scan progresses, xpt_scan_bus is used as the 5148 * callback on completion function. 5149 */ --- 46 unchanged lines hidden (view full) --- 5196 malloc(sizeof(xpt_scan_bus_info), M_CAMXPT, M_NOWAIT); 5197 if (scan_info == NULL) { 5198 request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 5199 xpt_done(request_ccb); 5200 return; 5201 } 5202 scan_info->request_ccb = request_ccb; 5203 scan_info->cpi = &work_ccb->cpi; |
5205 scan_info->roothold = root_mount_hold("CAM", M_NOWAIT); | |
5206 5207 /* Cache on our stack so we can work asynchronously */ 5208 max_target = scan_info->cpi->max_target; 5209 initiator_id = scan_info->cpi->initiator_id; 5210 5211 5212 /* 5213 * We can scan all targets in parallel, or do it sequentially. --- 15 unchanged lines hidden (view full) --- 5229 5230 status = xpt_create_path(&path, xpt_periph, 5231 request_ccb->ccb_h.path_id, 5232 i, 0); 5233 if (status != CAM_REQ_CMP) { 5234 printf("xpt_scan_bus: xpt_create_path failed" 5235 " with status %#x, bus scan halted\n", 5236 status); | 5204 5205 /* Cache on our stack so we can work asynchronously */ 5206 max_target = scan_info->cpi->max_target; 5207 initiator_id = scan_info->cpi->initiator_id; 5208 5209 5210 /* 5211 * We can scan all targets in parallel, or do it sequentially. --- 15 unchanged lines hidden (view full) --- 5227 5228 status = xpt_create_path(&path, xpt_periph, 5229 request_ccb->ccb_h.path_id, 5230 i, 0); 5231 if (status != CAM_REQ_CMP) { 5232 printf("xpt_scan_bus: xpt_create_path failed" 5233 " with status %#x, bus scan halted\n", 5234 status); |
5237 root_mount_rel(scan_info->roothold); | |
5238 free(scan_info, M_CAMXPT); 5239 request_ccb->ccb_h.status = status; 5240 xpt_free_ccb(work_ccb); 5241 xpt_done(request_ccb); 5242 break; 5243 } 5244 work_ccb = xpt_alloc_ccb_nowait(); 5245 if (work_ccb == NULL) { | 5235 free(scan_info, M_CAMXPT); 5236 request_ccb->ccb_h.status = status; 5237 xpt_free_ccb(work_ccb); 5238 xpt_done(request_ccb); 5239 break; 5240 } 5241 work_ccb = xpt_alloc_ccb_nowait(); 5242 if (work_ccb == NULL) { |
5246 root_mount_rel(scan_info->roothold); | |
5247 free(scan_info, M_CAMXPT); 5248 xpt_free_path(path); 5249 request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 5250 xpt_done(request_ccb); 5251 break; 5252 } 5253 xpt_setup_ccb(&work_ccb->ccb_h, path, 5254 request_ccb->ccb_h.pinfo.priority); --- 97 unchanged lines hidden (view full) --- 5352 if (scan_info->counter == 0) { 5353 done = 1; 5354 } 5355 } 5356 if (done) { 5357 xpt_free_ccb(request_ccb); 5358 xpt_free_ccb((union ccb *)scan_info->cpi); 5359 request_ccb = scan_info->request_ccb; | 5243 free(scan_info, M_CAMXPT); 5244 xpt_free_path(path); 5245 request_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 5246 xpt_done(request_ccb); 5247 break; 5248 } 5249 xpt_setup_ccb(&work_ccb->ccb_h, path, 5250 request_ccb->ccb_h.pinfo.priority); --- 97 unchanged lines hidden (view full) --- 5348 if (scan_info->counter == 0) { 5349 done = 1; 5350 } 5351 } 5352 if (done) { 5353 xpt_free_ccb(request_ccb); 5354 xpt_free_ccb((union ccb *)scan_info->cpi); 5355 request_ccb = scan_info->request_ccb; |
5360 root_mount_rel(scan_info->roothold); | |
5361 free(scan_info, M_CAMXPT); 5362 request_ccb->ccb_h.status = CAM_REQ_CMP; 5363 xpt_done(request_ccb); 5364 break; 5365 } 5366 5367 if ((scan_info->cpi->hba_misc & PIM_SEQSCAN) == 0) { 5368 break; 5369 } 5370 status = xpt_create_path(&path, xpt_periph, 5371 scan_info->request_ccb->ccb_h.path_id, 5372 scan_info->counter, 0); 5373 if (status != CAM_REQ_CMP) { 5374 printf("xpt_scan_bus: xpt_create_path failed" 5375 " with status %#x, bus scan halted\n", 5376 status); 5377 xpt_free_ccb(request_ccb); 5378 xpt_free_ccb((union ccb *)scan_info->cpi); 5379 request_ccb = scan_info->request_ccb; | 5356 free(scan_info, M_CAMXPT); 5357 request_ccb->ccb_h.status = CAM_REQ_CMP; 5358 xpt_done(request_ccb); 5359 break; 5360 } 5361 5362 if ((scan_info->cpi->hba_misc & PIM_SEQSCAN) == 0) { 5363 break; 5364 } 5365 status = xpt_create_path(&path, xpt_periph, 5366 scan_info->request_ccb->ccb_h.path_id, 5367 scan_info->counter, 0); 5368 if (status != CAM_REQ_CMP) { 5369 printf("xpt_scan_bus: xpt_create_path failed" 5370 " with status %#x, bus scan halted\n", 5371 status); 5372 xpt_free_ccb(request_ccb); 5373 xpt_free_ccb((union ccb *)scan_info->cpi); 5374 request_ccb = scan_info->request_ccb; |
5380 root_mount_rel(scan_info->roothold); | |
5381 free(scan_info, M_CAMXPT); 5382 request_ccb->ccb_h.status = status; 5383 xpt_done(request_ccb); 5384 break; 5385 } 5386 xpt_setup_ccb(&request_ccb->ccb_h, path, 5387 request_ccb->ccb_h.pinfo.priority); 5388 request_ccb->ccb_h.func_code = XPT_SCAN_LUN; --- 1940 unchanged lines hidden --- | 5375 free(scan_info, M_CAMXPT); 5376 request_ccb->ccb_h.status = status; 5377 xpt_done(request_ccb); 5378 break; 5379 } 5380 xpt_setup_ccb(&request_ccb->ccb_h, path, 5381 request_ccb->ccb_h.pinfo.priority); 5382 request_ccb->ccb_h.func_code = XPT_SCAN_LUN; --- 1940 unchanged lines hidden --- |