ctl_backend_block.c (287499) | ctl_backend_block.c (287500) |
---|---|
1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * All rights reserved. 6 * 7 * Portions of this software were developed by Edward Tomasz Napierala 8 * under sponsorship from the FreeBSD Foundation. --- 26 unchanged lines hidden (view full) --- 35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 36 */ 37/* 38 * CAM Target Layer driver backend for block devices. 39 * 40 * Author: Ken Merry <ken@FreeBSD.org> 41 */ 42#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * All rights reserved. 6 * 7 * Portions of this software were developed by Edward Tomasz Napierala 8 * under sponsorship from the FreeBSD Foundation. --- 26 unchanged lines hidden (view full) --- 35 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 36 */ 37/* 38 * CAM Target Layer driver backend for block devices. 39 * 40 * Author: Ken Merry <ken@FreeBSD.org> 41 */ 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 287499 2015-09-06 09:54:56Z mav $"); | 43__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 287500 2015-09-06 11:23:01Z mav $"); |
44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/kernel.h> 48#include <sys/types.h> 49#include <sys/kthread.h> 50#include <sys/bio.h> 51#include <sys/fcntl.h> --- 2366 unchanged lines hidden (view full) --- 2418{ 2419 struct ctl_lun_rm_params *params; 2420 struct ctl_be_block_lun *be_lun; 2421 int retval; 2422 2423 params = &req->reqdata.rm; 2424 2425 mtx_lock(&softc->lock); | 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/kernel.h> 48#include <sys/types.h> 49#include <sys/kthread.h> 50#include <sys/bio.h> 51#include <sys/fcntl.h> --- 2366 unchanged lines hidden (view full) --- 2418{ 2419 struct ctl_lun_rm_params *params; 2420 struct ctl_be_block_lun *be_lun; 2421 int retval; 2422 2423 params = &req->reqdata.rm; 2424 2425 mtx_lock(&softc->lock); |
2426 2427 be_lun = NULL; 2428 | |
2429 STAILQ_FOREACH(be_lun, &softc->lun_list, links) { 2430 if (be_lun->cbe_lun.lun_id == params->lun_id) 2431 break; 2432 } 2433 mtx_unlock(&softc->lock); 2434 2435 if (be_lun == NULL) { 2436 snprintf(req->error_str, sizeof(req->error_str), --- 147 unchanged lines hidden (view full) --- 2584 return (0); 2585} 2586 2587static int 2588ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) 2589{ 2590 struct ctl_lun_modify_params *params; 2591 struct ctl_be_block_lun *be_lun; | 2426 STAILQ_FOREACH(be_lun, &softc->lun_list, links) { 2427 if (be_lun->cbe_lun.lun_id == params->lun_id) 2428 break; 2429 } 2430 mtx_unlock(&softc->lock); 2431 2432 if (be_lun == NULL) { 2433 snprintf(req->error_str, sizeof(req->error_str), --- 147 unchanged lines hidden (view full) --- 2581 return (0); 2582} 2583 2584static int 2585ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) 2586{ 2587 struct ctl_lun_modify_params *params; 2588 struct ctl_be_block_lun *be_lun; |
2589 struct ctl_be_lun *cbe_lun; |
|
2592 uint64_t oldsize; 2593 int error; 2594 2595 params = &req->reqdata.modify; 2596 2597 mtx_lock(&softc->lock); | 2590 uint64_t oldsize; 2591 int error; 2592 2593 params = &req->reqdata.modify; 2594 2595 mtx_lock(&softc->lock); |
2598 be_lun = NULL; | |
2599 STAILQ_FOREACH(be_lun, &softc->lun_list, links) { 2600 if (be_lun->cbe_lun.lun_id == params->lun_id) 2601 break; 2602 } 2603 mtx_unlock(&softc->lock); 2604 2605 if (be_lun == NULL) { 2606 snprintf(req->error_str, sizeof(req->error_str), 2607 "LUN %u is not managed by the block backend", 2608 params->lun_id); 2609 goto bailout_error; 2610 } | 2596 STAILQ_FOREACH(be_lun, &softc->lun_list, links) { 2597 if (be_lun->cbe_lun.lun_id == params->lun_id) 2598 break; 2599 } 2600 mtx_unlock(&softc->lock); 2601 2602 if (be_lun == NULL) { 2603 snprintf(req->error_str, sizeof(req->error_str), 2604 "LUN %u is not managed by the block backend", 2605 params->lun_id); 2606 goto bailout_error; 2607 } |
2608 cbe_lun = &be_lun->cbe_lun; |
|
2611 | 2609 |
2612 be_lun->params.lun_size_bytes = params->lun_size_bytes; | 2610 if (params->lun_size_bytes != 0) 2611 be_lun->params.lun_size_bytes = params->lun_size_bytes; 2612 ctl_update_opts(&cbe_lun->options, req->num_be_args, req->kern_be_args); |
2613 2614 oldsize = be_lun->size_blocks; 2615 if (be_lun->vn == NULL) 2616 error = ctl_be_block_open(softc, be_lun, req); 2617 else if (vn_isdisk(be_lun->vn, &error)) 2618 error = ctl_be_block_modify_dev(be_lun, req); 2619 else if (be_lun->vn->v_type == VREG) 2620 error = ctl_be_block_modify_file(be_lun, req); 2621 else 2622 error = EINVAL; 2623 2624 if (be_lun->size_blocks != oldsize) | 2613 2614 oldsize = be_lun->size_blocks; 2615 if (be_lun->vn == NULL) 2616 error = ctl_be_block_open(softc, be_lun, req); 2617 else if (vn_isdisk(be_lun->vn, &error)) 2618 error = ctl_be_block_modify_dev(be_lun, req); 2619 else if (be_lun->vn->v_type == VREG) 2620 error = ctl_be_block_modify_file(be_lun, req); 2621 else 2622 error = EINVAL; 2623 2624 if (be_lun->size_blocks != oldsize) |
2625 ctl_lun_capacity_changed(&be_lun->cbe_lun); 2626 if ((be_lun->cbe_lun.flags & CTL_LUN_FLAG_OFFLINE) && | 2625 ctl_lun_capacity_changed(cbe_lun); 2626 if ((cbe_lun->flags & CTL_LUN_FLAG_OFFLINE) && |
2627 be_lun->vn != NULL) { | 2627 be_lun->vn != NULL) { |
2628 be_lun->cbe_lun.flags &= ~CTL_LUN_FLAG_OFFLINE; 2629 ctl_lun_online(&be_lun->cbe_lun); | 2628 cbe_lun->flags &= ~CTL_LUN_FLAG_OFFLINE; 2629 ctl_lun_online(cbe_lun); |
2630 } 2631 2632 /* Tell the user the exact size we ended up using */ 2633 params->lun_size_bytes = be_lun->size_bytes; 2634 2635 req->status = error ? CTL_LUN_WARNING : CTL_LUN_OK; 2636 return (0); 2637 --- 239 unchanged lines hidden --- | 2630 } 2631 2632 /* Tell the user the exact size we ended up using */ 2633 params->lun_size_bytes = be_lun->size_bytes; 2634 2635 req->status = error ? CTL_LUN_WARNING : CTL_LUN_OK; 2636 return (0); 2637 --- 239 unchanged lines hidden --- |