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
This commit is contained in:
commit
7f0f598a00
|
@ -217,6 +217,12 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
|
|||
return PTR_ERR(bio);
|
||||
|
||||
if (bio->bi_size != len) {
|
||||
/*
|
||||
* Grab an extra reference to this bio, as bio_unmap_user()
|
||||
* expects to be able to drop it twice as it happens on the
|
||||
* normal IO completion path
|
||||
*/
|
||||
bio_get(bio);
|
||||
bio_endio(bio, 0);
|
||||
bio_unmap_user(bio);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -768,6 +768,8 @@ static int __init genhd_device_init(void)
|
|||
bdev_map = kobj_map_init(base_probe, &block_class_lock);
|
||||
blk_dev_init();
|
||||
|
||||
register_blkdev(BLOCK_EXT_MAJOR, "blkext");
|
||||
|
||||
#ifndef CONFIG_SYSFS_DEPRECATED
|
||||
/* create top-level block dir */
|
||||
block_depr = kobject_create_and_add("block", NULL);
|
||||
|
|
|
@ -18,7 +18,6 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
|
|||
struct disk_part_iter piter;
|
||||
long long start, length;
|
||||
int partno;
|
||||
int err;
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN))
|
||||
return -EACCES;
|
||||
|
@ -61,10 +60,10 @@ static int blkpg_ioctl(struct block_device *bdev, struct blkpg_ioctl_arg __user
|
|||
disk_part_iter_exit(&piter);
|
||||
|
||||
/* all seems OK */
|
||||
err = add_partition(disk, partno, start, length,
|
||||
ADDPART_FLAG_NONE);
|
||||
part = add_partition(disk, partno, start, length,
|
||||
ADDPART_FLAG_NONE);
|
||||
mutex_unlock(&bdev->bd_mutex);
|
||||
return err;
|
||||
return IS_ERR(part) ? PTR_ERR(part) : 0;
|
||||
case BLKPG_DEL_PARTITION:
|
||||
part = disk_get_part(disk, partno);
|
||||
if (!part)
|
||||
|
|
|
@ -338,12 +338,18 @@ wait:
|
|||
static int xlvbd_init_blk_queue(struct gendisk *gd, u16 sector_size)
|
||||
{
|
||||
struct request_queue *rq;
|
||||
elevator_t *old_e;
|
||||
|
||||
rq = blk_init_queue(do_blkif_request, &blkif_io_lock);
|
||||
if (rq == NULL)
|
||||
return -1;
|
||||
|
||||
elevator_init(rq, "noop");
|
||||
old_e = rq->elevator;
|
||||
if (IS_ERR_VALUE(elevator_init(rq, "noop")))
|
||||
printk(KERN_WARNING
|
||||
"blkfront: Switch elevator failed, use default\n");
|
||||
else
|
||||
elevator_exit(old_e);
|
||||
|
||||
/* Hard sector size and max sectors impersonate the equiv. hardware. */
|
||||
blk_queue_hardsect_size(rq, sector_size);
|
||||
|
|
|
@ -348,8 +348,8 @@ static ssize_t whole_disk_show(struct device *dev,
|
|||
static DEVICE_ATTR(whole_disk, S_IRUSR | S_IRGRP | S_IROTH,
|
||||
whole_disk_show, NULL);
|
||||
|
||||
int add_partition(struct gendisk *disk, int partno,
|
||||
sector_t start, sector_t len, int flags)
|
||||
struct hd_struct *add_partition(struct gendisk *disk, int partno,
|
||||
sector_t start, sector_t len, int flags)
|
||||
{
|
||||
struct hd_struct *p;
|
||||
dev_t devt = MKDEV(0, 0);
|
||||
|
@ -361,15 +361,15 @@ int add_partition(struct gendisk *disk, int partno,
|
|||
|
||||
err = disk_expand_part_tbl(disk, partno);
|
||||
if (err)
|
||||
return err;
|
||||
return ERR_PTR(err);
|
||||
ptbl = disk->part_tbl;
|
||||
|
||||
if (ptbl->part[partno])
|
||||
return -EBUSY;
|
||||
return ERR_PTR(-EBUSY);
|
||||
|
||||
p = kzalloc(sizeof(*p), GFP_KERNEL);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
return ERR_PTR(-EBUSY);
|
||||
|
||||
if (!init_part_stats(p)) {
|
||||
err = -ENOMEM;
|
||||
|
@ -395,7 +395,7 @@ int add_partition(struct gendisk *disk, int partno,
|
|||
|
||||
err = blk_alloc_devt(p, &devt);
|
||||
if (err)
|
||||
goto out_free;
|
||||
goto out_free_stats;
|
||||
pdev->devt = devt;
|
||||
|
||||
/* delay uevent until 'holders' subdir is created */
|
||||
|
@ -424,18 +424,20 @@ int add_partition(struct gendisk *disk, int partno,
|
|||
if (!ddev->uevent_suppress)
|
||||
kobject_uevent(&pdev->kobj, KOBJ_ADD);
|
||||
|
||||
return 0;
|
||||
return p;
|
||||
|
||||
out_free_stats:
|
||||
free_part_stats(p);
|
||||
out_free:
|
||||
kfree(p);
|
||||
return err;
|
||||
return ERR_PTR(err);
|
||||
out_del:
|
||||
kobject_put(p->holder_dir);
|
||||
device_del(pdev);
|
||||
out_put:
|
||||
put_device(pdev);
|
||||
blk_free_devt(devt);
|
||||
return err;
|
||||
return ERR_PTR(err);
|
||||
}
|
||||
|
||||
/* Not exported, helper to add_disk(). */
|
||||
|
@ -566,15 +568,16 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
|
|||
disk->disk_name, p, (unsigned long long) size);
|
||||
size = get_capacity(disk) - from;
|
||||
}
|
||||
res = add_partition(disk, p, from, size, state->parts[p].flags);
|
||||
if (res) {
|
||||
printk(KERN_ERR " %s: p%d could not be added: %d\n",
|
||||
disk->disk_name, p, -res);
|
||||
part = add_partition(disk, p, from, size,
|
||||
state->parts[p].flags);
|
||||
if (IS_ERR(part)) {
|
||||
printk(KERN_ERR " %s: p%d could not be added: %ld\n",
|
||||
disk->disk_name, p, -PTR_ERR(part));
|
||||
continue;
|
||||
}
|
||||
#ifdef CONFIG_BLK_DEV_MD
|
||||
if (state->parts[p].flags & ADDPART_FLAG_RAID)
|
||||
md_autodetect_dev(bdev->bd_dev+p);
|
||||
md_autodetect_dev(part_to_dev(part)->devt);
|
||||
#endif
|
||||
}
|
||||
kfree(state);
|
||||
|
|
|
@ -522,7 +522,9 @@ extern char *disk_name (struct gendisk *hd, int partno, char *buf);
|
|||
|
||||
extern int disk_expand_part_tbl(struct gendisk *disk, int target);
|
||||
extern int rescan_partitions(struct gendisk *disk, struct block_device *bdev);
|
||||
extern int __must_check add_partition(struct gendisk *, int, sector_t, sector_t, int);
|
||||
extern struct hd_struct * __must_check add_partition(struct gendisk *disk,
|
||||
int partno, sector_t start,
|
||||
sector_t len, int flags);
|
||||
extern void delete_partition(struct gendisk *, int);
|
||||
extern void printk_all_partitions(void);
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ void relay_reset(struct rchan *chan)
|
|||
}
|
||||
|
||||
mutex_lock(&relay_channels_mutex);
|
||||
for_each_online_cpu(i)
|
||||
for_each_possible_cpu(i)
|
||||
if (chan->buf[i])
|
||||
__relay_reset(chan->buf[i], 0);
|
||||
mutex_unlock(&relay_channels_mutex);
|
||||
|
@ -611,10 +611,9 @@ struct rchan *relay_open(const char *base_filename,
|
|||
return chan;
|
||||
|
||||
free_bufs:
|
||||
for_each_online_cpu(i) {
|
||||
if (!chan->buf[i])
|
||||
break;
|
||||
relay_close_buf(chan->buf[i]);
|
||||
for_each_possible_cpu(i) {
|
||||
if (chan->buf[i])
|
||||
relay_close_buf(chan->buf[i]);
|
||||
}
|
||||
|
||||
kref_put(&chan->kref, relay_destroy_channel);
|
||||
|
|
Loading…
Reference in a new issue