aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/Kconfig4
-rw-r--r--drivers/block/acsi_slm.c1
-rw-r--r--drivers/block/cciss.c333
-rw-r--r--drivers/block/cciss_scsi.c1
-rw-r--r--drivers/block/floppy.c7
-rw-r--r--drivers/block/loop.c171
-rw-r--r--drivers/block/nbd.c15
-rw-r--r--drivers/block/rd.c2
-rw-r--r--drivers/block/umem.c1
9 files changed, 314 insertions, 221 deletions
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig
index 17ee97f3a99b..b4c8319138b2 100644
--- a/drivers/block/Kconfig
+++ b/drivers/block/Kconfig
@@ -444,8 +444,6 @@ config CDROM_PKTCDVD_WCACHE
444 this option is dangerous unless the CD-RW media is known good, as we 444 this option is dangerous unless the CD-RW media is known good, as we
445 don't do deferred write error handling yet. 445 don't do deferred write error handling yet.
446 446
447source "drivers/s390/block/Kconfig"
448
449config ATA_OVER_ETH 447config ATA_OVER_ETH
450 tristate "ATA over Ethernet support" 448 tristate "ATA over Ethernet support"
451 depends on NET 449 depends on NET
@@ -453,6 +451,8 @@ config ATA_OVER_ETH
453 This driver provides Support for ATA over Ethernet block 451 This driver provides Support for ATA over Ethernet block
454 devices like the Coraid EtherDrive (R) Storage Blade. 452 devices like the Coraid EtherDrive (R) Storage Blade.
455 453
454source "drivers/s390/block/Kconfig"
455
456endmenu 456endmenu
457 457
458endif 458endif
diff --git a/drivers/block/acsi_slm.c b/drivers/block/acsi_slm.c
index e2e043290963..1d9d9b4f48cc 100644
--- a/drivers/block/acsi_slm.c
+++ b/drivers/block/acsi_slm.c
@@ -65,7 +65,6 @@ not be guaranteed. There are several ways to assure this:
65#include <linux/time.h> 65#include <linux/time.h>
66#include <linux/mm.h> 66#include <linux/mm.h>
67#include <linux/slab.h> 67#include <linux/slab.h>
68#include <linux/smp_lock.h>
69 68
70#include <asm/pgtable.h> 69#include <asm/pgtable.h>
71#include <asm/system.h> 70#include <asm/system.h>
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 65a725cd3422..5acc6c44aead 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -45,6 +45,10 @@
45#include <linux/blkdev.h> 45#include <linux/blkdev.h>
46#include <linux/genhd.h> 46#include <linux/genhd.h>
47#include <linux/completion.h> 47#include <linux/completion.h>
48#include <scsi/scsi.h>
49#include <scsi/sg.h>
50#include <scsi/scsi_ioctl.h>
51#include <linux/cdrom.h>
48 52
49#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin)) 53#define CCISS_DRIVER_VERSION(maj,min,submin) ((maj<<16)|(min<<8)|(submin))
50#define DRIVER_NAME "HP CISS Driver (v 3.6.14)" 54#define DRIVER_NAME "HP CISS Driver (v 3.6.14)"
@@ -1152,6 +1156,30 @@ static int cciss_ioctl(struct inode *inode, struct file *filep,
1152 kfree(ioc); 1156 kfree(ioc);
1153 return status; 1157 return status;
1154 } 1158 }
1159
1160 /* scsi_cmd_ioctl handles these, below, though some are not */
1161 /* very meaningful for cciss. SG_IO is the main one people want. */
1162
1163 case SG_GET_VERSION_NUM:
1164 case SG_SET_TIMEOUT:
1165 case SG_GET_TIMEOUT:
1166 case SG_GET_RESERVED_SIZE:
1167 case SG_SET_RESERVED_SIZE:
1168 case SG_EMULATED_HOST:
1169 case SG_IO:
1170 case SCSI_IOCTL_SEND_COMMAND:
1171 return scsi_cmd_ioctl(filep, disk, cmd, argp);
1172
1173 /* scsi_cmd_ioctl would normally handle these, below, but */
1174 /* they aren't a good fit for cciss, as CD-ROMs are */
1175 /* not supported, and we don't have any bus/target/lun */
1176 /* which we present to the kernel. */
1177
1178 case CDROM_SEND_PACKET:
1179 case CDROMCLOSETRAY:
1180 case CDROMEJECT:
1181 case SCSI_IOCTL_GET_IDLUN:
1182 case SCSI_IOCTL_GET_BUS_NUMBER:
1155 default: 1183 default:
1156 return -ENOTTY; 1184 return -ENOTTY;
1157 } 1185 }
@@ -1234,7 +1262,7 @@ static void cciss_softirq_done(struct request *rq)
1234 pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); 1262 pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir);
1235 } 1263 }
1236 1264
1237 complete_buffers(rq->bio, rq->errors); 1265 complete_buffers(rq->bio, (rq->errors == 0));
1238 1266
1239 if (blk_fs_request(rq)) { 1267 if (blk_fs_request(rq)) {
1240 const int rw = rq_data_dir(rq); 1268 const int rw = rq_data_dir(rq);
@@ -1248,7 +1276,7 @@ static void cciss_softirq_done(struct request *rq)
1248 1276
1249 add_disk_randomness(rq->rq_disk); 1277 add_disk_randomness(rq->rq_disk);
1250 spin_lock_irqsave(&h->lock, flags); 1278 spin_lock_irqsave(&h->lock, flags);
1251 end_that_request_last(rq, rq->errors); 1279 end_that_request_last(rq, (rq->errors == 0));
1252 cmd_free(h, cmd, 1); 1280 cmd_free(h, cmd, 1);
1253 cciss_check_queues(h); 1281 cciss_check_queues(h);
1254 spin_unlock_irqrestore(&h->lock, flags); 1282 spin_unlock_irqrestore(&h->lock, flags);
@@ -2336,6 +2364,44 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c)
2336 start_io(h); 2364 start_io(h);
2337} 2365}
2338 2366
2367static inline int evaluate_target_status(CommandList_struct *cmd)
2368{
2369 unsigned char sense_key;
2370 int error_count = 1;
2371
2372 if (cmd->err_info->ScsiStatus != 0x02) { /* not check condition? */
2373 if (!blk_pc_request(cmd->rq))
2374 printk(KERN_WARNING "cciss: cmd %p "
2375 "has SCSI Status 0x%x\n",
2376 cmd, cmd->err_info->ScsiStatus);
2377 return error_count;
2378 }
2379
2380 /* check the sense key */
2381 sense_key = 0xf & cmd->err_info->SenseInfo[2];
2382 /* no status or recovered error */
2383 if ((sense_key == 0x0) || (sense_key == 0x1))
2384 error_count = 0;
2385
2386 if (!blk_pc_request(cmd->rq)) { /* Not SG_IO or similar? */
2387 if (error_count != 0)
2388 printk(KERN_WARNING "cciss: cmd %p has CHECK CONDITION"
2389 " sense key = 0x%x\n", cmd, sense_key);
2390 return error_count;
2391 }
2392
2393 /* SG_IO or similar, copy sense data back */
2394 if (cmd->rq->sense) {
2395 if (cmd->rq->sense_len > cmd->err_info->SenseLen)
2396 cmd->rq->sense_len = cmd->err_info->SenseLen;
2397 memcpy(cmd->rq->sense, cmd->err_info->SenseInfo,
2398 cmd->rq->sense_len);
2399 } else
2400 cmd->rq->sense_len = 0;
2401
2402 return error_count;
2403}
2404
2339/* checks the status of the job and calls complete buffers to mark all 2405/* checks the status of the job and calls complete buffers to mark all
2340 * buffers for the completed job. Note that this function does not need 2406 * buffers for the completed job. Note that this function does not need
2341 * to hold the hba/queue lock. 2407 * to hold the hba/queue lock.
@@ -2343,109 +2409,99 @@ static inline void resend_cciss_cmd(ctlr_info_t *h, CommandList_struct *c)
2343static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd, 2409static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
2344 int timeout) 2410 int timeout)
2345{ 2411{
2346 int status = 1;
2347 int retry_cmd = 0; 2412 int retry_cmd = 0;
2413 struct request *rq = cmd->rq;
2414
2415 rq->errors = 0;
2348 2416
2349 if (timeout) 2417 if (timeout)
2350 status = 0; 2418 rq->errors = 1;
2351 2419
2352 if (cmd->err_info->CommandStatus != 0) { /* an error has occurred */ 2420 if (cmd->err_info->CommandStatus == 0) /* no error has occurred */
2353 switch (cmd->err_info->CommandStatus) { 2421 goto after_error_processing;
2354 unsigned char sense_key;
2355 case CMD_TARGET_STATUS:
2356 status = 0;
2357 2422
2358 if (cmd->err_info->ScsiStatus == 0x02) { 2423 switch (cmd->err_info->CommandStatus) {
2359 printk(KERN_WARNING "cciss: cmd %p " 2424 case CMD_TARGET_STATUS:
2360 "has CHECK CONDITION " 2425 rq->errors = evaluate_target_status(cmd);
2361 " byte 2 = 0x%x\n", cmd, 2426 break;
2362 cmd->err_info->SenseInfo[2] 2427 case CMD_DATA_UNDERRUN:
2363 ); 2428 if (blk_fs_request(cmd->rq)) {
2364 /* check the sense key */
2365 sense_key = 0xf & cmd->err_info->SenseInfo[2];
2366 /* no status or recovered error */
2367 if ((sense_key == 0x0) || (sense_key == 0x1)) {
2368 status = 1;
2369 }
2370 } else {
2371 printk(KERN_WARNING "cciss: cmd %p "
2372 "has SCSI Status 0x%x\n",
2373 cmd, cmd->err_info->ScsiStatus);
2374 }
2375 break;
2376 case CMD_DATA_UNDERRUN:
2377 printk(KERN_WARNING "cciss: cmd %p has" 2429 printk(KERN_WARNING "cciss: cmd %p has"
2378 " completed with data underrun " 2430 " completed with data underrun "
2379 "reported\n", cmd); 2431 "reported\n", cmd);
2380 break; 2432 cmd->rq->data_len = cmd->err_info->ResidualCnt;
2381 case CMD_DATA_OVERRUN: 2433 }
2434 break;
2435 case CMD_DATA_OVERRUN:
2436 if (blk_fs_request(cmd->rq))
2382 printk(KERN_WARNING "cciss: cmd %p has" 2437 printk(KERN_WARNING "cciss: cmd %p has"
2383 " completed with data overrun " 2438 " completed with data overrun "
2384 "reported\n", cmd); 2439 "reported\n", cmd);
2385 break; 2440 break;
2386 case CMD_INVALID: 2441 case CMD_INVALID:
2387 printk(KERN_WARNING "cciss: cmd %p is " 2442 printk(KERN_WARNING "cciss: cmd %p is "
2388 "reported invalid\n", cmd); 2443 "reported invalid\n", cmd);
2389 status = 0; 2444 rq->errors = 1;
2390 break; 2445 break;
2391 case CMD_PROTOCOL_ERR: 2446 case CMD_PROTOCOL_ERR:
2392 printk(KERN_WARNING "cciss: cmd %p has " 2447 printk(KERN_WARNING "cciss: cmd %p has "
2393 "protocol error \n", cmd); 2448 "protocol error \n", cmd);
2394 status = 0; 2449 rq->errors = 1;
2395 break; 2450 break;
2396 case CMD_HARDWARE_ERR: 2451 case CMD_HARDWARE_ERR:
2397 printk(KERN_WARNING "cciss: cmd %p had " 2452 printk(KERN_WARNING "cciss: cmd %p had "
2398 " hardware error\n", cmd); 2453 " hardware error\n", cmd);
2399 status = 0; 2454 rq->errors = 1;
2400 break; 2455 break;
2401 case CMD_CONNECTION_LOST: 2456 case CMD_CONNECTION_LOST:
2402 printk(KERN_WARNING "cciss: cmd %p had " 2457 printk(KERN_WARNING "cciss: cmd %p had "
2403 "connection lost\n", cmd); 2458 "connection lost\n", cmd);
2404 status = 0; 2459 rq->errors = 1;
2405 break; 2460 break;
2406 case CMD_ABORTED: 2461 case CMD_ABORTED:
2407 printk(KERN_WARNING "cciss: cmd %p was " 2462 printk(KERN_WARNING "cciss: cmd %p was "
2408 "aborted\n", cmd); 2463 "aborted\n", cmd);
2409 status = 0; 2464 rq->errors = 1;
2410 break; 2465 break;
2411 case CMD_ABORT_FAILED: 2466 case CMD_ABORT_FAILED:
2412 printk(KERN_WARNING "cciss: cmd %p reports " 2467 printk(KERN_WARNING "cciss: cmd %p reports "
2413 "abort failed\n", cmd); 2468 "abort failed\n", cmd);
2414 status = 0; 2469 rq->errors = 1;
2415 break; 2470 break;
2416 case CMD_UNSOLICITED_ABORT: 2471 case CMD_UNSOLICITED_ABORT:
2417 printk(KERN_WARNING "cciss%d: unsolicited " 2472 printk(KERN_WARNING "cciss%d: unsolicited "
2418 "abort %p\n", h->ctlr, cmd); 2473 "abort %p\n", h->ctlr, cmd);
2419 if (cmd->retry_count < MAX_CMD_RETRIES) { 2474 if (cmd->retry_count < MAX_CMD_RETRIES) {
2420 retry_cmd = 1; 2475 retry_cmd = 1;
2421 printk(KERN_WARNING 2476 printk(KERN_WARNING
2422 "cciss%d: retrying %p\n", h->ctlr, cmd); 2477 "cciss%d: retrying %p\n", h->ctlr, cmd);
2423 cmd->retry_count++; 2478 cmd->retry_count++;
2424 } else 2479 } else
2425 printk(KERN_WARNING 2480 printk(KERN_WARNING
2426 "cciss%d: %p retried too " 2481 "cciss%d: %p retried too "
2427 "many times\n", h->ctlr, cmd); 2482 "many times\n", h->ctlr, cmd);
2428 status = 0; 2483 rq->errors = 1;
2429 break; 2484 break;
2430 case CMD_TIMEOUT: 2485 case CMD_TIMEOUT:
2431 printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd); 2486 printk(KERN_WARNING "cciss: cmd %p timedout\n", cmd);
2432 status = 0; 2487 rq->errors = 1;
2433 break; 2488 break;
2434 default: 2489 default:
2435 printk(KERN_WARNING "cciss: cmd %p returned " 2490 printk(KERN_WARNING "cciss: cmd %p returned "
2436 "unknown status %x\n", cmd, 2491 "unknown status %x\n", cmd,
2437 cmd->err_info->CommandStatus); 2492 cmd->err_info->CommandStatus);
2438 status = 0; 2493 rq->errors = 1;
2439 }
2440 } 2494 }
2495
2496after_error_processing:
2497
2441 /* We need to return this command */ 2498 /* We need to return this command */
2442 if (retry_cmd) { 2499 if (retry_cmd) {
2443 resend_cciss_cmd(h, cmd); 2500 resend_cciss_cmd(h, cmd);
2444 return; 2501 return;
2445 } 2502 }
2446 2503 cmd->rq->data_len = 0;
2447 cmd->rq->completion_data = cmd; 2504 cmd->rq->completion_data = cmd;
2448 cmd->rq->errors = status;
2449 blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE); 2505 blk_add_trace_rq(cmd->rq->q, cmd->rq, BLK_TA_COMPLETE);
2450 blk_complete_request(cmd->rq); 2506 blk_complete_request(cmd->rq);
2451} 2507}
@@ -2539,32 +2595,40 @@ static void do_cciss_request(request_queue_t *q)
2539#endif /* CCISS_DEBUG */ 2595#endif /* CCISS_DEBUG */
2540 2596
2541 c->Header.SGList = c->Header.SGTotal = seg; 2597 c->Header.SGList = c->Header.SGTotal = seg;
2542 if(h->cciss_read == CCISS_READ_10) { 2598 if (likely(blk_fs_request(creq))) {
2543 c->Request.CDB[1] = 0; 2599 if(h->cciss_read == CCISS_READ_10) {
2544 c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB 2600 c->Request.CDB[1] = 0;
2545 c->Request.CDB[3] = (start_blk >> 16) & 0xff; 2601 c->Request.CDB[2] = (start_blk >> 24) & 0xff; //MSB
2546 c->Request.CDB[4] = (start_blk >> 8) & 0xff; 2602 c->Request.CDB[3] = (start_blk >> 16) & 0xff;
2547 c->Request.CDB[5] = start_blk & 0xff; 2603 c->Request.CDB[4] = (start_blk >> 8) & 0xff;
2548 c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB 2604 c->Request.CDB[5] = start_blk & 0xff;
2549 c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff; 2605 c->Request.CDB[6] = 0; // (sect >> 24) & 0xff; MSB
2550 c->Request.CDB[8] = creq->nr_sectors & 0xff; 2606 c->Request.CDB[7] = (creq->nr_sectors >> 8) & 0xff;
2551 c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0; 2607 c->Request.CDB[8] = creq->nr_sectors & 0xff;
2608 c->Request.CDB[9] = c->Request.CDB[11] = c->Request.CDB[12] = 0;
2609 } else {
2610 c->Request.CDBLen = 16;
2611 c->Request.CDB[1]= 0;
2612 c->Request.CDB[2]= (start_blk >> 56) & 0xff; //MSB
2613 c->Request.CDB[3]= (start_blk >> 48) & 0xff;
2614 c->Request.CDB[4]= (start_blk >> 40) & 0xff;
2615 c->Request.CDB[5]= (start_blk >> 32) & 0xff;
2616 c->Request.CDB[6]= (start_blk >> 24) & 0xff;
2617 c->Request.CDB[7]= (start_blk >> 16) & 0xff;
2618 c->Request.CDB[8]= (start_blk >> 8) & 0xff;
2619 c->Request.CDB[9]= start_blk & 0xff;
2620 c->Request.CDB[10]= (creq->nr_sectors >> 24) & 0xff;
2621 c->Request.CDB[11]= (creq->nr_sectors >> 16) & 0xff;
2622 c->Request.CDB[12]= (creq->nr_sectors >> 8) & 0xff;
2623 c->Request.CDB[13]= creq->nr_sectors & 0xff;
2624 c->Request.CDB[14] = c->Request.CDB[15] = 0;
2625 }
2626 } else if (blk_pc_request(creq)) {
2627 c->Request.CDBLen = creq->cmd_len;
2628 memcpy(c->Request.CDB, creq->cmd, BLK_MAX_CDB);
2552 } else { 2629 } else {
2553 c->Request.CDBLen = 16; 2630 printk(KERN_WARNING "cciss%d: bad request type %d\n", h->ctlr, creq->cmd_type);
2554 c->Request.CDB[1]= 0; 2631 BUG();
2555 c->Request.CDB[2]= (start_blk >> 56) & 0xff; //MSB
2556 c->Request.CDB[3]= (start_blk >> 48) & 0xff;
2557 c->Request.CDB[4]= (start_blk >> 40) & 0xff;
2558 c->Request.CDB[5]= (start_blk >> 32) & 0xff;
2559 c->Request.CDB[6]= (start_blk >> 24) & 0xff;
2560 c->Request.CDB[7]= (start_blk >> 16) & 0xff;
2561 c->Request.CDB[8]= (start_blk >> 8) & 0xff;
2562 c->Request.CDB[9]= start_blk & 0xff;
2563 c->Request.CDB[10]= (creq->nr_sectors >> 24) & 0xff;
2564 c->Request.CDB[11]= (creq->nr_sectors >> 16) & 0xff;
2565 c->Request.CDB[12]= (creq->nr_sectors >> 8) & 0xff;
2566 c->Request.CDB[13]= creq->nr_sectors & 0xff;
2567 c->Request.CDB[14] = c->Request.CDB[15] = 0;
2568 } 2632 }
2569 2633
2570 spin_lock_irq(q->queue_lock); 2634 spin_lock_irq(q->queue_lock);
@@ -3405,13 +3469,39 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
3405 return -1; 3469 return -1;
3406} 3470}
3407 3471
3408static void cciss_remove_one(struct pci_dev *pdev) 3472static void cciss_shutdown(struct pci_dev *pdev)
3409{ 3473{
3410 ctlr_info_t *tmp_ptr; 3474 ctlr_info_t *tmp_ptr;
3411 int i, j; 3475 int i;
3412 char flush_buf[4]; 3476 char flush_buf[4];
3413 int return_code; 3477 int return_code;
3414 3478
3479 tmp_ptr = pci_get_drvdata(pdev);
3480 if (tmp_ptr == NULL)
3481 return;
3482 i = tmp_ptr->ctlr;
3483 if (hba[i] == NULL)
3484 return;
3485
3486 /* Turn board interrupts off and send the flush cache command */
3487 /* sendcmd will turn off interrupt, and send the flush...
3488 * To write all data in the battery backed cache to disks */
3489 memset(flush_buf, 0, 4);
3490 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL,
3491 TYPE_CMD);
3492 if (return_code == IO_OK) {
3493 printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
3494 } else {
3495 printk(KERN_WARNING "Error flushing cache on controller %d\n", i);
3496 }
3497 free_irq(hba[i]->intr[2], hba[i]);
3498}
3499
3500static void __devexit cciss_remove_one(struct pci_dev *pdev)
3501{
3502 ctlr_info_t *tmp_ptr;
3503 int i, j;
3504
3415 if (pci_get_drvdata(pdev) == NULL) { 3505 if (pci_get_drvdata(pdev) == NULL) {
3416 printk(KERN_ERR "cciss: Unable to remove device \n"); 3506 printk(KERN_ERR "cciss: Unable to remove device \n");
3417 return; 3507 return;
@@ -3442,18 +3532,7 @@ static void cciss_remove_one(struct pci_dev *pdev)
3442 3532
3443 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */ 3533 cciss_unregister_scsi(i); /* unhook from SCSI subsystem */
3444 3534
3445 /* Turn board interrupts off and send the flush cache command */ 3535 cciss_shutdown(pdev);
3446 /* sendcmd will turn off interrupt, and send the flush...
3447 * To write all data in the battery backed cache to disks */
3448 memset(flush_buf, 0, 4);
3449 return_code = sendcmd(CCISS_CACHE_FLUSH, i, flush_buf, 4, 0, 0, 0, NULL,
3450 TYPE_CMD);
3451 if (return_code == IO_OK) {
3452 printk(KERN_INFO "Completed flushing cache on controller %d\n", i);
3453 } else {
3454 printk(KERN_WARNING "Error flushing cache on controller %d\n", i);
3455 }
3456 free_irq(hba[i]->intr[2], hba[i]);
3457 3536
3458#ifdef CONFIG_PCI_MSI 3537#ifdef CONFIG_PCI_MSI
3459 if (hba[i]->msix_vector) 3538 if (hba[i]->msix_vector)
@@ -3486,7 +3565,7 @@ static struct pci_driver cciss_pci_driver = {
3486 .probe = cciss_init_one, 3565 .probe = cciss_init_one,
3487 .remove = __devexit_p(cciss_remove_one), 3566 .remove = __devexit_p(cciss_remove_one),
3488 .id_table = cciss_pci_device_id, /* id_table */ 3567 .id_table = cciss_pci_device_id, /* id_table */
3489 .shutdown = cciss_remove_one, 3568 .shutdown = cciss_shutdown,
3490}; 3569};
3491 3570
3492/* 3571/*
diff --git a/drivers/block/cciss_scsi.c b/drivers/block/cciss_scsi.c
index bb15051ffbe0..90961a8ea895 100644
--- a/drivers/block/cciss_scsi.c
+++ b/drivers/block/cciss_scsi.c
@@ -35,7 +35,6 @@
35 35
36#include <asm/atomic.h> 36#include <asm/atomic.h>
37 37
38#include <scsi/scsi.h>
39#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
40#include <scsi/scsi_device.h> 39#include <scsi/scsi_device.h>
41#include <scsi/scsi_host.h> 40#include <scsi/scsi_host.h>
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 5231ed7e723f..3587cb434371 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4334,7 +4334,10 @@ static int __init floppy_init(void)
4334 if (err) 4334 if (err)
4335 goto out_flush_work; 4335 goto out_flush_work;
4336 4336
4337 device_create_file(&floppy_device[drive].dev,&dev_attr_cmos); 4337 err = device_create_file(&floppy_device[drive].dev,&dev_attr_cmos);
4338 if (err)
4339 goto out_unreg_platform_dev;
4340
4338 /* to be cleaned up... */ 4341 /* to be cleaned up... */
4339 disks[drive]->private_data = (void *)(long)drive; 4342 disks[drive]->private_data = (void *)(long)drive;
4340 disks[drive]->queue = floppy_queue; 4343 disks[drive]->queue = floppy_queue;
@@ -4345,6 +4348,8 @@ static int __init floppy_init(void)
4345 4348
4346 return 0; 4349 return 0;
4347 4350
4351out_unreg_platform_dev:
4352 platform_device_unregister(&floppy_device[drive]);
4348out_flush_work: 4353out_flush_work:
4349 flush_scheduled_work(); 4354 flush_scheduled_work();
4350 if (usage_count) 4355 if (usage_count)
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 0d4ccd4a0957..5526eadb6592 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -77,9 +77,8 @@
77 77
78#include <asm/uaccess.h> 78#include <asm/uaccess.h>
79 79
80static int max_loop = 8; 80static LIST_HEAD(loop_devices);
81static struct loop_device *loop_dev; 81static DEFINE_MUTEX(loop_devices_mutex);
82static struct gendisk **disks;
83 82
84/* 83/*
85 * Transfer functions 84 * Transfer functions
@@ -183,7 +182,7 @@ figure_loop_size(struct loop_device *lo)
183 if (unlikely((loff_t)x != size)) 182 if (unlikely((loff_t)x != size))
184 return -EFBIG; 183 return -EFBIG;
185 184
186 set_capacity(disks[lo->lo_number], x); 185 set_capacity(lo->lo_disk, x);
187 return 0; 186 return 0;
188} 187}
189 188
@@ -244,17 +243,13 @@ static int do_lo_send_aops(struct loop_device *lo, struct bio_vec *bvec,
244 transfer_result = lo_do_transfer(lo, WRITE, page, offset, 243 transfer_result = lo_do_transfer(lo, WRITE, page, offset,
245 bvec->bv_page, bv_offs, size, IV); 244 bvec->bv_page, bv_offs, size, IV);
246 if (unlikely(transfer_result)) { 245 if (unlikely(transfer_result)) {
247 char *kaddr;
248
249 /* 246 /*
250 * The transfer failed, but we still write the data to 247 * The transfer failed, but we still write the data to
251 * keep prepare/commit calls balanced. 248 * keep prepare/commit calls balanced.
252 */ 249 */
253 printk(KERN_ERR "loop: transfer error block %llu\n", 250 printk(KERN_ERR "loop: transfer error block %llu\n",
254 (unsigned long long)index); 251 (unsigned long long)index);
255 kaddr = kmap_atomic(page, KM_USER0); 252 zero_user_page(page, offset, size, KM_USER0);
256 memset(kaddr + offset, 0, size);
257 kunmap_atomic(kaddr, KM_USER0);
258 } 253 }
259 flush_dcache_page(page); 254 flush_dcache_page(page);
260 ret = aops->commit_write(file, page, offset, 255 ret = aops->commit_write(file, page, offset,
@@ -812,7 +807,7 @@ static int loop_set_fd(struct loop_device *lo, struct file *lo_file,
812 lo->lo_queue->queuedata = lo; 807 lo->lo_queue->queuedata = lo;
813 lo->lo_queue->unplug_fn = loop_unplug; 808 lo->lo_queue->unplug_fn = loop_unplug;
814 809
815 set_capacity(disks[lo->lo_number], size); 810 set_capacity(lo->lo_disk, size);
816 bd_set_size(bdev, size << 9); 811 bd_set_size(bdev, size << 9);
817 812
818 set_blocksize(bdev, lo_blocksize); 813 set_blocksize(bdev, lo_blocksize);
@@ -832,7 +827,7 @@ out_clr:
832 lo->lo_device = NULL; 827 lo->lo_device = NULL;
833 lo->lo_backing_file = NULL; 828 lo->lo_backing_file = NULL;
834 lo->lo_flags = 0; 829 lo->lo_flags = 0;
835 set_capacity(disks[lo->lo_number], 0); 830 set_capacity(lo->lo_disk, 0);
836 invalidate_bdev(bdev); 831 invalidate_bdev(bdev);
837 bd_set_size(bdev, 0); 832 bd_set_size(bdev, 0);
838 mapping_set_gfp_mask(mapping, lo->old_gfp_mask); 833 mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
@@ -918,7 +913,7 @@ static int loop_clr_fd(struct loop_device *lo, struct block_device *bdev)
918 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE); 913 memset(lo->lo_crypt_name, 0, LO_NAME_SIZE);
919 memset(lo->lo_file_name, 0, LO_NAME_SIZE); 914 memset(lo->lo_file_name, 0, LO_NAME_SIZE);
920 invalidate_bdev(bdev); 915 invalidate_bdev(bdev);
921 set_capacity(disks[lo->lo_number], 0); 916 set_capacity(lo->lo_disk, 0);
922 bd_set_size(bdev, 0); 917 bd_set_size(bdev, 0);
923 mapping_set_gfp_mask(filp->f_mapping, gfp); 918 mapping_set_gfp_mask(filp->f_mapping, gfp);
924 lo->lo_state = Lo_unbound; 919 lo->lo_state = Lo_unbound;
@@ -1357,8 +1352,9 @@ static struct block_device_operations lo_fops = {
1357/* 1352/*
1358 * And now the modules code and kernel interface. 1353 * And now the modules code and kernel interface.
1359 */ 1354 */
1355static int max_loop;
1360module_param(max_loop, int, 0); 1356module_param(max_loop, int, 0);
1361MODULE_PARM_DESC(max_loop, "Maximum number of loop devices (1-256)"); 1357MODULE_PARM_DESC(max_loop, "obsolete, loop device is created on-demand");
1362MODULE_LICENSE("GPL"); 1358MODULE_LICENSE("GPL");
1363MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR); 1359MODULE_ALIAS_BLOCKDEV_MAJOR(LOOP_MAJOR);
1364 1360
@@ -1383,7 +1379,7 @@ int loop_unregister_transfer(int number)
1383 1379
1384 xfer_funcs[n] = NULL; 1380 xfer_funcs[n] = NULL;
1385 1381
1386 for (lo = &loop_dev[0]; lo < &loop_dev[max_loop]; lo++) { 1382 list_for_each_entry(lo, &loop_devices, lo_list) {
1387 mutex_lock(&lo->lo_ctl_mutex); 1383 mutex_lock(&lo->lo_ctl_mutex);
1388 1384
1389 if (lo->lo_encryption == xfer) 1385 if (lo->lo_encryption == xfer)
@@ -1398,91 +1394,100 @@ int loop_unregister_transfer(int number)
1398EXPORT_SYMBOL(loop_register_transfer); 1394EXPORT_SYMBOL(loop_register_transfer);
1399EXPORT_SYMBOL(loop_unregister_transfer); 1395EXPORT_SYMBOL(loop_unregister_transfer);
1400 1396
1401static int __init loop_init(void) 1397static struct loop_device *loop_init_one(int i)
1402{ 1398{
1403 int i; 1399 struct loop_device *lo;
1400 struct gendisk *disk;
1404 1401
1405 if (max_loop < 1 || max_loop > 256) { 1402 list_for_each_entry(lo, &loop_devices, lo_list) {
1406 printk(KERN_WARNING "loop: invalid max_loop (must be between" 1403 if (lo->lo_number == i)
1407 " 1 and 256), using default (8)\n"); 1404 return lo;
1408 max_loop = 8;
1409 } 1405 }
1410 1406
1411 if (register_blkdev(LOOP_MAJOR, "loop")) 1407 lo = kzalloc(sizeof(*lo), GFP_KERNEL);
1412 return -EIO; 1408 if (!lo)
1413 1409 goto out;
1414 loop_dev = kmalloc(max_loop * sizeof(struct loop_device), GFP_KERNEL);
1415 if (!loop_dev)
1416 goto out_mem1;
1417 memset(loop_dev, 0, max_loop * sizeof(struct loop_device));
1418 1410
1419 disks = kmalloc(max_loop * sizeof(struct gendisk *), GFP_KERNEL); 1411 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
1420 if (!disks) 1412 if (!lo->lo_queue)
1421 goto out_mem2; 1413 goto out_free_dev;
1414
1415 disk = lo->lo_disk = alloc_disk(1);
1416 if (!disk)
1417 goto out_free_queue;
1418
1419 mutex_init(&lo->lo_ctl_mutex);
1420 lo->lo_number = i;
1421 lo->lo_thread = NULL;
1422 init_waitqueue_head(&lo->lo_event);
1423 spin_lock_init(&lo->lo_lock);
1424 disk->major = LOOP_MAJOR;
1425 disk->first_minor = i;
1426 disk->fops = &lo_fops;
1427 disk->private_data = lo;
1428 disk->queue = lo->lo_queue;
1429 sprintf(disk->disk_name, "loop%d", i);
1430 add_disk(disk);
1431 list_add_tail(&lo->lo_list, &loop_devices);
1432 return lo;
1433
1434out_free_queue:
1435 blk_cleanup_queue(lo->lo_queue);
1436out_free_dev:
1437 kfree(lo);
1438out:
1439 return NULL;
1440}
1422 1441
1423 for (i = 0; i < max_loop; i++) { 1442static void loop_del_one(struct loop_device *lo)
1424 disks[i] = alloc_disk(1); 1443{
1425 if (!disks[i]) 1444 del_gendisk(lo->lo_disk);
1426 goto out_mem3; 1445 blk_cleanup_queue(lo->lo_queue);
1427 } 1446 put_disk(lo->lo_disk);
1447 list_del(&lo->lo_list);
1448 kfree(lo);
1449}
1428 1450
1429 for (i = 0; i < max_loop; i++) { 1451static struct kobject *loop_probe(dev_t dev, int *part, void *data)
1430 struct loop_device *lo = &loop_dev[i]; 1452{
1431 struct gendisk *disk = disks[i]; 1453 struct loop_device *lo;
1432 1454 struct kobject *kobj;
1433 memset(lo, 0, sizeof(*lo));
1434 lo->lo_queue = blk_alloc_queue(GFP_KERNEL);
1435 if (!lo->lo_queue)
1436 goto out_mem4;
1437 mutex_init(&lo->lo_ctl_mutex);
1438 lo->lo_number = i;
1439 lo->lo_thread = NULL;
1440 init_waitqueue_head(&lo->lo_event);
1441 spin_lock_init(&lo->lo_lock);
1442 disk->major = LOOP_MAJOR;
1443 disk->first_minor = i;
1444 disk->fops = &lo_fops;
1445 sprintf(disk->disk_name, "loop%d", i);
1446 disk->private_data = lo;
1447 disk->queue = lo->lo_queue;
1448 }
1449 1455
1450 /* We cannot fail after we call this, so another loop!*/ 1456 mutex_lock(&loop_devices_mutex);
1451 for (i = 0; i < max_loop; i++) 1457 lo = loop_init_one(dev & MINORMASK);
1452 add_disk(disks[i]); 1458 kobj = lo ? get_disk(lo->lo_disk) : ERR_PTR(-ENOMEM);
1453 printk(KERN_INFO "loop: loaded (max %d devices)\n", max_loop); 1459 mutex_unlock(&loop_devices_mutex);
1454 return 0;
1455 1460
1456out_mem4: 1461 *part = 0;
1457 while (i--) 1462 return kobj;
1458 blk_cleanup_queue(loop_dev[i].lo_queue);
1459 i = max_loop;
1460out_mem3:
1461 while (i--)
1462 put_disk(disks[i]);
1463 kfree(disks);
1464out_mem2:
1465 kfree(loop_dev);
1466out_mem1:
1467 unregister_blkdev(LOOP_MAJOR, "loop");
1468 printk(KERN_ERR "loop: ran out of memory\n");
1469 return -ENOMEM;
1470} 1463}
1471 1464
1472static void loop_exit(void) 1465static int __init loop_init(void)
1473{ 1466{
1474 int i; 1467 if (register_blkdev(LOOP_MAJOR, "loop"))
1468 return -EIO;
1469 blk_register_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS,
1470 THIS_MODULE, loop_probe, NULL, NULL);
1471
1472 if (max_loop) {
1473 printk(KERN_INFO "loop: the max_loop option is obsolete "
1474 "and will be removed in March 2008\n");
1475 1475
1476 for (i = 0; i < max_loop; i++) {
1477 del_gendisk(disks[i]);
1478 blk_cleanup_queue(loop_dev[i].lo_queue);
1479 put_disk(disks[i]);
1480 } 1476 }
1477 printk(KERN_INFO "loop: module loaded\n");
1478 return 0;
1479}
1480
1481static void __exit loop_exit(void)
1482{
1483 struct loop_device *lo, *next;
1484
1485 list_for_each_entry_safe(lo, next, &loop_devices, lo_list)
1486 loop_del_one(lo);
1487
1488 blk_unregister_region(MKDEV(LOOP_MAJOR, 0), 1UL << MINORBITS);
1481 if (unregister_blkdev(LOOP_MAJOR, "loop")) 1489 if (unregister_blkdev(LOOP_MAJOR, "loop"))
1482 printk(KERN_WARNING "loop: cannot unregister blkdev\n"); 1490 printk(KERN_WARNING "loop: cannot unregister blkdev\n");
1483
1484 kfree(disks);
1485 kfree(loop_dev);
1486} 1491}
1487 1492
1488module_init(loop_init); 1493module_init(loop_init);
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 090796bef78f..069ae39a9cd9 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -366,20 +366,25 @@ static struct disk_attribute pid_attr = {
366 .show = pid_show, 366 .show = pid_show,
367}; 367};
368 368
369static void nbd_do_it(struct nbd_device *lo) 369static int nbd_do_it(struct nbd_device *lo)
370{ 370{
371 struct request *req; 371 struct request *req;
372 int ret;
372 373
373 BUG_ON(lo->magic != LO_MAGIC); 374 BUG_ON(lo->magic != LO_MAGIC);
374 375
375 lo->pid = current->pid; 376 lo->pid = current->pid;
376 sysfs_create_file(&lo->disk->kobj, &pid_attr.attr); 377 ret = sysfs_create_file(&lo->disk->kobj, &pid_attr.attr);
378 if (ret) {
379 printk(KERN_ERR "nbd: sysfs_create_file failed!");
380 return ret;
381 }
377 382
378 while ((req = nbd_read_stat(lo)) != NULL) 383 while ((req = nbd_read_stat(lo)) != NULL)
379 nbd_end_request(req); 384 nbd_end_request(req);
380 385
381 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr); 386 sysfs_remove_file(&lo->disk->kobj, &pid_attr.attr);
382 return; 387 return 0;
383} 388}
384 389
385static void nbd_clear_que(struct nbd_device *lo) 390static void nbd_clear_que(struct nbd_device *lo)
@@ -569,7 +574,9 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
569 case NBD_DO_IT: 574 case NBD_DO_IT:
570 if (!lo->file) 575 if (!lo->file)
571 return -EINVAL; 576 return -EINVAL;
572 nbd_do_it(lo); 577 error = nbd_do_it(lo);
578 if (error)
579 return error;
573 /* on return tidy up in case we have a signal */ 580 /* on return tidy up in case we have a signal */
574 /* Forcibly shutdown the socket causing all listeners 581 /* Forcibly shutdown the socket causing all listeners
575 * to error 582 * to error
diff --git a/drivers/block/rd.c b/drivers/block/rd.c
index 43d4ebcb3b44..a1512da32410 100644
--- a/drivers/block/rd.c
+++ b/drivers/block/rd.c
@@ -151,7 +151,7 @@ static int ramdisk_commit_write(struct file *file, struct page *page,
151} 151}
152 152
153/* 153/*
154 * ->writepage to the the blockdev's mapping has to redirty the page so that the 154 * ->writepage to the blockdev's mapping has to redirty the page so that the
155 * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM 155 * VM doesn't go and steal it. We return AOP_WRITEPAGE_ACTIVATE so that the VM
156 * won't try to (pointlessly) write the page again for a while. 156 * won't try to (pointlessly) write the page again for a while.
157 * 157 *
diff --git a/drivers/block/umem.c b/drivers/block/umem.c
index 5872036e8ae6..6f5d6203d725 100644
--- a/drivers/block/umem.c
+++ b/drivers/block/umem.c
@@ -44,7 +44,6 @@
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/init.h> 45#include <linux/init.h>
46#include <linux/interrupt.h> 46#include <linux/interrupt.h>
47#include <linux/smp_lock.h>
48#include <linux/timer.h> 47#include <linux/timer.h>
49#include <linux/pci.h> 48#include <linux/pci.h>
50#include <linux/slab.h> 49#include <linux/slab.h>