Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block

* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
block: hold extra reference to bio in blk_rq_map_user_iov()
relay: fix cpu offline problem
Release old elevator on change elevator
block: fix boot failure with CONFIG_DEBUG_BLOCK_EXT_DEVT=y and nash
block/md: fix md autodetection
block: make add_partition() return pointer to hd_struct
block: fix add_partition() error path

+42 -25
+6
block/blk-map.c
··· 217 217 return PTR_ERR(bio); 218 218 219 219 if (bio->bi_size != len) { 220 + /* 221 + * Grab an extra reference to this bio, as bio_unmap_user() 222 + * expects to be able to drop it twice as it happens on the 223 + * normal IO completion path 224 + */ 225 + bio_get(bio); 220 226 bio_endio(bio, 0); 221 227 bio_unmap_user(bio); 222 228 return -EINVAL;
+2
block/genhd.c
··· 768 768 bdev_map = kobj_map_init(base_probe, &block_class_lock); 769 769 blk_dev_init(); 770 770 771 + register_blkdev(BLOCK_EXT_MAJOR, "blkext"); 772 + 771 773 #ifndef CONFIG_SYSFS_DEPRECATED 772 774 /* create top-level block dir */ 773 775 block_depr = kobject_create_and_add("block", NULL);
+3 -4
block/ioctl.c
··· 18 18 struct disk_part_iter piter; 19 19 long long start, length; 20 20 int partno; 21 - int err; 22 21 23 22 if (!capable(CAP_SYS_ADMIN)) 24 23 return -EACCES; ··· 60 61 disk_part_iter_exit(&piter); 61 62 62 63 /* all seems OK */ 63 - err = add_partition(disk, partno, start, length, 64 - ADDPART_FLAG_NONE); 64 + part = add_partition(disk, partno, start, length, 65 + ADDPART_FLAG_NONE); 65 66 mutex_unlock(&bdev->bd_mutex); 66 - return err; 67 + return IS_ERR(part) ? PTR_ERR(part) : 0; 67 68 case BLKPG_DEL_PARTITION: 68 69 part = disk_get_part(disk, partno); 69 70 if (!part)
+7 -1
drivers/block/xen-blkfront.c
··· 338 338 static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size) 339 339 { 340 340 struct request_queue *rq; 341 + elevator_t *old_e; 341 342 342 343 rq = blk_init_queue(do_blkif_request, &blkif_io_lock); 343 344 if (rq == NULL) 344 345 return -1; 345 346 346 - elevator_init(rq, "noop"); 347 + old_e = rq->elevator; 348 + if (IS_ERR_VALUE(elevator_init(rq, "noop"))) 349 + printk(KERN_WARNING 350 + "blkfront: Switch elevator failed, use default\n"); 351 + else 352 + elevator_exit(old_e); 347 353 348 354 /* Hard sector size and max sectors impersonate the equiv. hardware. */ 349 355 blk_queue_hardsect_size(rq, sector_size);
+17 -14
fs/partitions/check.c
··· 348 348 static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH, 349 349 whole_disk_show, NULL); 350 350 351 - int add_partition(struct gendisk *disk, int partno, 352 - sector_t start, sector_t len, int flags) 351 + struct hd_struct *add_partition(struct gendisk *disk, int partno, 352 + sector_t start, sector_t len, int flags) 353 353 { 354 354 struct hd_struct *p; 355 355 dev_t devt = MKDEV(0, 0); ··· 361 361 362 362 err = disk_expand_part_tbl(disk, partno); 363 363 if (err) 364 - return err; 364 + return ERR_PTR(err); 365 365 ptbl = disk->part_tbl; 366 366 367 367 if (ptbl->part[partno]) 368 - return -EBUSY; 368 + return ERR_PTR(-EBUSY); 369 369 370 370 p = kzalloc(sizeof(*p), GFP_KERNEL); 371 371 if (!p) 372 - return -ENOMEM; 372 + return ERR_PTR(-EBUSY); 373 373 374 374 if (!init_part_stats(p)) { 375 375 err = -ENOMEM; ··· 395 395 396 396 err = blk_alloc_devt(p, &devt); 397 397 if (err) 398 - goto out_free; 398 + goto out_free_stats; 399 399 pdev->devt = devt; 400 400 401 401 /* delay uevent until 'holders' subdir is created */ ··· 424 424 if (!ddev->uevent_suppress) 425 425 kobject_uevent(&pdev->kobj, KOBJ_ADD); 426 426 427 - return 0; 427 + return p; 428 428 429 + out_free_stats: 430 + free_part_stats(p); 429 431 out_free: 430 432 kfree(p); 431 - return err; 433 + return ERR_PTR(err); 432 434 out_del: 433 435 kobject_put(p->holder_dir); 434 436 device_del(pdev); 435 437 out_put: 436 438 put_device(pdev); 437 439 blk_free_devt(devt); 438 - return err; 440 + return ERR_PTR(err); 439 441 } 440 442 441 443 /* Not exported, helper to add_disk(). */ ··· 568 566 disk->disk_name, p, (unsigned long long) size); 569 567 size = get_capacity(disk) - from; 570 568 } 571 - res = add_partition(disk, p, from, size, state->parts[p].flags); 572 - if (res) { 573 - printk(KERN_ERR " %s: p%d could not be added: %d\n", 574 - disk->disk_name, p, -res); 569 + part = add_partition(disk, p, from, size, 570 + state->parts[p].flags); 571 + if (IS_ERR(part)) { 572 + printk(KERN_ERR " %s: p%d could not be added: %ld\n", 573 + disk->disk_name, p, -PTR_ERR(part)); 575 574 continue; 576 575 } 577 576 #ifdef CONFIG_BLK_DEV_MD 578 577 if (state->parts[p].flags & ADDPART_FLAG_RAID) 579 - md_autodetect_dev(bdev->bd_dev+p); 578 + md_autodetect_dev(part_to_dev(part)->devt); 580 579 #endif 581 580 } 582 581 kfree(state);
+3 -1
include/linux/genhd.h
··· 522 522 523 523 extern int disk_expand_part_tbl(struct gendisk *disk, int target); 524 524 extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev); 525 - extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int); 525 + extern struct hd_struct * __must_check add_partition(struct gendisk *disk, 526 + int partno, sector_t start, 527 + sector_t len, int flags); 526 528 extern void delete_partition(struct gendisk *, int); 527 529 extern void printk_all_partitions(void); 528 530
+4 -5
kernel/relay.c
··· 400 400 } 401 401 402 402 mutex_lock(&relay_channels_mutex); 403 - for_each_online_cpu(i) 403 + for_each_possible_cpu(i) 404 404 if (chan->buf[i]) 405 405 __relay_reset(chan->buf[i], 0); 406 406 mutex_unlock(&relay_channels_mutex); ··· 611 611 return chan; 612 612 613 613 free_bufs: 614 - for_each_online_cpu(i) { 615 - if (!chan->buf[i]) 616 - break; 617 - relay_close_buf(chan->buf[i]); 614 + for_each_possible_cpu(i) { 615 + if (chan->buf[i]) 616 + relay_close_buf(chan->buf[i]); 618 617 } 619 618 620 619 kref_put(&chan->kref, relay_destroy_channel);