diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 13:52:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-10 13:52:45 -0400 |
commit | e26feff647ef34423b048b940540a0059001ddb0 (patch) | |
tree | acafe68602ee2f6f1a438c113073ffcc0040e949 /drivers | |
parent | d403a6484f0341bf0624d17ece46f24f741b6a92 (diff) | |
parent | b911e473d24633c19414b54b82b9ff0b1a2419d7 (diff) |
Merge branch 'for-2.6.28' of git://git.kernel.dk/linux-2.6-block
* 'for-2.6.28' of git://git.kernel.dk/linux-2.6-block: (132 commits)
doc/cdrom: Trvial documentation error, file not present
block_dev: fix kernel-doc in new functions
block: add some comments around the bio read-write flags
block: mark bio_split_pool static
block: Find bio sector offset given idx and offset
block: gendisk integrity wrapper
block: Switch blk_integrity_compare from bdev to gendisk
block: Fix double put in blk_integrity_unregister
block: Introduce integrity data ownership flag
block: revert part of d7533ad0e132f92e75c1b2eb7c26387b25a583c1
bio.h: Remove unused conditional code
block: remove end_{queued|dequeued}_request()
block: change elevator to use __blk_end_request()
gdrom: change to use __blk_end_request()
memstick: change to use __blk_end_request()
virtio_blk: change to use __blk_end_request()
blktrace: use BLKTRACE_BDEV_SIZE as the name size for setup structure
block: add lld busy state exporting interface
block: Fix blk_start_queueing() to not kick a stopped queue
include blktrace_api.h in headers_install
...
Diffstat (limited to 'drivers')
70 files changed, 902 insertions, 1092 deletions
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index f2dd99122bd6..a93247cc395a 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
@@ -33,6 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
36 | #include <linux/blkdev.h> | ||
36 | #include <linux/pci.h> | 37 | #include <linux/pci.h> |
37 | #include <scsi/scsi.h> | 38 | #include <scsi/scsi.h> |
38 | #include <scsi/scsi_host.h> | 39 | #include <scsi/scsi_host.h> |
@@ -459,29 +460,29 @@ static void ata_eh_clear_action(struct ata_link *link, struct ata_device *dev, | |||
459 | * RETURNS: | 460 | * RETURNS: |
460 | * EH_HANDLED or EH_NOT_HANDLED | 461 | * EH_HANDLED or EH_NOT_HANDLED |
461 | */ | 462 | */ |
462 | enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) | 463 | enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd) |
463 | { | 464 | { |
464 | struct Scsi_Host *host = cmd->device->host; | 465 | struct Scsi_Host *host = cmd->device->host; |
465 | struct ata_port *ap = ata_shost_to_port(host); | 466 | struct ata_port *ap = ata_shost_to_port(host); |
466 | unsigned long flags; | 467 | unsigned long flags; |
467 | struct ata_queued_cmd *qc; | 468 | struct ata_queued_cmd *qc; |
468 | enum scsi_eh_timer_return ret; | 469 | enum blk_eh_timer_return ret; |
469 | 470 | ||
470 | DPRINTK("ENTER\n"); | 471 | DPRINTK("ENTER\n"); |
471 | 472 | ||
472 | if (ap->ops->error_handler) { | 473 | if (ap->ops->error_handler) { |
473 | ret = EH_NOT_HANDLED; | 474 | ret = BLK_EH_NOT_HANDLED; |
474 | goto out; | 475 | goto out; |
475 | } | 476 | } |
476 | 477 | ||
477 | ret = EH_HANDLED; | 478 | ret = BLK_EH_HANDLED; |
478 | spin_lock_irqsave(ap->lock, flags); | 479 | spin_lock_irqsave(ap->lock, flags); |
479 | qc = ata_qc_from_tag(ap, ap->link.active_tag); | 480 | qc = ata_qc_from_tag(ap, ap->link.active_tag); |
480 | if (qc) { | 481 | if (qc) { |
481 | WARN_ON(qc->scsicmd != cmd); | 482 | WARN_ON(qc->scsicmd != cmd); |
482 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; | 483 | qc->flags |= ATA_QCFLAG_EH_SCHEDULED; |
483 | qc->err_mask |= AC_ERR_TIMEOUT; | 484 | qc->err_mask |= AC_ERR_TIMEOUT; |
484 | ret = EH_NOT_HANDLED; | 485 | ret = BLK_EH_NOT_HANDLED; |
485 | } | 486 | } |
486 | spin_unlock_irqrestore(ap->lock, flags); | 487 | spin_unlock_irqrestore(ap->lock, flags); |
487 | 488 | ||
@@ -833,7 +834,7 @@ void ata_qc_schedule_eh(struct ata_queued_cmd *qc) | |||
833 | * Note that ATA_QCFLAG_FAILED is unconditionally set after | 834 | * Note that ATA_QCFLAG_FAILED is unconditionally set after |
834 | * this function completes. | 835 | * this function completes. |
835 | */ | 836 | */ |
836 | scsi_req_abort_cmd(qc->scsicmd); | 837 | blk_abort_request(qc->scsicmd->request); |
837 | } | 838 | } |
838 | 839 | ||
839 | /** | 840 | /** |
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index fccd5e496c62..59fe051957ef 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
@@ -1085,6 +1085,10 @@ static int ata_scsi_dev_config(struct scsi_device *sdev, | |||
1085 | 1085 | ||
1086 | blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); | 1086 | blk_queue_dma_drain(q, atapi_drain_needed, buf, ATAPI_MAX_DRAIN); |
1087 | } else { | 1087 | } else { |
1088 | if (ata_id_is_ssd(dev->id)) | ||
1089 | queue_flag_set_unlocked(QUEUE_FLAG_NONROT, | ||
1090 | sdev->request_queue); | ||
1091 | |||
1088 | /* ATA devices must be sector aligned */ | 1092 | /* ATA devices must be sector aligned */ |
1089 | blk_queue_update_dma_alignment(sdev->request_queue, | 1093 | blk_queue_update_dma_alignment(sdev->request_queue, |
1090 | ATA_SECT_SIZE - 1); | 1094 | ATA_SECT_SIZE - 1); |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index e96de96e3020..fe2839e58774 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
@@ -155,7 +155,7 @@ extern int ata_bus_probe(struct ata_port *ap); | |||
155 | /* libata-eh.c */ | 155 | /* libata-eh.c */ |
156 | extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd); | 156 | extern unsigned long ata_internal_cmd_timeout(struct ata_device *dev, u8 cmd); |
157 | extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd); | 157 | extern void ata_internal_cmd_timed_out(struct ata_device *dev, u8 cmd); |
158 | extern enum scsi_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); | 158 | extern enum blk_eh_timer_return ata_scsi_timed_out(struct scsi_cmnd *cmd); |
159 | extern void ata_scsi_error(struct Scsi_Host *host); | 159 | extern void ata_scsi_error(struct Scsi_Host *host); |
160 | extern void ata_port_wait_eh(struct ata_port *ap); | 160 | extern void ata_port_wait_eh(struct ata_port *ap); |
161 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); | 161 | extern void ata_eh_fastdrain_timerfn(unsigned long arg); |
diff --git a/drivers/base/base.h b/drivers/base/base.h index 31dc0cd84afa..0a5f055dffba 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h | |||
@@ -54,7 +54,7 @@ struct driver_private { | |||
54 | */ | 54 | */ |
55 | struct class_private { | 55 | struct class_private { |
56 | struct kset class_subsys; | 56 | struct kset class_subsys; |
57 | struct list_head class_devices; | 57 | struct klist class_devices; |
58 | struct list_head class_interfaces; | 58 | struct list_head class_interfaces; |
59 | struct kset class_dirs; | 59 | struct kset class_dirs; |
60 | struct mutex class_mutex; | 60 | struct mutex class_mutex; |
diff --git a/drivers/base/class.c b/drivers/base/class.c index cc5e28c8885c..eb85e4312301 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -135,6 +135,20 @@ static void remove_class_attrs(struct class *cls) | |||
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | static void klist_class_dev_get(struct klist_node *n) | ||
139 | { | ||
140 | struct device *dev = container_of(n, struct device, knode_class); | ||
141 | |||
142 | get_device(dev); | ||
143 | } | ||
144 | |||
145 | static void klist_class_dev_put(struct klist_node *n) | ||
146 | { | ||
147 | struct device *dev = container_of(n, struct device, knode_class); | ||
148 | |||
149 | put_device(dev); | ||
150 | } | ||
151 | |||
138 | int __class_register(struct class *cls, struct lock_class_key *key) | 152 | int __class_register(struct class *cls, struct lock_class_key *key) |
139 | { | 153 | { |
140 | struct class_private *cp; | 154 | struct class_private *cp; |
@@ -145,7 +159,7 @@ int __class_register(struct class *cls, struct lock_class_key *key) | |||
145 | cp = kzalloc(sizeof(*cp), GFP_KERNEL); | 159 | cp = kzalloc(sizeof(*cp), GFP_KERNEL); |
146 | if (!cp) | 160 | if (!cp) |
147 | return -ENOMEM; | 161 | return -ENOMEM; |
148 | INIT_LIST_HEAD(&cp->class_devices); | 162 | klist_init(&cp->class_devices, klist_class_dev_get, klist_class_dev_put); |
149 | INIT_LIST_HEAD(&cp->class_interfaces); | 163 | INIT_LIST_HEAD(&cp->class_interfaces); |
150 | kset_init(&cp->class_dirs); | 164 | kset_init(&cp->class_dirs); |
151 | __mutex_init(&cp->class_mutex, "struct class mutex", key); | 165 | __mutex_init(&cp->class_mutex, "struct class mutex", key); |
@@ -269,6 +283,71 @@ char *make_class_name(const char *name, struct kobject *kobj) | |||
269 | #endif | 283 | #endif |
270 | 284 | ||
271 | /** | 285 | /** |
286 | * class_dev_iter_init - initialize class device iterator | ||
287 | * @iter: class iterator to initialize | ||
288 | * @class: the class we wanna iterate over | ||
289 | * @start: the device to start iterating from, if any | ||
290 | * @type: device_type of the devices to iterate over, NULL for all | ||
291 | * | ||
292 | * Initialize class iterator @iter such that it iterates over devices | ||
293 | * of @class. If @start is set, the list iteration will start there, | ||
294 | * otherwise if it is NULL, the iteration starts at the beginning of | ||
295 | * the list. | ||
296 | */ | ||
297 | void class_dev_iter_init(struct class_dev_iter *iter, struct class *class, | ||
298 | struct device *start, const struct device_type *type) | ||
299 | { | ||
300 | struct klist_node *start_knode = NULL; | ||
301 | |||
302 | if (start) | ||
303 | start_knode = &start->knode_class; | ||
304 | klist_iter_init_node(&class->p->class_devices, &iter->ki, start_knode); | ||
305 | iter->type = type; | ||
306 | } | ||
307 | EXPORT_SYMBOL_GPL(class_dev_iter_init); | ||
308 | |||
309 | /** | ||
310 | * class_dev_iter_next - iterate to the next device | ||
311 | * @iter: class iterator to proceed | ||
312 | * | ||
313 | * Proceed @iter to the next device and return it. Returns NULL if | ||
314 | * iteration is complete. | ||
315 | * | ||
316 | * The returned device is referenced and won't be released till | ||
317 | * iterator is proceed to the next device or exited. The caller is | ||
318 | * free to do whatever it wants to do with the device including | ||
319 | * calling back into class code. | ||
320 | */ | ||
321 | struct device *class_dev_iter_next(struct class_dev_iter *iter) | ||
322 | { | ||
323 | struct klist_node *knode; | ||
324 | struct device *dev; | ||
325 | |||
326 | while (1) { | ||
327 | knode = klist_next(&iter->ki); | ||
328 | if (!knode) | ||
329 | return NULL; | ||
330 | dev = container_of(knode, struct device, knode_class); | ||
331 | if (!iter->type || iter->type == dev->type) | ||
332 | return dev; | ||
333 | } | ||
334 | } | ||
335 | EXPORT_SYMBOL_GPL(class_dev_iter_next); | ||
336 | |||
337 | /** | ||
338 | * class_dev_iter_exit - finish iteration | ||
339 | * @iter: class iterator to finish | ||
340 | * | ||
341 | * Finish an iteration. Always call this function after iteration is | ||
342 | * complete whether the iteration ran till the end or not. | ||
343 | */ | ||
344 | void class_dev_iter_exit(struct class_dev_iter *iter) | ||
345 | { | ||
346 | klist_iter_exit(&iter->ki); | ||
347 | } | ||
348 | EXPORT_SYMBOL_GPL(class_dev_iter_exit); | ||
349 | |||
350 | /** | ||
272 | * class_for_each_device - device iterator | 351 | * class_for_each_device - device iterator |
273 | * @class: the class we're iterating | 352 | * @class: the class we're iterating |
274 | * @start: the device to start with in the list, if any. | 353 | * @start: the device to start with in the list, if any. |
@@ -283,13 +362,13 @@ char *make_class_name(const char *name, struct kobject *kobj) | |||
283 | * We check the return of @fn each time. If it returns anything | 362 | * We check the return of @fn each time. If it returns anything |
284 | * other than 0, we break out and return that value. | 363 | * other than 0, we break out and return that value. |
285 | * | 364 | * |
286 | * Note, we hold class->class_mutex in this function, so it can not be | 365 | * @fn is allowed to do anything including calling back into class |
287 | * re-acquired in @fn, otherwise it will self-deadlocking. For | 366 | * code. There's no locking restriction. |
288 | * example, calls to add or remove class members would be verboten. | ||
289 | */ | 367 | */ |
290 | int class_for_each_device(struct class *class, struct device *start, | 368 | int class_for_each_device(struct class *class, struct device *start, |
291 | void *data, int (*fn)(struct device *, void *)) | 369 | void *data, int (*fn)(struct device *, void *)) |
292 | { | 370 | { |
371 | struct class_dev_iter iter; | ||
293 | struct device *dev; | 372 | struct device *dev; |
294 | int error = 0; | 373 | int error = 0; |
295 | 374 | ||
@@ -301,20 +380,13 @@ int class_for_each_device(struct class *class, struct device *start, | |||
301 | return -EINVAL; | 380 | return -EINVAL; |
302 | } | 381 | } |
303 | 382 | ||
304 | mutex_lock(&class->p->class_mutex); | 383 | class_dev_iter_init(&iter, class, start, NULL); |
305 | list_for_each_entry(dev, &class->p->class_devices, node) { | 384 | while ((dev = class_dev_iter_next(&iter))) { |
306 | if (start) { | ||
307 | if (start == dev) | ||
308 | start = NULL; | ||
309 | continue; | ||
310 | } | ||
311 | dev = get_device(dev); | ||
312 | error = fn(dev, data); | 385 | error = fn(dev, data); |
313 | put_device(dev); | ||
314 | if (error) | 386 | if (error) |
315 | break; | 387 | break; |
316 | } | 388 | } |
317 | mutex_unlock(&class->p->class_mutex); | 389 | class_dev_iter_exit(&iter); |
318 | 390 | ||
319 | return error; | 391 | return error; |
320 | } | 392 | } |
@@ -337,16 +409,15 @@ EXPORT_SYMBOL_GPL(class_for_each_device); | |||
337 | * | 409 | * |
338 | * Note, you will need to drop the reference with put_device() after use. | 410 | * Note, you will need to drop the reference with put_device() after use. |
339 | * | 411 | * |
340 | * We hold class->class_mutex in this function, so it can not be | 412 | * @fn is allowed to do anything including calling back into class |
341 | * re-acquired in @match, otherwise it will self-deadlocking. For | 413 | * code. There's no locking restriction. |
342 | * example, calls to add or remove class members would be verboten. | ||
343 | */ | 414 | */ |
344 | struct device *class_find_device(struct class *class, struct device *start, | 415 | struct device *class_find_device(struct class *class, struct device *start, |
345 | void *data, | 416 | void *data, |
346 | int (*match)(struct device *, void *)) | 417 | int (*match)(struct device *, void *)) |
347 | { | 418 | { |
419 | struct class_dev_iter iter; | ||
348 | struct device *dev; | 420 | struct device *dev; |
349 | int found = 0; | ||
350 | 421 | ||
351 | if (!class) | 422 | if (!class) |
352 | return NULL; | 423 | return NULL; |
@@ -356,29 +427,23 @@ struct device *class_find_device(struct class *class, struct device *start, | |||
356 | return NULL; | 427 | return NULL; |
357 | } | 428 | } |
358 | 429 | ||
359 | mutex_lock(&class->p->class_mutex); | 430 | class_dev_iter_init(&iter, class, start, NULL); |
360 | list_for_each_entry(dev, &class->p->class_devices, node) { | 431 | while ((dev = class_dev_iter_next(&iter))) { |
361 | if (start) { | ||
362 | if (start == dev) | ||
363 | start = NULL; | ||
364 | continue; | ||
365 | } | ||
366 | dev = get_device(dev); | ||
367 | if (match(dev, data)) { | 432 | if (match(dev, data)) { |
368 | found = 1; | 433 | get_device(dev); |
369 | break; | 434 | break; |
370 | } else | 435 | } |
371 | put_device(dev); | ||
372 | } | 436 | } |
373 | mutex_unlock(&class->p->class_mutex); | 437 | class_dev_iter_exit(&iter); |
374 | 438 | ||
375 | return found ? dev : NULL; | 439 | return dev; |
376 | } | 440 | } |
377 | EXPORT_SYMBOL_GPL(class_find_device); | 441 | EXPORT_SYMBOL_GPL(class_find_device); |
378 | 442 | ||
379 | int class_interface_register(struct class_interface *class_intf) | 443 | int class_interface_register(struct class_interface *class_intf) |
380 | { | 444 | { |
381 | struct class *parent; | 445 | struct class *parent; |
446 | struct class_dev_iter iter; | ||
382 | struct device *dev; | 447 | struct device *dev; |
383 | 448 | ||
384 | if (!class_intf || !class_intf->class) | 449 | if (!class_intf || !class_intf->class) |
@@ -391,8 +456,10 @@ int class_interface_register(struct class_interface *class_intf) | |||
391 | mutex_lock(&parent->p->class_mutex); | 456 | mutex_lock(&parent->p->class_mutex); |
392 | list_add_tail(&class_intf->node, &parent->p->class_interfaces); | 457 | list_add_tail(&class_intf->node, &parent->p->class_interfaces); |
393 | if (class_intf->add_dev) { | 458 | if (class_intf->add_dev) { |
394 | list_for_each_entry(dev, &parent->p->class_devices, node) | 459 | class_dev_iter_init(&iter, parent, NULL, NULL); |
460 | while ((dev = class_dev_iter_next(&iter))) | ||
395 | class_intf->add_dev(dev, class_intf); | 461 | class_intf->add_dev(dev, class_intf); |
462 | class_dev_iter_exit(&iter); | ||
396 | } | 463 | } |
397 | mutex_unlock(&parent->p->class_mutex); | 464 | mutex_unlock(&parent->p->class_mutex); |
398 | 465 | ||
@@ -402,6 +469,7 @@ int class_interface_register(struct class_interface *class_intf) | |||
402 | void class_interface_unregister(struct class_interface *class_intf) | 469 | void class_interface_unregister(struct class_interface *class_intf) |
403 | { | 470 | { |
404 | struct class *parent = class_intf->class; | 471 | struct class *parent = class_intf->class; |
472 | struct class_dev_iter iter; | ||
405 | struct device *dev; | 473 | struct device *dev; |
406 | 474 | ||
407 | if (!parent) | 475 | if (!parent) |
@@ -410,8 +478,10 @@ void class_interface_unregister(struct class_interface *class_intf) | |||
410 | mutex_lock(&parent->p->class_mutex); | 478 | mutex_lock(&parent->p->class_mutex); |
411 | list_del_init(&class_intf->node); | 479 | list_del_init(&class_intf->node); |
412 | if (class_intf->remove_dev) { | 480 | if (class_intf->remove_dev) { |
413 | list_for_each_entry(dev, &parent->p->class_devices, node) | 481 | class_dev_iter_init(&iter, parent, NULL, NULL); |
482 | while ((dev = class_dev_iter_next(&iter))) | ||
414 | class_intf->remove_dev(dev, class_intf); | 483 | class_intf->remove_dev(dev, class_intf); |
484 | class_dev_iter_exit(&iter); | ||
415 | } | 485 | } |
416 | mutex_unlock(&parent->p->class_mutex); | 486 | mutex_unlock(&parent->p->class_mutex); |
417 | 487 | ||
diff --git a/drivers/base/core.c b/drivers/base/core.c index d021c98605b3..b98cb1416a2d 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c | |||
@@ -536,7 +536,6 @@ void device_initialize(struct device *dev) | |||
536 | klist_init(&dev->klist_children, klist_children_get, | 536 | klist_init(&dev->klist_children, klist_children_get, |
537 | klist_children_put); | 537 | klist_children_put); |
538 | INIT_LIST_HEAD(&dev->dma_pools); | 538 | INIT_LIST_HEAD(&dev->dma_pools); |
539 | INIT_LIST_HEAD(&dev->node); | ||
540 | init_MUTEX(&dev->sem); | 539 | init_MUTEX(&dev->sem); |
541 | spin_lock_init(&dev->devres_lock); | 540 | spin_lock_init(&dev->devres_lock); |
542 | INIT_LIST_HEAD(&dev->devres_head); | 541 | INIT_LIST_HEAD(&dev->devres_head); |
@@ -916,7 +915,8 @@ int device_add(struct device *dev) | |||
916 | if (dev->class) { | 915 | if (dev->class) { |
917 | mutex_lock(&dev->class->p->class_mutex); | 916 | mutex_lock(&dev->class->p->class_mutex); |
918 | /* tie the class to the device */ | 917 | /* tie the class to the device */ |
919 | list_add_tail(&dev->node, &dev->class->p->class_devices); | 918 | klist_add_tail(&dev->knode_class, |
919 | &dev->class->p->class_devices); | ||
920 | 920 | ||
921 | /* notify any interfaces that the device is here */ | 921 | /* notify any interfaces that the device is here */ |
922 | list_for_each_entry(class_intf, | 922 | list_for_each_entry(class_intf, |
@@ -1032,7 +1032,7 @@ void device_del(struct device *dev) | |||
1032 | if (class_intf->remove_dev) | 1032 | if (class_intf->remove_dev) |
1033 | class_intf->remove_dev(dev, class_intf); | 1033 | class_intf->remove_dev(dev, class_intf); |
1034 | /* remove the device from the class list */ | 1034 | /* remove the device from the class list */ |
1035 | list_del_init(&dev->node); | 1035 | klist_del(&dev->knode_class); |
1036 | mutex_unlock(&dev->class->p->class_mutex); | 1036 | mutex_unlock(&dev->class->p->class_mutex); |
1037 | } | 1037 | } |
1038 | device_remove_file(dev, &uevent_attr); | 1038 | device_remove_file(dev, &uevent_attr); |
diff --git a/drivers/block/aoe/aoeblk.c b/drivers/block/aoe/aoeblk.c index 0c39782b2660..aa69556c3485 100644 --- a/drivers/block/aoe/aoeblk.c +++ b/drivers/block/aoe/aoeblk.c | |||
@@ -109,12 +109,12 @@ static const struct attribute_group attr_group = { | |||
109 | static int | 109 | static int |
110 | aoedisk_add_sysfs(struct aoedev *d) | 110 | aoedisk_add_sysfs(struct aoedev *d) |
111 | { | 111 | { |
112 | return sysfs_create_group(&d->gd->dev.kobj, &attr_group); | 112 | return sysfs_create_group(&disk_to_dev(d->gd)->kobj, &attr_group); |
113 | } | 113 | } |
114 | void | 114 | void |
115 | aoedisk_rm_sysfs(struct aoedev *d) | 115 | aoedisk_rm_sysfs(struct aoedev *d) |
116 | { | 116 | { |
117 | sysfs_remove_group(&d->gd->dev.kobj, &attr_group); | 117 | sysfs_remove_group(&disk_to_dev(d->gd)->kobj, &attr_group); |
118 | } | 118 | } |
119 | 119 | ||
120 | static int | 120 | static int |
@@ -276,7 +276,7 @@ aoeblk_gdalloc(void *vp) | |||
276 | gd->first_minor = d->sysminor * AOE_PARTITIONS; | 276 | gd->first_minor = d->sysminor * AOE_PARTITIONS; |
277 | gd->fops = &aoe_bdops; | 277 | gd->fops = &aoe_bdops; |
278 | gd->private_data = d; | 278 | gd->private_data = d; |
279 | gd->capacity = d->ssize; | 279 | set_capacity(gd, d->ssize); |
280 | snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d", | 280 | snprintf(gd->disk_name, sizeof gd->disk_name, "etherd/e%ld.%d", |
281 | d->aoemajor, d->aoeminor); | 281 | d->aoemajor, d->aoeminor); |
282 | 282 | ||
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index 2f1746295d06..961d29a53cab 100644 --- a/drivers/block/aoe/aoecmd.c +++ b/drivers/block/aoe/aoecmd.c | |||
@@ -645,7 +645,7 @@ aoecmd_sleepwork(struct work_struct *work) | |||
645 | unsigned long flags; | 645 | unsigned long flags; |
646 | u64 ssize; | 646 | u64 ssize; |
647 | 647 | ||
648 | ssize = d->gd->capacity; | 648 | ssize = get_capacity(d->gd); |
649 | bd = bdget_disk(d->gd, 0); | 649 | bd = bdget_disk(d->gd, 0); |
650 | 650 | ||
651 | if (bd) { | 651 | if (bd) { |
@@ -707,7 +707,7 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id) | |||
707 | if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) | 707 | if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE)) |
708 | return; | 708 | return; |
709 | if (d->gd != NULL) { | 709 | if (d->gd != NULL) { |
710 | d->gd->capacity = ssize; | 710 | set_capacity(d->gd, ssize); |
711 | d->flags |= DEVFL_NEWSIZE; | 711 | d->flags |= DEVFL_NEWSIZE; |
712 | } else | 712 | } else |
713 | d->flags |= DEVFL_GDALLOC; | 713 | d->flags |= DEVFL_GDALLOC; |
@@ -756,12 +756,17 @@ diskstats(struct gendisk *disk, struct bio *bio, ulong duration, sector_t sector | |||
756 | unsigned long n_sect = bio->bi_size >> 9; | 756 | unsigned long n_sect = bio->bi_size >> 9; |
757 | const int rw = bio_data_dir(bio); | 757 | const int rw = bio_data_dir(bio); |
758 | struct hd_struct *part; | 758 | struct hd_struct *part; |
759 | int cpu; | ||
759 | 760 | ||
760 | part = get_part(disk, sector); | 761 | cpu = part_stat_lock(); |
761 | all_stat_inc(disk, part, ios[rw], sector); | 762 | part = disk_map_sector_rcu(disk, sector); |
762 | all_stat_add(disk, part, ticks[rw], duration, sector); | 763 | |
763 | all_stat_add(disk, part, sectors[rw], n_sect, sector); | 764 | part_stat_inc(cpu, part, ios[rw]); |
764 | all_stat_add(disk, part, io_ticks, duration, sector); | 765 | part_stat_add(cpu, part, ticks[rw], duration); |
766 | part_stat_add(cpu, part, sectors[rw], n_sect); | ||
767 | part_stat_add(cpu, part, io_ticks, duration); | ||
768 | |||
769 | part_stat_unlock(); | ||
765 | } | 770 | } |
766 | 771 | ||
767 | void | 772 | void |
diff --git a/drivers/block/aoe/aoedev.c b/drivers/block/aoe/aoedev.c index a1d813ab0d6b..6a8038d115b5 100644 --- a/drivers/block/aoe/aoedev.c +++ b/drivers/block/aoe/aoedev.c | |||
@@ -91,7 +91,7 @@ aoedev_downdev(struct aoedev *d) | |||
91 | } | 91 | } |
92 | 92 | ||
93 | if (d->gd) | 93 | if (d->gd) |
94 | d->gd->capacity = 0; | 94 | set_capacity(d->gd, 0); |
95 | 95 | ||
96 | d->flags &= ~DEVFL_UP; | 96 | d->flags &= ~DEVFL_UP; |
97 | } | 97 | } |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index b73116ef9236..1e1f9153000c 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -3460,8 +3460,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
3460 | hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); | 3460 | hba[i]->intr[SIMPLE_MODE_INT], dac ? "" : " not"); |
3461 | 3461 | ||
3462 | hba[i]->cmd_pool_bits = | 3462 | hba[i]->cmd_pool_bits = |
3463 | kmalloc(((hba[i]->nr_cmds + BITS_PER_LONG - | 3463 | kmalloc(DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG) |
3464 | 1) / BITS_PER_LONG) * sizeof(unsigned long), GFP_KERNEL); | 3464 | * sizeof(unsigned long), GFP_KERNEL); |
3465 | hba[i]->cmd_pool = (CommandList_struct *) | 3465 | hba[i]->cmd_pool = (CommandList_struct *) |
3466 | pci_alloc_consistent(hba[i]->pdev, | 3466 | pci_alloc_consistent(hba[i]->pdev, |
3467 | hba[i]->nr_cmds * sizeof(CommandList_struct), | 3467 | hba[i]->nr_cmds * sizeof(CommandList_struct), |
@@ -3493,8 +3493,8 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, | |||
3493 | /* command and error info recs zeroed out before | 3493 | /* command and error info recs zeroed out before |
3494 | they are used */ | 3494 | they are used */ |
3495 | memset(hba[i]->cmd_pool_bits, 0, | 3495 | memset(hba[i]->cmd_pool_bits, 0, |
3496 | ((hba[i]->nr_cmds + BITS_PER_LONG - | 3496 | DIV_ROUND_UP(hba[i]->nr_cmds, BITS_PER_LONG) |
3497 | 1) / BITS_PER_LONG) * sizeof(unsigned long)); | 3497 | * sizeof(unsigned long)); |
3498 | 3498 | ||
3499 | hba[i]->num_luns = 0; | 3499 | hba[i]->num_luns = 0; |
3500 | hba[i]->highest_lun = -1; | 3500 | hba[i]->highest_lun = -1; |
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c index e1233aabda77..a3fd87b41444 100644 --- a/drivers/block/cciss_scsi.c +++ b/drivers/block/cciss_scsi.c | |||
@@ -365,7 +365,7 @@ struct scsi2map { | |||
365 | 365 | ||
366 | static int | 366 | static int |
367 | cciss_scsi_add_entry(int ctlr, int hostno, | 367 | cciss_scsi_add_entry(int ctlr, int hostno, |
368 | unsigned char *scsi3addr, int devtype, | 368 | struct cciss_scsi_dev_t *device, |
369 | struct scsi2map *added, int *nadded) | 369 | struct scsi2map *added, int *nadded) |
370 | { | 370 | { |
371 | /* assumes hba[ctlr]->scsi_ctlr->lock is held */ | 371 | /* assumes hba[ctlr]->scsi_ctlr->lock is held */ |
@@ -384,12 +384,12 @@ cciss_scsi_add_entry(int ctlr, int hostno, | |||
384 | lun = 0; | 384 | lun = 0; |
385 | /* Is this device a non-zero lun of a multi-lun device */ | 385 | /* Is this device a non-zero lun of a multi-lun device */ |
386 | /* byte 4 of the 8-byte LUN addr will contain the logical unit no. */ | 386 | /* byte 4 of the 8-byte LUN addr will contain the logical unit no. */ |
387 | if (scsi3addr[4] != 0) { | 387 | if (device->scsi3addr[4] != 0) { |
388 | /* Search through our list and find the device which */ | 388 | /* Search through our list and find the device which */ |
389 | /* has the same 8 byte LUN address, excepting byte 4. */ | 389 | /* has the same 8 byte LUN address, excepting byte 4. */ |
390 | /* Assign the same bus and target for this new LUN. */ | 390 | /* Assign the same bus and target for this new LUN. */ |
391 | /* Use the logical unit number from the firmware. */ | 391 | /* Use the logical unit number from the firmware. */ |
392 | memcpy(addr1, scsi3addr, 8); | 392 | memcpy(addr1, device->scsi3addr, 8); |
393 | addr1[4] = 0; | 393 | addr1[4] = 0; |
394 | for (i = 0; i < n; i++) { | 394 | for (i = 0; i < n; i++) { |
395 | sd = &ccissscsi[ctlr].dev[i]; | 395 | sd = &ccissscsi[ctlr].dev[i]; |
@@ -399,7 +399,7 @@ cciss_scsi_add_entry(int ctlr, int hostno, | |||
399 | if (memcmp(addr1, addr2, 8) == 0) { | 399 | if (memcmp(addr1, addr2, 8) == 0) { |
400 | bus = sd->bus; | 400 | bus = sd->bus; |
401 | target = sd->target; | 401 | target = sd->target; |
402 | lun = scsi3addr[4]; | 402 | lun = device->scsi3addr[4]; |
403 | break; | 403 | break; |
404 | } | 404 | } |
405 | } | 405 | } |
@@ -420,8 +420,12 @@ cciss_scsi_add_entry(int ctlr, int hostno, | |||
420 | added[*nadded].lun = sd->lun; | 420 | added[*nadded].lun = sd->lun; |
421 | (*nadded)++; | 421 | (*nadded)++; |
422 | 422 | ||
423 | memcpy(&sd->scsi3addr[0], scsi3addr, 8); | 423 | memcpy(sd->scsi3addr, device->scsi3addr, 8); |
424 | sd->devtype = devtype; | 424 | memcpy(sd->vendor, device->vendor, sizeof(sd->vendor)); |
425 | memcpy(sd->revision, device->revision, sizeof(sd->revision)); | ||
426 | memcpy(sd->device_id, device->device_id, sizeof(sd->device_id)); | ||
427 | sd->devtype = device->devtype; | ||
428 | |||
425 | ccissscsi[ctlr].ndevices++; | 429 | ccissscsi[ctlr].ndevices++; |
426 | 430 | ||
427 | /* initially, (before registering with scsi layer) we don't | 431 | /* initially, (before registering with scsi layer) we don't |
@@ -487,6 +491,22 @@ static void fixup_botched_add(int ctlr, char *scsi3addr) | |||
487 | CPQ_TAPE_UNLOCK(ctlr, flags); | 491 | CPQ_TAPE_UNLOCK(ctlr, flags); |
488 | } | 492 | } |
489 | 493 | ||
494 | static int device_is_the_same(struct cciss_scsi_dev_t *dev1, | ||
495 | struct cciss_scsi_dev_t *dev2) | ||
496 | { | ||
497 | return dev1->devtype == dev2->devtype && | ||
498 | memcmp(dev1->scsi3addr, dev2->scsi3addr, | ||
499 | sizeof(dev1->scsi3addr)) == 0 && | ||
500 | memcmp(dev1->device_id, dev2->device_id, | ||
501 | sizeof(dev1->device_id)) == 0 && | ||
502 | memcmp(dev1->vendor, dev2->vendor, | ||
503 | sizeof(dev1->vendor)) == 0 && | ||
504 | memcmp(dev1->model, dev2->model, | ||
505 | sizeof(dev1->model)) == 0 && | ||
506 | memcmp(dev1->revision, dev2->revision, | ||
507 | sizeof(dev1->revision)) == 0; | ||
508 | } | ||
509 | |||
490 | static int | 510 | static int |
491 | adjust_cciss_scsi_table(int ctlr, int hostno, | 511 | adjust_cciss_scsi_table(int ctlr, int hostno, |
492 | struct cciss_scsi_dev_t sd[], int nsds) | 512 | struct cciss_scsi_dev_t sd[], int nsds) |
@@ -532,7 +552,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno, | |||
532 | for (j=0;j<nsds;j++) { | 552 | for (j=0;j<nsds;j++) { |
533 | if (SCSI3ADDR_EQ(sd[j].scsi3addr, | 553 | if (SCSI3ADDR_EQ(sd[j].scsi3addr, |
534 | csd->scsi3addr)) { | 554 | csd->scsi3addr)) { |
535 | if (sd[j].devtype == csd->devtype) | 555 | if (device_is_the_same(&sd[j], csd)) |
536 | found=2; | 556 | found=2; |
537 | else | 557 | else |
538 | found=1; | 558 | found=1; |
@@ -548,22 +568,26 @@ adjust_cciss_scsi_table(int ctlr, int hostno, | |||
548 | cciss_scsi_remove_entry(ctlr, hostno, i, | 568 | cciss_scsi_remove_entry(ctlr, hostno, i, |
549 | removed, &nremoved); | 569 | removed, &nremoved); |
550 | /* remove ^^^, hence i not incremented */ | 570 | /* remove ^^^, hence i not incremented */ |
551 | } | 571 | } else if (found == 1) { /* device is different in some way */ |
552 | else if (found == 1) { /* device is different kind */ | ||
553 | changes++; | 572 | changes++; |
554 | printk("cciss%d: device c%db%dt%dl%d type changed " | 573 | printk("cciss%d: device c%db%dt%dl%d has changed.\n", |
555 | "(device type now %s).\n", | 574 | ctlr, hostno, csd->bus, csd->target, csd->lun); |
556 | ctlr, hostno, csd->bus, csd->target, csd->lun, | ||
557 | scsi_device_type(csd->devtype)); | ||
558 | cciss_scsi_remove_entry(ctlr, hostno, i, | 575 | cciss_scsi_remove_entry(ctlr, hostno, i, |
559 | removed, &nremoved); | 576 | removed, &nremoved); |
560 | /* remove ^^^, hence i not incremented */ | 577 | /* remove ^^^, hence i not incremented */ |
561 | if (cciss_scsi_add_entry(ctlr, hostno, | 578 | if (cciss_scsi_add_entry(ctlr, hostno, &sd[j], |
562 | &sd[j].scsi3addr[0], sd[j].devtype, | ||
563 | added, &nadded) != 0) | 579 | added, &nadded) != 0) |
564 | /* we just removed one, so add can't fail. */ | 580 | /* we just removed one, so add can't fail. */ |
565 | BUG(); | 581 | BUG(); |
566 | csd->devtype = sd[j].devtype; | 582 | csd->devtype = sd[j].devtype; |
583 | memcpy(csd->device_id, sd[j].device_id, | ||
584 | sizeof(csd->device_id)); | ||
585 | memcpy(csd->vendor, sd[j].vendor, | ||
586 | sizeof(csd->vendor)); | ||
587 | memcpy(csd->model, sd[j].model, | ||
588 | sizeof(csd->model)); | ||
589 | memcpy(csd->revision, sd[j].revision, | ||
590 | sizeof(csd->revision)); | ||
567 | } else /* device is same as it ever was, */ | 591 | } else /* device is same as it ever was, */ |
568 | i++; /* so just move along. */ | 592 | i++; /* so just move along. */ |
569 | } | 593 | } |
@@ -577,7 +601,7 @@ adjust_cciss_scsi_table(int ctlr, int hostno, | |||
577 | csd = &ccissscsi[ctlr].dev[j]; | 601 | csd = &ccissscsi[ctlr].dev[j]; |
578 | if (SCSI3ADDR_EQ(sd[i].scsi3addr, | 602 | if (SCSI3ADDR_EQ(sd[i].scsi3addr, |
579 | csd->scsi3addr)) { | 603 | csd->scsi3addr)) { |
580 | if (sd[i].devtype == csd->devtype) | 604 | if (device_is_the_same(&sd[i], csd)) |
581 | found=2; /* found device */ | 605 | found=2; /* found device */ |
582 | else | 606 | else |
583 | found=1; /* found a bug. */ | 607 | found=1; /* found a bug. */ |
@@ -586,16 +610,14 @@ adjust_cciss_scsi_table(int ctlr, int hostno, | |||
586 | } | 610 | } |
587 | if (!found) { | 611 | if (!found) { |
588 | changes++; | 612 | changes++; |
589 | if (cciss_scsi_add_entry(ctlr, hostno, | 613 | if (cciss_scsi_add_entry(ctlr, hostno, &sd[i], |
590 | |||
591 | &sd[i].scsi3addr[0], sd[i].devtype, | ||
592 | added, &nadded) != 0) | 614 | added, &nadded) != 0) |
593 | break; | 615 | break; |
594 | } else if (found == 1) { | 616 | } else if (found == 1) { |
595 | /* should never happen... */ | 617 | /* should never happen... */ |
596 | changes++; | 618 | changes++; |
597 | printk("cciss%d: device unexpectedly changed type\n", | 619 | printk(KERN_WARNING "cciss%d: device " |
598 | ctlr); | 620 | "unexpectedly changed\n", ctlr); |
599 | /* but if it does happen, we just ignore that device */ | 621 | /* but if it does happen, we just ignore that device */ |
600 | } | 622 | } |
601 | } | 623 | } |
@@ -1012,7 +1034,8 @@ cciss_scsi_interpret_error(CommandList_struct *cp) | |||
1012 | 1034 | ||
1013 | static int | 1035 | static int |
1014 | cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, | 1036 | cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, |
1015 | unsigned char *buf, unsigned char bufsize) | 1037 | unsigned char page, unsigned char *buf, |
1038 | unsigned char bufsize) | ||
1016 | { | 1039 | { |
1017 | int rc; | 1040 | int rc; |
1018 | CommandList_struct *cp; | 1041 | CommandList_struct *cp; |
@@ -1032,8 +1055,8 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, | |||
1032 | ei = cp->err_info; | 1055 | ei = cp->err_info; |
1033 | 1056 | ||
1034 | cdb[0] = CISS_INQUIRY; | 1057 | cdb[0] = CISS_INQUIRY; |
1035 | cdb[1] = 0; | 1058 | cdb[1] = (page != 0); |
1036 | cdb[2] = 0; | 1059 | cdb[2] = page; |
1037 | cdb[3] = 0; | 1060 | cdb[3] = 0; |
1038 | cdb[4] = bufsize; | 1061 | cdb[4] = bufsize; |
1039 | cdb[5] = 0; | 1062 | cdb[5] = 0; |
@@ -1053,6 +1076,25 @@ cciss_scsi_do_inquiry(ctlr_info_t *c, unsigned char *scsi3addr, | |||
1053 | return rc; | 1076 | return rc; |
1054 | } | 1077 | } |
1055 | 1078 | ||
1079 | /* Get the device id from inquiry page 0x83 */ | ||
1080 | static int cciss_scsi_get_device_id(ctlr_info_t *c, unsigned char *scsi3addr, | ||
1081 | unsigned char *device_id, int buflen) | ||
1082 | { | ||
1083 | int rc; | ||
1084 | unsigned char *buf; | ||
1085 | |||
1086 | if (buflen > 16) | ||
1087 | buflen = 16; | ||
1088 | buf = kzalloc(64, GFP_KERNEL); | ||
1089 | if (!buf) | ||
1090 | return -1; | ||
1091 | rc = cciss_scsi_do_inquiry(c, scsi3addr, 0x83, buf, 64); | ||
1092 | if (rc == 0) | ||
1093 | memcpy(device_id, &buf[8], buflen); | ||
1094 | kfree(buf); | ||
1095 | return rc != 0; | ||
1096 | } | ||
1097 | |||
1056 | static int | 1098 | static int |
1057 | cciss_scsi_do_report_phys_luns(ctlr_info_t *c, | 1099 | cciss_scsi_do_report_phys_luns(ctlr_info_t *c, |
1058 | ReportLunData_struct *buf, int bufsize) | 1100 | ReportLunData_struct *buf, int bufsize) |
@@ -1142,25 +1184,21 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) | |||
1142 | ctlr_info_t *c; | 1184 | ctlr_info_t *c; |
1143 | __u32 num_luns=0; | 1185 | __u32 num_luns=0; |
1144 | unsigned char *ch; | 1186 | unsigned char *ch; |
1145 | /* unsigned char found[CCISS_MAX_SCSI_DEVS_PER_HBA]; */ | 1187 | struct cciss_scsi_dev_t *currentsd, *this_device; |
1146 | struct cciss_scsi_dev_t currentsd[CCISS_MAX_SCSI_DEVS_PER_HBA]; | ||
1147 | int ncurrent=0; | 1188 | int ncurrent=0; |
1148 | int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8; | 1189 | int reportlunsize = sizeof(*ld_buff) + CISS_MAX_PHYS_LUN * 8; |
1149 | int i; | 1190 | int i; |
1150 | 1191 | ||
1151 | c = (ctlr_info_t *) hba[cntl_num]; | 1192 | c = (ctlr_info_t *) hba[cntl_num]; |
1152 | ld_buff = kzalloc(reportlunsize, GFP_KERNEL); | 1193 | ld_buff = kzalloc(reportlunsize, GFP_KERNEL); |
1153 | if (ld_buff == NULL) { | ||
1154 | printk(KERN_ERR "cciss: out of memory\n"); | ||
1155 | return; | ||
1156 | } | ||
1157 | inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); | 1194 | inq_buff = kmalloc(OBDR_TAPE_INQ_SIZE, GFP_KERNEL); |
1158 | if (inq_buff == NULL) { | 1195 | currentsd = kzalloc(sizeof(*currentsd) * |
1159 | printk(KERN_ERR "cciss: out of memory\n"); | 1196 | (CCISS_MAX_SCSI_DEVS_PER_HBA+1), GFP_KERNEL); |
1160 | kfree(ld_buff); | 1197 | if (ld_buff == NULL || inq_buff == NULL || currentsd == NULL) { |
1161 | return; | 1198 | printk(KERN_ERR "cciss: out of memory\n"); |
1199 | goto out; | ||
1162 | } | 1200 | } |
1163 | 1201 | this_device = ¤tsd[CCISS_MAX_SCSI_DEVS_PER_HBA]; | |
1164 | if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) { | 1202 | if (cciss_scsi_do_report_phys_luns(c, ld_buff, reportlunsize) == 0) { |
1165 | ch = &ld_buff->LUNListLength[0]; | 1203 | ch = &ld_buff->LUNListLength[0]; |
1166 | num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8; | 1204 | num_luns = ((ch[0]<<24) | (ch[1]<<16) | (ch[2]<<8) | ch[3]) / 8; |
@@ -1179,23 +1217,34 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) | |||
1179 | 1217 | ||
1180 | 1218 | ||
1181 | /* adjust our table of devices */ | 1219 | /* adjust our table of devices */ |
1182 | for(i=0; i<num_luns; i++) | 1220 | for (i = 0; i < num_luns; i++) { |
1183 | { | ||
1184 | int devtype; | ||
1185 | |||
1186 | /* for each physical lun, do an inquiry */ | 1221 | /* for each physical lun, do an inquiry */ |
1187 | if (ld_buff->LUN[i][3] & 0xC0) continue; | 1222 | if (ld_buff->LUN[i][3] & 0xC0) continue; |
1188 | memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); | 1223 | memset(inq_buff, 0, OBDR_TAPE_INQ_SIZE); |
1189 | memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); | 1224 | memcpy(&scsi3addr[0], &ld_buff->LUN[i][0], 8); |
1190 | 1225 | ||
1191 | if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, inq_buff, | 1226 | if (cciss_scsi_do_inquiry(hba[cntl_num], scsi3addr, 0, inq_buff, |
1192 | (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) { | 1227 | (unsigned char) OBDR_TAPE_INQ_SIZE) != 0) |
1193 | /* Inquiry failed (msg printed already) */ | 1228 | /* Inquiry failed (msg printed already) */ |
1194 | devtype = 0; /* so we will skip this device. */ | 1229 | continue; /* so we will skip this device. */ |
1195 | } else /* what kind of device is this? */ | 1230 | |
1196 | devtype = (inq_buff[0] & 0x1f); | 1231 | this_device->devtype = (inq_buff[0] & 0x1f); |
1197 | 1232 | this_device->bus = -1; | |
1198 | switch (devtype) | 1233 | this_device->target = -1; |
1234 | this_device->lun = -1; | ||
1235 | memcpy(this_device->scsi3addr, scsi3addr, 8); | ||
1236 | memcpy(this_device->vendor, &inq_buff[8], | ||
1237 | sizeof(this_device->vendor)); | ||
1238 | memcpy(this_device->model, &inq_buff[16], | ||
1239 | sizeof(this_device->model)); | ||
1240 | memcpy(this_device->revision, &inq_buff[32], | ||
1241 | sizeof(this_device->revision)); | ||
1242 | memset(this_device->device_id, 0, | ||
1243 | sizeof(this_device->device_id)); | ||
1244 | cciss_scsi_get_device_id(hba[cntl_num], scsi3addr, | ||
1245 | this_device->device_id, sizeof(this_device->device_id)); | ||
1246 | |||
1247 | switch (this_device->devtype) | ||
1199 | { | 1248 | { |
1200 | case 0x05: /* CD-ROM */ { | 1249 | case 0x05: /* CD-ROM */ { |
1201 | 1250 | ||
@@ -1220,15 +1269,10 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) | |||
1220 | if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { | 1269 | if (ncurrent >= CCISS_MAX_SCSI_DEVS_PER_HBA) { |
1221 | printk(KERN_INFO "cciss%d: %s ignored, " | 1270 | printk(KERN_INFO "cciss%d: %s ignored, " |
1222 | "too many devices.\n", cntl_num, | 1271 | "too many devices.\n", cntl_num, |
1223 | scsi_device_type(devtype)); | 1272 | scsi_device_type(this_device->devtype)); |
1224 | break; | 1273 | break; |
1225 | } | 1274 | } |
1226 | memcpy(¤tsd[ncurrent].scsi3addr[0], | 1275 | currentsd[ncurrent] = *this_device; |
1227 | &scsi3addr[0], 8); | ||
1228 | currentsd[ncurrent].devtype = devtype; | ||
1229 | currentsd[ncurrent].bus = -1; | ||
1230 | currentsd[ncurrent].target = -1; | ||
1231 | currentsd[ncurrent].lun = -1; | ||
1232 | ncurrent++; | 1276 | ncurrent++; |
1233 | break; | 1277 | break; |
1234 | default: | 1278 | default: |
@@ -1240,6 +1284,7 @@ cciss_update_non_disk_devices(int cntl_num, int hostno) | |||
1240 | out: | 1284 | out: |
1241 | kfree(inq_buff); | 1285 | kfree(inq_buff); |
1242 | kfree(ld_buff); | 1286 | kfree(ld_buff); |
1287 | kfree(currentsd); | ||
1243 | return; | 1288 | return; |
1244 | } | 1289 | } |
1245 | 1290 | ||
diff --git a/drivers/block/cciss_scsi.h b/drivers/block/cciss_scsi.h index d9c2c586502f..7b750245ae76 100644 --- a/drivers/block/cciss_scsi.h +++ b/drivers/block/cciss_scsi.h | |||
@@ -66,6 +66,10 @@ struct cciss_scsi_dev_t { | |||
66 | int devtype; | 66 | int devtype; |
67 | int bus, target, lun; /* as presented to the OS */ | 67 | int bus, target, lun; /* as presented to the OS */ |
68 | unsigned char scsi3addr[8]; /* as presented to the HW */ | 68 | unsigned char scsi3addr[8]; /* as presented to the HW */ |
69 | unsigned char device_id[16]; /* from inquiry pg. 0x83 */ | ||
70 | unsigned char vendor[8]; /* bytes 8-15 of inquiry data */ | ||
71 | unsigned char model[16]; /* bytes 16-31 of inquiry data */ | ||
72 | unsigned char revision[4]; /* bytes 32-35 of inquiry data */ | ||
69 | }; | 73 | }; |
70 | 74 | ||
71 | struct cciss_scsi_hba_t { | 75 | struct cciss_scsi_hba_t { |
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c index 09c14341e6e3..3d967525e9a9 100644 --- a/drivers/block/cpqarray.c +++ b/drivers/block/cpqarray.c | |||
@@ -424,7 +424,7 @@ static int __init cpqarray_register_ctlr( int i, struct pci_dev *pdev) | |||
424 | hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), | 424 | hba[i]->pci_dev, NR_CMDS * sizeof(cmdlist_t), |
425 | &(hba[i]->cmd_pool_dhandle)); | 425 | &(hba[i]->cmd_pool_dhandle)); |
426 | hba[i]->cmd_pool_bits = kcalloc( | 426 | hba[i]->cmd_pool_bits = kcalloc( |
427 | (NR_CMDS+BITS_PER_LONG-1)/BITS_PER_LONG, sizeof(unsigned long), | 427 | DIV_ROUND_UP(NR_CMDS, BITS_PER_LONG), sizeof(unsigned long), |
428 | GFP_KERNEL); | 428 | GFP_KERNEL); |
429 | 429 | ||
430 | if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) | 430 | if (!hba[i]->cmd_pool_bits || !hba[i]->cmd_pool) |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 395f8ea7981c..cf64ddf5d839 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -423,8 +423,15 @@ static struct floppy_raw_cmd *raw_cmd, default_raw_cmd; | |||
423 | * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical | 423 | * 1581's logical side 0 is on physical side 1, whereas the Sharp's logical |
424 | * side 0 is on physical side 0 (but with the misnamed sector IDs). | 424 | * side 0 is on physical side 0 (but with the misnamed sector IDs). |
425 | * 'stretch' should probably be renamed to something more general, like | 425 | * 'stretch' should probably be renamed to something more general, like |
426 | * 'options'. Other parameters should be self-explanatory (see also | 426 | * 'options'. |
427 | * setfdprm(8)). | 427 | * |
428 | * Bits 2 through 9 of 'stretch' tell the number of the first sector. | ||
429 | * The LSB (bit 2) is flipped. For most disks, the first sector | ||
430 | * is 1 (represented by 0x00<<2). For some CP/M and music sampler | ||
431 | * disks (such as Ensoniq EPS 16plus) it is 0 (represented as 0x01<<2). | ||
432 | * For Amstrad CPC disks it is 0xC1 (represented as 0xC0<<2). | ||
433 | * | ||
434 | * Other parameters should be self-explanatory (see also setfdprm(8)). | ||
428 | */ | 435 | */ |
429 | /* | 436 | /* |
430 | Size | 437 | Size |
@@ -1355,20 +1362,20 @@ static void fdc_specify(void) | |||
1355 | } | 1362 | } |
1356 | 1363 | ||
1357 | /* Convert step rate from microseconds to milliseconds and 4 bits */ | 1364 | /* Convert step rate from microseconds to milliseconds and 4 bits */ |
1358 | srt = 16 - (DP->srt * scale_dtr / 1000 + NOMINAL_DTR - 1) / NOMINAL_DTR; | 1365 | srt = 16 - DIV_ROUND_UP(DP->srt * scale_dtr / 1000, NOMINAL_DTR); |
1359 | if (slow_floppy) { | 1366 | if (slow_floppy) { |
1360 | srt = srt / 4; | 1367 | srt = srt / 4; |
1361 | } | 1368 | } |
1362 | SUPBOUND(srt, 0xf); | 1369 | SUPBOUND(srt, 0xf); |
1363 | INFBOUND(srt, 0); | 1370 | INFBOUND(srt, 0); |
1364 | 1371 | ||
1365 | hlt = (DP->hlt * scale_dtr / 2 + NOMINAL_DTR - 1) / NOMINAL_DTR; | 1372 | hlt = DIV_ROUND_UP(DP->hlt * scale_dtr / 2, NOMINAL_DTR); |
1366 | if (hlt < 0x01) | 1373 | if (hlt < 0x01) |
1367 | hlt = 0x01; | 1374 | hlt = 0x01; |
1368 | else if (hlt > 0x7f) | 1375 | else if (hlt > 0x7f) |
1369 | hlt = hlt_max_code; | 1376 | hlt = hlt_max_code; |
1370 | 1377 | ||
1371 | hut = (DP->hut * scale_dtr / 16 + NOMINAL_DTR - 1) / NOMINAL_DTR; | 1378 | hut = DIV_ROUND_UP(DP->hut * scale_dtr / 16, NOMINAL_DTR); |
1372 | if (hut < 0x1) | 1379 | if (hut < 0x1) |
1373 | hut = 0x1; | 1380 | hut = 0x1; |
1374 | else if (hut > 0xf) | 1381 | else if (hut > 0xf) |
@@ -2236,9 +2243,9 @@ static void setup_format_params(int track) | |||
2236 | } | 2243 | } |
2237 | } | 2244 | } |
2238 | } | 2245 | } |
2239 | if (_floppy->stretch & FD_ZEROBASED) { | 2246 | if (_floppy->stretch & FD_SECTBASEMASK) { |
2240 | for (count = 0; count < F_SECT_PER_TRACK; count++) | 2247 | for (count = 0; count < F_SECT_PER_TRACK; count++) |
2241 | here[count].sect--; | 2248 | here[count].sect += FD_SECTBASE(_floppy) - 1; |
2242 | } | 2249 | } |
2243 | } | 2250 | } |
2244 | 2251 | ||
@@ -2385,7 +2392,7 @@ static void rw_interrupt(void) | |||
2385 | 2392 | ||
2386 | #ifdef FLOPPY_SANITY_CHECK | 2393 | #ifdef FLOPPY_SANITY_CHECK |
2387 | if (nr_sectors / ssize > | 2394 | if (nr_sectors / ssize > |
2388 | (in_sector_offset + current_count_sectors + ssize - 1) / ssize) { | 2395 | DIV_ROUND_UP(in_sector_offset + current_count_sectors, ssize)) { |
2389 | DPRINT("long rw: %x instead of %lx\n", | 2396 | DPRINT("long rw: %x instead of %lx\n", |
2390 | nr_sectors, current_count_sectors); | 2397 | nr_sectors, current_count_sectors); |
2391 | printk("rs=%d s=%d\n", R_SECTOR, SECTOR); | 2398 | printk("rs=%d s=%d\n", R_SECTOR, SECTOR); |
@@ -2649,7 +2656,7 @@ static int make_raw_rw_request(void) | |||
2649 | } | 2656 | } |
2650 | HEAD = fsector_t / _floppy->sect; | 2657 | HEAD = fsector_t / _floppy->sect; |
2651 | 2658 | ||
2652 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_ZEROBASED)) || | 2659 | if (((_floppy->stretch & (FD_SWAPSIDES | FD_SECTBASEMASK)) || |
2653 | TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) | 2660 | TESTF(FD_NEED_TWADDLE)) && fsector_t < _floppy->sect) |
2654 | max_sector = _floppy->sect; | 2661 | max_sector = _floppy->sect; |
2655 | 2662 | ||
@@ -2679,7 +2686,7 @@ static int make_raw_rw_request(void) | |||
2679 | CODE2SIZE; | 2686 | CODE2SIZE; |
2680 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; | 2687 | SECT_PER_TRACK = _floppy->sect << 2 >> SIZECODE; |
2681 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + | 2688 | SECTOR = ((fsector_t % _floppy->sect) << 2 >> SIZECODE) + |
2682 | ((_floppy->stretch & FD_ZEROBASED) ? 0 : 1); | 2689 | FD_SECTBASE(_floppy); |
2683 | 2690 | ||
2684 | /* tracksize describes the size which can be filled up with sectors | 2691 | /* tracksize describes the size which can be filled up with sectors |
2685 | * of size ssize. | 2692 | * of size ssize. |
@@ -3311,7 +3318,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3311 | g->head <= 0 || | 3318 | g->head <= 0 || |
3312 | g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || | 3319 | g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) || |
3313 | /* check if reserved bits are set */ | 3320 | /* check if reserved bits are set */ |
3314 | (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_ZEROBASED)) != 0) | 3321 | (g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK)) != 0) |
3315 | return -EINVAL; | 3322 | return -EINVAL; |
3316 | if (type) { | 3323 | if (type) { |
3317 | if (!capable(CAP_SYS_ADMIN)) | 3324 | if (!capable(CAP_SYS_ADMIN)) |
@@ -3356,7 +3363,7 @@ static inline int set_geometry(unsigned int cmd, struct floppy_struct *g, | |||
3356 | if (DRS->maxblock > user_params[drive].sect || | 3363 | if (DRS->maxblock > user_params[drive].sect || |
3357 | DRS->maxtrack || | 3364 | DRS->maxtrack || |
3358 | ((user_params[drive].sect ^ oldStretch) & | 3365 | ((user_params[drive].sect ^ oldStretch) & |
3359 | (FD_SWAPSIDES | FD_ZEROBASED))) | 3366 | (FD_SWAPSIDES | FD_SECTBASEMASK))) |
3360 | invalidate_drive(bdev); | 3367 | invalidate_drive(bdev); |
3361 | else | 3368 | else |
3362 | process_fd_request(); | 3369 | process_fd_request(); |
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 1778e4a2c672..7b3351260d56 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -403,7 +403,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
403 | BUG_ON(lo->magic != LO_MAGIC); | 403 | BUG_ON(lo->magic != LO_MAGIC); |
404 | 404 | ||
405 | lo->pid = current->pid; | 405 | lo->pid = current->pid; |
406 | ret = sysfs_create_file(&lo->disk->dev.kobj, &pid_attr.attr); | 406 | ret = sysfs_create_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); |
407 | if (ret) { | 407 | if (ret) { |
408 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); | 408 | printk(KERN_ERR "nbd: sysfs_create_file failed!"); |
409 | return ret; | 409 | return ret; |
@@ -412,7 +412,7 @@ static int nbd_do_it(struct nbd_device *lo) | |||
412 | while ((req = nbd_read_stat(lo)) != NULL) | 412 | while ((req = nbd_read_stat(lo)) != NULL) |
413 | nbd_end_request(req); | 413 | nbd_end_request(req); |
414 | 414 | ||
415 | sysfs_remove_file(&lo->disk->dev.kobj, &pid_attr.attr); | 415 | sysfs_remove_file(&disk_to_dev(lo->disk)->kobj, &pid_attr.attr); |
416 | return 0; | 416 | return 0; |
417 | } | 417 | } |
418 | 418 | ||
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 29b7a648cc6e..0e077150568b 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -2544,7 +2544,7 @@ static int pkt_make_request(struct request_queue *q, struct bio *bio) | |||
2544 | if (last_zone != zone) { | 2544 | if (last_zone != zone) { |
2545 | BUG_ON(last_zone != zone + pd->settings.size); | 2545 | BUG_ON(last_zone != zone + pd->settings.size); |
2546 | first_sectors = last_zone - bio->bi_sector; | 2546 | first_sectors = last_zone - bio->bi_sector; |
2547 | bp = bio_split(bio, bio_split_pool, first_sectors); | 2547 | bp = bio_split(bio, first_sectors); |
2548 | BUG_ON(!bp); | 2548 | BUG_ON(!bp); |
2549 | pkt_make_request(q, &bp->bio1); | 2549 | pkt_make_request(q, &bp->bio1); |
2550 | pkt_make_request(q, &bp->bio2); | 2550 | pkt_make_request(q, &bp->bio2); |
@@ -2911,7 +2911,7 @@ static int pkt_setup_dev(dev_t dev, dev_t* pkt_dev) | |||
2911 | if (!disk->queue) | 2911 | if (!disk->queue) |
2912 | goto out_mem2; | 2912 | goto out_mem2; |
2913 | 2913 | ||
2914 | pd->pkt_dev = MKDEV(disk->major, disk->first_minor); | 2914 | pd->pkt_dev = MKDEV(pktdev_major, idx); |
2915 | ret = pkt_new_dev(pd, dev); | 2915 | ret = pkt_new_dev(pd, dev); |
2916 | if (ret) | 2916 | if (ret) |
2917 | goto out_new_dev; | 2917 | goto out_new_dev; |
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c index d797e209951d..936466f62afd 100644 --- a/drivers/block/ps3disk.c +++ b/drivers/block/ps3disk.c | |||
@@ -199,7 +199,8 @@ static void ps3disk_do_request(struct ps3_storage_device *dev, | |||
199 | if (blk_fs_request(req)) { | 199 | if (blk_fs_request(req)) { |
200 | if (ps3disk_submit_request_sg(dev, req)) | 200 | if (ps3disk_submit_request_sg(dev, req)) |
201 | break; | 201 | break; |
202 | } else if (req->cmd_type == REQ_TYPE_FLUSH) { | 202 | } else if (req->cmd_type == REQ_TYPE_LINUX_BLOCK && |
203 | req->cmd[0] == REQ_LB_OP_FLUSH) { | ||
203 | if (ps3disk_submit_flush_request(dev, req)) | 204 | if (ps3disk_submit_flush_request(dev, req)) |
204 | break; | 205 | break; |
205 | } else { | 206 | } else { |
@@ -257,7 +258,8 @@ static irqreturn_t ps3disk_interrupt(int irq, void *data) | |||
257 | return IRQ_HANDLED; | 258 | return IRQ_HANDLED; |
258 | } | 259 | } |
259 | 260 | ||
260 | if (req->cmd_type == REQ_TYPE_FLUSH) { | 261 | if (req->cmd_type == REQ_TYPE_LINUX_BLOCK && |
262 | req->cmd[0] == REQ_LB_OP_FLUSH) { | ||
261 | read = 0; | 263 | read = 0; |
262 | num_sectors = req->hard_cur_sectors; | 264 | num_sectors = req->hard_cur_sectors; |
263 | op = "flush"; | 265 | op = "flush"; |
@@ -405,7 +407,8 @@ static void ps3disk_prepare_flush(struct request_queue *q, struct request *req) | |||
405 | 407 | ||
406 | dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); | 408 | dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__); |
407 | 409 | ||
408 | req->cmd_type = REQ_TYPE_FLUSH; | 410 | req->cmd_type = REQ_TYPE_LINUX_BLOCK; |
411 | req->cmd[0] = REQ_LB_OP_FLUSH; | ||
409 | } | 412 | } |
410 | 413 | ||
411 | static unsigned long ps3disk_mask; | 414 | static unsigned long ps3disk_mask; |
@@ -538,7 +541,7 @@ static int ps3disk_remove(struct ps3_system_bus_device *_dev) | |||
538 | struct ps3disk_private *priv = dev->sbd.core.driver_data; | 541 | struct ps3disk_private *priv = dev->sbd.core.driver_data; |
539 | 542 | ||
540 | mutex_lock(&ps3disk_mask_mutex); | 543 | mutex_lock(&ps3disk_mask_mutex); |
541 | __clear_bit(priv->gendisk->first_minor / PS3DISK_MINORS, | 544 | __clear_bit(MINOR(disk_devt(priv->gendisk)) / PS3DISK_MINORS, |
542 | &ps3disk_mask); | 545 | &ps3disk_mask); |
543 | mutex_unlock(&ps3disk_mask_mutex); | 546 | mutex_unlock(&ps3disk_mask_mutex); |
544 | del_gendisk(priv->gendisk); | 547 | del_gendisk(priv->gendisk); |
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 42251095134f..6ec5fc052786 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -47,20 +47,20 @@ static void blk_done(struct virtqueue *vq) | |||
47 | 47 | ||
48 | spin_lock_irqsave(&vblk->lock, flags); | 48 | spin_lock_irqsave(&vblk->lock, flags); |
49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { | 49 | while ((vbr = vblk->vq->vq_ops->get_buf(vblk->vq, &len)) != NULL) { |
50 | int uptodate; | 50 | int error; |
51 | switch (vbr->status) { | 51 | switch (vbr->status) { |
52 | case VIRTIO_BLK_S_OK: | 52 | case VIRTIO_BLK_S_OK: |
53 | uptodate = 1; | 53 | error = 0; |
54 | break; | 54 | break; |
55 | case VIRTIO_BLK_S_UNSUPP: | 55 | case VIRTIO_BLK_S_UNSUPP: |
56 | uptodate = -ENOTTY; | 56 | error = -ENOTTY; |
57 | break; | 57 | break; |
58 | default: | 58 | default: |
59 | uptodate = 0; | 59 | error = -EIO; |
60 | break; | 60 | break; |
61 | } | 61 | } |
62 | 62 | ||
63 | end_dequeued_request(vbr->req, uptodate); | 63 | __blk_end_request(vbr->req, error, blk_rq_bytes(vbr->req)); |
64 | list_del(&vbr->list); | 64 | list_del(&vbr->list); |
65 | mempool_free(vbr, vblk->pool); | 65 | mempool_free(vbr, vblk->pool); |
66 | } | 66 | } |
@@ -84,11 +84,11 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk, | |||
84 | if (blk_fs_request(vbr->req)) { | 84 | if (blk_fs_request(vbr->req)) { |
85 | vbr->out_hdr.type = 0; | 85 | vbr->out_hdr.type = 0; |
86 | vbr->out_hdr.sector = vbr->req->sector; | 86 | vbr->out_hdr.sector = vbr->req->sector; |
87 | vbr->out_hdr.ioprio = vbr->req->ioprio; | 87 | vbr->out_hdr.ioprio = req_get_ioprio(vbr->req); |
88 | } else if (blk_pc_request(vbr->req)) { | 88 | } else if (blk_pc_request(vbr->req)) { |
89 | vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD; | 89 | vbr->out_hdr.type = VIRTIO_BLK_T_SCSI_CMD; |
90 | vbr->out_hdr.sector = 0; | 90 | vbr->out_hdr.sector = 0; |
91 | vbr->out_hdr.ioprio = vbr->req->ioprio; | 91 | vbr->out_hdr.ioprio = req_get_ioprio(vbr->req); |
92 | } else { | 92 | } else { |
93 | /* We don't put anything else in the queue. */ | 93 | /* We don't put anything else in the queue. */ |
94 | BUG(); | 94 | BUG(); |
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 3ca643cafccd..bff602ccccf3 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
@@ -105,15 +105,17 @@ static DEFINE_SPINLOCK(blkif_io_lock); | |||
105 | #define GRANT_INVALID_REF 0 | 105 | #define GRANT_INVALID_REF 0 |
106 | 106 | ||
107 | #define PARTS_PER_DISK 16 | 107 | #define PARTS_PER_DISK 16 |
108 | #define PARTS_PER_EXT_DISK 256 | ||
108 | 109 | ||
109 | #define BLKIF_MAJOR(dev) ((dev)>>8) | 110 | #define BLKIF_MAJOR(dev) ((dev)>>8) |
110 | #define BLKIF_MINOR(dev) ((dev) & 0xff) | 111 | #define BLKIF_MINOR(dev) ((dev) & 0xff) |
111 | 112 | ||
112 | #define DEV_NAME "xvd" /* name in /dev */ | 113 | #define EXT_SHIFT 28 |
114 | #define EXTENDED (1<<EXT_SHIFT) | ||
115 | #define VDEV_IS_EXTENDED(dev) ((dev)&(EXTENDED)) | ||
116 | #define BLKIF_MINOR_EXT(dev) ((dev)&(~EXTENDED)) | ||
113 | 117 | ||
114 | /* Information about our VBDs. */ | 118 | #define DEV_NAME "xvd" /* name in /dev */ |
115 | #define MAX_VBDS 64 | ||
116 | static LIST_HEAD(vbds_list); | ||
117 | 119 | ||
118 | static int get_id_from_freelist(struct blkfront_info *info) | 120 | static int get_id_from_freelist(struct blkfront_info *info) |
119 | { | 121 | { |
@@ -386,31 +388,60 @@ static int xlvbd_barrier(struct blkfront_info *info) | |||
386 | } | 388 | } |
387 | 389 | ||
388 | 390 | ||
389 | static int xlvbd_alloc_gendisk(int minor, blkif_sector_t capacity, | 391 | static int xlvbd_alloc_gendisk(blkif_sector_t capacity, |
390 | int vdevice, u16 vdisk_info, u16 sector_size, | 392 | struct blkfront_info *info, |
391 | struct blkfront_info *info) | 393 | u16 vdisk_info, u16 sector_size) |
392 | { | 394 | { |
393 | struct gendisk *gd; | 395 | struct gendisk *gd; |
394 | int nr_minors = 1; | 396 | int nr_minors = 1; |
395 | int err = -ENODEV; | 397 | int err = -ENODEV; |
398 | unsigned int offset; | ||
399 | int minor; | ||
400 | int nr_parts; | ||
396 | 401 | ||
397 | BUG_ON(info->gd != NULL); | 402 | BUG_ON(info->gd != NULL); |
398 | BUG_ON(info->rq != NULL); | 403 | BUG_ON(info->rq != NULL); |
399 | 404 | ||
400 | if ((minor % PARTS_PER_DISK) == 0) | 405 | if ((info->vdevice>>EXT_SHIFT) > 1) { |
401 | nr_minors = PARTS_PER_DISK; | 406 | /* this is above the extended range; something is wrong */ |
407 | printk(KERN_WARNING "blkfront: vdevice 0x%x is above the extended range; ignoring\n", info->vdevice); | ||
408 | return -ENODEV; | ||
409 | } | ||
410 | |||
411 | if (!VDEV_IS_EXTENDED(info->vdevice)) { | ||
412 | minor = BLKIF_MINOR(info->vdevice); | ||
413 | nr_parts = PARTS_PER_DISK; | ||
414 | } else { | ||
415 | minor = BLKIF_MINOR_EXT(info->vdevice); | ||
416 | nr_parts = PARTS_PER_EXT_DISK; | ||
417 | } | ||
418 | |||
419 | if ((minor % nr_parts) == 0) | ||
420 | nr_minors = nr_parts; | ||
402 | 421 | ||
403 | gd = alloc_disk(nr_minors); | 422 | gd = alloc_disk(nr_minors); |
404 | if (gd == NULL) | 423 | if (gd == NULL) |
405 | goto out; | 424 | goto out; |
406 | 425 | ||
407 | if (nr_minors > 1) | 426 | offset = minor / nr_parts; |
408 | sprintf(gd->disk_name, "%s%c", DEV_NAME, | 427 | |
409 | 'a' + minor / PARTS_PER_DISK); | 428 | if (nr_minors > 1) { |
410 | else | 429 | if (offset < 26) |
411 | sprintf(gd->disk_name, "%s%c%d", DEV_NAME, | 430 | sprintf(gd->disk_name, "%s%c", DEV_NAME, 'a' + offset); |
412 | 'a' + minor / PARTS_PER_DISK, | 431 | else |
413 | minor % PARTS_PER_DISK); | 432 | sprintf(gd->disk_name, "%s%c%c", DEV_NAME, |
433 | 'a' + ((offset / 26)-1), 'a' + (offset % 26)); | ||
434 | } else { | ||
435 | if (offset < 26) | ||
436 | sprintf(gd->disk_name, "%s%c%d", DEV_NAME, | ||
437 | 'a' + offset, | ||
438 | minor & (nr_parts - 1)); | ||
439 | else | ||
440 | sprintf(gd->disk_name, "%s%c%c%d", DEV_NAME, | ||
441 | 'a' + ((offset / 26) - 1), | ||
442 | 'a' + (offset % 26), | ||
443 | minor & (nr_parts - 1)); | ||
444 | } | ||
414 | 445 | ||
415 | gd->major = XENVBD_MAJOR; | 446 | gd->major = XENVBD_MAJOR; |
416 | gd->first_minor = minor; | 447 | gd->first_minor = minor; |
@@ -699,8 +730,13 @@ static int blkfront_probe(struct xenbus_device *dev, | |||
699 | err = xenbus_scanf(XBT_NIL, dev->nodename, | 730 | err = xenbus_scanf(XBT_NIL, dev->nodename, |
700 | "virtual-device", "%i", &vdevice); | 731 | "virtual-device", "%i", &vdevice); |
701 | if (err != 1) { | 732 | if (err != 1) { |
702 | xenbus_dev_fatal(dev, err, "reading virtual-device"); | 733 | /* go looking in the extended area instead */ |
703 | return err; | 734 | err = xenbus_scanf(XBT_NIL, dev->nodename, "virtual-device-ext", |
735 | "%i", &vdevice); | ||
736 | if (err != 1) { | ||
737 | xenbus_dev_fatal(dev, err, "reading virtual-device"); | ||
738 | return err; | ||
739 | } | ||
704 | } | 740 | } |
705 | 741 | ||
706 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 742 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -861,9 +897,7 @@ static void blkfront_connect(struct blkfront_info *info) | |||
861 | if (err) | 897 | if (err) |
862 | info->feature_barrier = 0; | 898 | info->feature_barrier = 0; |
863 | 899 | ||
864 | err = xlvbd_alloc_gendisk(BLKIF_MINOR(info->vdevice), | 900 | err = xlvbd_alloc_gendisk(sectors, info, binfo, sector_size); |
865 | sectors, info->vdevice, | ||
866 | binfo, sector_size, info); | ||
867 | if (err) { | 901 | if (err) { |
868 | xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", | 902 | xenbus_dev_fatal(info->xbdev, err, "xlvbd_add at %s", |
869 | info->xbdev->otherend); | 903 | info->xbdev->otherend); |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 74031de517e6..d47f2f80accd 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
@@ -2097,7 +2097,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
2097 | 2097 | ||
2098 | len = nr * CD_FRAMESIZE_RAW; | 2098 | len = nr * CD_FRAMESIZE_RAW; |
2099 | 2099 | ||
2100 | ret = blk_rq_map_user(q, rq, ubuf, len); | 2100 | ret = blk_rq_map_user(q, rq, NULL, ubuf, len, GFP_KERNEL); |
2101 | if (ret) | 2101 | if (ret) |
2102 | break; | 2102 | break; |
2103 | 2103 | ||
diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c index 1231d95aa695..d6ba77a2dd7b 100644 --- a/drivers/cdrom/gdrom.c +++ b/drivers/cdrom/gdrom.c | |||
@@ -624,14 +624,14 @@ static void gdrom_readdisk_dma(struct work_struct *work) | |||
624 | ctrl_outb(1, GDROM_DMA_STATUS_REG); | 624 | ctrl_outb(1, GDROM_DMA_STATUS_REG); |
625 | wait_event_interruptible_timeout(request_queue, | 625 | wait_event_interruptible_timeout(request_queue, |
626 | gd.transfer == 0, GDROM_DEFAULT_TIMEOUT); | 626 | gd.transfer == 0, GDROM_DEFAULT_TIMEOUT); |
627 | err = gd.transfer; | 627 | err = gd.transfer ? -EIO : 0; |
628 | gd.transfer = 0; | 628 | gd.transfer = 0; |
629 | gd.pending = 0; | 629 | gd.pending = 0; |
630 | /* now seek to take the request spinlock | 630 | /* now seek to take the request spinlock |
631 | * before handling ending the request */ | 631 | * before handling ending the request */ |
632 | spin_lock(&gdrom_lock); | 632 | spin_lock(&gdrom_lock); |
633 | list_del_init(&req->queuelist); | 633 | list_del_init(&req->queuelist); |
634 | end_dequeued_request(req, 1 - err); | 634 | __blk_end_request(req, err, blk_rq_bytes(req)); |
635 | } | 635 | } |
636 | spin_unlock(&gdrom_lock); | 636 | spin_unlock(&gdrom_lock); |
637 | kfree(read_command); | 637 | kfree(read_command); |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 7ce1ac4baa6d..6af435b89867 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -661,10 +661,10 @@ void add_disk_randomness(struct gendisk *disk) | |||
661 | if (!disk || !disk->random) | 661 | if (!disk || !disk->random) |
662 | return; | 662 | return; |
663 | /* first major is 1, so we get >= 0x200 here */ | 663 | /* first major is 1, so we get >= 0x200 here */ |
664 | DEBUG_ENT("disk event %d:%d\n", disk->major, disk->first_minor); | 664 | DEBUG_ENT("disk event %d:%d\n", |
665 | MAJOR(disk_devt(disk)), MINOR(disk_devt(disk))); | ||
665 | 666 | ||
666 | add_timer_randomness(disk->random, | 667 | add_timer_randomness(disk->random, 0x100 + disk_devt(disk)); |
667 | 0x100 + MKDEV(disk->major, disk->first_minor)); | ||
668 | } | 668 | } |
669 | #endif | 669 | #endif |
670 | 670 | ||
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index f16bb4667238..03c2cb6a58bc 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -1113,7 +1113,7 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq) | |||
1113 | 1113 | ||
1114 | if (write) { | 1114 | if (write) { |
1115 | /* disk has become write protected */ | 1115 | /* disk has become write protected */ |
1116 | if (cd->disk->policy) { | 1116 | if (get_disk_ro(cd->disk)) { |
1117 | cdrom_end_request(drive, 0); | 1117 | cdrom_end_request(drive, 0); |
1118 | return ide_stopped; | 1118 | return ide_stopped; |
1119 | } | 1119 | } |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 07ef88bd109b..33ea8c048717 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -41,6 +41,12 @@ | |||
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | #include <asm/div64.h> | 42 | #include <asm/div64.h> |
43 | 43 | ||
44 | #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) | ||
45 | #define IDE_DISK_MINORS (1 << PARTN_BITS) | ||
46 | #else | ||
47 | #define IDE_DISK_MINORS 0 | ||
48 | #endif | ||
49 | |||
44 | struct ide_disk_obj { | 50 | struct ide_disk_obj { |
45 | ide_drive_t *drive; | 51 | ide_drive_t *drive; |
46 | ide_driver_t *driver; | 52 | ide_driver_t *driver; |
@@ -1151,8 +1157,7 @@ static int ide_disk_probe(ide_drive_t *drive) | |||
1151 | if (!idkp) | 1157 | if (!idkp) |
1152 | goto failed; | 1158 | goto failed; |
1153 | 1159 | ||
1154 | g = alloc_disk_node(1 << PARTN_BITS, | 1160 | g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif)); |
1155 | hwif_to_node(drive->hwif)); | ||
1156 | if (!g) | 1161 | if (!g) |
1157 | goto out_free_idkp; | 1162 | goto out_free_idkp; |
1158 | 1163 | ||
@@ -1178,9 +1183,11 @@ static int ide_disk_probe(ide_drive_t *drive) | |||
1178 | } else | 1183 | } else |
1179 | drive->attach = 1; | 1184 | drive->attach = 1; |
1180 | 1185 | ||
1181 | g->minors = 1 << PARTN_BITS; | 1186 | g->minors = IDE_DISK_MINORS; |
1182 | g->driverfs_dev = &drive->gendev; | 1187 | g->driverfs_dev = &drive->gendev; |
1183 | g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; | 1188 | g->flags |= GENHD_FL_EXT_DEVT; |
1189 | if (drive->removable) | ||
1190 | g->flags |= GENHD_FL_REMOVABLE; | ||
1184 | set_capacity(g, idedisk_capacity(drive)); | 1191 | set_capacity(g, idedisk_capacity(drive)); |
1185 | g->fops = &idedisk_ops; | 1192 | g->fops = &idedisk_ops; |
1186 | add_disk(g); | 1193 | add_disk(g); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index a51a30e9eab3..70aa86c8807e 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
@@ -1188,7 +1188,7 @@ static struct kobject *exact_match(dev_t dev, int *part, void *data) | |||
1188 | { | 1188 | { |
1189 | struct gendisk *p = data; | 1189 | struct gendisk *p = data; |
1190 | *part &= (1 << PARTN_BITS) - 1; | 1190 | *part &= (1 << PARTN_BITS) - 1; |
1191 | return &p->dev.kobj; | 1191 | return &disk_to_dev(p)->kobj; |
1192 | } | 1192 | } |
1193 | 1193 | ||
1194 | static int exact_lock(dev_t dev, void *data) | 1194 | static int exact_lock(dev_t dev, void *data) |
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index b262c0042de3..5b919159f084 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -426,7 +426,7 @@ static int list_devices(struct dm_ioctl *param, size_t param_size) | |||
426 | old_nl->next = (uint32_t) ((void *) nl - | 426 | old_nl->next = (uint32_t) ((void *) nl - |
427 | (void *) old_nl); | 427 | (void *) old_nl); |
428 | disk = dm_disk(hc->md); | 428 | disk = dm_disk(hc->md); |
429 | nl->dev = huge_encode_dev(MKDEV(disk->major, disk->first_minor)); | 429 | nl->dev = huge_encode_dev(disk_devt(disk)); |
430 | nl->next = 0; | 430 | nl->next = 0; |
431 | strcpy(nl->name, hc->name); | 431 | strcpy(nl->name, hc->name); |
432 | 432 | ||
@@ -539,7 +539,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param) | |||
539 | if (dm_suspended(md)) | 539 | if (dm_suspended(md)) |
540 | param->flags |= DM_SUSPEND_FLAG; | 540 | param->flags |= DM_SUSPEND_FLAG; |
541 | 541 | ||
542 | param->dev = huge_encode_dev(MKDEV(disk->major, disk->first_minor)); | 542 | param->dev = huge_encode_dev(disk_devt(disk)); |
543 | 543 | ||
544 | /* | 544 | /* |
545 | * Yes, this will be out of date by the time it gets back | 545 | * Yes, this will be out of date by the time it gets back |
@@ -548,7 +548,7 @@ static int __dev_status(struct mapped_device *md, struct dm_ioctl *param) | |||
548 | */ | 548 | */ |
549 | param->open_count = dm_open_count(md); | 549 | param->open_count = dm_open_count(md); |
550 | 550 | ||
551 | if (disk->policy) | 551 | if (get_disk_ro(disk)) |
552 | param->flags |= DM_READONLY_FLAG; | 552 | param->flags |= DM_READONLY_FLAG; |
553 | 553 | ||
554 | param->event_nr = dm_get_event_nr(md); | 554 | param->event_nr = dm_get_event_nr(md); |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index c2fcf28b4c70..3d3848132c69 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -33,6 +33,7 @@ struct pgpath { | |||
33 | unsigned fail_count; /* Cumulative failure count */ | 33 | unsigned fail_count; /* Cumulative failure count */ |
34 | 34 | ||
35 | struct dm_path path; | 35 | struct dm_path path; |
36 | struct work_struct deactivate_path; | ||
36 | }; | 37 | }; |
37 | 38 | ||
38 | #define path_to_pgpath(__pgp) container_of((__pgp), struct pgpath, path) | 39 | #define path_to_pgpath(__pgp) container_of((__pgp), struct pgpath, path) |
@@ -112,6 +113,7 @@ static struct workqueue_struct *kmultipathd, *kmpath_handlerd; | |||
112 | static void process_queued_ios(struct work_struct *work); | 113 | static void process_queued_ios(struct work_struct *work); |
113 | static void trigger_event(struct work_struct *work); | 114 | static void trigger_event(struct work_struct *work); |
114 | static void activate_path(struct work_struct *work); | 115 | static void activate_path(struct work_struct *work); |
116 | static void deactivate_path(struct work_struct *work); | ||
115 | 117 | ||
116 | 118 | ||
117 | /*----------------------------------------------- | 119 | /*----------------------------------------------- |
@@ -122,8 +124,10 @@ static struct pgpath *alloc_pgpath(void) | |||
122 | { | 124 | { |
123 | struct pgpath *pgpath = kzalloc(sizeof(*pgpath), GFP_KERNEL); | 125 | struct pgpath *pgpath = kzalloc(sizeof(*pgpath), GFP_KERNEL); |
124 | 126 | ||
125 | if (pgpath) | 127 | if (pgpath) { |
126 | pgpath->path.is_active = 1; | 128 | pgpath->path.is_active = 1; |
129 | INIT_WORK(&pgpath->deactivate_path, deactivate_path); | ||
130 | } | ||
127 | 131 | ||
128 | return pgpath; | 132 | return pgpath; |
129 | } | 133 | } |
@@ -133,6 +137,14 @@ static void free_pgpath(struct pgpath *pgpath) | |||
133 | kfree(pgpath); | 137 | kfree(pgpath); |
134 | } | 138 | } |
135 | 139 | ||
140 | static void deactivate_path(struct work_struct *work) | ||
141 | { | ||
142 | struct pgpath *pgpath = | ||
143 | container_of(work, struct pgpath, deactivate_path); | ||
144 | |||
145 | blk_abort_queue(pgpath->path.dev->bdev->bd_disk->queue); | ||
146 | } | ||
147 | |||
136 | static struct priority_group *alloc_priority_group(void) | 148 | static struct priority_group *alloc_priority_group(void) |
137 | { | 149 | { |
138 | struct priority_group *pg; | 150 | struct priority_group *pg; |
@@ -870,6 +882,7 @@ static int fail_path(struct pgpath *pgpath) | |||
870 | pgpath->path.dev->name, m->nr_valid_paths); | 882 | pgpath->path.dev->name, m->nr_valid_paths); |
871 | 883 | ||
872 | queue_work(kmultipathd, &m->trigger_event); | 884 | queue_work(kmultipathd, &m->trigger_event); |
885 | queue_work(kmultipathd, &pgpath->deactivate_path); | ||
873 | 886 | ||
874 | out: | 887 | out: |
875 | spin_unlock_irqrestore(&m->lock, flags); | 888 | spin_unlock_irqrestore(&m->lock, flags); |
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 4de90ab3968b..b745d8ac625b 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c | |||
@@ -284,8 +284,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, | |||
284 | 284 | ||
285 | memset(major_minor, 0, sizeof(major_minor)); | 285 | memset(major_minor, 0, sizeof(major_minor)); |
286 | sprintf(major_minor, "%d:%d", | 286 | sprintf(major_minor, "%d:%d", |
287 | bio->bi_bdev->bd_disk->major, | 287 | MAJOR(disk_devt(bio->bi_bdev->bd_disk)), |
288 | bio->bi_bdev->bd_disk->first_minor); | 288 | MINOR(disk_devt(bio->bi_bdev->bd_disk))); |
289 | 289 | ||
290 | /* | 290 | /* |
291 | * Test to see which stripe drive triggered the event | 291 | * Test to see which stripe drive triggered the event |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index ace998ce59f6..327de03a5bdf 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -377,13 +377,14 @@ static void free_tio(struct mapped_device *md, struct dm_target_io *tio) | |||
377 | static void start_io_acct(struct dm_io *io) | 377 | static void start_io_acct(struct dm_io *io) |
378 | { | 378 | { |
379 | struct mapped_device *md = io->md; | 379 | struct mapped_device *md = io->md; |
380 | int cpu; | ||
380 | 381 | ||
381 | io->start_time = jiffies; | 382 | io->start_time = jiffies; |
382 | 383 | ||
383 | preempt_disable(); | 384 | cpu = part_stat_lock(); |
384 | disk_round_stats(dm_disk(md)); | 385 | part_round_stats(cpu, &dm_disk(md)->part0); |
385 | preempt_enable(); | 386 | part_stat_unlock(); |
386 | dm_disk(md)->in_flight = atomic_inc_return(&md->pending); | 387 | dm_disk(md)->part0.in_flight = atomic_inc_return(&md->pending); |
387 | } | 388 | } |
388 | 389 | ||
389 | static int end_io_acct(struct dm_io *io) | 390 | static int end_io_acct(struct dm_io *io) |
@@ -391,15 +392,16 @@ static int end_io_acct(struct dm_io *io) | |||
391 | struct mapped_device *md = io->md; | 392 | struct mapped_device *md = io->md; |
392 | struct bio *bio = io->bio; | 393 | struct bio *bio = io->bio; |
393 | unsigned long duration = jiffies - io->start_time; | 394 | unsigned long duration = jiffies - io->start_time; |
394 | int pending; | 395 | int pending, cpu; |
395 | int rw = bio_data_dir(bio); | 396 | int rw = bio_data_dir(bio); |
396 | 397 | ||
397 | preempt_disable(); | 398 | cpu = part_stat_lock(); |
398 | disk_round_stats(dm_disk(md)); | 399 | part_round_stats(cpu, &dm_disk(md)->part0); |
399 | preempt_enable(); | 400 | part_stat_add(cpu, &dm_disk(md)->part0, ticks[rw], duration); |
400 | dm_disk(md)->in_flight = pending = atomic_dec_return(&md->pending); | 401 | part_stat_unlock(); |
401 | 402 | ||
402 | disk_stat_add(dm_disk(md), ticks[rw], duration); | 403 | dm_disk(md)->part0.in_flight = pending = |
404 | atomic_dec_return(&md->pending); | ||
403 | 405 | ||
404 | return !pending; | 406 | return !pending; |
405 | } | 407 | } |
@@ -885,6 +887,7 @@ static int dm_request(struct request_queue *q, struct bio *bio) | |||
885 | int r = -EIO; | 887 | int r = -EIO; |
886 | int rw = bio_data_dir(bio); | 888 | int rw = bio_data_dir(bio); |
887 | struct mapped_device *md = q->queuedata; | 889 | struct mapped_device *md = q->queuedata; |
890 | int cpu; | ||
888 | 891 | ||
889 | /* | 892 | /* |
890 | * There is no use in forwarding any barrier request since we can't | 893 | * There is no use in forwarding any barrier request since we can't |
@@ -897,8 +900,10 @@ static int dm_request(struct request_queue *q, struct bio *bio) | |||
897 | 900 | ||
898 | down_read(&md->io_lock); | 901 | down_read(&md->io_lock); |
899 | 902 | ||
900 | disk_stat_inc(dm_disk(md), ios[rw]); | 903 | cpu = part_stat_lock(); |
901 | disk_stat_add(dm_disk(md), sectors[rw], bio_sectors(bio)); | 904 | part_stat_inc(cpu, &dm_disk(md)->part0, ios[rw]); |
905 | part_stat_add(cpu, &dm_disk(md)->part0, sectors[rw], bio_sectors(bio)); | ||
906 | part_stat_unlock(); | ||
902 | 907 | ||
903 | /* | 908 | /* |
904 | * If we're suspended we have to queue | 909 | * If we're suspended we have to queue |
@@ -1146,7 +1151,7 @@ static void unlock_fs(struct mapped_device *md); | |||
1146 | 1151 | ||
1147 | static void free_dev(struct mapped_device *md) | 1152 | static void free_dev(struct mapped_device *md) |
1148 | { | 1153 | { |
1149 | int minor = md->disk->first_minor; | 1154 | int minor = MINOR(disk_devt(md->disk)); |
1150 | 1155 | ||
1151 | if (md->suspended_bdev) { | 1156 | if (md->suspended_bdev) { |
1152 | unlock_fs(md); | 1157 | unlock_fs(md); |
@@ -1182,7 +1187,7 @@ static void event_callback(void *context) | |||
1182 | list_splice_init(&md->uevent_list, &uevents); | 1187 | list_splice_init(&md->uevent_list, &uevents); |
1183 | spin_unlock_irqrestore(&md->uevent_lock, flags); | 1188 | spin_unlock_irqrestore(&md->uevent_lock, flags); |
1184 | 1189 | ||
1185 | dm_send_uevents(&uevents, &md->disk->dev.kobj); | 1190 | dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj); |
1186 | 1191 | ||
1187 | atomic_inc(&md->event_nr); | 1192 | atomic_inc(&md->event_nr); |
1188 | wake_up(&md->eventq); | 1193 | wake_up(&md->eventq); |
@@ -1267,7 +1272,7 @@ static struct mapped_device *dm_find_md(dev_t dev) | |||
1267 | 1272 | ||
1268 | md = idr_find(&_minor_idr, minor); | 1273 | md = idr_find(&_minor_idr, minor); |
1269 | if (md && (md == MINOR_ALLOCED || | 1274 | if (md && (md == MINOR_ALLOCED || |
1270 | (dm_disk(md)->first_minor != minor) || | 1275 | (MINOR(disk_devt(dm_disk(md))) != minor) || |
1271 | test_bit(DMF_FREEING, &md->flags))) { | 1276 | test_bit(DMF_FREEING, &md->flags))) { |
1272 | md = NULL; | 1277 | md = NULL; |
1273 | goto out; | 1278 | goto out; |
@@ -1318,7 +1323,8 @@ void dm_put(struct mapped_device *md) | |||
1318 | 1323 | ||
1319 | if (atomic_dec_and_lock(&md->holders, &_minor_lock)) { | 1324 | if (atomic_dec_and_lock(&md->holders, &_minor_lock)) { |
1320 | map = dm_get_table(md); | 1325 | map = dm_get_table(md); |
1321 | idr_replace(&_minor_idr, MINOR_ALLOCED, dm_disk(md)->first_minor); | 1326 | idr_replace(&_minor_idr, MINOR_ALLOCED, |
1327 | MINOR(disk_devt(dm_disk(md)))); | ||
1322 | set_bit(DMF_FREEING, &md->flags); | 1328 | set_bit(DMF_FREEING, &md->flags); |
1323 | spin_unlock(&_minor_lock); | 1329 | spin_unlock(&_minor_lock); |
1324 | if (!dm_suspended(md)) { | 1330 | if (!dm_suspended(md)) { |
@@ -1638,7 +1644,7 @@ out: | |||
1638 | *---------------------------------------------------------------*/ | 1644 | *---------------------------------------------------------------*/ |
1639 | void dm_kobject_uevent(struct mapped_device *md) | 1645 | void dm_kobject_uevent(struct mapped_device *md) |
1640 | { | 1646 | { |
1641 | kobject_uevent(&md->disk->dev.kobj, KOBJ_CHANGE); | 1647 | kobject_uevent(&disk_to_dev(md->disk)->kobj, KOBJ_CHANGE); |
1642 | } | 1648 | } |
1643 | 1649 | ||
1644 | uint32_t dm_next_uevent_seq(struct mapped_device *md) | 1650 | uint32_t dm_next_uevent_seq(struct mapped_device *md) |
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index b1eebf88c209..b9cbee688fae 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -318,14 +318,18 @@ static int linear_make_request (struct request_queue *q, struct bio *bio) | |||
318 | mddev_t *mddev = q->queuedata; | 318 | mddev_t *mddev = q->queuedata; |
319 | dev_info_t *tmp_dev; | 319 | dev_info_t *tmp_dev; |
320 | sector_t block; | 320 | sector_t block; |
321 | int cpu; | ||
321 | 322 | ||
322 | if (unlikely(bio_barrier(bio))) { | 323 | if (unlikely(bio_barrier(bio))) { |
323 | bio_endio(bio, -EOPNOTSUPP); | 324 | bio_endio(bio, -EOPNOTSUPP); |
324 | return 0; | 325 | return 0; |
325 | } | 326 | } |
326 | 327 | ||
327 | disk_stat_inc(mddev->gendisk, ios[rw]); | 328 | cpu = part_stat_lock(); |
328 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); | 329 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
330 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
331 | bio_sectors(bio)); | ||
332 | part_stat_unlock(); | ||
329 | 333 | ||
330 | tmp_dev = which_dev(mddev, bio->bi_sector); | 334 | tmp_dev = which_dev(mddev, bio->bi_sector); |
331 | block = bio->bi_sector >> 1; | 335 | block = bio->bi_sector >> 1; |
@@ -349,7 +353,7 @@ static int linear_make_request (struct request_queue *q, struct bio *bio) | |||
349 | * split it. | 353 | * split it. |
350 | */ | 354 | */ |
351 | struct bio_pair *bp; | 355 | struct bio_pair *bp; |
352 | bp = bio_split(bio, bio_split_pool, | 356 | bp = bio_split(bio, |
353 | ((tmp_dev->offset + tmp_dev->size)<<1) - bio->bi_sector); | 357 | ((tmp_dev->offset + tmp_dev->size)<<1) - bio->bi_sector); |
354 | if (linear_make_request(q, &bp->bio1)) | 358 | if (linear_make_request(q, &bp->bio1)) |
355 | generic_make_request(&bp->bio1); | 359 | generic_make_request(&bp->bio1); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index deeac4b44173..0a3a4bdcd4af 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -1464,10 +1464,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) | |||
1464 | if ((err = kobject_add(&rdev->kobj, &mddev->kobj, "dev-%s", b))) | 1464 | if ((err = kobject_add(&rdev->kobj, &mddev->kobj, "dev-%s", b))) |
1465 | goto fail; | 1465 | goto fail; |
1466 | 1466 | ||
1467 | if (rdev->bdev->bd_part) | 1467 | ko = &part_to_dev(rdev->bdev->bd_part)->kobj; |
1468 | ko = &rdev->bdev->bd_part->dev.kobj; | ||
1469 | else | ||
1470 | ko = &rdev->bdev->bd_disk->dev.kobj; | ||
1471 | if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) { | 1468 | if ((err = sysfs_create_link(&rdev->kobj, ko, "block"))) { |
1472 | kobject_del(&rdev->kobj); | 1469 | kobject_del(&rdev->kobj); |
1473 | goto fail; | 1470 | goto fail; |
@@ -3470,8 +3467,8 @@ static struct kobject *md_probe(dev_t dev, int *part, void *data) | |||
3470 | disk->queue = mddev->queue; | 3467 | disk->queue = mddev->queue; |
3471 | add_disk(disk); | 3468 | add_disk(disk); |
3472 | mddev->gendisk = disk; | 3469 | mddev->gendisk = disk; |
3473 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, &disk->dev.kobj, | 3470 | error = kobject_init_and_add(&mddev->kobj, &md_ktype, |
3474 | "%s", "md"); | 3471 | &disk_to_dev(disk)->kobj, "%s", "md"); |
3475 | mutex_unlock(&disks_mutex); | 3472 | mutex_unlock(&disks_mutex); |
3476 | if (error) | 3473 | if (error) |
3477 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", | 3474 | printk(KERN_WARNING "md: cannot register %s/md - name in use\n", |
@@ -3761,7 +3758,7 @@ static int do_md_run(mddev_t * mddev) | |||
3761 | sysfs_notify(&mddev->kobj, NULL, "array_state"); | 3758 | sysfs_notify(&mddev->kobj, NULL, "array_state"); |
3762 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); | 3759 | sysfs_notify(&mddev->kobj, NULL, "sync_action"); |
3763 | sysfs_notify(&mddev->kobj, NULL, "degraded"); | 3760 | sysfs_notify(&mddev->kobj, NULL, "degraded"); |
3764 | kobject_uevent(&mddev->gendisk->dev.kobj, KOBJ_CHANGE); | 3761 | kobject_uevent(&disk_to_dev(mddev->gendisk)->kobj, KOBJ_CHANGE); |
3765 | return 0; | 3762 | return 0; |
3766 | } | 3763 | } |
3767 | 3764 | ||
@@ -5549,8 +5546,8 @@ static int is_mddev_idle(mddev_t *mddev) | |||
5549 | rcu_read_lock(); | 5546 | rcu_read_lock(); |
5550 | rdev_for_each_rcu(rdev, mddev) { | 5547 | rdev_for_each_rcu(rdev, mddev) { |
5551 | struct gendisk *disk = rdev->bdev->bd_contains->bd_disk; | 5548 | struct gendisk *disk = rdev->bdev->bd_contains->bd_disk; |
5552 | curr_events = disk_stat_read(disk, sectors[0]) + | 5549 | curr_events = part_stat_read(&disk->part0, sectors[0]) + |
5553 | disk_stat_read(disk, sectors[1]) - | 5550 | part_stat_read(&disk->part0, sectors[1]) - |
5554 | atomic_read(&disk->sync_io); | 5551 | atomic_read(&disk->sync_io); |
5555 | /* sync IO will cause sync_io to increase before the disk_stats | 5552 | /* sync IO will cause sync_io to increase before the disk_stats |
5556 | * as sync_io is counted when a request starts, and | 5553 | * as sync_io is counted when a request starts, and |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index c4779ccba1c3..8bb8794129b3 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -147,6 +147,7 @@ static int multipath_make_request (struct request_queue *q, struct bio * bio) | |||
147 | struct multipath_bh * mp_bh; | 147 | struct multipath_bh * mp_bh; |
148 | struct multipath_info *multipath; | 148 | struct multipath_info *multipath; |
149 | const int rw = bio_data_dir(bio); | 149 | const int rw = bio_data_dir(bio); |
150 | int cpu; | ||
150 | 151 | ||
151 | if (unlikely(bio_barrier(bio))) { | 152 | if (unlikely(bio_barrier(bio))) { |
152 | bio_endio(bio, -EOPNOTSUPP); | 153 | bio_endio(bio, -EOPNOTSUPP); |
@@ -158,8 +159,11 @@ static int multipath_make_request (struct request_queue *q, struct bio * bio) | |||
158 | mp_bh->master_bio = bio; | 159 | mp_bh->master_bio = bio; |
159 | mp_bh->mddev = mddev; | 160 | mp_bh->mddev = mddev; |
160 | 161 | ||
161 | disk_stat_inc(mddev->gendisk, ios[rw]); | 162 | cpu = part_stat_lock(); |
162 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); | 163 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
164 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
165 | bio_sectors(bio)); | ||
166 | part_stat_unlock(); | ||
163 | 167 | ||
164 | mp_bh->path = multipath_map(conf); | 168 | mp_bh->path = multipath_map(conf); |
165 | if (mp_bh->path < 0) { | 169 | if (mp_bh->path < 0) { |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 183610635661..53508a8a981d 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
@@ -399,14 +399,18 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) | |||
399 | sector_t chunk; | 399 | sector_t chunk; |
400 | sector_t block, rsect; | 400 | sector_t block, rsect; |
401 | const int rw = bio_data_dir(bio); | 401 | const int rw = bio_data_dir(bio); |
402 | int cpu; | ||
402 | 403 | ||
403 | if (unlikely(bio_barrier(bio))) { | 404 | if (unlikely(bio_barrier(bio))) { |
404 | bio_endio(bio, -EOPNOTSUPP); | 405 | bio_endio(bio, -EOPNOTSUPP); |
405 | return 0; | 406 | return 0; |
406 | } | 407 | } |
407 | 408 | ||
408 | disk_stat_inc(mddev->gendisk, ios[rw]); | 409 | cpu = part_stat_lock(); |
409 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); | 410 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
411 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
412 | bio_sectors(bio)); | ||
413 | part_stat_unlock(); | ||
410 | 414 | ||
411 | chunk_size = mddev->chunk_size >> 10; | 415 | chunk_size = mddev->chunk_size >> 10; |
412 | chunk_sects = mddev->chunk_size >> 9; | 416 | chunk_sects = mddev->chunk_size >> 9; |
@@ -423,7 +427,7 @@ static int raid0_make_request (struct request_queue *q, struct bio *bio) | |||
423 | /* This is a one page bio that upper layers | 427 | /* This is a one page bio that upper layers |
424 | * refuse to split for us, so we need to split it. | 428 | * refuse to split for us, so we need to split it. |
425 | */ | 429 | */ |
426 | bp = bio_split(bio, bio_split_pool, chunk_sects - (bio->bi_sector & (chunk_sects - 1)) ); | 430 | bp = bio_split(bio, chunk_sects - (bio->bi_sector & (chunk_sects - 1))); |
427 | if (raid0_make_request(q, &bp->bio1)) | 431 | if (raid0_make_request(q, &bp->bio1)) |
428 | generic_make_request(&bp->bio1); | 432 | generic_make_request(&bp->bio1); |
429 | if (raid0_make_request(q, &bp->bio2)) | 433 | if (raid0_make_request(q, &bp->bio2)) |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 03a5ab705c20..b9764429d856 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -779,7 +779,7 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
779 | struct page **behind_pages = NULL; | 779 | struct page **behind_pages = NULL; |
780 | const int rw = bio_data_dir(bio); | 780 | const int rw = bio_data_dir(bio); |
781 | const int do_sync = bio_sync(bio); | 781 | const int do_sync = bio_sync(bio); |
782 | int do_barriers; | 782 | int cpu, do_barriers; |
783 | mdk_rdev_t *blocked_rdev; | 783 | mdk_rdev_t *blocked_rdev; |
784 | 784 | ||
785 | /* | 785 | /* |
@@ -804,8 +804,11 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
804 | 804 | ||
805 | bitmap = mddev->bitmap; | 805 | bitmap = mddev->bitmap; |
806 | 806 | ||
807 | disk_stat_inc(mddev->gendisk, ios[rw]); | 807 | cpu = part_stat_lock(); |
808 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); | 808 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
809 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
810 | bio_sectors(bio)); | ||
811 | part_stat_unlock(); | ||
809 | 812 | ||
810 | /* | 813 | /* |
811 | * make_request() can abort the operation when READA is being | 814 | * make_request() can abort the operation when READA is being |
@@ -1302,9 +1305,6 @@ static void sync_request_write(mddev_t *mddev, r1bio_t *r1_bio) | |||
1302 | sbio->bi_size = r1_bio->sectors << 9; | 1305 | sbio->bi_size = r1_bio->sectors << 9; |
1303 | sbio->bi_idx = 0; | 1306 | sbio->bi_idx = 0; |
1304 | sbio->bi_phys_segments = 0; | 1307 | sbio->bi_phys_segments = 0; |
1305 | sbio->bi_hw_segments = 0; | ||
1306 | sbio->bi_hw_front_size = 0; | ||
1307 | sbio->bi_hw_back_size = 0; | ||
1308 | sbio->bi_flags &= ~(BIO_POOL_MASK - 1); | 1308 | sbio->bi_flags &= ~(BIO_POOL_MASK - 1); |
1309 | sbio->bi_flags |= 1 << BIO_UPTODATE; | 1309 | sbio->bi_flags |= 1 << BIO_UPTODATE; |
1310 | sbio->bi_next = NULL; | 1310 | sbio->bi_next = NULL; |
@@ -1790,7 +1790,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1790 | bio->bi_vcnt = 0; | 1790 | bio->bi_vcnt = 0; |
1791 | bio->bi_idx = 0; | 1791 | bio->bi_idx = 0; |
1792 | bio->bi_phys_segments = 0; | 1792 | bio->bi_phys_segments = 0; |
1793 | bio->bi_hw_segments = 0; | ||
1794 | bio->bi_size = 0; | 1793 | bio->bi_size = 0; |
1795 | bio->bi_end_io = NULL; | 1794 | bio->bi_end_io = NULL; |
1796 | bio->bi_private = NULL; | 1795 | bio->bi_private = NULL; |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index e34cd0e62473..8bdc9bfc2887 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -789,6 +789,7 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
789 | mirror_info_t *mirror; | 789 | mirror_info_t *mirror; |
790 | r10bio_t *r10_bio; | 790 | r10bio_t *r10_bio; |
791 | struct bio *read_bio; | 791 | struct bio *read_bio; |
792 | int cpu; | ||
792 | int i; | 793 | int i; |
793 | int chunk_sects = conf->chunk_mask + 1; | 794 | int chunk_sects = conf->chunk_mask + 1; |
794 | const int rw = bio_data_dir(bio); | 795 | const int rw = bio_data_dir(bio); |
@@ -816,7 +817,7 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
816 | /* This is a one page bio that upper layers | 817 | /* This is a one page bio that upper layers |
817 | * refuse to split for us, so we need to split it. | 818 | * refuse to split for us, so we need to split it. |
818 | */ | 819 | */ |
819 | bp = bio_split(bio, bio_split_pool, | 820 | bp = bio_split(bio, |
820 | chunk_sects - (bio->bi_sector & (chunk_sects - 1)) ); | 821 | chunk_sects - (bio->bi_sector & (chunk_sects - 1)) ); |
821 | if (make_request(q, &bp->bio1)) | 822 | if (make_request(q, &bp->bio1)) |
822 | generic_make_request(&bp->bio1); | 823 | generic_make_request(&bp->bio1); |
@@ -843,8 +844,11 @@ static int make_request(struct request_queue *q, struct bio * bio) | |||
843 | */ | 844 | */ |
844 | wait_barrier(conf); | 845 | wait_barrier(conf); |
845 | 846 | ||
846 | disk_stat_inc(mddev->gendisk, ios[rw]); | 847 | cpu = part_stat_lock(); |
847 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bio)); | 848 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
849 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
850 | bio_sectors(bio)); | ||
851 | part_stat_unlock(); | ||
848 | 852 | ||
849 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); | 853 | r10_bio = mempool_alloc(conf->r10bio_pool, GFP_NOIO); |
850 | 854 | ||
@@ -1345,9 +1349,6 @@ static void sync_request_write(mddev_t *mddev, r10bio_t *r10_bio) | |||
1345 | tbio->bi_size = r10_bio->sectors << 9; | 1349 | tbio->bi_size = r10_bio->sectors << 9; |
1346 | tbio->bi_idx = 0; | 1350 | tbio->bi_idx = 0; |
1347 | tbio->bi_phys_segments = 0; | 1351 | tbio->bi_phys_segments = 0; |
1348 | tbio->bi_hw_segments = 0; | ||
1349 | tbio->bi_hw_front_size = 0; | ||
1350 | tbio->bi_hw_back_size = 0; | ||
1351 | tbio->bi_flags &= ~(BIO_POOL_MASK - 1); | 1352 | tbio->bi_flags &= ~(BIO_POOL_MASK - 1); |
1352 | tbio->bi_flags |= 1 << BIO_UPTODATE; | 1353 | tbio->bi_flags |= 1 << BIO_UPTODATE; |
1353 | tbio->bi_next = NULL; | 1354 | tbio->bi_next = NULL; |
@@ -1947,7 +1948,6 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i | |||
1947 | bio->bi_vcnt = 0; | 1948 | bio->bi_vcnt = 0; |
1948 | bio->bi_idx = 0; | 1949 | bio->bi_idx = 0; |
1949 | bio->bi_phys_segments = 0; | 1950 | bio->bi_phys_segments = 0; |
1950 | bio->bi_hw_segments = 0; | ||
1951 | bio->bi_size = 0; | 1951 | bio->bi_size = 0; |
1952 | } | 1952 | } |
1953 | 1953 | ||
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 224de022e7c5..ae16794bef20 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -101,6 +101,40 @@ | |||
101 | const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256))); | 101 | const char raid6_empty_zero_page[PAGE_SIZE] __attribute__((aligned(256))); |
102 | #endif | 102 | #endif |
103 | 103 | ||
104 | /* | ||
105 | * We maintain a biased count of active stripes in the bottom 16 bits of | ||
106 | * bi_phys_segments, and a count of processed stripes in the upper 16 bits | ||
107 | */ | ||
108 | static inline int raid5_bi_phys_segments(struct bio *bio) | ||
109 | { | ||
110 | return bio->bi_phys_segments & 0xffff; | ||
111 | } | ||
112 | |||
113 | static inline int raid5_bi_hw_segments(struct bio *bio) | ||
114 | { | ||
115 | return (bio->bi_phys_segments >> 16) & 0xffff; | ||
116 | } | ||
117 | |||
118 | static inline int raid5_dec_bi_phys_segments(struct bio *bio) | ||
119 | { | ||
120 | --bio->bi_phys_segments; | ||
121 | return raid5_bi_phys_segments(bio); | ||
122 | } | ||
123 | |||
124 | static inline int raid5_dec_bi_hw_segments(struct bio *bio) | ||
125 | { | ||
126 | unsigned short val = raid5_bi_hw_segments(bio); | ||
127 | |||
128 | --val; | ||
129 | bio->bi_phys_segments = (val << 16) | raid5_bi_phys_segments(bio); | ||
130 | return val; | ||
131 | } | ||
132 | |||
133 | static inline void raid5_set_bi_hw_segments(struct bio *bio, unsigned int cnt) | ||
134 | { | ||
135 | bio->bi_phys_segments = raid5_bi_phys_segments(bio) || (cnt << 16); | ||
136 | } | ||
137 | |||
104 | static inline int raid6_next_disk(int disk, int raid_disks) | 138 | static inline int raid6_next_disk(int disk, int raid_disks) |
105 | { | 139 | { |
106 | disk++; | 140 | disk++; |
@@ -507,7 +541,7 @@ static void ops_complete_biofill(void *stripe_head_ref) | |||
507 | while (rbi && rbi->bi_sector < | 541 | while (rbi && rbi->bi_sector < |
508 | dev->sector + STRIPE_SECTORS) { | 542 | dev->sector + STRIPE_SECTORS) { |
509 | rbi2 = r5_next_bio(rbi, dev->sector); | 543 | rbi2 = r5_next_bio(rbi, dev->sector); |
510 | if (--rbi->bi_phys_segments == 0) { | 544 | if (!raid5_dec_bi_phys_segments(rbi)) { |
511 | rbi->bi_next = return_bi; | 545 | rbi->bi_next = return_bi; |
512 | return_bi = rbi; | 546 | return_bi = rbi; |
513 | } | 547 | } |
@@ -1725,7 +1759,7 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx, in | |||
1725 | if (*bip) | 1759 | if (*bip) |
1726 | bi->bi_next = *bip; | 1760 | bi->bi_next = *bip; |
1727 | *bip = bi; | 1761 | *bip = bi; |
1728 | bi->bi_phys_segments ++; | 1762 | bi->bi_phys_segments++; |
1729 | spin_unlock_irq(&conf->device_lock); | 1763 | spin_unlock_irq(&conf->device_lock); |
1730 | spin_unlock(&sh->lock); | 1764 | spin_unlock(&sh->lock); |
1731 | 1765 | ||
@@ -1819,7 +1853,7 @@ handle_failed_stripe(raid5_conf_t *conf, struct stripe_head *sh, | |||
1819 | sh->dev[i].sector + STRIPE_SECTORS) { | 1853 | sh->dev[i].sector + STRIPE_SECTORS) { |
1820 | struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector); | 1854 | struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector); |
1821 | clear_bit(BIO_UPTODATE, &bi->bi_flags); | 1855 | clear_bit(BIO_UPTODATE, &bi->bi_flags); |
1822 | if (--bi->bi_phys_segments == 0) { | 1856 | if (!raid5_dec_bi_phys_segments(bi)) { |
1823 | md_write_end(conf->mddev); | 1857 | md_write_end(conf->mddev); |
1824 | bi->bi_next = *return_bi; | 1858 | bi->bi_next = *return_bi; |
1825 | *return_bi = bi; | 1859 | *return_bi = bi; |
@@ -1834,7 +1868,7 @@ handle_failed_stripe(raid5_conf_t *conf, struct stripe_head *sh, | |||
1834 | sh->dev[i].sector + STRIPE_SECTORS) { | 1868 | sh->dev[i].sector + STRIPE_SECTORS) { |
1835 | struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector); | 1869 | struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector); |
1836 | clear_bit(BIO_UPTODATE, &bi->bi_flags); | 1870 | clear_bit(BIO_UPTODATE, &bi->bi_flags); |
1837 | if (--bi->bi_phys_segments == 0) { | 1871 | if (!raid5_dec_bi_phys_segments(bi)) { |
1838 | md_write_end(conf->mddev); | 1872 | md_write_end(conf->mddev); |
1839 | bi->bi_next = *return_bi; | 1873 | bi->bi_next = *return_bi; |
1840 | *return_bi = bi; | 1874 | *return_bi = bi; |
@@ -1858,7 +1892,7 @@ handle_failed_stripe(raid5_conf_t *conf, struct stripe_head *sh, | |||
1858 | struct bio *nextbi = | 1892 | struct bio *nextbi = |
1859 | r5_next_bio(bi, sh->dev[i].sector); | 1893 | r5_next_bio(bi, sh->dev[i].sector); |
1860 | clear_bit(BIO_UPTODATE, &bi->bi_flags); | 1894 | clear_bit(BIO_UPTODATE, &bi->bi_flags); |
1861 | if (--bi->bi_phys_segments == 0) { | 1895 | if (!raid5_dec_bi_phys_segments(bi)) { |
1862 | bi->bi_next = *return_bi; | 1896 | bi->bi_next = *return_bi; |
1863 | *return_bi = bi; | 1897 | *return_bi = bi; |
1864 | } | 1898 | } |
@@ -2033,7 +2067,7 @@ static void handle_stripe_clean_event(raid5_conf_t *conf, | |||
2033 | while (wbi && wbi->bi_sector < | 2067 | while (wbi && wbi->bi_sector < |
2034 | dev->sector + STRIPE_SECTORS) { | 2068 | dev->sector + STRIPE_SECTORS) { |
2035 | wbi2 = r5_next_bio(wbi, dev->sector); | 2069 | wbi2 = r5_next_bio(wbi, dev->sector); |
2036 | if (--wbi->bi_phys_segments == 0) { | 2070 | if (!raid5_dec_bi_phys_segments(wbi)) { |
2037 | md_write_end(conf->mddev); | 2071 | md_write_end(conf->mddev); |
2038 | wbi->bi_next = *return_bi; | 2072 | wbi->bi_next = *return_bi; |
2039 | *return_bi = wbi; | 2073 | *return_bi = wbi; |
@@ -2814,7 +2848,7 @@ static bool handle_stripe6(struct stripe_head *sh, struct page *tmp_page) | |||
2814 | copy_data(0, rbi, dev->page, dev->sector); | 2848 | copy_data(0, rbi, dev->page, dev->sector); |
2815 | rbi2 = r5_next_bio(rbi, dev->sector); | 2849 | rbi2 = r5_next_bio(rbi, dev->sector); |
2816 | spin_lock_irq(&conf->device_lock); | 2850 | spin_lock_irq(&conf->device_lock); |
2817 | if (--rbi->bi_phys_segments == 0) { | 2851 | if (!raid5_dec_bi_phys_segments(rbi)) { |
2818 | rbi->bi_next = return_bi; | 2852 | rbi->bi_next = return_bi; |
2819 | return_bi = rbi; | 2853 | return_bi = rbi; |
2820 | } | 2854 | } |
@@ -3155,8 +3189,11 @@ static struct bio *remove_bio_from_retry(raid5_conf_t *conf) | |||
3155 | if(bi) { | 3189 | if(bi) { |
3156 | conf->retry_read_aligned_list = bi->bi_next; | 3190 | conf->retry_read_aligned_list = bi->bi_next; |
3157 | bi->bi_next = NULL; | 3191 | bi->bi_next = NULL; |
3192 | /* | ||
3193 | * this sets the active strip count to 1 and the processed | ||
3194 | * strip count to zero (upper 8 bits) | ||
3195 | */ | ||
3158 | bi->bi_phys_segments = 1; /* biased count of active stripes */ | 3196 | bi->bi_phys_segments = 1; /* biased count of active stripes */ |
3159 | bi->bi_hw_segments = 0; /* count of processed stripes */ | ||
3160 | } | 3197 | } |
3161 | 3198 | ||
3162 | return bi; | 3199 | return bi; |
@@ -3206,8 +3243,7 @@ static int bio_fits_rdev(struct bio *bi) | |||
3206 | if ((bi->bi_size>>9) > q->max_sectors) | 3243 | if ((bi->bi_size>>9) > q->max_sectors) |
3207 | return 0; | 3244 | return 0; |
3208 | blk_recount_segments(q, bi); | 3245 | blk_recount_segments(q, bi); |
3209 | if (bi->bi_phys_segments > q->max_phys_segments || | 3246 | if (bi->bi_phys_segments > q->max_phys_segments) |
3210 | bi->bi_hw_segments > q->max_hw_segments) | ||
3211 | return 0; | 3247 | return 0; |
3212 | 3248 | ||
3213 | if (q->merge_bvec_fn) | 3249 | if (q->merge_bvec_fn) |
@@ -3351,7 +3387,7 @@ static int make_request(struct request_queue *q, struct bio * bi) | |||
3351 | sector_t logical_sector, last_sector; | 3387 | sector_t logical_sector, last_sector; |
3352 | struct stripe_head *sh; | 3388 | struct stripe_head *sh; |
3353 | const int rw = bio_data_dir(bi); | 3389 | const int rw = bio_data_dir(bi); |
3354 | int remaining; | 3390 | int cpu, remaining; |
3355 | 3391 | ||
3356 | if (unlikely(bio_barrier(bi))) { | 3392 | if (unlikely(bio_barrier(bi))) { |
3357 | bio_endio(bi, -EOPNOTSUPP); | 3393 | bio_endio(bi, -EOPNOTSUPP); |
@@ -3360,8 +3396,11 @@ static int make_request(struct request_queue *q, struct bio * bi) | |||
3360 | 3396 | ||
3361 | md_write_start(mddev, bi); | 3397 | md_write_start(mddev, bi); |
3362 | 3398 | ||
3363 | disk_stat_inc(mddev->gendisk, ios[rw]); | 3399 | cpu = part_stat_lock(); |
3364 | disk_stat_add(mddev->gendisk, sectors[rw], bio_sectors(bi)); | 3400 | part_stat_inc(cpu, &mddev->gendisk->part0, ios[rw]); |
3401 | part_stat_add(cpu, &mddev->gendisk->part0, sectors[rw], | ||
3402 | bio_sectors(bi)); | ||
3403 | part_stat_unlock(); | ||
3365 | 3404 | ||
3366 | if (rw == READ && | 3405 | if (rw == READ && |
3367 | mddev->reshape_position == MaxSector && | 3406 | mddev->reshape_position == MaxSector && |
@@ -3468,7 +3507,7 @@ static int make_request(struct request_queue *q, struct bio * bi) | |||
3468 | 3507 | ||
3469 | } | 3508 | } |
3470 | spin_lock_irq(&conf->device_lock); | 3509 | spin_lock_irq(&conf->device_lock); |
3471 | remaining = --bi->bi_phys_segments; | 3510 | remaining = raid5_dec_bi_phys_segments(bi); |
3472 | spin_unlock_irq(&conf->device_lock); | 3511 | spin_unlock_irq(&conf->device_lock); |
3473 | if (remaining == 0) { | 3512 | if (remaining == 0) { |
3474 | 3513 | ||
@@ -3752,7 +3791,7 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio) | |||
3752 | sector += STRIPE_SECTORS, | 3791 | sector += STRIPE_SECTORS, |
3753 | scnt++) { | 3792 | scnt++) { |
3754 | 3793 | ||
3755 | if (scnt < raid_bio->bi_hw_segments) | 3794 | if (scnt < raid5_bi_hw_segments(raid_bio)) |
3756 | /* already done this stripe */ | 3795 | /* already done this stripe */ |
3757 | continue; | 3796 | continue; |
3758 | 3797 | ||
@@ -3760,7 +3799,7 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio) | |||
3760 | 3799 | ||
3761 | if (!sh) { | 3800 | if (!sh) { |
3762 | /* failed to get a stripe - must wait */ | 3801 | /* failed to get a stripe - must wait */ |
3763 | raid_bio->bi_hw_segments = scnt; | 3802 | raid5_set_bi_hw_segments(raid_bio, scnt); |
3764 | conf->retry_read_aligned = raid_bio; | 3803 | conf->retry_read_aligned = raid_bio; |
3765 | return handled; | 3804 | return handled; |
3766 | } | 3805 | } |
@@ -3768,7 +3807,7 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio) | |||
3768 | set_bit(R5_ReadError, &sh->dev[dd_idx].flags); | 3807 | set_bit(R5_ReadError, &sh->dev[dd_idx].flags); |
3769 | if (!add_stripe_bio(sh, raid_bio, dd_idx, 0)) { | 3808 | if (!add_stripe_bio(sh, raid_bio, dd_idx, 0)) { |
3770 | release_stripe(sh); | 3809 | release_stripe(sh); |
3771 | raid_bio->bi_hw_segments = scnt; | 3810 | raid5_set_bi_hw_segments(raid_bio, scnt); |
3772 | conf->retry_read_aligned = raid_bio; | 3811 | conf->retry_read_aligned = raid_bio; |
3773 | return handled; | 3812 | return handled; |
3774 | } | 3813 | } |
@@ -3778,7 +3817,7 @@ static int retry_aligned_read(raid5_conf_t *conf, struct bio *raid_bio) | |||
3778 | handled++; | 3817 | handled++; |
3779 | } | 3818 | } |
3780 | spin_lock_irq(&conf->device_lock); | 3819 | spin_lock_irq(&conf->device_lock); |
3781 | remaining = --raid_bio->bi_phys_segments; | 3820 | remaining = raid5_dec_bi_phys_segments(raid_bio); |
3782 | spin_unlock_irq(&conf->device_lock); | 3821 | spin_unlock_irq(&conf->device_lock); |
3783 | if (remaining == 0) | 3822 | if (remaining == 0) |
3784 | bio_endio(raid_bio, 0); | 3823 | bio_endio(raid_bio, 0); |
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c index d2d2318dafa4..6e291bf8237a 100644 --- a/drivers/memstick/core/mspro_block.c +++ b/drivers/memstick/core/mspro_block.c | |||
@@ -197,7 +197,7 @@ static int mspro_block_bd_open(struct inode *inode, struct file *filp) | |||
197 | static int mspro_block_disk_release(struct gendisk *disk) | 197 | static int mspro_block_disk_release(struct gendisk *disk) |
198 | { | 198 | { |
199 | struct mspro_block_data *msb = disk->private_data; | 199 | struct mspro_block_data *msb = disk->private_data; |
200 | int disk_id = disk->first_minor >> MSPRO_BLOCK_PART_SHIFT; | 200 | int disk_id = MINOR(disk_devt(disk)) >> MSPRO_BLOCK_PART_SHIFT; |
201 | 201 | ||
202 | mutex_lock(&mspro_block_disk_lock); | 202 | mutex_lock(&mspro_block_disk_lock); |
203 | 203 | ||
@@ -828,7 +828,7 @@ static void mspro_block_submit_req(struct request_queue *q) | |||
828 | 828 | ||
829 | if (msb->eject) { | 829 | if (msb->eject) { |
830 | while ((req = elv_next_request(q)) != NULL) | 830 | while ((req = elv_next_request(q)) != NULL) |
831 | end_queued_request(req, -ENODEV); | 831 | __blk_end_request(req, -ENODEV, blk_rq_bytes(req)); |
832 | 832 | ||
833 | return; | 833 | return; |
834 | } | 834 | } |
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index ebc8b9d77613..97156b689e82 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -83,7 +83,7 @@ static void mmc_blk_put(struct mmc_blk_data *md) | |||
83 | mutex_lock(&open_lock); | 83 | mutex_lock(&open_lock); |
84 | md->usage--; | 84 | md->usage--; |
85 | if (md->usage == 0) { | 85 | if (md->usage == 0) { |
86 | int devidx = md->disk->first_minor >> MMC_SHIFT; | 86 | int devidx = MINOR(disk_devt(md->disk)) >> MMC_SHIFT; |
87 | __clear_bit(devidx, dev_use); | 87 | __clear_bit(devidx, dev_use); |
88 | 88 | ||
89 | put_disk(md->disk); | 89 | put_disk(md->disk); |
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index f34f20c78911..9bf581c4f740 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
@@ -1005,6 +1005,29 @@ static int ftl_writesect(struct mtd_blktrans_dev *dev, | |||
1005 | return ftl_write((void *)dev, buf, block, 1); | 1005 | return ftl_write((void *)dev, buf, block, 1); |
1006 | } | 1006 | } |
1007 | 1007 | ||
1008 | static int ftl_discardsect(struct mtd_blktrans_dev *dev, | ||
1009 | unsigned long sector, unsigned nr_sects) | ||
1010 | { | ||
1011 | partition_t *part = (void *)dev; | ||
1012 | uint32_t bsize = 1 << part->header.EraseUnitSize; | ||
1013 | |||
1014 | DEBUG(1, "FTL erase sector %ld for %d sectors\n", | ||
1015 | sector, nr_sects); | ||
1016 | |||
1017 | while (nr_sects) { | ||
1018 | uint32_t old_addr = part->VirtualBlockMap[sector]; | ||
1019 | if (old_addr != 0xffffffff) { | ||
1020 | part->VirtualBlockMap[sector] = 0xffffffff; | ||
1021 | part->EUNInfo[old_addr/bsize].Deleted++; | ||
1022 | if (set_bam_entry(part, old_addr, 0)) | ||
1023 | return -EIO; | ||
1024 | } | ||
1025 | nr_sects--; | ||
1026 | sector++; | ||
1027 | } | ||
1028 | |||
1029 | return 0; | ||
1030 | } | ||
1008 | /*====================================================================*/ | 1031 | /*====================================================================*/ |
1009 | 1032 | ||
1010 | static void ftl_freepart(partition_t *part) | 1033 | static void ftl_freepart(partition_t *part) |
@@ -1069,6 +1092,7 @@ static struct mtd_blktrans_ops ftl_tr = { | |||
1069 | .blksize = SECTOR_SIZE, | 1092 | .blksize = SECTOR_SIZE, |
1070 | .readsect = ftl_readsect, | 1093 | .readsect = ftl_readsect, |
1071 | .writesect = ftl_writesect, | 1094 | .writesect = ftl_writesect, |
1095 | .discard = ftl_discardsect, | ||
1072 | .getgeo = ftl_getgeo, | 1096 | .getgeo = ftl_getgeo, |
1073 | .add_mtd = ftl_add_mtd, | 1097 | .add_mtd = ftl_add_mtd, |
1074 | .remove_dev = ftl_remove_dev, | 1098 | .remove_dev = ftl_remove_dev, |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index 9ff007c4962c..681d5aca2af4 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
@@ -32,6 +32,14 @@ struct mtd_blkcore_priv { | |||
32 | spinlock_t queue_lock; | 32 | spinlock_t queue_lock; |
33 | }; | 33 | }; |
34 | 34 | ||
35 | static int blktrans_discard_request(struct request_queue *q, | ||
36 | struct request *req) | ||
37 | { | ||
38 | req->cmd_type = REQ_TYPE_LINUX_BLOCK; | ||
39 | req->cmd[0] = REQ_LB_OP_DISCARD; | ||
40 | return 0; | ||
41 | } | ||
42 | |||
35 | static int do_blktrans_request(struct mtd_blktrans_ops *tr, | 43 | static int do_blktrans_request(struct mtd_blktrans_ops *tr, |
36 | struct mtd_blktrans_dev *dev, | 44 | struct mtd_blktrans_dev *dev, |
37 | struct request *req) | 45 | struct request *req) |
@@ -44,6 +52,10 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr, | |||
44 | 52 | ||
45 | buf = req->buffer; | 53 | buf = req->buffer; |
46 | 54 | ||
55 | if (req->cmd_type == REQ_TYPE_LINUX_BLOCK && | ||
56 | req->cmd[0] == REQ_LB_OP_DISCARD) | ||
57 | return !tr->discard(dev, block, nsect); | ||
58 | |||
47 | if (!blk_fs_request(req)) | 59 | if (!blk_fs_request(req)) |
48 | return 0; | 60 | return 0; |
49 | 61 | ||
@@ -367,6 +379,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
367 | 379 | ||
368 | tr->blkcore_priv->rq->queuedata = tr; | 380 | tr->blkcore_priv->rq->queuedata = tr; |
369 | blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); | 381 | blk_queue_hardsect_size(tr->blkcore_priv->rq, tr->blksize); |
382 | if (tr->discard) | ||
383 | blk_queue_set_discard(tr->blkcore_priv->rq, | ||
384 | blktrans_discard_request); | ||
385 | |||
370 | tr->blkshift = ffs(tr->blksize) - 1; | 386 | tr->blkshift = ffs(tr->blksize) - 1; |
371 | 387 | ||
372 | tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr, | 388 | tr->blkcore_priv->thread = kthread_run(mtd_blktrans_thread, tr, |
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c index 03c0e40a92ff..e3b5c4d3036e 100644 --- a/drivers/s390/block/dasd_proc.c +++ b/drivers/s390/block/dasd_proc.c | |||
@@ -76,7 +76,8 @@ dasd_devices_show(struct seq_file *m, void *v) | |||
76 | /* Print kdev. */ | 76 | /* Print kdev. */ |
77 | if (block->gdp) | 77 | if (block->gdp) |
78 | seq_printf(m, " at (%3d:%6d)", | 78 | seq_printf(m, " at (%3d:%6d)", |
79 | block->gdp->major, block->gdp->first_minor); | 79 | MAJOR(disk_devt(block->gdp)), |
80 | MINOR(disk_devt(block->gdp))); | ||
80 | else | 81 | else |
81 | seq_printf(m, " at (???:??????)"); | 82 | seq_printf(m, " at (???:??????)"); |
82 | /* Print device name. */ | 83 | /* Print device name. */ |
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 711b3004b3e6..9481e4a3f76e 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c | |||
@@ -114,7 +114,7 @@ dcssblk_assign_free_minor(struct dcssblk_dev_info *dev_info) | |||
114 | found = 0; | 114 | found = 0; |
115 | // test if minor available | 115 | // test if minor available |
116 | list_for_each_entry(entry, &dcssblk_devices, lh) | 116 | list_for_each_entry(entry, &dcssblk_devices, lh) |
117 | if (minor == entry->gd->first_minor) | 117 | if (minor == MINOR(disk_devt(entry->gd))) |
118 | found++; | 118 | found++; |
119 | if (!found) break; // got unused minor | 119 | if (!found) break; // got unused minor |
120 | } | 120 | } |
@@ -397,7 +397,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char | |||
397 | goto unload_seg; | 397 | goto unload_seg; |
398 | } | 398 | } |
399 | sprintf(dev_info->gd->disk_name, "dcssblk%d", | 399 | sprintf(dev_info->gd->disk_name, "dcssblk%d", |
400 | dev_info->gd->first_minor); | 400 | MINOR(disk_devt(dev_info->gd))); |
401 | list_add_tail(&dev_info->lh, &dcssblk_devices); | 401 | list_add_tail(&dev_info->lh, &dcssblk_devices); |
402 | 402 | ||
403 | if (!try_module_get(THIS_MODULE)) { | 403 | if (!try_module_get(THIS_MODULE)) { |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index aa4e77c25273..8abfd06b5a72 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
@@ -1139,7 +1139,7 @@ static struct aac_srb * aac_scsi_common(struct fib * fib, struct scsi_cmnd * cmd | |||
1139 | srbcmd->id = cpu_to_le32(scmd_id(cmd)); | 1139 | srbcmd->id = cpu_to_le32(scmd_id(cmd)); |
1140 | srbcmd->lun = cpu_to_le32(cmd->device->lun); | 1140 | srbcmd->lun = cpu_to_le32(cmd->device->lun); |
1141 | srbcmd->flags = cpu_to_le32(flag); | 1141 | srbcmd->flags = cpu_to_le32(flag); |
1142 | timeout = cmd->timeout_per_command/HZ; | 1142 | timeout = cmd->request->timeout/HZ; |
1143 | if (timeout == 0) | 1143 | if (timeout == 0) |
1144 | timeout = 1; | 1144 | timeout = 1; |
1145 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds | 1145 | srbcmd->timeout = cpu_to_le32(timeout); // timeout in seconds |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 822d5214692b..c387c15a2128 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -464,7 +464,6 @@ int __gdth_execute(struct scsi_device *sdev, gdth_cmd_str *gdtcmd, char *cmnd, | |||
464 | 464 | ||
465 | /* use request field to save the ptr. to completion struct. */ | 465 | /* use request field to save the ptr. to completion struct. */ |
466 | scp->request = (struct request *)&wait; | 466 | scp->request = (struct request *)&wait; |
467 | scp->timeout_per_command = timeout*HZ; | ||
468 | scp->cmd_len = 12; | 467 | scp->cmd_len = 12; |
469 | scp->cmnd = cmnd; | 468 | scp->cmnd = cmnd; |
470 | cmndinfo.priority = IOCTL_PRI; | 469 | cmndinfo.priority = IOCTL_PRI; |
@@ -1995,23 +1994,12 @@ static void gdth_putq(gdth_ha_str *ha, Scsi_Cmnd *scp, unchar priority) | |||
1995 | register Scsi_Cmnd *pscp; | 1994 | register Scsi_Cmnd *pscp; |
1996 | register Scsi_Cmnd *nscp; | 1995 | register Scsi_Cmnd *nscp; |
1997 | ulong flags; | 1996 | ulong flags; |
1998 | unchar b, t; | ||
1999 | 1997 | ||
2000 | TRACE(("gdth_putq() priority %d\n",priority)); | 1998 | TRACE(("gdth_putq() priority %d\n",priority)); |
2001 | spin_lock_irqsave(&ha->smp_lock, flags); | 1999 | spin_lock_irqsave(&ha->smp_lock, flags); |
2002 | 2000 | ||
2003 | if (!cmndinfo->internal_command) { | 2001 | if (!cmndinfo->internal_command) |
2004 | cmndinfo->priority = priority; | 2002 | cmndinfo->priority = priority; |
2005 | b = scp->device->channel; | ||
2006 | t = scp->device->id; | ||
2007 | if (priority >= DEFAULT_PRI) { | ||
2008 | if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha,b)].lock) || | ||
2009 | (b==ha->virt_bus && t<MAX_HDRIVES && ha->hdr[t].lock)) { | ||
2010 | TRACE2(("gdth_putq(): locked IO ->update_timeout()\n")); | ||
2011 | cmndinfo->timeout = gdth_update_timeout(scp, 0); | ||
2012 | } | ||
2013 | } | ||
2014 | } | ||
2015 | 2003 | ||
2016 | if (ha->req_first==NULL) { | 2004 | if (ha->req_first==NULL) { |
2017 | ha->req_first = scp; /* queue was empty */ | 2005 | ha->req_first = scp; /* queue was empty */ |
@@ -3899,6 +3887,39 @@ static const char *gdth_info(struct Scsi_Host *shp) | |||
3899 | return ((const char *)ha->binfo.type_string); | 3887 | return ((const char *)ha->binfo.type_string); |
3900 | } | 3888 | } |
3901 | 3889 | ||
3890 | static enum blk_eh_timer_return gdth_timed_out(struct scsi_cmnd *scp) | ||
3891 | { | ||
3892 | gdth_ha_str *ha = shost_priv(scp->device->host); | ||
3893 | struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); | ||
3894 | unchar b, t; | ||
3895 | ulong flags; | ||
3896 | enum blk_eh_timer_return retval = BLK_EH_NOT_HANDLED; | ||
3897 | |||
3898 | TRACE(("%s() cmd 0x%x\n", scp->cmnd[0], __func__)); | ||
3899 | b = scp->device->channel; | ||
3900 | t = scp->device->id; | ||
3901 | |||
3902 | /* | ||
3903 | * We don't really honor the command timeout, but we try to | ||
3904 | * honor 6 times of the actual command timeout! So reset the | ||
3905 | * timer if this is less than 6th timeout on this command! | ||
3906 | */ | ||
3907 | if (++cmndinfo->timeout_count < 6) | ||
3908 | retval = BLK_EH_RESET_TIMER; | ||
3909 | |||
3910 | /* Reset the timeout if it is locked IO */ | ||
3911 | spin_lock_irqsave(&ha->smp_lock, flags); | ||
3912 | if ((b != ha->virt_bus && ha->raw[BUS_L2P(ha, b)].lock) || | ||
3913 | (b == ha->virt_bus && t < MAX_HDRIVES && ha->hdr[t].lock)) { | ||
3914 | TRACE2(("%s(): locked IO, reset timeout\n", __func__)); | ||
3915 | retval = BLK_EH_RESET_TIMER; | ||
3916 | } | ||
3917 | spin_unlock_irqrestore(&ha->smp_lock, flags); | ||
3918 | |||
3919 | return retval; | ||
3920 | } | ||
3921 | |||
3922 | |||
3902 | static int gdth_eh_bus_reset(Scsi_Cmnd *scp) | 3923 | static int gdth_eh_bus_reset(Scsi_Cmnd *scp) |
3903 | { | 3924 | { |
3904 | gdth_ha_str *ha = shost_priv(scp->device->host); | 3925 | gdth_ha_str *ha = shost_priv(scp->device->host); |
@@ -3992,7 +4013,7 @@ static int gdth_queuecommand(struct scsi_cmnd *scp, | |||
3992 | BUG_ON(!cmndinfo); | 4013 | BUG_ON(!cmndinfo); |
3993 | 4014 | ||
3994 | scp->scsi_done = done; | 4015 | scp->scsi_done = done; |
3995 | gdth_update_timeout(scp, scp->timeout_per_command * 6); | 4016 | cmndinfo->timeout_count = 0; |
3996 | cmndinfo->priority = DEFAULT_PRI; | 4017 | cmndinfo->priority = DEFAULT_PRI; |
3997 | 4018 | ||
3998 | return __gdth_queuecommand(ha, scp, cmndinfo); | 4019 | return __gdth_queuecommand(ha, scp, cmndinfo); |
@@ -4096,12 +4117,10 @@ static int ioc_lockdrv(void __user *arg) | |||
4096 | ha->hdr[j].lock = 1; | 4117 | ha->hdr[j].lock = 1; |
4097 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 4118 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
4098 | gdth_wait_completion(ha, ha->bus_cnt, j); | 4119 | gdth_wait_completion(ha, ha->bus_cnt, j); |
4099 | gdth_stop_timeout(ha, ha->bus_cnt, j); | ||
4100 | } else { | 4120 | } else { |
4101 | spin_lock_irqsave(&ha->smp_lock, flags); | 4121 | spin_lock_irqsave(&ha->smp_lock, flags); |
4102 | ha->hdr[j].lock = 0; | 4122 | ha->hdr[j].lock = 0; |
4103 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 4123 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
4104 | gdth_start_timeout(ha, ha->bus_cnt, j); | ||
4105 | gdth_next(ha); | 4124 | gdth_next(ha); |
4106 | } | 4125 | } |
4107 | } | 4126 | } |
@@ -4539,18 +4558,14 @@ static int gdth_ioctl(struct inode *inode, struct file *filep, | |||
4539 | spin_lock_irqsave(&ha->smp_lock, flags); | 4558 | spin_lock_irqsave(&ha->smp_lock, flags); |
4540 | ha->raw[i].lock = 1; | 4559 | ha->raw[i].lock = 1; |
4541 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 4560 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
4542 | for (j = 0; j < ha->tid_cnt; ++j) { | 4561 | for (j = 0; j < ha->tid_cnt; ++j) |
4543 | gdth_wait_completion(ha, i, j); | 4562 | gdth_wait_completion(ha, i, j); |
4544 | gdth_stop_timeout(ha, i, j); | ||
4545 | } | ||
4546 | } else { | 4563 | } else { |
4547 | spin_lock_irqsave(&ha->smp_lock, flags); | 4564 | spin_lock_irqsave(&ha->smp_lock, flags); |
4548 | ha->raw[i].lock = 0; | 4565 | ha->raw[i].lock = 0; |
4549 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 4566 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
4550 | for (j = 0; j < ha->tid_cnt; ++j) { | 4567 | for (j = 0; j < ha->tid_cnt; ++j) |
4551 | gdth_start_timeout(ha, i, j); | ||
4552 | gdth_next(ha); | 4568 | gdth_next(ha); |
4553 | } | ||
4554 | } | 4569 | } |
4555 | } | 4570 | } |
4556 | break; | 4571 | break; |
@@ -4644,6 +4659,7 @@ static struct scsi_host_template gdth_template = { | |||
4644 | .slave_configure = gdth_slave_configure, | 4659 | .slave_configure = gdth_slave_configure, |
4645 | .bios_param = gdth_bios_param, | 4660 | .bios_param = gdth_bios_param, |
4646 | .proc_info = gdth_proc_info, | 4661 | .proc_info = gdth_proc_info, |
4662 | .eh_timed_out = gdth_timed_out, | ||
4647 | .proc_name = "gdth", | 4663 | .proc_name = "gdth", |
4648 | .can_queue = GDTH_MAXCMDS, | 4664 | .can_queue = GDTH_MAXCMDS, |
4649 | .this_id = -1, | 4665 | .this_id = -1, |
diff --git a/drivers/scsi/gdth.h b/drivers/scsi/gdth.h index ca92476727cf..1646444e9bd5 100644 --- a/drivers/scsi/gdth.h +++ b/drivers/scsi/gdth.h | |||
@@ -916,7 +916,7 @@ typedef struct { | |||
916 | gdth_cmd_str *internal_cmd_str; /* crier for internal messages*/ | 916 | gdth_cmd_str *internal_cmd_str; /* crier for internal messages*/ |
917 | dma_addr_t sense_paddr; /* sense dma-addr */ | 917 | dma_addr_t sense_paddr; /* sense dma-addr */ |
918 | unchar priority; | 918 | unchar priority; |
919 | int timeout; | 919 | int timeout_count; /* # of timeout calls */ |
920 | volatile int wait_for_completion; | 920 | volatile int wait_for_completion; |
921 | ushort status; | 921 | ushort status; |
922 | ulong32 info; | 922 | ulong32 info; |
diff --git a/drivers/scsi/gdth_proc.c b/drivers/scsi/gdth_proc.c index ce0228e26aec..59349a316e13 100644 --- a/drivers/scsi/gdth_proc.c +++ b/drivers/scsi/gdth_proc.c | |||
@@ -748,69 +748,3 @@ static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id) | |||
748 | } | 748 | } |
749 | spin_unlock_irqrestore(&ha->smp_lock, flags); | 749 | spin_unlock_irqrestore(&ha->smp_lock, flags); |
750 | } | 750 | } |
751 | |||
752 | static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id) | ||
753 | { | ||
754 | ulong flags; | ||
755 | Scsi_Cmnd *scp; | ||
756 | unchar b, t; | ||
757 | |||
758 | spin_lock_irqsave(&ha->smp_lock, flags); | ||
759 | |||
760 | for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { | ||
761 | struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); | ||
762 | if (!cmndinfo->internal_command) { | ||
763 | b = scp->device->channel; | ||
764 | t = scp->device->id; | ||
765 | if (t == (unchar)id && b == (unchar)busnum) { | ||
766 | TRACE2(("gdth_stop_timeout(): update_timeout()\n")); | ||
767 | cmndinfo->timeout = gdth_update_timeout(scp, 0); | ||
768 | } | ||
769 | } | ||
770 | } | ||
771 | spin_unlock_irqrestore(&ha->smp_lock, flags); | ||
772 | } | ||
773 | |||
774 | static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id) | ||
775 | { | ||
776 | ulong flags; | ||
777 | Scsi_Cmnd *scp; | ||
778 | unchar b, t; | ||
779 | |||
780 | spin_lock_irqsave(&ha->smp_lock, flags); | ||
781 | |||
782 | for (scp = ha->req_first; scp; scp = (Scsi_Cmnd *)scp->SCp.ptr) { | ||
783 | struct gdth_cmndinfo *cmndinfo = gdth_cmnd_priv(scp); | ||
784 | if (!cmndinfo->internal_command) { | ||
785 | b = scp->device->channel; | ||
786 | t = scp->device->id; | ||
787 | if (t == (unchar)id && b == (unchar)busnum) { | ||
788 | TRACE2(("gdth_start_timeout(): update_timeout()\n")); | ||
789 | gdth_update_timeout(scp, cmndinfo->timeout); | ||
790 | } | ||
791 | } | ||
792 | } | ||
793 | spin_unlock_irqrestore(&ha->smp_lock, flags); | ||
794 | } | ||
795 | |||
796 | static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout) | ||
797 | { | ||
798 | int oldto; | ||
799 | |||
800 | oldto = scp->timeout_per_command; | ||
801 | scp->timeout_per_command = timeout; | ||
802 | |||
803 | if (timeout == 0) { | ||
804 | del_timer(&scp->eh_timeout); | ||
805 | scp->eh_timeout.data = (unsigned long) NULL; | ||
806 | scp->eh_timeout.expires = 0; | ||
807 | } else { | ||
808 | if (scp->eh_timeout.data != (unsigned long) NULL) | ||
809 | del_timer(&scp->eh_timeout); | ||
810 | scp->eh_timeout.data = (unsigned long) scp; | ||
811 | scp->eh_timeout.expires = jiffies + timeout; | ||
812 | add_timer(&scp->eh_timeout); | ||
813 | } | ||
814 | |||
815 | return oldto; | ||
816 | } | ||
diff --git a/drivers/scsi/gdth_proc.h b/drivers/scsi/gdth_proc.h index 45e6fdacf36e..9b900cc9ebe8 100644 --- a/drivers/scsi/gdth_proc.h +++ b/drivers/scsi/gdth_proc.h | |||
@@ -20,9 +20,6 @@ static char *gdth_ioctl_alloc(gdth_ha_str *ha, int size, int scratch, | |||
20 | ulong64 *paddr); | 20 | ulong64 *paddr); |
21 | static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr); | 21 | static void gdth_ioctl_free(gdth_ha_str *ha, int size, char *buf, ulong64 paddr); |
22 | static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id); | 22 | static void gdth_wait_completion(gdth_ha_str *ha, int busnum, int id); |
23 | static void gdth_stop_timeout(gdth_ha_str *ha, int busnum, int id); | ||
24 | static void gdth_start_timeout(gdth_ha_str *ha, int busnum, int id); | ||
25 | static int gdth_update_timeout(Scsi_Cmnd *scp, int timeout); | ||
26 | 23 | ||
27 | #endif | 24 | #endif |
28 | 25 | ||
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c index 7b1502c0ab6e..87e09f35d3d4 100644 --- a/drivers/scsi/ibmvscsi/ibmvscsi.c +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c | |||
@@ -756,7 +756,7 @@ static int ibmvscsi_queuecommand(struct scsi_cmnd *cmnd, | |||
756 | init_event_struct(evt_struct, | 756 | init_event_struct(evt_struct, |
757 | handle_cmd_rsp, | 757 | handle_cmd_rsp, |
758 | VIOSRP_SRP_FORMAT, | 758 | VIOSRP_SRP_FORMAT, |
759 | cmnd->timeout_per_command/HZ); | 759 | cmnd->request->timeout/HZ); |
760 | 760 | ||
761 | evt_struct->cmnd = cmnd; | 761 | evt_struct->cmnd = cmnd; |
762 | evt_struct->cmnd_done = done; | 762 | evt_struct->cmnd_done = done; |
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 461331d3dc45..81c16cba5417 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -612,7 +612,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
612 | pc->req_xfer = pc->buf_size = scsi_bufflen(cmd); | 612 | pc->req_xfer = pc->buf_size = scsi_bufflen(cmd); |
613 | pc->scsi_cmd = cmd; | 613 | pc->scsi_cmd = cmd; |
614 | pc->done = done; | 614 | pc->done = done; |
615 | pc->timeout = jiffies + cmd->timeout_per_command; | 615 | pc->timeout = jiffies + cmd->request->timeout; |
616 | 616 | ||
617 | if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { | 617 | if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) { |
618 | printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); | 618 | printk ("ide-scsi: %s: que %lu, cmd = ", drive->name, cmd->serial_number); |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index e7a3a6554425..d30eb7ba018e 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
@@ -3670,7 +3670,8 @@ static int ipr_slave_configure(struct scsi_device *sdev) | |||
3670 | sdev->no_uld_attach = 1; | 3670 | sdev->no_uld_attach = 1; |
3671 | } | 3671 | } |
3672 | if (ipr_is_vset_device(res)) { | 3672 | if (ipr_is_vset_device(res)) { |
3673 | sdev->timeout = IPR_VSET_RW_TIMEOUT; | 3673 | blk_queue_rq_timeout(sdev->request_queue, |
3674 | IPR_VSET_RW_TIMEOUT); | ||
3674 | blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS); | 3675 | blk_queue_max_sectors(sdev->request_queue, IPR_VSET_MAX_SECTORS); |
3675 | } | 3676 | } |
3676 | if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) | 3677 | if (ipr_is_vset_device(res) || ipr_is_scsi_disk(res)) |
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c index bc9e6ddf41df..ef683f0d2b5a 100644 --- a/drivers/scsi/ips.c +++ b/drivers/scsi/ips.c | |||
@@ -3818,7 +3818,7 @@ ips_send_cmd(ips_ha_t * ha, ips_scb_t * scb) | |||
3818 | scb->cmd.dcdb.segment_4G = 0; | 3818 | scb->cmd.dcdb.segment_4G = 0; |
3819 | scb->cmd.dcdb.enhanced_sg = 0; | 3819 | scb->cmd.dcdb.enhanced_sg = 0; |
3820 | 3820 | ||
3821 | TimeOut = scb->scsi_cmd->timeout_per_command; | 3821 | TimeOut = scb->scsi_cmd->request->timeout; |
3822 | 3822 | ||
3823 | if (ha->subsys->param[4] & 0x00100000) { /* If NEW Tape DCDB is Supported */ | 3823 | if (ha->subsys->param[4] & 0x00100000) { /* If NEW Tape DCDB is Supported */ |
3824 | if (!scb->sg_len) { | 3824 | if (!scb->sg_len) { |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 299e075a7b34..1eca82420aab 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
@@ -1476,12 +1476,12 @@ static void iscsi_start_tx(struct iscsi_conn *conn) | |||
1476 | scsi_queue_work(conn->session->host, &conn->xmitwork); | 1476 | scsi_queue_work(conn->session->host, &conn->xmitwork); |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | 1479 | static enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) |
1480 | { | 1480 | { |
1481 | struct iscsi_cls_session *cls_session; | 1481 | struct iscsi_cls_session *cls_session; |
1482 | struct iscsi_session *session; | 1482 | struct iscsi_session *session; |
1483 | struct iscsi_conn *conn; | 1483 | struct iscsi_conn *conn; |
1484 | enum scsi_eh_timer_return rc = EH_NOT_HANDLED; | 1484 | enum blk_eh_timer_return rc = BLK_EH_NOT_HANDLED; |
1485 | 1485 | ||
1486 | cls_session = starget_to_session(scsi_target(scmd->device)); | 1486 | cls_session = starget_to_session(scsi_target(scmd->device)); |
1487 | session = cls_session->dd_data; | 1487 | session = cls_session->dd_data; |
@@ -1494,14 +1494,14 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | |||
1494 | * We are probably in the middle of iscsi recovery so let | 1494 | * We are probably in the middle of iscsi recovery so let |
1495 | * that complete and handle the error. | 1495 | * that complete and handle the error. |
1496 | */ | 1496 | */ |
1497 | rc = EH_RESET_TIMER; | 1497 | rc = BLK_EH_RESET_TIMER; |
1498 | goto done; | 1498 | goto done; |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | conn = session->leadconn; | 1501 | conn = session->leadconn; |
1502 | if (!conn) { | 1502 | if (!conn) { |
1503 | /* In the middle of shuting down */ | 1503 | /* In the middle of shuting down */ |
1504 | rc = EH_RESET_TIMER; | 1504 | rc = BLK_EH_RESET_TIMER; |
1505 | goto done; | 1505 | goto done; |
1506 | } | 1506 | } |
1507 | 1507 | ||
@@ -1513,20 +1513,21 @@ static enum scsi_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *scmd) | |||
1513 | */ | 1513 | */ |
1514 | if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) + | 1514 | if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ) + |
1515 | (conn->ping_timeout * HZ), jiffies)) | 1515 | (conn->ping_timeout * HZ), jiffies)) |
1516 | rc = EH_RESET_TIMER; | 1516 | rc = BLK_EH_RESET_TIMER; |
1517 | /* | 1517 | /* |
1518 | * if we are about to check the transport then give the command | 1518 | * if we are about to check the transport then give the command |
1519 | * more time | 1519 | * more time |
1520 | */ | 1520 | */ |
1521 | if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ), | 1521 | if (time_before_eq(conn->last_recv + (conn->recv_timeout * HZ), |
1522 | jiffies)) | 1522 | jiffies)) |
1523 | rc = EH_RESET_TIMER; | 1523 | rc = BLK_EH_RESET_TIMER; |
1524 | /* if in the middle of checking the transport then give us more time */ | 1524 | /* if in the middle of checking the transport then give us more time */ |
1525 | if (conn->ping_task) | 1525 | if (conn->ping_task) |
1526 | rc = EH_RESET_TIMER; | 1526 | rc = BLK_EH_RESET_TIMER; |
1527 | done: | 1527 | done: |
1528 | spin_unlock(&session->lock); | 1528 | spin_unlock(&session->lock); |
1529 | debug_scsi("return %s\n", rc == EH_RESET_TIMER ? "timer reset" : "nh"); | 1529 | debug_scsi("return %s\n", rc == BLK_EH_RESET_TIMER ? |
1530 | "timer reset" : "nh"); | ||
1530 | return rc; | 1531 | return rc; |
1531 | } | 1532 | } |
1532 | 1533 | ||
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index e1872989710a..e15501170698 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c | |||
@@ -398,7 +398,7 @@ void sas_ata_task_abort(struct sas_task *task) | |||
398 | 398 | ||
399 | /* Bounce SCSI-initiated commands to the SCSI EH */ | 399 | /* Bounce SCSI-initiated commands to the SCSI EH */ |
400 | if (qc->scsicmd) { | 400 | if (qc->scsicmd) { |
401 | scsi_req_abort_cmd(qc->scsicmd); | 401 | blk_abort_request(qc->scsicmd->request); |
402 | scsi_schedule_eh(qc->scsicmd->device->host); | 402 | scsi_schedule_eh(qc->scsicmd->device->host); |
403 | return; | 403 | return; |
404 | } | 404 | } |
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h index b4f9368f116a..0001374bd6b2 100644 --- a/drivers/scsi/libsas/sas_internal.h +++ b/drivers/scsi/libsas/sas_internal.h | |||
@@ -55,7 +55,7 @@ void sas_unregister_phys(struct sas_ha_struct *sas_ha); | |||
55 | int sas_register_ports(struct sas_ha_struct *sas_ha); | 55 | int sas_register_ports(struct sas_ha_struct *sas_ha); |
56 | void sas_unregister_ports(struct sas_ha_struct *sas_ha); | 56 | void sas_unregister_ports(struct sas_ha_struct *sas_ha); |
57 | 57 | ||
58 | enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *); | 58 | enum blk_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *); |
59 | 59 | ||
60 | int sas_init_queue(struct sas_ha_struct *sas_ha); | 60 | int sas_init_queue(struct sas_ha_struct *sas_ha); |
61 | int sas_init_events(struct sas_ha_struct *sas_ha); | 61 | int sas_init_events(struct sas_ha_struct *sas_ha); |
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index a8e3ef309070..744838780ada 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c | |||
@@ -673,43 +673,43 @@ out: | |||
673 | return; | 673 | return; |
674 | } | 674 | } |
675 | 675 | ||
676 | enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd) | 676 | enum blk_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd) |
677 | { | 677 | { |
678 | struct sas_task *task = TO_SAS_TASK(cmd); | 678 | struct sas_task *task = TO_SAS_TASK(cmd); |
679 | unsigned long flags; | 679 | unsigned long flags; |
680 | 680 | ||
681 | if (!task) { | 681 | if (!task) { |
682 | cmd->timeout_per_command /= 2; | 682 | cmd->request->timeout /= 2; |
683 | SAS_DPRINTK("command 0x%p, task 0x%p, gone: %s\n", | 683 | SAS_DPRINTK("command 0x%p, task 0x%p, gone: %s\n", |
684 | cmd, task, (cmd->timeout_per_command ? | 684 | cmd, task, (cmd->request->timeout ? |
685 | "EH_RESET_TIMER" : "EH_NOT_HANDLED")); | 685 | "BLK_EH_RESET_TIMER" : "BLK_EH_NOT_HANDLED")); |
686 | if (!cmd->timeout_per_command) | 686 | if (!cmd->request->timeout) |
687 | return EH_NOT_HANDLED; | 687 | return BLK_EH_NOT_HANDLED; |
688 | return EH_RESET_TIMER; | 688 | return BLK_EH_RESET_TIMER; |
689 | } | 689 | } |
690 | 690 | ||
691 | spin_lock_irqsave(&task->task_state_lock, flags); | 691 | spin_lock_irqsave(&task->task_state_lock, flags); |
692 | BUG_ON(task->task_state_flags & SAS_TASK_STATE_ABORTED); | 692 | BUG_ON(task->task_state_flags & SAS_TASK_STATE_ABORTED); |
693 | if (task->task_state_flags & SAS_TASK_STATE_DONE) { | 693 | if (task->task_state_flags & SAS_TASK_STATE_DONE) { |
694 | spin_unlock_irqrestore(&task->task_state_lock, flags); | 694 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
695 | SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_HANDLED\n", | 695 | SAS_DPRINTK("command 0x%p, task 0x%p, timed out: " |
696 | cmd, task); | 696 | "BLK_EH_HANDLED\n", cmd, task); |
697 | return EH_HANDLED; | 697 | return BLK_EH_HANDLED; |
698 | } | 698 | } |
699 | if (!(task->task_state_flags & SAS_TASK_AT_INITIATOR)) { | 699 | if (!(task->task_state_flags & SAS_TASK_AT_INITIATOR)) { |
700 | spin_unlock_irqrestore(&task->task_state_lock, flags); | 700 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
701 | SAS_DPRINTK("command 0x%p, task 0x%p, not at initiator: " | 701 | SAS_DPRINTK("command 0x%p, task 0x%p, not at initiator: " |
702 | "EH_RESET_TIMER\n", | 702 | "BLK_EH_RESET_TIMER\n", |
703 | cmd, task); | 703 | cmd, task); |
704 | return EH_RESET_TIMER; | 704 | return BLK_EH_RESET_TIMER; |
705 | } | 705 | } |
706 | task->task_state_flags |= SAS_TASK_STATE_ABORTED; | 706 | task->task_state_flags |= SAS_TASK_STATE_ABORTED; |
707 | spin_unlock_irqrestore(&task->task_state_lock, flags); | 707 | spin_unlock_irqrestore(&task->task_state_lock, flags); |
708 | 708 | ||
709 | SAS_DPRINTK("command 0x%p, task 0x%p, timed out: EH_NOT_HANDLED\n", | 709 | SAS_DPRINTK("command 0x%p, task 0x%p, timed out: BLK_EH_NOT_HANDLED\n", |
710 | cmd, task); | 710 | cmd, task); |
711 | 711 | ||
712 | return EH_NOT_HANDLED; | 712 | return BLK_EH_NOT_HANDLED; |
713 | } | 713 | } |
714 | 714 | ||
715 | int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) | 715 | int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) |
@@ -1039,7 +1039,7 @@ void sas_task_abort(struct sas_task *task) | |||
1039 | return; | 1039 | return; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | scsi_req_abort_cmd(sc); | 1042 | blk_abort_request(sc->request); |
1043 | scsi_schedule_eh(sc->device->host); | 1043 | scsi_schedule_eh(sc->device->host); |
1044 | } | 1044 | } |
1045 | 1045 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 97b763378e7d..afe1de998763 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -1167,7 +1167,7 @@ static int megasas_generic_reset(struct scsi_cmnd *scmd) | |||
1167 | * cmd has not been completed within the timeout period. | 1167 | * cmd has not been completed within the timeout period. |
1168 | */ | 1168 | */ |
1169 | static enum | 1169 | static enum |
1170 | scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) | 1170 | blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) |
1171 | { | 1171 | { |
1172 | struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr; | 1172 | struct megasas_cmd *cmd = (struct megasas_cmd *)scmd->SCp.ptr; |
1173 | struct megasas_instance *instance; | 1173 | struct megasas_instance *instance; |
@@ -1175,7 +1175,7 @@ scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) | |||
1175 | 1175 | ||
1176 | if (time_after(jiffies, scmd->jiffies_at_alloc + | 1176 | if (time_after(jiffies, scmd->jiffies_at_alloc + |
1177 | (MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) { | 1177 | (MEGASAS_DEFAULT_CMD_TIMEOUT * 2) * HZ)) { |
1178 | return EH_NOT_HANDLED; | 1178 | return BLK_EH_NOT_HANDLED; |
1179 | } | 1179 | } |
1180 | 1180 | ||
1181 | instance = cmd->instance; | 1181 | instance = cmd->instance; |
@@ -1189,7 +1189,7 @@ scsi_eh_timer_return megasas_reset_timer(struct scsi_cmnd *scmd) | |||
1189 | 1189 | ||
1190 | spin_unlock_irqrestore(instance->host->host_lock, flags); | 1190 | spin_unlock_irqrestore(instance->host->host_lock, flags); |
1191 | } | 1191 | } |
1192 | return EH_RESET_TIMER; | 1192 | return BLK_EH_RESET_TIMER; |
1193 | } | 1193 | } |
1194 | 1194 | ||
1195 | /** | 1195 | /** |
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c index c57c94c0ffd2..3b7240e40819 100644 --- a/drivers/scsi/ncr53c8xx.c +++ b/drivers/scsi/ncr53c8xx.c | |||
@@ -4170,8 +4170,8 @@ static int ncr_queue_command (struct ncb *np, struct scsi_cmnd *cmd) | |||
4170 | ** | 4170 | ** |
4171 | **---------------------------------------------------- | 4171 | **---------------------------------------------------- |
4172 | */ | 4172 | */ |
4173 | if (np->settle_time && cmd->timeout_per_command >= HZ) { | 4173 | if (np->settle_time && cmd->request->timeout >= HZ) { |
4174 | u_long tlimit = jiffies + cmd->timeout_per_command - HZ; | 4174 | u_long tlimit = jiffies + cmd->request->timeout - HZ; |
4175 | if (time_after(np->settle_time, tlimit)) | 4175 | if (time_after(np->settle_time, tlimit)) |
4176 | np->settle_time = tlimit; | 4176 | np->settle_time = tlimit; |
4177 | } | 4177 | } |
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c index 37f9ba0cd798..b6cd12b2e996 100644 --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c | |||
@@ -2845,7 +2845,7 @@ qla1280_64bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
2845 | memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); | 2845 | memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); |
2846 | 2846 | ||
2847 | /* Set ISP command timeout. */ | 2847 | /* Set ISP command timeout. */ |
2848 | pkt->timeout = cpu_to_le16(cmd->timeout_per_command/HZ); | 2848 | pkt->timeout = cpu_to_le16(cmd->request->timeout/HZ); |
2849 | 2849 | ||
2850 | /* Set device target ID and LUN */ | 2850 | /* Set device target ID and LUN */ |
2851 | pkt->lun = SCSI_LUN_32(cmd); | 2851 | pkt->lun = SCSI_LUN_32(cmd); |
@@ -3114,7 +3114,7 @@ qla1280_32bit_start_scsi(struct scsi_qla_host *ha, struct srb * sp) | |||
3114 | memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); | 3114 | memset(((char *)pkt + 8), 0, (REQUEST_ENTRY_SIZE - 8)); |
3115 | 3115 | ||
3116 | /* Set ISP command timeout. */ | 3116 | /* Set ISP command timeout. */ |
3117 | pkt->timeout = cpu_to_le16(cmd->timeout_per_command/HZ); | 3117 | pkt->timeout = cpu_to_le16(cmd->request->timeout/HZ); |
3118 | 3118 | ||
3119 | /* Set device target ID and LUN */ | 3119 | /* Set device target ID and LUN */ |
3120 | pkt->lun = SCSI_LUN_32(cmd); | 3120 | pkt->lun = SCSI_LUN_32(cmd); |
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c index 88bebb13bc52..de8279ad7d89 100644 --- a/drivers/scsi/qla4xxx/ql4_os.c +++ b/drivers/scsi/qla4xxx/ql4_os.c | |||
@@ -1542,7 +1542,7 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd) | |||
1542 | DEBUG2(printk(KERN_INFO | 1542 | DEBUG2(printk(KERN_INFO |
1543 | "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x," | 1543 | "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x," |
1544 | "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no, | 1544 | "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no, |
1545 | cmd, jiffies, cmd->timeout_per_command / HZ, | 1545 | cmd, jiffies, cmd->request->timeout / HZ, |
1546 | ha->dpc_flags, cmd->result, cmd->allowed)); | 1546 | ha->dpc_flags, cmd->result, cmd->allowed)); |
1547 | 1547 | ||
1548 | /* FIXME: wait for hba to go online */ | 1548 | /* FIXME: wait for hba to go online */ |
@@ -1598,7 +1598,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd) | |||
1598 | DEBUG2(printk(KERN_INFO | 1598 | DEBUG2(printk(KERN_INFO |
1599 | "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, " | 1599 | "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, " |
1600 | "to=%x,dpc_flags=%lx, status=%x allowed=%d\n", | 1600 | "to=%x,dpc_flags=%lx, status=%x allowed=%d\n", |
1601 | ha->host_no, cmd, jiffies, cmd->timeout_per_command / HZ, | 1601 | ha->host_no, cmd, jiffies, cmd->request->timeout / HZ, |
1602 | ha->dpc_flags, cmd->result, cmd->allowed)); | 1602 | ha->dpc_flags, cmd->result, cmd->allowed)); |
1603 | 1603 | ||
1604 | stat = qla4xxx_reset_target(ha, ddb_entry); | 1604 | stat = qla4xxx_reset_target(ha, ddb_entry); |
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index ee6be596503d..dbeb86cafc0d 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c | |||
@@ -291,7 +291,6 @@ struct scsi_cmnd *scsi_get_command(struct scsi_device *dev, gfp_t gfp_mask) | |||
291 | unsigned long flags; | 291 | unsigned long flags; |
292 | 292 | ||
293 | cmd->device = dev; | 293 | cmd->device = dev; |
294 | init_timer(&cmd->eh_timeout); | ||
295 | INIT_LIST_HEAD(&cmd->list); | 294 | INIT_LIST_HEAD(&cmd->list); |
296 | spin_lock_irqsave(&dev->list_lock, flags); | 295 | spin_lock_irqsave(&dev->list_lock, flags); |
297 | list_add_tail(&cmd->list, &dev->cmd_list); | 296 | list_add_tail(&cmd->list, &dev->cmd_list); |
@@ -652,14 +651,19 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
652 | unsigned long timeout; | 651 | unsigned long timeout; |
653 | int rtn = 0; | 652 | int rtn = 0; |
654 | 653 | ||
654 | /* | ||
655 | * We will use a queued command if possible, otherwise we will | ||
656 | * emulate the queuing and calling of completion function ourselves. | ||
657 | */ | ||
658 | atomic_inc(&cmd->device->iorequest_cnt); | ||
659 | |||
655 | /* check if the device is still usable */ | 660 | /* check if the device is still usable */ |
656 | if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { | 661 | if (unlikely(cmd->device->sdev_state == SDEV_DEL)) { |
657 | /* in SDEV_DEL we error all commands. DID_NO_CONNECT | 662 | /* in SDEV_DEL we error all commands. DID_NO_CONNECT |
658 | * returns an immediate error upwards, and signals | 663 | * returns an immediate error upwards, and signals |
659 | * that the device is no longer present */ | 664 | * that the device is no longer present */ |
660 | cmd->result = DID_NO_CONNECT << 16; | 665 | cmd->result = DID_NO_CONNECT << 16; |
661 | atomic_inc(&cmd->device->iorequest_cnt); | 666 | scsi_done(cmd); |
662 | __scsi_done(cmd); | ||
663 | /* return 0 (because the command has been processed) */ | 667 | /* return 0 (because the command has been processed) */ |
664 | goto out; | 668 | goto out; |
665 | } | 669 | } |
@@ -672,6 +676,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
672 | * future requests should not occur until the device | 676 | * future requests should not occur until the device |
673 | * transitions out of the suspend state. | 677 | * transitions out of the suspend state. |
674 | */ | 678 | */ |
679 | |||
675 | scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); | 680 | scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY); |
676 | 681 | ||
677 | SCSI_LOG_MLQUEUE(3, printk("queuecommand : device blocked \n")); | 682 | SCSI_LOG_MLQUEUE(3, printk("queuecommand : device blocked \n")); |
@@ -714,21 +719,9 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
714 | host->resetting = 0; | 719 | host->resetting = 0; |
715 | } | 720 | } |
716 | 721 | ||
717 | /* | ||
718 | * AK: unlikely race here: for some reason the timer could | ||
719 | * expire before the serial number is set up below. | ||
720 | */ | ||
721 | scsi_add_timer(cmd, cmd->timeout_per_command, scsi_times_out); | ||
722 | |||
723 | scsi_log_send(cmd); | 722 | scsi_log_send(cmd); |
724 | 723 | ||
725 | /* | 724 | /* |
726 | * We will use a queued command if possible, otherwise we will | ||
727 | * emulate the queuing and calling of completion function ourselves. | ||
728 | */ | ||
729 | atomic_inc(&cmd->device->iorequest_cnt); | ||
730 | |||
731 | /* | ||
732 | * Before we queue this command, check if the command | 725 | * Before we queue this command, check if the command |
733 | * length exceeds what the host adapter can handle. | 726 | * length exceeds what the host adapter can handle. |
734 | */ | 727 | */ |
@@ -744,6 +737,12 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
744 | } | 737 | } |
745 | 738 | ||
746 | spin_lock_irqsave(host->host_lock, flags); | 739 | spin_lock_irqsave(host->host_lock, flags); |
740 | /* | ||
741 | * AK: unlikely race here: for some reason the timer could | ||
742 | * expire before the serial number is set up below. | ||
743 | * | ||
744 | * TODO: kill serial or move to blk layer | ||
745 | */ | ||
747 | scsi_cmd_get_serial(host, cmd); | 746 | scsi_cmd_get_serial(host, cmd); |
748 | 747 | ||
749 | if (unlikely(host->shost_state == SHOST_DEL)) { | 748 | if (unlikely(host->shost_state == SHOST_DEL)) { |
@@ -754,12 +753,8 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
754 | } | 753 | } |
755 | spin_unlock_irqrestore(host->host_lock, flags); | 754 | spin_unlock_irqrestore(host->host_lock, flags); |
756 | if (rtn) { | 755 | if (rtn) { |
757 | if (scsi_delete_timer(cmd)) { | 756 | scsi_queue_insert(cmd, (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ? |
758 | atomic_inc(&cmd->device->iodone_cnt); | 757 | rtn : SCSI_MLQUEUE_HOST_BUSY); |
759 | scsi_queue_insert(cmd, | ||
760 | (rtn == SCSI_MLQUEUE_DEVICE_BUSY) ? | ||
761 | rtn : SCSI_MLQUEUE_HOST_BUSY); | ||
762 | } | ||
763 | SCSI_LOG_MLQUEUE(3, | 758 | SCSI_LOG_MLQUEUE(3, |
764 | printk("queuecommand : request rejected\n")); | 759 | printk("queuecommand : request rejected\n")); |
765 | } | 760 | } |
@@ -770,24 +765,6 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd) | |||
770 | } | 765 | } |
771 | 766 | ||
772 | /** | 767 | /** |
773 | * scsi_req_abort_cmd -- Request command recovery for the specified command | ||
774 | * @cmd: pointer to the SCSI command of interest | ||
775 | * | ||
776 | * This function requests that SCSI Core start recovery for the | ||
777 | * command by deleting the timer and adding the command to the eh | ||
778 | * queue. It can be called by either LLDDs or SCSI Core. LLDDs who | ||
779 | * implement their own error recovery MAY ignore the timeout event if | ||
780 | * they generated scsi_req_abort_cmd. | ||
781 | */ | ||
782 | void scsi_req_abort_cmd(struct scsi_cmnd *cmd) | ||
783 | { | ||
784 | if (!scsi_delete_timer(cmd)) | ||
785 | return; | ||
786 | scsi_times_out(cmd); | ||
787 | } | ||
788 | EXPORT_SYMBOL(scsi_req_abort_cmd); | ||
789 | |||
790 | /** | ||
791 | * scsi_done - Enqueue the finished SCSI command into the done queue. | 768 | * scsi_done - Enqueue the finished SCSI command into the done queue. |
792 | * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives | 769 | * @cmd: The SCSI Command for which a low-level device driver (LLDD) gives |
793 | * ownership back to SCSI Core -- i.e. the LLDD has finished with it. | 770 | * ownership back to SCSI Core -- i.e. the LLDD has finished with it. |
@@ -802,42 +779,7 @@ EXPORT_SYMBOL(scsi_req_abort_cmd); | |||
802 | */ | 779 | */ |
803 | static void scsi_done(struct scsi_cmnd *cmd) | 780 | static void scsi_done(struct scsi_cmnd *cmd) |
804 | { | 781 | { |
805 | /* | 782 | blk_complete_request(cmd->request); |
806 | * We don't have to worry about this one timing out anymore. | ||
807 | * If we are unable to remove the timer, then the command | ||
808 | * has already timed out. In which case, we have no choice but to | ||
809 | * let the timeout function run, as we have no idea where in fact | ||
810 | * that function could really be. It might be on another processor, | ||
811 | * etc, etc. | ||
812 | */ | ||
813 | if (!scsi_delete_timer(cmd)) | ||
814 | return; | ||
815 | __scsi_done(cmd); | ||
816 | } | ||
817 | |||
818 | /* Private entry to scsi_done() to complete a command when the timer | ||
819 | * isn't running --- used by scsi_times_out */ | ||
820 | void __scsi_done(struct scsi_cmnd *cmd) | ||
821 | { | ||
822 | struct request *rq = cmd->request; | ||
823 | |||
824 | /* | ||
825 | * Set the serial numbers back to zero | ||
826 | */ | ||
827 | cmd->serial_number = 0; | ||
828 | |||
829 | atomic_inc(&cmd->device->iodone_cnt); | ||
830 | if (cmd->result) | ||
831 | atomic_inc(&cmd->device->ioerr_cnt); | ||
832 | |||
833 | BUG_ON(!rq); | ||
834 | |||
835 | /* | ||
836 | * The uptodate/nbytes values don't matter, as we allow partial | ||
837 | * completes and thus will check this in the softirq callback | ||
838 | */ | ||
839 | rq->completion_data = cmd; | ||
840 | blk_complete_request(rq); | ||
841 | } | 783 | } |
842 | 784 | ||
843 | /* Move this to a header if it becomes more generally useful */ | 785 | /* Move this to a header if it becomes more generally useful */ |
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 39ce3aba1dac..fecefa05cb62 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c | |||
@@ -112,69 +112,8 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | /** | 114 | /** |
115 | * scsi_add_timer - Start timeout timer for a single scsi command. | ||
116 | * @scmd: scsi command that is about to start running. | ||
117 | * @timeout: amount of time to allow this command to run. | ||
118 | * @complete: timeout function to call if timer isn't canceled. | ||
119 | * | ||
120 | * Notes: | ||
121 | * This should be turned into an inline function. Each scsi command | ||
122 | * has its own timer, and as it is added to the queue, we set up the | ||
123 | * timer. When the command completes, we cancel the timer. | ||
124 | */ | ||
125 | void scsi_add_timer(struct scsi_cmnd *scmd, int timeout, | ||
126 | void (*complete)(struct scsi_cmnd *)) | ||
127 | { | ||
128 | |||
129 | /* | ||
130 | * If the clock was already running for this command, then | ||
131 | * first delete the timer. The timer handling code gets rather | ||
132 | * confused if we don't do this. | ||
133 | */ | ||
134 | if (scmd->eh_timeout.function) | ||
135 | del_timer(&scmd->eh_timeout); | ||
136 | |||
137 | scmd->eh_timeout.data = (unsigned long)scmd; | ||
138 | scmd->eh_timeout.expires = jiffies + timeout; | ||
139 | scmd->eh_timeout.function = (void (*)(unsigned long)) complete; | ||
140 | |||
141 | SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p, time:" | ||
142 | " %d, (%p)\n", __func__, | ||
143 | scmd, timeout, complete)); | ||
144 | |||
145 | add_timer(&scmd->eh_timeout); | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * scsi_delete_timer - Delete/cancel timer for a given function. | ||
150 | * @scmd: Cmd that we are canceling timer for | ||
151 | * | ||
152 | * Notes: | ||
153 | * This should be turned into an inline function. | ||
154 | * | ||
155 | * Return value: | ||
156 | * 1 if we were able to detach the timer. 0 if we blew it, and the | ||
157 | * timer function has already started to run. | ||
158 | */ | ||
159 | int scsi_delete_timer(struct scsi_cmnd *scmd) | ||
160 | { | ||
161 | int rtn; | ||
162 | |||
163 | rtn = del_timer(&scmd->eh_timeout); | ||
164 | |||
165 | SCSI_LOG_ERROR_RECOVERY(5, printk("%s: scmd: %p," | ||
166 | " rtn: %d\n", __func__, | ||
167 | scmd, rtn)); | ||
168 | |||
169 | scmd->eh_timeout.data = (unsigned long)NULL; | ||
170 | scmd->eh_timeout.function = NULL; | ||
171 | |||
172 | return rtn; | ||
173 | } | ||
174 | |||
175 | /** | ||
176 | * scsi_times_out - Timeout function for normal scsi commands. | 115 | * scsi_times_out - Timeout function for normal scsi commands. |
177 | * @scmd: Cmd that is timing out. | 116 | * @req: request that is timing out. |
178 | * | 117 | * |
179 | * Notes: | 118 | * Notes: |
180 | * We do not need to lock this. There is the potential for a race | 119 | * We do not need to lock this. There is the potential for a race |
@@ -182,9 +121,11 @@ int scsi_delete_timer(struct scsi_cmnd *scmd) | |||
182 | * normal completion function determines that the timer has already | 121 | * normal completion function determines that the timer has already |
183 | * fired, then it mustn't do anything. | 122 | * fired, then it mustn't do anything. |
184 | */ | 123 | */ |
185 | void scsi_times_out(struct scsi_cmnd *scmd) | 124 | enum blk_eh_timer_return scsi_times_out(struct request *req) |
186 | { | 125 | { |
187 | enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *); | 126 | struct scsi_cmnd *scmd = req->special; |
127 | enum blk_eh_timer_return (*eh_timed_out)(struct scsi_cmnd *); | ||
128 | enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED; | ||
188 | 129 | ||
189 | scsi_log_completion(scmd, TIMEOUT_ERROR); | 130 | scsi_log_completion(scmd, TIMEOUT_ERROR); |
190 | 131 | ||
@@ -196,22 +137,20 @@ void scsi_times_out(struct scsi_cmnd *scmd) | |||
196 | eh_timed_out = NULL; | 137 | eh_timed_out = NULL; |
197 | 138 | ||
198 | if (eh_timed_out) | 139 | if (eh_timed_out) |
199 | switch (eh_timed_out(scmd)) { | 140 | rtn = eh_timed_out(scmd); |
200 | case EH_HANDLED: | 141 | switch (rtn) { |
201 | __scsi_done(scmd); | 142 | case BLK_EH_NOT_HANDLED: |
202 | return; | ||
203 | case EH_RESET_TIMER: | ||
204 | scsi_add_timer(scmd, scmd->timeout_per_command, | ||
205 | scsi_times_out); | ||
206 | return; | ||
207 | case EH_NOT_HANDLED: | ||
208 | break; | 143 | break; |
144 | default: | ||
145 | return rtn; | ||
209 | } | 146 | } |
210 | 147 | ||
211 | if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { | 148 | if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) { |
212 | scmd->result |= DID_TIME_OUT << 16; | 149 | scmd->result |= DID_TIME_OUT << 16; |
213 | __scsi_done(scmd); | 150 | return BLK_EH_HANDLED; |
214 | } | 151 | } |
152 | |||
153 | return BLK_EH_NOT_HANDLED; | ||
215 | } | 154 | } |
216 | 155 | ||
217 | /** | 156 | /** |
@@ -1793,7 +1732,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag) | |||
1793 | 1732 | ||
1794 | blk_rq_init(NULL, &req); | 1733 | blk_rq_init(NULL, &req); |
1795 | scmd->request = &req; | 1734 | scmd->request = &req; |
1796 | memset(&scmd->eh_timeout, 0, sizeof(scmd->eh_timeout)); | ||
1797 | 1735 | ||
1798 | scmd->cmnd = req.cmd; | 1736 | scmd->cmnd = req.cmd; |
1799 | 1737 | ||
@@ -1804,8 +1742,6 @@ scsi_reset_provider(struct scsi_device *dev, int flag) | |||
1804 | 1742 | ||
1805 | scmd->sc_data_direction = DMA_BIDIRECTIONAL; | 1743 | scmd->sc_data_direction = DMA_BIDIRECTIONAL; |
1806 | 1744 | ||
1807 | init_timer(&scmd->eh_timeout); | ||
1808 | |||
1809 | spin_lock_irqsave(shost->host_lock, flags); | 1745 | spin_lock_irqsave(shost->host_lock, flags); |
1810 | shost->tmf_in_progress = 1; | 1746 | shost->tmf_in_progress = 1; |
1811 | spin_unlock_irqrestore(shost->host_lock, flags); | 1747 | spin_unlock_irqrestore(shost->host_lock, flags); |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 62307bd794a9..e7686500e9dd 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
@@ -1181,7 +1181,6 @@ int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req) | |||
1181 | 1181 | ||
1182 | cmd->transfersize = req->data_len; | 1182 | cmd->transfersize = req->data_len; |
1183 | cmd->allowed = req->retries; | 1183 | cmd->allowed = req->retries; |
1184 | cmd->timeout_per_command = req->timeout; | ||
1185 | return BLKPREP_OK; | 1184 | return BLKPREP_OK; |
1186 | } | 1185 | } |
1187 | EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd); | 1186 | EXPORT_SYMBOL(scsi_setup_blk_pc_cmnd); |
@@ -1416,17 +1415,26 @@ static void scsi_kill_request(struct request *req, struct request_queue *q) | |||
1416 | spin_unlock(shost->host_lock); | 1415 | spin_unlock(shost->host_lock); |
1417 | spin_lock(sdev->request_queue->queue_lock); | 1416 | spin_lock(sdev->request_queue->queue_lock); |
1418 | 1417 | ||
1419 | __scsi_done(cmd); | 1418 | blk_complete_request(req); |
1420 | } | 1419 | } |
1421 | 1420 | ||
1422 | static void scsi_softirq_done(struct request *rq) | 1421 | static void scsi_softirq_done(struct request *rq) |
1423 | { | 1422 | { |
1424 | struct scsi_cmnd *cmd = rq->completion_data; | 1423 | struct scsi_cmnd *cmd = rq->special; |
1425 | unsigned long wait_for = (cmd->allowed + 1) * cmd->timeout_per_command; | 1424 | unsigned long wait_for = (cmd->allowed + 1) * rq->timeout; |
1426 | int disposition; | 1425 | int disposition; |
1427 | 1426 | ||
1428 | INIT_LIST_HEAD(&cmd->eh_entry); | 1427 | INIT_LIST_HEAD(&cmd->eh_entry); |
1429 | 1428 | ||
1429 | /* | ||
1430 | * Set the serial numbers back to zero | ||
1431 | */ | ||
1432 | cmd->serial_number = 0; | ||
1433 | |||
1434 | atomic_inc(&cmd->device->iodone_cnt); | ||
1435 | if (cmd->result) | ||
1436 | atomic_inc(&cmd->device->ioerr_cnt); | ||
1437 | |||
1430 | disposition = scsi_decide_disposition(cmd); | 1438 | disposition = scsi_decide_disposition(cmd); |
1431 | if (disposition != SUCCESS && | 1439 | if (disposition != SUCCESS && |
1432 | time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) { | 1440 | time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) { |
@@ -1675,6 +1683,7 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev) | |||
1675 | 1683 | ||
1676 | blk_queue_prep_rq(q, scsi_prep_fn); | 1684 | blk_queue_prep_rq(q, scsi_prep_fn); |
1677 | blk_queue_softirq_done(q, scsi_softirq_done); | 1685 | blk_queue_softirq_done(q, scsi_softirq_done); |
1686 | blk_queue_rq_timed_out(q, scsi_times_out); | ||
1678 | return q; | 1687 | return q; |
1679 | } | 1688 | } |
1680 | 1689 | ||
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h index 79f0f7511204..6cddd5dd323c 100644 --- a/drivers/scsi/scsi_priv.h +++ b/drivers/scsi/scsi_priv.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/device.h> | 4 | #include <linux/device.h> |
5 | 5 | ||
6 | struct request_queue; | 6 | struct request_queue; |
7 | struct request; | ||
7 | struct scsi_cmnd; | 8 | struct scsi_cmnd; |
8 | struct scsi_device; | 9 | struct scsi_device; |
9 | struct scsi_host_template; | 10 | struct scsi_host_template; |
@@ -27,7 +28,6 @@ extern void scsi_exit_hosts(void); | |||
27 | extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); | 28 | extern int scsi_dispatch_cmd(struct scsi_cmnd *cmd); |
28 | extern int scsi_setup_command_freelist(struct Scsi_Host *shost); | 29 | extern int scsi_setup_command_freelist(struct Scsi_Host *shost); |
29 | extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); | 30 | extern void scsi_destroy_command_freelist(struct Scsi_Host *shost); |
30 | extern void __scsi_done(struct scsi_cmnd *cmd); | ||
31 | #ifdef CONFIG_SCSI_LOGGING | 31 | #ifdef CONFIG_SCSI_LOGGING |
32 | void scsi_log_send(struct scsi_cmnd *cmd); | 32 | void scsi_log_send(struct scsi_cmnd *cmd); |
33 | void scsi_log_completion(struct scsi_cmnd *cmd, int disposition); | 33 | void scsi_log_completion(struct scsi_cmnd *cmd, int disposition); |
@@ -49,10 +49,7 @@ extern int __init scsi_init_devinfo(void); | |||
49 | extern void scsi_exit_devinfo(void); | 49 | extern void scsi_exit_devinfo(void); |
50 | 50 | ||
51 | /* scsi_error.c */ | 51 | /* scsi_error.c */ |
52 | extern void scsi_add_timer(struct scsi_cmnd *, int, | 52 | extern enum blk_eh_timer_return scsi_times_out(struct request *req); |
53 | void (*)(struct scsi_cmnd *)); | ||
54 | extern int scsi_delete_timer(struct scsi_cmnd *); | ||
55 | extern void scsi_times_out(struct scsi_cmnd *cmd); | ||
56 | extern int scsi_error_handler(void *host); | 53 | extern int scsi_error_handler(void *host); |
57 | extern int scsi_decide_disposition(struct scsi_cmnd *cmd); | 54 | extern int scsi_decide_disposition(struct scsi_cmnd *cmd); |
58 | extern void scsi_eh_wakeup(struct Scsi_Host *shost); | 55 | extern void scsi_eh_wakeup(struct Scsi_Host *shost); |
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index ab3c71869be5..7f618ee5ecea 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -560,12 +560,15 @@ sdev_rd_attr (vendor, "%.8s\n"); | |||
560 | sdev_rd_attr (model, "%.16s\n"); | 560 | sdev_rd_attr (model, "%.16s\n"); |
561 | sdev_rd_attr (rev, "%.4s\n"); | 561 | sdev_rd_attr (rev, "%.4s\n"); |
562 | 562 | ||
563 | /* | ||
564 | * TODO: can we make these symlinks to the block layer ones? | ||
565 | */ | ||
563 | static ssize_t | 566 | static ssize_t |
564 | sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf) | 567 | sdev_show_timeout (struct device *dev, struct device_attribute *attr, char *buf) |
565 | { | 568 | { |
566 | struct scsi_device *sdev; | 569 | struct scsi_device *sdev; |
567 | sdev = to_scsi_device(dev); | 570 | sdev = to_scsi_device(dev); |
568 | return snprintf (buf, 20, "%d\n", sdev->timeout / HZ); | 571 | return snprintf(buf, 20, "%d\n", sdev->request_queue->rq_timeout / HZ); |
569 | } | 572 | } |
570 | 573 | ||
571 | static ssize_t | 574 | static ssize_t |
@@ -576,7 +579,7 @@ sdev_store_timeout (struct device *dev, struct device_attribute *attr, | |||
576 | int timeout; | 579 | int timeout; |
577 | sdev = to_scsi_device(dev); | 580 | sdev = to_scsi_device(dev); |
578 | sscanf (buf, "%d\n", &timeout); | 581 | sscanf (buf, "%d\n", &timeout); |
579 | sdev->timeout = timeout * HZ; | 582 | blk_queue_rq_timeout(sdev->request_queue, timeout * HZ); |
580 | return count; | 583 | return count; |
581 | } | 584 | } |
582 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); | 585 | static DEVICE_ATTR(timeout, S_IRUGO | S_IWUSR, sdev_show_timeout, sdev_store_timeout); |
diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c index 257e097c39af..3117bb106b5d 100644 --- a/drivers/scsi/scsi_tgt_lib.c +++ b/drivers/scsi/scsi_tgt_lib.c | |||
@@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd, | |||
362 | int err; | 362 | int err; |
363 | 363 | ||
364 | dprintk("%lx %u\n", uaddr, len); | 364 | dprintk("%lx %u\n", uaddr, len); |
365 | err = blk_rq_map_user(q, rq, (void *)uaddr, len); | 365 | err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL); |
366 | if (err) { | 366 | if (err) { |
367 | /* | 367 | /* |
368 | * TODO: need to fixup sg_tablesize, max_segment_size, | 368 | * TODO: need to fixup sg_tablesize, max_segment_size, |
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c index 56823fd1fb84..9168883d0dfe 100644 --- a/drivers/scsi/scsi_transport_fc.c +++ b/drivers/scsi/scsi_transport_fc.c | |||
@@ -1950,15 +1950,15 @@ static int fc_vport_match(struct attribute_container *cont, | |||
1950 | * Notes: | 1950 | * Notes: |
1951 | * This routine assumes no locks are held on entry. | 1951 | * This routine assumes no locks are held on entry. |
1952 | */ | 1952 | */ |
1953 | static enum scsi_eh_timer_return | 1953 | static enum blk_eh_timer_return |
1954 | fc_timed_out(struct scsi_cmnd *scmd) | 1954 | fc_timed_out(struct scsi_cmnd *scmd) |
1955 | { | 1955 | { |
1956 | struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device)); | 1956 | struct fc_rport *rport = starget_to_rport(scsi_target(scmd->device)); |
1957 | 1957 | ||
1958 | if (rport->port_state == FC_PORTSTATE_BLOCKED) | 1958 | if (rport->port_state == FC_PORTSTATE_BLOCKED) |
1959 | return EH_RESET_TIMER; | 1959 | return BLK_EH_RESET_TIMER; |
1960 | 1960 | ||
1961 | return EH_NOT_HANDLED; | 1961 | return BLK_EH_NOT_HANDLED; |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | /* | 1964 | /* |
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e5e7d7856454..c0cf4acda7de 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -86,6 +86,12 @@ MODULE_ALIAS_SCSI_DEVICE(TYPE_DISK); | |||
86 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); | 86 | MODULE_ALIAS_SCSI_DEVICE(TYPE_MOD); |
87 | MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); | 87 | MODULE_ALIAS_SCSI_DEVICE(TYPE_RBC); |
88 | 88 | ||
89 | #if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT) | ||
90 | #define SD_MINORS 16 | ||
91 | #else | ||
92 | #define SD_MINORS 0 | ||
93 | #endif | ||
94 | |||
89 | static int sd_revalidate_disk(struct gendisk *); | 95 | static int sd_revalidate_disk(struct gendisk *); |
90 | static int sd_probe(struct device *); | 96 | static int sd_probe(struct device *); |
91 | static int sd_remove(struct device *); | 97 | static int sd_remove(struct device *); |
@@ -159,7 +165,7 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr, | |||
159 | sd_print_sense_hdr(sdkp, &sshdr); | 165 | sd_print_sense_hdr(sdkp, &sshdr); |
160 | return -EINVAL; | 166 | return -EINVAL; |
161 | } | 167 | } |
162 | sd_revalidate_disk(sdkp->disk); | 168 | revalidate_disk(sdkp->disk); |
163 | return count; | 169 | return count; |
164 | } | 170 | } |
165 | 171 | ||
@@ -377,7 +383,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
377 | sector_t block = rq->sector; | 383 | sector_t block = rq->sector; |
378 | sector_t threshold; | 384 | sector_t threshold; |
379 | unsigned int this_count = rq->nr_sectors; | 385 | unsigned int this_count = rq->nr_sectors; |
380 | unsigned int timeout = sdp->timeout; | ||
381 | int ret; | 386 | int ret; |
382 | 387 | ||
383 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { | 388 | if (rq->cmd_type == REQ_TYPE_BLOCK_PC) { |
@@ -578,7 +583,6 @@ static int sd_prep_fn(struct request_queue *q, struct request *rq) | |||
578 | SCpnt->transfersize = sdp->sector_size; | 583 | SCpnt->transfersize = sdp->sector_size; |
579 | SCpnt->underflow = this_count << 9; | 584 | SCpnt->underflow = this_count << 9; |
580 | SCpnt->allowed = SD_MAX_RETRIES; | 585 | SCpnt->allowed = SD_MAX_RETRIES; |
581 | SCpnt->timeout_per_command = timeout; | ||
582 | 586 | ||
583 | /* | 587 | /* |
584 | * This indicates that the command is ready from our end to be | 588 | * This indicates that the command is ready from our end to be |
@@ -910,7 +914,7 @@ static void sd_rescan(struct device *dev) | |||
910 | struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); | 914 | struct scsi_disk *sdkp = scsi_disk_get_from_dev(dev); |
911 | 915 | ||
912 | if (sdkp) { | 916 | if (sdkp) { |
913 | sd_revalidate_disk(sdkp->disk); | 917 | revalidate_disk(sdkp->disk); |
914 | scsi_disk_put(sdkp); | 918 | scsi_disk_put(sdkp); |
915 | } | 919 | } |
916 | } | 920 | } |
@@ -1764,6 +1768,52 @@ static int sd_revalidate_disk(struct gendisk *disk) | |||
1764 | } | 1768 | } |
1765 | 1769 | ||
1766 | /** | 1770 | /** |
1771 | * sd_format_disk_name - format disk name | ||
1772 | * @prefix: name prefix - ie. "sd" for SCSI disks | ||
1773 | * @index: index of the disk to format name for | ||
1774 | * @buf: output buffer | ||
1775 | * @buflen: length of the output buffer | ||
1776 | * | ||
1777 | * SCSI disk names starts at sda. The 26th device is sdz and the | ||
1778 | * 27th is sdaa. The last one for two lettered suffix is sdzz | ||
1779 | * which is followed by sdaaa. | ||
1780 | * | ||
1781 | * This is basically 26 base counting with one extra 'nil' entry | ||
1782 | * at the beggining from the second digit on and can be | ||
1783 | * determined using similar method as 26 base conversion with the | ||
1784 | * index shifted -1 after each digit is computed. | ||
1785 | * | ||
1786 | * CONTEXT: | ||
1787 | * Don't care. | ||
1788 | * | ||
1789 | * RETURNS: | ||
1790 | * 0 on success, -errno on failure. | ||
1791 | */ | ||
1792 | static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen) | ||
1793 | { | ||
1794 | const int base = 'z' - 'a' + 1; | ||
1795 | char *begin = buf + strlen(prefix); | ||
1796 | char *end = buf + buflen; | ||
1797 | char *p; | ||
1798 | int unit; | ||
1799 | |||
1800 | p = end - 1; | ||
1801 | *p = '\0'; | ||
1802 | unit = base; | ||
1803 | do { | ||
1804 | if (p == begin) | ||
1805 | return -EINVAL; | ||
1806 | *--p = 'a' + (index % unit); | ||
1807 | index = (index / unit) - 1; | ||
1808 | } while (index >= 0); | ||
1809 | |||
1810 | memmove(begin, p, end - p); | ||
1811 | memcpy(buf, prefix, strlen(prefix)); | ||
1812 | |||
1813 | return 0; | ||
1814 | } | ||
1815 | |||
1816 | /** | ||
1767 | * sd_probe - called during driver initialization and whenever a | 1817 | * sd_probe - called during driver initialization and whenever a |
1768 | * new scsi device is attached to the system. It is called once | 1818 | * new scsi device is attached to the system. It is called once |
1769 | * for each scsi device (not just disks) present. | 1819 | * for each scsi device (not just disks) present. |
@@ -1801,7 +1851,7 @@ static int sd_probe(struct device *dev) | |||
1801 | if (!sdkp) | 1851 | if (!sdkp) |
1802 | goto out; | 1852 | goto out; |
1803 | 1853 | ||
1804 | gd = alloc_disk(16); | 1854 | gd = alloc_disk(SD_MINORS); |
1805 | if (!gd) | 1855 | if (!gd) |
1806 | goto out_free; | 1856 | goto out_free; |
1807 | 1857 | ||
@@ -1815,8 +1865,8 @@ static int sd_probe(struct device *dev) | |||
1815 | if (error) | 1865 | if (error) |
1816 | goto out_put; | 1866 | goto out_put; |
1817 | 1867 | ||
1818 | error = -EBUSY; | 1868 | error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); |
1819 | if (index >= SD_MAX_DISKS) | 1869 | if (error) |
1820 | goto out_free_index; | 1870 | goto out_free_index; |
1821 | 1871 | ||
1822 | sdkp->device = sdp; | 1872 | sdkp->device = sdp; |
@@ -1826,11 +1876,12 @@ static int sd_probe(struct device *dev) | |||
1826 | sdkp->openers = 0; | 1876 | sdkp->openers = 0; |
1827 | sdkp->previous_state = 1; | 1877 | sdkp->previous_state = 1; |
1828 | 1878 | ||
1829 | if (!sdp->timeout) { | 1879 | if (!sdp->request_queue->rq_timeout) { |
1830 | if (sdp->type != TYPE_MOD) | 1880 | if (sdp->type != TYPE_MOD) |
1831 | sdp->timeout = SD_TIMEOUT; | 1881 | blk_queue_rq_timeout(sdp->request_queue, SD_TIMEOUT); |
1832 | else | 1882 | else |
1833 | sdp->timeout = SD_MOD_TIMEOUT; | 1883 | blk_queue_rq_timeout(sdp->request_queue, |
1884 | SD_MOD_TIMEOUT); | ||
1834 | } | 1885 | } |
1835 | 1886 | ||
1836 | device_initialize(&sdkp->dev); | 1887 | device_initialize(&sdkp->dev); |
@@ -1843,24 +1894,12 @@ static int sd_probe(struct device *dev) | |||
1843 | 1894 | ||
1844 | get_device(&sdp->sdev_gendev); | 1895 | get_device(&sdp->sdev_gendev); |
1845 | 1896 | ||
1846 | gd->major = sd_major((index & 0xf0) >> 4); | 1897 | if (index < SD_MAX_DISKS) { |
1847 | gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); | 1898 | gd->major = sd_major((index & 0xf0) >> 4); |
1848 | gd->minors = 16; | 1899 | gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00); |
1849 | gd->fops = &sd_fops; | 1900 | gd->minors = SD_MINORS; |
1850 | |||
1851 | if (index < 26) { | ||
1852 | sprintf(gd->disk_name, "sd%c", 'a' + index % 26); | ||
1853 | } else if (index < (26 + 1) * 26) { | ||
1854 | sprintf(gd->disk_name, "sd%c%c", | ||
1855 | 'a' + index / 26 - 1,'a' + index % 26); | ||
1856 | } else { | ||
1857 | const unsigned int m1 = (index / 26 - 1) / 26 - 1; | ||
1858 | const unsigned int m2 = (index / 26 - 1) % 26; | ||
1859 | const unsigned int m3 = index % 26; | ||
1860 | sprintf(gd->disk_name, "sd%c%c%c", | ||
1861 | 'a' + m1, 'a' + m2, 'a' + m3); | ||
1862 | } | 1901 | } |
1863 | 1902 | gd->fops = &sd_fops; | |
1864 | gd->private_data = &sdkp->driver; | 1903 | gd->private_data = &sdkp->driver; |
1865 | gd->queue = sdkp->device->request_queue; | 1904 | gd->queue = sdkp->device->request_queue; |
1866 | 1905 | ||
@@ -1869,7 +1908,7 @@ static int sd_probe(struct device *dev) | |||
1869 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); | 1908 | blk_queue_prep_rq(sdp->request_queue, sd_prep_fn); |
1870 | 1909 | ||
1871 | gd->driverfs_dev = &sdp->sdev_gendev; | 1910 | gd->driverfs_dev = &sdp->sdev_gendev; |
1872 | gd->flags = GENHD_FL_DRIVERFS; | 1911 | gd->flags = GENHD_FL_EXT_DEVT | GENHD_FL_DRIVERFS; |
1873 | if (sdp->removable) | 1912 | if (sdp->removable) |
1874 | gd->flags |= GENHD_FL_REMOVABLE; | 1913 | gd->flags |= GENHD_FL_REMOVABLE; |
1875 | 1914 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 661f9f21650a..ba9b9bbd4e73 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -47,7 +47,6 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
47 | #include <linux/seq_file.h> | 47 | #include <linux/seq_file.h> |
48 | #include <linux/blkdev.h> | 48 | #include <linux/blkdev.h> |
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/scatterlist.h> | ||
51 | #include <linux/blktrace_api.h> | 50 | #include <linux/blktrace_api.h> |
52 | #include <linux/smp_lock.h> | 51 | #include <linux/smp_lock.h> |
53 | 52 | ||
@@ -69,7 +68,6 @@ static void sg_proc_cleanup(void); | |||
69 | #endif | 68 | #endif |
70 | 69 | ||
71 | #define SG_ALLOW_DIO_DEF 0 | 70 | #define SG_ALLOW_DIO_DEF 0 |
72 | #define SG_ALLOW_DIO_CODE /* compile out by commenting this define */ | ||
73 | 71 | ||
74 | #define SG_MAX_DEVS 32768 | 72 | #define SG_MAX_DEVS 32768 |
75 | 73 | ||
@@ -118,8 +116,8 @@ typedef struct sg_scatter_hold { /* holding area for scsi scatter gather info */ | |||
118 | unsigned short k_use_sg; /* Count of kernel scatter-gather pieces */ | 116 | unsigned short k_use_sg; /* Count of kernel scatter-gather pieces */ |
119 | unsigned sglist_len; /* size of malloc'd scatter-gather list ++ */ | 117 | unsigned sglist_len; /* size of malloc'd scatter-gather list ++ */ |
120 | unsigned bufflen; /* Size of (aggregate) data buffer */ | 118 | unsigned bufflen; /* Size of (aggregate) data buffer */ |
121 | unsigned b_malloc_len; /* actual len malloc'ed in buffer */ | 119 | struct page **pages; |
122 | struct scatterlist *buffer;/* scatter list */ | 120 | int page_order; |
123 | char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */ | 121 | char dio_in_use; /* 0->indirect IO (or mmap), 1->dio */ |
124 | unsigned char cmd_opcode; /* first byte of command */ | 122 | unsigned char cmd_opcode; /* first byte of command */ |
125 | } Sg_scatter_hold; | 123 | } Sg_scatter_hold; |
@@ -137,6 +135,8 @@ typedef struct sg_request { /* SG_MAX_QUEUE requests outstanding per file */ | |||
137 | char orphan; /* 1 -> drop on sight, 0 -> normal */ | 135 | char orphan; /* 1 -> drop on sight, 0 -> normal */ |
138 | char sg_io_owned; /* 1 -> packet belongs to SG_IO */ | 136 | char sg_io_owned; /* 1 -> packet belongs to SG_IO */ |
139 | volatile char done; /* 0->before bh, 1->before read, 2->read */ | 137 | volatile char done; /* 0->before bh, 1->before read, 2->read */ |
138 | struct request *rq; | ||
139 | struct bio *bio; | ||
140 | } Sg_request; | 140 | } Sg_request; |
141 | 141 | ||
142 | typedef struct sg_fd { /* holds the state of a file descriptor */ | 142 | typedef struct sg_fd { /* holds the state of a file descriptor */ |
@@ -175,8 +175,8 @@ typedef struct sg_device { /* holds the state of each scsi generic device */ | |||
175 | 175 | ||
176 | static int sg_fasync(int fd, struct file *filp, int mode); | 176 | static int sg_fasync(int fd, struct file *filp, int mode); |
177 | /* tasklet or soft irq callback */ | 177 | /* tasklet or soft irq callback */ |
178 | static void sg_cmd_done(void *data, char *sense, int result, int resid); | 178 | static void sg_rq_end_io(struct request *rq, int uptodate); |
179 | static int sg_start_req(Sg_request * srp); | 179 | static int sg_start_req(Sg_request *srp, unsigned char *cmd); |
180 | static void sg_finish_rem_req(Sg_request * srp); | 180 | static void sg_finish_rem_req(Sg_request * srp); |
181 | static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); | 181 | static int sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size); |
182 | static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, | 182 | static int sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, |
@@ -188,17 +188,11 @@ static ssize_t sg_new_write(Sg_fd *sfp, struct file *file, | |||
188 | int read_only, Sg_request **o_srp); | 188 | int read_only, Sg_request **o_srp); |
189 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, | 189 | static int sg_common_write(Sg_fd * sfp, Sg_request * srp, |
190 | unsigned char *cmnd, int timeout, int blocking); | 190 | unsigned char *cmnd, int timeout, int blocking); |
191 | static int sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, | ||
192 | int wr_xf, int *countp, unsigned char __user **up); | ||
193 | static int sg_write_xfer(Sg_request * srp); | ||
194 | static int sg_read_xfer(Sg_request * srp); | ||
195 | static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer); | 191 | static int sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer); |
196 | static void sg_remove_scat(Sg_scatter_hold * schp); | 192 | static void sg_remove_scat(Sg_scatter_hold * schp); |
197 | static void sg_build_reserve(Sg_fd * sfp, int req_size); | 193 | static void sg_build_reserve(Sg_fd * sfp, int req_size); |
198 | static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size); | 194 | static void sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size); |
199 | static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp); | 195 | static void sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp); |
200 | static struct page *sg_page_malloc(int rqSz, int lowDma, int *retSzp); | ||
201 | static void sg_page_free(struct page *page, int size); | ||
202 | static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev); | 196 | static Sg_fd *sg_add_sfp(Sg_device * sdp, int dev); |
203 | static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); | 197 | static int sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); |
204 | static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); | 198 | static void __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp); |
@@ -206,7 +200,6 @@ static Sg_request *sg_get_rq_mark(Sg_fd * sfp, int pack_id); | |||
206 | static Sg_request *sg_add_request(Sg_fd * sfp); | 200 | static Sg_request *sg_add_request(Sg_fd * sfp); |
207 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); | 201 | static int sg_remove_request(Sg_fd * sfp, Sg_request * srp); |
208 | static int sg_res_in_use(Sg_fd * sfp); | 202 | static int sg_res_in_use(Sg_fd * sfp); |
209 | static int sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len); | ||
210 | static Sg_device *sg_get_dev(int dev); | 203 | static Sg_device *sg_get_dev(int dev); |
211 | #ifdef CONFIG_SCSI_PROC_FS | 204 | #ifdef CONFIG_SCSI_PROC_FS |
212 | static int sg_last_dev(void); | 205 | static int sg_last_dev(void); |
@@ -529,8 +522,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) | |||
529 | err = -EFAULT; | 522 | err = -EFAULT; |
530 | goto err_out; | 523 | goto err_out; |
531 | } | 524 | } |
532 | err = sg_read_xfer(srp); | 525 | err_out: |
533 | err_out: | ||
534 | sg_finish_rem_req(srp); | 526 | sg_finish_rem_req(srp); |
535 | return (0 == err) ? count : err; | 527 | return (0 == err) ? count : err; |
536 | } | 528 | } |
@@ -612,7 +604,10 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) | |||
612 | else | 604 | else |
613 | hp->dxfer_direction = (mxsize > 0) ? SG_DXFER_FROM_DEV : SG_DXFER_NONE; | 605 | hp->dxfer_direction = (mxsize > 0) ? SG_DXFER_FROM_DEV : SG_DXFER_NONE; |
614 | hp->dxfer_len = mxsize; | 606 | hp->dxfer_len = mxsize; |
615 | hp->dxferp = (char __user *)buf + cmd_size; | 607 | if (hp->dxfer_direction == SG_DXFER_TO_DEV) |
608 | hp->dxferp = (char __user *)buf + cmd_size; | ||
609 | else | ||
610 | hp->dxferp = NULL; | ||
616 | hp->sbp = NULL; | 611 | hp->sbp = NULL; |
617 | hp->timeout = old_hdr.reply_len; /* structure abuse ... */ | 612 | hp->timeout = old_hdr.reply_len; /* structure abuse ... */ |
618 | hp->flags = input_size; /* structure abuse ... */ | 613 | hp->flags = input_size; /* structure abuse ... */ |
@@ -732,16 +727,12 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, | |||
732 | SCSI_LOG_TIMEOUT(4, printk("sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n", | 727 | SCSI_LOG_TIMEOUT(4, printk("sg_common_write: scsi opcode=0x%02x, cmd_size=%d\n", |
733 | (int) cmnd[0], (int) hp->cmd_len)); | 728 | (int) cmnd[0], (int) hp->cmd_len)); |
734 | 729 | ||
735 | if ((k = sg_start_req(srp))) { | 730 | k = sg_start_req(srp, cmnd); |
731 | if (k) { | ||
736 | SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k)); | 732 | SCSI_LOG_TIMEOUT(1, printk("sg_common_write: start_req err=%d\n", k)); |
737 | sg_finish_rem_req(srp); | 733 | sg_finish_rem_req(srp); |
738 | return k; /* probably out of space --> ENOMEM */ | 734 | return k; /* probably out of space --> ENOMEM */ |
739 | } | 735 | } |
740 | if ((k = sg_write_xfer(srp))) { | ||
741 | SCSI_LOG_TIMEOUT(1, printk("sg_common_write: write_xfer, bad address\n")); | ||
742 | sg_finish_rem_req(srp); | ||
743 | return k; | ||
744 | } | ||
745 | if (sdp->detached) { | 736 | if (sdp->detached) { |
746 | sg_finish_rem_req(srp); | 737 | sg_finish_rem_req(srp); |
747 | return -ENODEV; | 738 | return -ENODEV; |
@@ -763,20 +754,11 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp, | |||
763 | break; | 754 | break; |
764 | } | 755 | } |
765 | hp->duration = jiffies_to_msecs(jiffies); | 756 | hp->duration = jiffies_to_msecs(jiffies); |
766 | /* Now send everything of to mid-level. The next time we hear about this | 757 | |
767 | packet is when sg_cmd_done() is called (i.e. a callback). */ | 758 | srp->rq->timeout = timeout; |
768 | if (scsi_execute_async(sdp->device, cmnd, hp->cmd_len, data_dir, srp->data.buffer, | 759 | blk_execute_rq_nowait(sdp->device->request_queue, sdp->disk, |
769 | hp->dxfer_len, srp->data.k_use_sg, timeout, | 760 | srp->rq, 1, sg_rq_end_io); |
770 | SG_DEFAULT_RETRIES, srp, sg_cmd_done, | 761 | return 0; |
771 | GFP_ATOMIC)) { | ||
772 | SCSI_LOG_TIMEOUT(1, printk("sg_common_write: scsi_execute_async failed\n")); | ||
773 | /* | ||
774 | * most likely out of mem, but could also be a bad map | ||
775 | */ | ||
776 | sg_finish_rem_req(srp); | ||
777 | return -ENOMEM; | ||
778 | } else | ||
779 | return 0; | ||
780 | } | 762 | } |
781 | 763 | ||
782 | static int | 764 | static int |
@@ -1192,8 +1174,7 @@ sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1192 | Sg_fd *sfp; | 1174 | Sg_fd *sfp; |
1193 | unsigned long offset, len, sa; | 1175 | unsigned long offset, len, sa; |
1194 | Sg_scatter_hold *rsv_schp; | 1176 | Sg_scatter_hold *rsv_schp; |
1195 | struct scatterlist *sg; | 1177 | int k, length; |
1196 | int k; | ||
1197 | 1178 | ||
1198 | if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) | 1179 | if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data))) |
1199 | return VM_FAULT_SIGBUS; | 1180 | return VM_FAULT_SIGBUS; |
@@ -1203,15 +1184,14 @@ sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1203 | return VM_FAULT_SIGBUS; | 1184 | return VM_FAULT_SIGBUS; |
1204 | SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n", | 1185 | SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n", |
1205 | offset, rsv_schp->k_use_sg)); | 1186 | offset, rsv_schp->k_use_sg)); |
1206 | sg = rsv_schp->buffer; | ||
1207 | sa = vma->vm_start; | 1187 | sa = vma->vm_start; |
1208 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); | 1188 | length = 1 << (PAGE_SHIFT + rsv_schp->page_order); |
1209 | ++k, sg = sg_next(sg)) { | 1189 | for (k = 0; k < rsv_schp->k_use_sg && sa < vma->vm_end; k++) { |
1210 | len = vma->vm_end - sa; | 1190 | len = vma->vm_end - sa; |
1211 | len = (len < sg->length) ? len : sg->length; | 1191 | len = (len < length) ? len : length; |
1212 | if (offset < len) { | 1192 | if (offset < len) { |
1213 | struct page *page; | 1193 | struct page *page = nth_page(rsv_schp->pages[k], |
1214 | page = virt_to_page(page_address(sg_page(sg)) + offset); | 1194 | offset >> PAGE_SHIFT); |
1215 | get_page(page); /* increment page count */ | 1195 | get_page(page); /* increment page count */ |
1216 | vmf->page = page; | 1196 | vmf->page = page; |
1217 | return 0; /* success */ | 1197 | return 0; /* success */ |
@@ -1233,8 +1213,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1233 | Sg_fd *sfp; | 1213 | Sg_fd *sfp; |
1234 | unsigned long req_sz, len, sa; | 1214 | unsigned long req_sz, len, sa; |
1235 | Sg_scatter_hold *rsv_schp; | 1215 | Sg_scatter_hold *rsv_schp; |
1236 | int k; | 1216 | int k, length; |
1237 | struct scatterlist *sg; | ||
1238 | 1217 | ||
1239 | if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) | 1218 | if ((!filp) || (!vma) || (!(sfp = (Sg_fd *) filp->private_data))) |
1240 | return -ENXIO; | 1219 | return -ENXIO; |
@@ -1248,11 +1227,10 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1248 | return -ENOMEM; /* cannot map more than reserved buffer */ | 1227 | return -ENOMEM; /* cannot map more than reserved buffer */ |
1249 | 1228 | ||
1250 | sa = vma->vm_start; | 1229 | sa = vma->vm_start; |
1251 | sg = rsv_schp->buffer; | 1230 | length = 1 << (PAGE_SHIFT + rsv_schp->page_order); |
1252 | for (k = 0; (k < rsv_schp->k_use_sg) && (sa < vma->vm_end); | 1231 | for (k = 0; k < rsv_schp->k_use_sg && sa < vma->vm_end; k++) { |
1253 | ++k, sg = sg_next(sg)) { | ||
1254 | len = vma->vm_end - sa; | 1232 | len = vma->vm_end - sa; |
1255 | len = (len < sg->length) ? len : sg->length; | 1233 | len = (len < length) ? len : length; |
1256 | sa += len; | 1234 | sa += len; |
1257 | } | 1235 | } |
1258 | 1236 | ||
@@ -1263,16 +1241,19 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma) | |||
1263 | return 0; | 1241 | return 0; |
1264 | } | 1242 | } |
1265 | 1243 | ||
1266 | /* This function is a "bottom half" handler that is called by the | 1244 | /* |
1267 | * mid level when a command is completed (or has failed). */ | 1245 | * This function is a "bottom half" handler that is called by the mid |
1268 | static void | 1246 | * level when a command is completed (or has failed). |
1269 | sg_cmd_done(void *data, char *sense, int result, int resid) | 1247 | */ |
1248 | static void sg_rq_end_io(struct request *rq, int uptodate) | ||
1270 | { | 1249 | { |
1271 | Sg_request *srp = data; | 1250 | struct sg_request *srp = rq->end_io_data; |
1272 | Sg_device *sdp = NULL; | 1251 | Sg_device *sdp = NULL; |
1273 | Sg_fd *sfp; | 1252 | Sg_fd *sfp; |
1274 | unsigned long iflags; | 1253 | unsigned long iflags; |
1275 | unsigned int ms; | 1254 | unsigned int ms; |
1255 | char *sense; | ||
1256 | int result, resid; | ||
1276 | 1257 | ||
1277 | if (NULL == srp) { | 1258 | if (NULL == srp) { |
1278 | printk(KERN_ERR "sg_cmd_done: NULL request\n"); | 1259 | printk(KERN_ERR "sg_cmd_done: NULL request\n"); |
@@ -1286,6 +1267,9 @@ sg_cmd_done(void *data, char *sense, int result, int resid) | |||
1286 | return; | 1267 | return; |
1287 | } | 1268 | } |
1288 | 1269 | ||
1270 | sense = rq->sense; | ||
1271 | result = rq->errors; | ||
1272 | resid = rq->data_len; | ||
1289 | 1273 | ||
1290 | SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", | 1274 | SCSI_LOG_TIMEOUT(4, printk("sg_cmd_done: %s, pack_id=%d, res=0x%x\n", |
1291 | sdp->disk->disk_name, srp->header.pack_id, result)); | 1275 | sdp->disk->disk_name, srp->header.pack_id, result)); |
@@ -1296,7 +1280,6 @@ sg_cmd_done(void *data, char *sense, int result, int resid) | |||
1296 | if (0 != result) { | 1280 | if (0 != result) { |
1297 | struct scsi_sense_hdr sshdr; | 1281 | struct scsi_sense_hdr sshdr; |
1298 | 1282 | ||
1299 | memcpy(srp->sense_b, sense, sizeof (srp->sense_b)); | ||
1300 | srp->header.status = 0xff & result; | 1283 | srp->header.status = 0xff & result; |
1301 | srp->header.masked_status = status_byte(result); | 1284 | srp->header.masked_status = status_byte(result); |
1302 | srp->header.msg_status = msg_byte(result); | 1285 | srp->header.msg_status = msg_byte(result); |
@@ -1634,37 +1617,79 @@ exit_sg(void) | |||
1634 | idr_destroy(&sg_index_idr); | 1617 | idr_destroy(&sg_index_idr); |
1635 | } | 1618 | } |
1636 | 1619 | ||
1637 | static int | 1620 | static int sg_start_req(Sg_request *srp, unsigned char *cmd) |
1638 | sg_start_req(Sg_request * srp) | ||
1639 | { | 1621 | { |
1640 | int res; | 1622 | int res; |
1623 | struct request *rq; | ||
1641 | Sg_fd *sfp = srp->parentfp; | 1624 | Sg_fd *sfp = srp->parentfp; |
1642 | sg_io_hdr_t *hp = &srp->header; | 1625 | sg_io_hdr_t *hp = &srp->header; |
1643 | int dxfer_len = (int) hp->dxfer_len; | 1626 | int dxfer_len = (int) hp->dxfer_len; |
1644 | int dxfer_dir = hp->dxfer_direction; | 1627 | int dxfer_dir = hp->dxfer_direction; |
1628 | unsigned int iov_count = hp->iovec_count; | ||
1645 | Sg_scatter_hold *req_schp = &srp->data; | 1629 | Sg_scatter_hold *req_schp = &srp->data; |
1646 | Sg_scatter_hold *rsv_schp = &sfp->reserve; | 1630 | Sg_scatter_hold *rsv_schp = &sfp->reserve; |
1631 | struct request_queue *q = sfp->parentdp->device->request_queue; | ||
1632 | struct rq_map_data *md, map_data; | ||
1633 | int rw = hp->dxfer_direction == SG_DXFER_TO_DEV ? WRITE : READ; | ||
1634 | |||
1635 | SCSI_LOG_TIMEOUT(4, printk(KERN_INFO "sg_start_req: dxfer_len=%d\n", | ||
1636 | dxfer_len)); | ||
1637 | |||
1638 | rq = blk_get_request(q, rw, GFP_ATOMIC); | ||
1639 | if (!rq) | ||
1640 | return -ENOMEM; | ||
1641 | |||
1642 | memcpy(rq->cmd, cmd, hp->cmd_len); | ||
1643 | |||
1644 | rq->cmd_len = hp->cmd_len; | ||
1645 | rq->cmd_type = REQ_TYPE_BLOCK_PC; | ||
1646 | |||
1647 | srp->rq = rq; | ||
1648 | rq->end_io_data = srp; | ||
1649 | rq->sense = srp->sense_b; | ||
1650 | rq->retries = SG_DEFAULT_RETRIES; | ||
1647 | 1651 | ||
1648 | SCSI_LOG_TIMEOUT(4, printk("sg_start_req: dxfer_len=%d\n", dxfer_len)); | ||
1649 | if ((dxfer_len <= 0) || (dxfer_dir == SG_DXFER_NONE)) | 1652 | if ((dxfer_len <= 0) || (dxfer_dir == SG_DXFER_NONE)) |
1650 | return 0; | 1653 | return 0; |
1651 | if (sg_allow_dio && (hp->flags & SG_FLAG_DIRECT_IO) && | 1654 | |
1652 | (dxfer_dir != SG_DXFER_UNKNOWN) && (0 == hp->iovec_count) && | 1655 | if (sg_allow_dio && hp->flags & SG_FLAG_DIRECT_IO && |
1653 | (!sfp->parentdp->device->host->unchecked_isa_dma)) { | 1656 | dxfer_dir != SG_DXFER_UNKNOWN && !iov_count && |
1654 | res = sg_build_direct(srp, sfp, dxfer_len); | 1657 | !sfp->parentdp->device->host->unchecked_isa_dma && |
1655 | if (res <= 0) /* -ve -> error, 0 -> done, 1 -> try indirect */ | 1658 | blk_rq_aligned(q, hp->dxferp, dxfer_len)) |
1656 | return res; | 1659 | md = NULL; |
1657 | } | 1660 | else |
1658 | if ((!sg_res_in_use(sfp)) && (dxfer_len <= rsv_schp->bufflen)) | 1661 | md = &map_data; |
1659 | sg_link_reserve(sfp, srp, dxfer_len); | 1662 | |
1660 | else { | 1663 | if (md) { |
1661 | res = sg_build_indirect(req_schp, sfp, dxfer_len); | 1664 | if (!sg_res_in_use(sfp) && dxfer_len <= rsv_schp->bufflen) |
1662 | if (res) { | 1665 | sg_link_reserve(sfp, srp, dxfer_len); |
1663 | sg_remove_scat(req_schp); | 1666 | else { |
1664 | return res; | 1667 | res = sg_build_indirect(req_schp, sfp, dxfer_len); |
1668 | if (res) | ||
1669 | return res; | ||
1665 | } | 1670 | } |
1671 | |||
1672 | md->pages = req_schp->pages; | ||
1673 | md->page_order = req_schp->page_order; | ||
1674 | md->nr_entries = req_schp->k_use_sg; | ||
1666 | } | 1675 | } |
1667 | return 0; | 1676 | |
1677 | if (iov_count) | ||
1678 | res = blk_rq_map_user_iov(q, rq, md, hp->dxferp, iov_count, | ||
1679 | hp->dxfer_len, GFP_ATOMIC); | ||
1680 | else | ||
1681 | res = blk_rq_map_user(q, rq, md, hp->dxferp, | ||
1682 | hp->dxfer_len, GFP_ATOMIC); | ||
1683 | |||
1684 | if (!res) { | ||
1685 | srp->bio = rq->bio; | ||
1686 | |||
1687 | if (!md) { | ||
1688 | req_schp->dio_in_use = 1; | ||
1689 | hp->info |= SG_INFO_DIRECT_IO; | ||
1690 | } | ||
1691 | } | ||
1692 | return res; | ||
1668 | } | 1693 | } |
1669 | 1694 | ||
1670 | static void | 1695 | static void |
@@ -1678,186 +1703,37 @@ sg_finish_rem_req(Sg_request * srp) | |||
1678 | sg_unlink_reserve(sfp, srp); | 1703 | sg_unlink_reserve(sfp, srp); |
1679 | else | 1704 | else |
1680 | sg_remove_scat(req_schp); | 1705 | sg_remove_scat(req_schp); |
1706 | |||
1707 | if (srp->rq) { | ||
1708 | if (srp->bio) | ||
1709 | blk_rq_unmap_user(srp->bio); | ||
1710 | |||
1711 | blk_put_request(srp->rq); | ||
1712 | } | ||
1713 | |||
1681 | sg_remove_request(sfp, srp); | 1714 | sg_remove_request(sfp, srp); |
1682 | } | 1715 | } |
1683 | 1716 | ||
1684 | static int | 1717 | static int |
1685 | sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) | 1718 | sg_build_sgat(Sg_scatter_hold * schp, const Sg_fd * sfp, int tablesize) |
1686 | { | 1719 | { |
1687 | int sg_bufflen = tablesize * sizeof(struct scatterlist); | 1720 | int sg_bufflen = tablesize * sizeof(struct page *); |
1688 | gfp_t gfp_flags = GFP_ATOMIC | __GFP_NOWARN; | 1721 | gfp_t gfp_flags = GFP_ATOMIC | __GFP_NOWARN; |
1689 | 1722 | ||
1690 | /* | 1723 | schp->pages = kzalloc(sg_bufflen, gfp_flags); |
1691 | * TODO: test without low_dma, we should not need it since | 1724 | if (!schp->pages) |
1692 | * the block layer will bounce the buffer for us | ||
1693 | * | ||
1694 | * XXX(hch): we shouldn't need GFP_DMA for the actual S/G list. | ||
1695 | */ | ||
1696 | if (sfp->low_dma) | ||
1697 | gfp_flags |= GFP_DMA; | ||
1698 | schp->buffer = kzalloc(sg_bufflen, gfp_flags); | ||
1699 | if (!schp->buffer) | ||
1700 | return -ENOMEM; | 1725 | return -ENOMEM; |
1701 | sg_init_table(schp->buffer, tablesize); | ||
1702 | schp->sglist_len = sg_bufflen; | 1726 | schp->sglist_len = sg_bufflen; |
1703 | return tablesize; /* number of scat_gath elements allocated */ | 1727 | return tablesize; /* number of scat_gath elements allocated */ |
1704 | } | 1728 | } |
1705 | 1729 | ||
1706 | #ifdef SG_ALLOW_DIO_CODE | ||
1707 | /* vvvvvvvv following code borrowed from st driver's direct IO vvvvvvvvv */ | ||
1708 | /* TODO: hopefully we can use the generic block layer code */ | ||
1709 | |||
1710 | /* Pin down user pages and put them into a scatter gather list. Returns <= 0 if | ||
1711 | - mapping of all pages not successful | ||
1712 | (i.e., either completely successful or fails) | ||
1713 | */ | ||
1714 | static int | ||
1715 | st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages, | ||
1716 | unsigned long uaddr, size_t count, int rw) | ||
1717 | { | ||
1718 | unsigned long end = (uaddr + count + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
1719 | unsigned long start = uaddr >> PAGE_SHIFT; | ||
1720 | const int nr_pages = end - start; | ||
1721 | int res, i, j; | ||
1722 | struct page **pages; | ||
1723 | |||
1724 | /* User attempted Overflow! */ | ||
1725 | if ((uaddr + count) < uaddr) | ||
1726 | return -EINVAL; | ||
1727 | |||
1728 | /* Too big */ | ||
1729 | if (nr_pages > max_pages) | ||
1730 | return -ENOMEM; | ||
1731 | |||
1732 | /* Hmm? */ | ||
1733 | if (count == 0) | ||
1734 | return 0; | ||
1735 | |||
1736 | if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_ATOMIC)) == NULL) | ||
1737 | return -ENOMEM; | ||
1738 | |||
1739 | /* Try to fault in all of the necessary pages */ | ||
1740 | down_read(¤t->mm->mmap_sem); | ||
1741 | /* rw==READ means read from drive, write into memory area */ | ||
1742 | res = get_user_pages( | ||
1743 | current, | ||
1744 | current->mm, | ||
1745 | uaddr, | ||
1746 | nr_pages, | ||
1747 | rw == READ, | ||
1748 | 0, /* don't force */ | ||
1749 | pages, | ||
1750 | NULL); | ||
1751 | up_read(¤t->mm->mmap_sem); | ||
1752 | |||
1753 | /* Errors and no page mapped should return here */ | ||
1754 | if (res < nr_pages) | ||
1755 | goto out_unmap; | ||
1756 | |||
1757 | for (i=0; i < nr_pages; i++) { | ||
1758 | /* FIXME: flush superflous for rw==READ, | ||
1759 | * probably wrong function for rw==WRITE | ||
1760 | */ | ||
1761 | flush_dcache_page(pages[i]); | ||
1762 | /* ?? Is locking needed? I don't think so */ | ||
1763 | /* if (!trylock_page(pages[i])) | ||
1764 | goto out_unlock; */ | ||
1765 | } | ||
1766 | |||
1767 | sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK); | ||
1768 | if (nr_pages > 1) { | ||
1769 | sgl[0].length = PAGE_SIZE - sgl[0].offset; | ||
1770 | count -= sgl[0].length; | ||
1771 | for (i=1; i < nr_pages ; i++) | ||
1772 | sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0); | ||
1773 | } | ||
1774 | else { | ||
1775 | sgl[0].length = count; | ||
1776 | } | ||
1777 | |||
1778 | kfree(pages); | ||
1779 | return nr_pages; | ||
1780 | |||
1781 | out_unmap: | ||
1782 | if (res > 0) { | ||
1783 | for (j=0; j < res; j++) | ||
1784 | page_cache_release(pages[j]); | ||
1785 | res = 0; | ||
1786 | } | ||
1787 | kfree(pages); | ||
1788 | return res; | ||
1789 | } | ||
1790 | |||
1791 | |||
1792 | /* And unmap them... */ | ||
1793 | static int | ||
1794 | st_unmap_user_pages(struct scatterlist *sgl, const unsigned int nr_pages, | ||
1795 | int dirtied) | ||
1796 | { | ||
1797 | int i; | ||
1798 | |||
1799 | for (i=0; i < nr_pages; i++) { | ||
1800 | struct page *page = sg_page(&sgl[i]); | ||
1801 | |||
1802 | if (dirtied) | ||
1803 | SetPageDirty(page); | ||
1804 | /* unlock_page(page); */ | ||
1805 | /* FIXME: cache flush missing for rw==READ | ||
1806 | * FIXME: call the correct reference counting function | ||
1807 | */ | ||
1808 | page_cache_release(page); | ||
1809 | } | ||
1810 | |||
1811 | return 0; | ||
1812 | } | ||
1813 | |||
1814 | /* ^^^^^^^^ above code borrowed from st driver's direct IO ^^^^^^^^^ */ | ||
1815 | #endif | ||
1816 | |||
1817 | |||
1818 | /* Returns: -ve -> error, 0 -> done, 1 -> try indirect */ | ||
1819 | static int | ||
1820 | sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len) | ||
1821 | { | ||
1822 | #ifdef SG_ALLOW_DIO_CODE | ||
1823 | sg_io_hdr_t *hp = &srp->header; | ||
1824 | Sg_scatter_hold *schp = &srp->data; | ||
1825 | int sg_tablesize = sfp->parentdp->sg_tablesize; | ||
1826 | int mx_sc_elems, res; | ||
1827 | struct scsi_device *sdev = sfp->parentdp->device; | ||
1828 | |||
1829 | if (((unsigned long)hp->dxferp & | ||
1830 | queue_dma_alignment(sdev->request_queue)) != 0) | ||
1831 | return 1; | ||
1832 | |||
1833 | mx_sc_elems = sg_build_sgat(schp, sfp, sg_tablesize); | ||
1834 | if (mx_sc_elems <= 0) { | ||
1835 | return 1; | ||
1836 | } | ||
1837 | res = st_map_user_pages(schp->buffer, mx_sc_elems, | ||
1838 | (unsigned long)hp->dxferp, dxfer_len, | ||
1839 | (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0); | ||
1840 | if (res <= 0) { | ||
1841 | sg_remove_scat(schp); | ||
1842 | return 1; | ||
1843 | } | ||
1844 | schp->k_use_sg = res; | ||
1845 | schp->dio_in_use = 1; | ||
1846 | hp->info |= SG_INFO_DIRECT_IO; | ||
1847 | return 0; | ||
1848 | #else | ||
1849 | return 1; | ||
1850 | #endif | ||
1851 | } | ||
1852 | |||
1853 | static int | 1730 | static int |
1854 | sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | 1731 | sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) |
1855 | { | 1732 | { |
1856 | struct scatterlist *sg; | 1733 | int ret_sz = 0, i, k, rem_sz, num, mx_sc_elems; |
1857 | int ret_sz = 0, k, rem_sz, num, mx_sc_elems; | ||
1858 | int sg_tablesize = sfp->parentdp->sg_tablesize; | 1734 | int sg_tablesize = sfp->parentdp->sg_tablesize; |
1859 | int blk_size = buff_size; | 1735 | int blk_size = buff_size, order; |
1860 | struct page *p = NULL; | 1736 | gfp_t gfp_mask = GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN; |
1861 | 1737 | ||
1862 | if (blk_size < 0) | 1738 | if (blk_size < 0) |
1863 | return -EFAULT; | 1739 | return -EFAULT; |
@@ -1881,15 +1757,26 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1881 | } else | 1757 | } else |
1882 | scatter_elem_sz_prev = num; | 1758 | scatter_elem_sz_prev = num; |
1883 | } | 1759 | } |
1884 | for (k = 0, sg = schp->buffer, rem_sz = blk_size; | 1760 | |
1885 | (rem_sz > 0) && (k < mx_sc_elems); | 1761 | if (sfp->low_dma) |
1886 | ++k, rem_sz -= ret_sz, sg = sg_next(sg)) { | 1762 | gfp_mask |= GFP_DMA; |
1887 | 1763 | ||
1764 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
1765 | gfp_mask |= __GFP_ZERO; | ||
1766 | |||
1767 | order = get_order(num); | ||
1768 | retry: | ||
1769 | ret_sz = 1 << (PAGE_SHIFT + order); | ||
1770 | |||
1771 | for (k = 0, rem_sz = blk_size; rem_sz > 0 && k < mx_sc_elems; | ||
1772 | k++, rem_sz -= ret_sz) { | ||
1773 | |||
1888 | num = (rem_sz > scatter_elem_sz_prev) ? | 1774 | num = (rem_sz > scatter_elem_sz_prev) ? |
1889 | scatter_elem_sz_prev : rem_sz; | 1775 | scatter_elem_sz_prev : rem_sz; |
1890 | p = sg_page_malloc(num, sfp->low_dma, &ret_sz); | 1776 | |
1891 | if (!p) | 1777 | schp->pages[k] = alloc_pages(gfp_mask, order); |
1892 | return -ENOMEM; | 1778 | if (!schp->pages[k]) |
1779 | goto out; | ||
1893 | 1780 | ||
1894 | if (num == scatter_elem_sz_prev) { | 1781 | if (num == scatter_elem_sz_prev) { |
1895 | if (unlikely(ret_sz > scatter_elem_sz_prev)) { | 1782 | if (unlikely(ret_sz > scatter_elem_sz_prev)) { |
@@ -1897,12 +1784,12 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1897 | scatter_elem_sz_prev = ret_sz; | 1784 | scatter_elem_sz_prev = ret_sz; |
1898 | } | 1785 | } |
1899 | } | 1786 | } |
1900 | sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0); | ||
1901 | 1787 | ||
1902 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " | 1788 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " |
1903 | "ret_sz=%d\n", k, num, ret_sz)); | 1789 | "ret_sz=%d\n", k, num, ret_sz)); |
1904 | } /* end of for loop */ | 1790 | } /* end of for loop */ |
1905 | 1791 | ||
1792 | schp->page_order = order; | ||
1906 | schp->k_use_sg = k; | 1793 | schp->k_use_sg = k; |
1907 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, " | 1794 | SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k_use_sg=%d, " |
1908 | "rem_sz=%d\n", k, rem_sz)); | 1795 | "rem_sz=%d\n", k, rem_sz)); |
@@ -1910,223 +1797,42 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size) | |||
1910 | schp->bufflen = blk_size; | 1797 | schp->bufflen = blk_size; |
1911 | if (rem_sz > 0) /* must have failed */ | 1798 | if (rem_sz > 0) /* must have failed */ |
1912 | return -ENOMEM; | 1799 | return -ENOMEM; |
1913 | |||
1914 | return 0; | 1800 | return 0; |
1915 | } | 1801 | out: |
1916 | 1802 | for (i = 0; i < k; i++) | |
1917 | static int | 1803 | __free_pages(schp->pages[k], order); |
1918 | sg_write_xfer(Sg_request * srp) | ||
1919 | { | ||
1920 | sg_io_hdr_t *hp = &srp->header; | ||
1921 | Sg_scatter_hold *schp = &srp->data; | ||
1922 | struct scatterlist *sg = schp->buffer; | ||
1923 | int num_xfer = 0; | ||
1924 | int j, k, onum, usglen, ksglen, res; | ||
1925 | int iovec_count = (int) hp->iovec_count; | ||
1926 | int dxfer_dir = hp->dxfer_direction; | ||
1927 | unsigned char *p; | ||
1928 | unsigned char __user *up; | ||
1929 | int new_interface = ('\0' == hp->interface_id) ? 0 : 1; | ||
1930 | |||
1931 | if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_TO_DEV == dxfer_dir) || | ||
1932 | (SG_DXFER_TO_FROM_DEV == dxfer_dir)) { | ||
1933 | num_xfer = (int) (new_interface ? hp->dxfer_len : hp->flags); | ||
1934 | if (schp->bufflen < num_xfer) | ||
1935 | num_xfer = schp->bufflen; | ||
1936 | } | ||
1937 | if ((num_xfer <= 0) || (schp->dio_in_use) || | ||
1938 | (new_interface | ||
1939 | && ((SG_FLAG_NO_DXFER | SG_FLAG_MMAP_IO) & hp->flags))) | ||
1940 | return 0; | ||
1941 | |||
1942 | SCSI_LOG_TIMEOUT(4, printk("sg_write_xfer: num_xfer=%d, iovec_count=%d, k_use_sg=%d\n", | ||
1943 | num_xfer, iovec_count, schp->k_use_sg)); | ||
1944 | if (iovec_count) { | ||
1945 | onum = iovec_count; | ||
1946 | if (!access_ok(VERIFY_READ, hp->dxferp, SZ_SG_IOVEC * onum)) | ||
1947 | return -EFAULT; | ||
1948 | } else | ||
1949 | onum = 1; | ||
1950 | |||
1951 | ksglen = sg->length; | ||
1952 | p = page_address(sg_page(sg)); | ||
1953 | for (j = 0, k = 0; j < onum; ++j) { | ||
1954 | res = sg_u_iovec(hp, iovec_count, j, 1, &usglen, &up); | ||
1955 | if (res) | ||
1956 | return res; | ||
1957 | |||
1958 | for (; p; sg = sg_next(sg), ksglen = sg->length, | ||
1959 | p = page_address(sg_page(sg))) { | ||
1960 | if (usglen <= 0) | ||
1961 | break; | ||
1962 | if (ksglen > usglen) { | ||
1963 | if (usglen >= num_xfer) { | ||
1964 | if (__copy_from_user(p, up, num_xfer)) | ||
1965 | return -EFAULT; | ||
1966 | return 0; | ||
1967 | } | ||
1968 | if (__copy_from_user(p, up, usglen)) | ||
1969 | return -EFAULT; | ||
1970 | p += usglen; | ||
1971 | ksglen -= usglen; | ||
1972 | break; | ||
1973 | } else { | ||
1974 | if (ksglen >= num_xfer) { | ||
1975 | if (__copy_from_user(p, up, num_xfer)) | ||
1976 | return -EFAULT; | ||
1977 | return 0; | ||
1978 | } | ||
1979 | if (__copy_from_user(p, up, ksglen)) | ||
1980 | return -EFAULT; | ||
1981 | up += ksglen; | ||
1982 | usglen -= ksglen; | ||
1983 | } | ||
1984 | ++k; | ||
1985 | if (k >= schp->k_use_sg) | ||
1986 | return 0; | ||
1987 | } | ||
1988 | } | ||
1989 | |||
1990 | return 0; | ||
1991 | } | ||
1992 | 1804 | ||
1993 | static int | 1805 | if (--order >= 0) |
1994 | sg_u_iovec(sg_io_hdr_t * hp, int sg_num, int ind, | 1806 | goto retry; |
1995 | int wr_xf, int *countp, unsigned char __user **up) | ||
1996 | { | ||
1997 | int num_xfer = (int) hp->dxfer_len; | ||
1998 | unsigned char __user *p = hp->dxferp; | ||
1999 | int count; | ||
2000 | 1807 | ||
2001 | if (0 == sg_num) { | 1808 | return -ENOMEM; |
2002 | if (wr_xf && ('\0' == hp->interface_id)) | ||
2003 | count = (int) hp->flags; /* holds "old" input_size */ | ||
2004 | else | ||
2005 | count = num_xfer; | ||
2006 | } else { | ||
2007 | sg_iovec_t iovec; | ||
2008 | if (__copy_from_user(&iovec, p + ind*SZ_SG_IOVEC, SZ_SG_IOVEC)) | ||
2009 | return -EFAULT; | ||
2010 | p = iovec.iov_base; | ||
2011 | count = (int) iovec.iov_len; | ||
2012 | } | ||
2013 | if (!access_ok(wr_xf ? VERIFY_READ : VERIFY_WRITE, p, count)) | ||
2014 | return -EFAULT; | ||
2015 | if (up) | ||
2016 | *up = p; | ||
2017 | if (countp) | ||
2018 | *countp = count; | ||
2019 | return 0; | ||
2020 | } | 1809 | } |
2021 | 1810 | ||
2022 | static void | 1811 | static void |
2023 | sg_remove_scat(Sg_scatter_hold * schp) | 1812 | sg_remove_scat(Sg_scatter_hold * schp) |
2024 | { | 1813 | { |
2025 | SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg)); | 1814 | SCSI_LOG_TIMEOUT(4, printk("sg_remove_scat: k_use_sg=%d\n", schp->k_use_sg)); |
2026 | if (schp->buffer && (schp->sglist_len > 0)) { | 1815 | if (schp->pages && schp->sglist_len > 0) { |
2027 | struct scatterlist *sg = schp->buffer; | 1816 | if (!schp->dio_in_use) { |
2028 | |||
2029 | if (schp->dio_in_use) { | ||
2030 | #ifdef SG_ALLOW_DIO_CODE | ||
2031 | st_unmap_user_pages(sg, schp->k_use_sg, TRUE); | ||
2032 | #endif | ||
2033 | } else { | ||
2034 | int k; | 1817 | int k; |
2035 | 1818 | ||
2036 | for (k = 0; (k < schp->k_use_sg) && sg_page(sg); | 1819 | for (k = 0; k < schp->k_use_sg && schp->pages[k]; k++) { |
2037 | ++k, sg = sg_next(sg)) { | ||
2038 | SCSI_LOG_TIMEOUT(5, printk( | 1820 | SCSI_LOG_TIMEOUT(5, printk( |
2039 | "sg_remove_scat: k=%d, pg=0x%p, len=%d\n", | 1821 | "sg_remove_scat: k=%d, pg=0x%p\n", |
2040 | k, sg_page(sg), sg->length)); | 1822 | k, schp->pages[k])); |
2041 | sg_page_free(sg_page(sg), sg->length); | 1823 | __free_pages(schp->pages[k], schp->page_order); |
2042 | } | 1824 | } |
2043 | } | ||
2044 | kfree(schp->buffer); | ||
2045 | } | ||
2046 | memset(schp, 0, sizeof (*schp)); | ||
2047 | } | ||
2048 | 1825 | ||
2049 | static int | 1826 | kfree(schp->pages); |
2050 | sg_read_xfer(Sg_request * srp) | ||
2051 | { | ||
2052 | sg_io_hdr_t *hp = &srp->header; | ||
2053 | Sg_scatter_hold *schp = &srp->data; | ||
2054 | struct scatterlist *sg = schp->buffer; | ||
2055 | int num_xfer = 0; | ||
2056 | int j, k, onum, usglen, ksglen, res; | ||
2057 | int iovec_count = (int) hp->iovec_count; | ||
2058 | int dxfer_dir = hp->dxfer_direction; | ||
2059 | unsigned char *p; | ||
2060 | unsigned char __user *up; | ||
2061 | int new_interface = ('\0' == hp->interface_id) ? 0 : 1; | ||
2062 | |||
2063 | if ((SG_DXFER_UNKNOWN == dxfer_dir) || (SG_DXFER_FROM_DEV == dxfer_dir) | ||
2064 | || (SG_DXFER_TO_FROM_DEV == dxfer_dir)) { | ||
2065 | num_xfer = hp->dxfer_len; | ||
2066 | if (schp->bufflen < num_xfer) | ||
2067 | num_xfer = schp->bufflen; | ||
2068 | } | ||
2069 | if ((num_xfer <= 0) || (schp->dio_in_use) || | ||
2070 | (new_interface | ||
2071 | && ((SG_FLAG_NO_DXFER | SG_FLAG_MMAP_IO) & hp->flags))) | ||
2072 | return 0; | ||
2073 | |||
2074 | SCSI_LOG_TIMEOUT(4, printk("sg_read_xfer: num_xfer=%d, iovec_count=%d, k_use_sg=%d\n", | ||
2075 | num_xfer, iovec_count, schp->k_use_sg)); | ||
2076 | if (iovec_count) { | ||
2077 | onum = iovec_count; | ||
2078 | if (!access_ok(VERIFY_READ, hp->dxferp, SZ_SG_IOVEC * onum)) | ||
2079 | return -EFAULT; | ||
2080 | } else | ||
2081 | onum = 1; | ||
2082 | |||
2083 | p = page_address(sg_page(sg)); | ||
2084 | ksglen = sg->length; | ||
2085 | for (j = 0, k = 0; j < onum; ++j) { | ||
2086 | res = sg_u_iovec(hp, iovec_count, j, 0, &usglen, &up); | ||
2087 | if (res) | ||
2088 | return res; | ||
2089 | |||
2090 | for (; p; sg = sg_next(sg), ksglen = sg->length, | ||
2091 | p = page_address(sg_page(sg))) { | ||
2092 | if (usglen <= 0) | ||
2093 | break; | ||
2094 | if (ksglen > usglen) { | ||
2095 | if (usglen >= num_xfer) { | ||
2096 | if (__copy_to_user(up, p, num_xfer)) | ||
2097 | return -EFAULT; | ||
2098 | return 0; | ||
2099 | } | ||
2100 | if (__copy_to_user(up, p, usglen)) | ||
2101 | return -EFAULT; | ||
2102 | p += usglen; | ||
2103 | ksglen -= usglen; | ||
2104 | break; | ||
2105 | } else { | ||
2106 | if (ksglen >= num_xfer) { | ||
2107 | if (__copy_to_user(up, p, num_xfer)) | ||
2108 | return -EFAULT; | ||
2109 | return 0; | ||
2110 | } | ||
2111 | if (__copy_to_user(up, p, ksglen)) | ||
2112 | return -EFAULT; | ||
2113 | up += ksglen; | ||
2114 | usglen -= ksglen; | ||
2115 | } | ||
2116 | ++k; | ||
2117 | if (k >= schp->k_use_sg) | ||
2118 | return 0; | ||
2119 | } | 1827 | } |
2120 | } | 1828 | } |
2121 | 1829 | memset(schp, 0, sizeof (*schp)); | |
2122 | return 0; | ||
2123 | } | 1830 | } |
2124 | 1831 | ||
2125 | static int | 1832 | static int |
2126 | sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) | 1833 | sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) |
2127 | { | 1834 | { |
2128 | Sg_scatter_hold *schp = &srp->data; | 1835 | Sg_scatter_hold *schp = &srp->data; |
2129 | struct scatterlist *sg = schp->buffer; | ||
2130 | int k, num; | 1836 | int k, num; |
2131 | 1837 | ||
2132 | SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n", | 1838 | SCSI_LOG_TIMEOUT(4, printk("sg_read_oxfer: num_read_xfer=%d\n", |
@@ -2134,15 +1840,15 @@ sg_read_oxfer(Sg_request * srp, char __user *outp, int num_read_xfer) | |||
2134 | if ((!outp) || (num_read_xfer <= 0)) | 1840 | if ((!outp) || (num_read_xfer <= 0)) |
2135 | return 0; | 1841 | return 0; |
2136 | 1842 | ||
2137 | for (k = 0; (k < schp->k_use_sg) && sg_page(sg); ++k, sg = sg_next(sg)) { | 1843 | num = 1 << (PAGE_SHIFT + schp->page_order); |
2138 | num = sg->length; | 1844 | for (k = 0; k < schp->k_use_sg && schp->pages[k]; k++) { |
2139 | if (num > num_read_xfer) { | 1845 | if (num > num_read_xfer) { |
2140 | if (__copy_to_user(outp, page_address(sg_page(sg)), | 1846 | if (__copy_to_user(outp, page_address(schp->pages[k]), |
2141 | num_read_xfer)) | 1847 | num_read_xfer)) |
2142 | return -EFAULT; | 1848 | return -EFAULT; |
2143 | break; | 1849 | break; |
2144 | } else { | 1850 | } else { |
2145 | if (__copy_to_user(outp, page_address(sg_page(sg)), | 1851 | if (__copy_to_user(outp, page_address(schp->pages[k]), |
2146 | num)) | 1852 | num)) |
2147 | return -EFAULT; | 1853 | return -EFAULT; |
2148 | num_read_xfer -= num; | 1854 | num_read_xfer -= num; |
@@ -2177,24 +1883,21 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size) | |||
2177 | { | 1883 | { |
2178 | Sg_scatter_hold *req_schp = &srp->data; | 1884 | Sg_scatter_hold *req_schp = &srp->data; |
2179 | Sg_scatter_hold *rsv_schp = &sfp->reserve; | 1885 | Sg_scatter_hold *rsv_schp = &sfp->reserve; |
2180 | struct scatterlist *sg = rsv_schp->buffer; | ||
2181 | int k, num, rem; | 1886 | int k, num, rem; |
2182 | 1887 | ||
2183 | srp->res_used = 1; | 1888 | srp->res_used = 1; |
2184 | SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); | 1889 | SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size)); |
2185 | rem = size; | 1890 | rem = size; |
2186 | 1891 | ||
2187 | for (k = 0; k < rsv_schp->k_use_sg; ++k, sg = sg_next(sg)) { | 1892 | num = 1 << (PAGE_SHIFT + rsv_schp->page_order); |
2188 | num = sg->length; | 1893 | for (k = 0; k < rsv_schp->k_use_sg; k++) { |
2189 | if (rem <= num) { | 1894 | if (rem <= num) { |
2190 | sfp->save_scat_len = num; | ||
2191 | sg->length = rem; | ||
2192 | req_schp->k_use_sg = k + 1; | 1895 | req_schp->k_use_sg = k + 1; |
2193 | req_schp->sglist_len = rsv_schp->sglist_len; | 1896 | req_schp->sglist_len = rsv_schp->sglist_len; |
2194 | req_schp->buffer = rsv_schp->buffer; | 1897 | req_schp->pages = rsv_schp->pages; |
2195 | 1898 | ||
2196 | req_schp->bufflen = size; | 1899 | req_schp->bufflen = size; |
2197 | req_schp->b_malloc_len = rsv_schp->b_malloc_len; | 1900 | req_schp->page_order = rsv_schp->page_order; |
2198 | break; | 1901 | break; |
2199 | } else | 1902 | } else |
2200 | rem -= num; | 1903 | rem -= num; |
@@ -2208,22 +1911,13 @@ static void | |||
2208 | sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) | 1911 | sg_unlink_reserve(Sg_fd * sfp, Sg_request * srp) |
2209 | { | 1912 | { |
2210 | Sg_scatter_hold *req_schp = &srp->data; | 1913 | Sg_scatter_hold *req_schp = &srp->data; |
2211 | Sg_scatter_hold *rsv_schp = &sfp->reserve; | ||
2212 | 1914 | ||
2213 | SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n", | 1915 | SCSI_LOG_TIMEOUT(4, printk("sg_unlink_reserve: req->k_use_sg=%d\n", |
2214 | (int) req_schp->k_use_sg)); | 1916 | (int) req_schp->k_use_sg)); |
2215 | if ((rsv_schp->k_use_sg > 0) && (req_schp->k_use_sg > 0)) { | ||
2216 | struct scatterlist *sg = rsv_schp->buffer; | ||
2217 | |||
2218 | if (sfp->save_scat_len > 0) | ||
2219 | (sg + (req_schp->k_use_sg - 1))->length = | ||
2220 | (unsigned) sfp->save_scat_len; | ||
2221 | else | ||
2222 | SCSI_LOG_TIMEOUT(1, printk ("sg_unlink_reserve: BAD save_scat_len\n")); | ||
2223 | } | ||
2224 | req_schp->k_use_sg = 0; | 1917 | req_schp->k_use_sg = 0; |
2225 | req_schp->bufflen = 0; | 1918 | req_schp->bufflen = 0; |
2226 | req_schp->buffer = NULL; | 1919 | req_schp->pages = NULL; |
1920 | req_schp->page_order = 0; | ||
2227 | req_schp->sglist_len = 0; | 1921 | req_schp->sglist_len = 0; |
2228 | sfp->save_scat_len = 0; | 1922 | sfp->save_scat_len = 0; |
2229 | srp->res_used = 0; | 1923 | srp->res_used = 0; |
@@ -2481,53 +2175,6 @@ sg_res_in_use(Sg_fd * sfp) | |||
2481 | return srp ? 1 : 0; | 2175 | return srp ? 1 : 0; |
2482 | } | 2176 | } |
2483 | 2177 | ||
2484 | /* The size fetched (value output via retSzp) set when non-NULL return */ | ||
2485 | static struct page * | ||
2486 | sg_page_malloc(int rqSz, int lowDma, int *retSzp) | ||
2487 | { | ||
2488 | struct page *resp = NULL; | ||
2489 | gfp_t page_mask; | ||
2490 | int order, a_size; | ||
2491 | int resSz; | ||
2492 | |||
2493 | if ((rqSz <= 0) || (NULL == retSzp)) | ||
2494 | return resp; | ||
2495 | |||
2496 | if (lowDma) | ||
2497 | page_mask = GFP_ATOMIC | GFP_DMA | __GFP_COMP | __GFP_NOWARN; | ||
2498 | else | ||
2499 | page_mask = GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN; | ||
2500 | |||
2501 | for (order = 0, a_size = PAGE_SIZE; a_size < rqSz; | ||
2502 | order++, a_size <<= 1) ; | ||
2503 | resSz = a_size; /* rounded up if necessary */ | ||
2504 | resp = alloc_pages(page_mask, order); | ||
2505 | while ((!resp) && order) { | ||
2506 | --order; | ||
2507 | a_size >>= 1; /* divide by 2, until PAGE_SIZE */ | ||
2508 | resp = alloc_pages(page_mask, order); /* try half */ | ||
2509 | resSz = a_size; | ||
2510 | } | ||
2511 | if (resp) { | ||
2512 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
2513 | memset(page_address(resp), 0, resSz); | ||
2514 | *retSzp = resSz; | ||
2515 | } | ||
2516 | return resp; | ||
2517 | } | ||
2518 | |||
2519 | static void | ||
2520 | sg_page_free(struct page *page, int size) | ||
2521 | { | ||
2522 | int order, a_size; | ||
2523 | |||
2524 | if (!page) | ||
2525 | return; | ||
2526 | for (order = 0, a_size = PAGE_SIZE; a_size < size; | ||
2527 | order++, a_size <<= 1) ; | ||
2528 | __free_pages(page, order); | ||
2529 | } | ||
2530 | |||
2531 | #ifdef CONFIG_SCSI_PROC_FS | 2178 | #ifdef CONFIG_SCSI_PROC_FS |
2532 | static int | 2179 | static int |
2533 | sg_idr_max_id(int id, void *p, void *data) | 2180 | sg_idr_max_id(int id, void *p, void *data) |
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 27f5bfd1def3..0f17009c99d2 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c | |||
@@ -331,7 +331,7 @@ static int sr_done(struct scsi_cmnd *SCpnt) | |||
331 | 331 | ||
332 | static int sr_prep_fn(struct request_queue *q, struct request *rq) | 332 | static int sr_prep_fn(struct request_queue *q, struct request *rq) |
333 | { | 333 | { |
334 | int block=0, this_count, s_size, timeout = SR_TIMEOUT; | 334 | int block = 0, this_count, s_size; |
335 | struct scsi_cd *cd; | 335 | struct scsi_cd *cd; |
336 | struct scsi_cmnd *SCpnt; | 336 | struct scsi_cmnd *SCpnt; |
337 | struct scsi_device *sdp = q->queuedata; | 337 | struct scsi_device *sdp = q->queuedata; |
@@ -461,7 +461,6 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq) | |||
461 | SCpnt->transfersize = cd->device->sector_size; | 461 | SCpnt->transfersize = cd->device->sector_size; |
462 | SCpnt->underflow = this_count << 9; | 462 | SCpnt->underflow = this_count << 9; |
463 | SCpnt->allowed = MAX_RETRIES; | 463 | SCpnt->allowed = MAX_RETRIES; |
464 | SCpnt->timeout_per_command = timeout; | ||
465 | 464 | ||
466 | /* | 465 | /* |
467 | * This indicates that the command is ready from our end to be | 466 | * This indicates that the command is ready from our end to be |
@@ -620,6 +619,8 @@ static int sr_probe(struct device *dev) | |||
620 | disk->fops = &sr_bdops; | 619 | disk->fops = &sr_bdops; |
621 | disk->flags = GENHD_FL_CD; | 620 | disk->flags = GENHD_FL_CD; |
622 | 621 | ||
622 | blk_queue_rq_timeout(sdev->request_queue, SR_TIMEOUT); | ||
623 | |||
623 | cd->device = sdev; | 624 | cd->device = sdev; |
624 | cd->disk = disk; | 625 | cd->disk = disk; |
625 | cd->driver = &sr_template; | 626 | cd->driver = &sr_template; |
@@ -878,7 +879,7 @@ static void sr_kref_release(struct kref *kref) | |||
878 | struct gendisk *disk = cd->disk; | 879 | struct gendisk *disk = cd->disk; |
879 | 880 | ||
880 | spin_lock(&sr_index_lock); | 881 | spin_lock(&sr_index_lock); |
881 | clear_bit(disk->first_minor, sr_index_bits); | 882 | clear_bit(MINOR(disk_devt(disk)), sr_index_bits); |
882 | spin_unlock(&sr_index_lock); | 883 | spin_unlock(&sr_index_lock); |
883 | 884 | ||
884 | unregister_cdrom(&cd->cdi); | 885 | unregister_cdrom(&cd->cdi); |
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c index d39107b7669b..f4e6cde1fd0d 100644 --- a/drivers/scsi/sym53c8xx_2/sym_glue.c +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c | |||
@@ -519,8 +519,8 @@ static int sym53c8xx_queue_command(struct scsi_cmnd *cmd, | |||
519 | * Shorten our settle_time if needed for | 519 | * Shorten our settle_time if needed for |
520 | * this command not to time out. | 520 | * this command not to time out. |
521 | */ | 521 | */ |
522 | if (np->s.settle_time_valid && cmd->timeout_per_command) { | 522 | if (np->s.settle_time_valid && cmd->request->timeout) { |
523 | unsigned long tlimit = jiffies + cmd->timeout_per_command; | 523 | unsigned long tlimit = jiffies + cmd->request->timeout; |
524 | tlimit -= SYM_CONF_TIMER_INTERVAL*2; | 524 | tlimit -= SYM_CONF_TIMER_INTERVAL*2; |
525 | if (time_after(np->s.settle_time, tlimit)) { | 525 | if (time_after(np->s.settle_time, tlimit)) { |
526 | np->s.settle_time = tlimit; | 526 | np->s.settle_time = tlimit; |