aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_file.c
diff options
context:
space:
mode:
authorAndy Grover <agrover@redhat.com>2011-07-19 04:55:10 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2011-07-22 05:37:43 -0400
commite3d6f909ed803d92a5ac9b4a2c087e0eae9b90d0 (patch)
tree2eb65e958a2cc35c896a0e184ec09edcb9076b3b /drivers/target/target_core_file.c
parenta8c6da90b823fb94ca76ca0df6bb44e6e205dc87 (diff)
target: Core cleanups from AGrover (round 1)
This patch contains the squashed version of a number of cleanups and minor fixes from Andy's initial series (round 1) for target core this past spring. The condensed log looks like: target: use errno values instead of returning -1 for everything target: Rename transport_calc_sg_num to transport_init_task_sg target: Fix leak in error path in transport_init_task_sg target/pscsi: Remove pscsi_get_sh() usage target: Make two runtime checks into WARN_ONs target: Remove hba queue depth and convert to spin_lock_irq usage target: dev->dev_status_queue_obj is unused target: Make struct se_queue_req.cmd type struct se_cmd * target: Remove __transport_get_qr_from_queue() target: Rename se_dev->g_se_dev_list to se_dev_node target: Remove struct se_global target: Simplify scsi mib index table code target: Make dev_queue_obj a member of se_device instead of a pointer target: remove extraneous returns at end of void functions target: Ensure transport_dump_vpd_ident_type returns null-terminated str target: Function pointers don't need to use '&' to be assigned target: Fix comment in __transport_execute_tasks() target: Misc style cleanups target: rename struct pr_reservation_template to pr_reservation target: Remove #defines that just perform indirection target: Inline transport_get_task_from_execute_queue() target: Minor header comment fixes Signed-off-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_file.c')
-rw-r--r--drivers/target/target_core_file.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
index 150c4305f385..0c44bc051484 100644
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -67,22 +67,19 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id)
67 fd_host = kzalloc(sizeof(struct fd_host), GFP_KERNEL); 67 fd_host = kzalloc(sizeof(struct fd_host), GFP_KERNEL);
68 if (!(fd_host)) { 68 if (!(fd_host)) {
69 printk(KERN_ERR "Unable to allocate memory for struct fd_host\n"); 69 printk(KERN_ERR "Unable to allocate memory for struct fd_host\n");
70 return -1; 70 return -ENOMEM;
71 } 71 }
72 72
73 fd_host->fd_host_id = host_id; 73 fd_host->fd_host_id = host_id;
74 74
75 atomic_set(&hba->left_queue_depth, FD_HBA_QUEUE_DEPTH); 75 hba->hba_ptr = fd_host;
76 atomic_set(&hba->max_queue_depth, FD_HBA_QUEUE_DEPTH);
77 hba->hba_ptr = (void *) fd_host;
78 76
79 printk(KERN_INFO "CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic" 77 printk(KERN_INFO "CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic"
80 " Target Core Stack %s\n", hba->hba_id, FD_VERSION, 78 " Target Core Stack %s\n", hba->hba_id, FD_VERSION,
81 TARGET_CORE_MOD_VERSION); 79 TARGET_CORE_MOD_VERSION);
82 printk(KERN_INFO "CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic" 80 printk(KERN_INFO "CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic"
83 " Target Core with TCQ Depth: %d MaxSectors: %u\n", 81 " MaxSectors: %u\n",
84 hba->hba_id, fd_host->fd_host_id, 82 hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS);
85 atomic_read(&hba->max_queue_depth), FD_MAX_SECTORS);
86 83
87 return 0; 84 return 0;
88} 85}
@@ -282,7 +279,7 @@ fd_alloc_task(struct se_cmd *cmd)
282 return NULL; 279 return NULL;
283 } 280 }
284 281
285 fd_req->fd_dev = SE_DEV(cmd)->dev_ptr; 282 fd_req->fd_dev = cmd->se_lun->lun_se_dev->dev_ptr;
286 283
287 return &fd_req->fd_task; 284 return &fd_req->fd_task;
288} 285}
@@ -294,13 +291,14 @@ static int fd_do_readv(struct se_task *task)
294 struct scatterlist *sg = task->task_sg; 291 struct scatterlist *sg = task->task_sg;
295 struct iovec *iov; 292 struct iovec *iov;
296 mm_segment_t old_fs; 293 mm_segment_t old_fs;
297 loff_t pos = (task->task_lba * DEV_ATTRIB(task->se_dev)->block_size); 294 loff_t pos = (task->task_lba *
295 task->se_dev->se_sub_dev->se_dev_attrib.block_size);
298 int ret = 0, i; 296 int ret = 0, i;
299 297
300 iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL); 298 iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
301 if (!(iov)) { 299 if (!(iov)) {
302 printk(KERN_ERR "Unable to allocate fd_do_readv iov[]\n"); 300 printk(KERN_ERR "Unable to allocate fd_do_readv iov[]\n");
303 return -1; 301 return -ENOMEM;
304 } 302 }
305 303
306 for (i = 0; i < task->task_sg_num; i++) { 304 for (i = 0; i < task->task_sg_num; i++) {
@@ -324,13 +322,13 @@ static int fd_do_readv(struct se_task *task)
324 printk(KERN_ERR "vfs_readv() returned %d," 322 printk(KERN_ERR "vfs_readv() returned %d,"
325 " expecting %d for S_ISBLK\n", ret, 323 " expecting %d for S_ISBLK\n", ret,
326 (int)task->task_size); 324 (int)task->task_size);
327 return -1; 325 return (ret < 0 ? ret : -EINVAL);
328 } 326 }
329 } else { 327 } else {
330 if (ret < 0) { 328 if (ret < 0) {
331 printk(KERN_ERR "vfs_readv() returned %d for non" 329 printk(KERN_ERR "vfs_readv() returned %d for non"
332 " S_ISBLK\n", ret); 330 " S_ISBLK\n", ret);
333 return -1; 331 return ret;
334 } 332 }
335 } 333 }
336 334
@@ -344,13 +342,14 @@ static int fd_do_writev(struct se_task *task)
344 struct scatterlist *sg = task->task_sg; 342 struct scatterlist *sg = task->task_sg;
345 struct iovec *iov; 343 struct iovec *iov;
346 mm_segment_t old_fs; 344 mm_segment_t old_fs;
347 loff_t pos = (task->task_lba * DEV_ATTRIB(task->se_dev)->block_size); 345 loff_t pos = (task->task_lba *
346 task->se_dev->se_sub_dev->se_dev_attrib.block_size);
348 int ret, i = 0; 347 int ret, i = 0;
349 348
350 iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL); 349 iov = kzalloc(sizeof(struct iovec) * task->task_sg_num, GFP_KERNEL);
351 if (!(iov)) { 350 if (!(iov)) {
352 printk(KERN_ERR "Unable to allocate fd_do_writev iov[]\n"); 351 printk(KERN_ERR "Unable to allocate fd_do_writev iov[]\n");
353 return -1; 352 return -ENOMEM;
354 } 353 }
355 354
356 for (i = 0; i < task->task_sg_num; i++) { 355 for (i = 0; i < task->task_sg_num; i++) {
@@ -367,7 +366,7 @@ static int fd_do_writev(struct se_task *task)
367 366
368 if (ret < 0 || ret != task->task_size) { 367 if (ret < 0 || ret != task->task_size) {
369 printk(KERN_ERR "vfs_writev() returned %d\n", ret); 368 printk(KERN_ERR "vfs_writev() returned %d\n", ret);
370 return -1; 369 return (ret < 0 ? ret : -EINVAL);
371 } 370 }
372 371
373 return 1; 372 return 1;
@@ -375,7 +374,7 @@ static int fd_do_writev(struct se_task *task)
375 374
376static void fd_emulate_sync_cache(struct se_task *task) 375static void fd_emulate_sync_cache(struct se_task *task)
377{ 376{
378 struct se_cmd *cmd = TASK_CMD(task); 377 struct se_cmd *cmd = task->task_se_cmd;
379 struct se_device *dev = cmd->se_dev; 378 struct se_device *dev = cmd->se_dev;
380 struct fd_dev *fd_dev = dev->dev_ptr; 379 struct fd_dev *fd_dev = dev->dev_ptr;
381 int immed = (cmd->t_task->t_task_cdb[1] & 0x2); 380 int immed = (cmd->t_task->t_task_cdb[1] & 0x2);
@@ -396,7 +395,7 @@ static void fd_emulate_sync_cache(struct se_task *task)
396 start = 0; 395 start = 0;
397 end = LLONG_MAX; 396 end = LLONG_MAX;
398 } else { 397 } else {
399 start = cmd->t_task->t_task_lba * DEV_ATTRIB(dev)->block_size; 398 start = cmd->t_task->t_task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
400 if (cmd->data_length) 399 if (cmd->data_length)
401 end = start + cmd->data_length; 400 end = start + cmd->data_length;
402 else 401 else
@@ -446,7 +445,7 @@ static void fd_emulate_write_fua(struct se_cmd *cmd, struct se_task *task)
446{ 445{
447 struct se_device *dev = cmd->se_dev; 446 struct se_device *dev = cmd->se_dev;
448 struct fd_dev *fd_dev = dev->dev_ptr; 447 struct fd_dev *fd_dev = dev->dev_ptr;
449 loff_t start = task->task_lba * DEV_ATTRIB(dev)->block_size; 448 loff_t start = task->task_lba * dev->se_sub_dev->se_dev_attrib.block_size;
450 loff_t end = start + task->task_size; 449 loff_t end = start + task->task_size;
451 int ret; 450 int ret;
452 451
@@ -474,9 +473,9 @@ static int fd_do_task(struct se_task *task)
474 ret = fd_do_writev(task); 473 ret = fd_do_writev(task);
475 474
476 if (ret > 0 && 475 if (ret > 0 &&
477 DEV_ATTRIB(dev)->emulate_write_cache > 0 && 476 dev->se_sub_dev->se_dev_attrib.emulate_write_cache > 0 &&
478 DEV_ATTRIB(dev)->emulate_fua_write > 0 && 477 dev->se_sub_dev->se_dev_attrib.emulate_fua_write > 0 &&
479 T_TASK(cmd)->t_tasks_fua) { 478 cmd->t_task->t_tasks_fua) {
480 /* 479 /*
481 * We might need to be a bit smarter here 480 * We might need to be a bit smarter here
482 * and return some sense data to let the initiator 481 * and return some sense data to let the initiator
@@ -599,7 +598,7 @@ static ssize_t fd_check_configfs_dev_params(struct se_hba *hba, struct se_subsys
599 598
600 if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) { 599 if (!(fd_dev->fbd_flags & FBDF_HAS_PATH)) {
601 printk(KERN_ERR "Missing fd_dev_name=\n"); 600 printk(KERN_ERR "Missing fd_dev_name=\n");
602 return -1; 601 return -EINVAL;
603 } 602 }
604 603
605 return 0; 604 return 0;
@@ -654,7 +653,7 @@ static sector_t fd_get_blocks(struct se_device *dev)
654{ 653{
655 struct fd_dev *fd_dev = dev->dev_ptr; 654 struct fd_dev *fd_dev = dev->dev_ptr;
656 unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size, 655 unsigned long long blocks_long = div_u64(fd_dev->fd_dev_size,
657 DEV_ATTRIB(dev)->block_size); 656 dev->se_sub_dev->se_dev_attrib.block_size);
658 657
659 return blocks_long; 658 return blocks_long;
660} 659}