summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--block/blk-core.c2
-rw-r--r--block/genhd.c21
-rw-r--r--drivers/scsi/sd.c41
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/linux/genhd.h8
5 files changed, 8 insertions, 65 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 1086dac8724c..a76895c9776d 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -578,8 +578,6 @@ void blk_cleanup_queue(struct request_queue *q)
578 q->queue_lock = &q->__queue_lock; 578 q->queue_lock = &q->__queue_lock;
579 spin_unlock_irq(lock); 579 spin_unlock_irq(lock);
580 580
581 put_disk_devt(q->disk_devt);
582
583 /* @q is and will stay empty, shutdown and put */ 581 /* @q is and will stay empty, shutdown and put */
584 blk_put_queue(q); 582 blk_put_queue(q);
585} 583}
diff --git a/block/genhd.c b/block/genhd.c
index 94f323842b52..a9c516a8b37d 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -572,20 +572,6 @@ exit:
572 disk_part_iter_exit(&piter); 572 disk_part_iter_exit(&piter);
573} 573}
574 574
575void put_disk_devt(struct disk_devt *disk_devt)
576{
577 if (disk_devt && atomic_dec_and_test(&disk_devt->count))
578 disk_devt->release(disk_devt);
579}
580EXPORT_SYMBOL(put_disk_devt);
581
582void get_disk_devt(struct disk_devt *disk_devt)
583{
584 if (disk_devt)
585 atomic_inc(&disk_devt->count);
586}
587EXPORT_SYMBOL(get_disk_devt);
588
589/** 575/**
590 * device_add_disk - add partitioning information to kernel list 576 * device_add_disk - add partitioning information to kernel list
591 * @parent: parent device for the disk 577 * @parent: parent device for the disk
@@ -626,13 +612,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk)
626 612
627 disk_alloc_events(disk); 613 disk_alloc_events(disk);
628 614
629 /*
630 * Take a reference on the devt and assign it to queue since it
631 * must not be reallocated while the bdi is registered
632 */
633 disk->queue->disk_devt = disk->disk_devt;
634 get_disk_devt(disk->disk_devt);
635
636 /* Register BDI before referencing it from bdev */ 615 /* Register BDI before referencing it from bdev */
637 bdi = disk->queue->backing_dev_info; 616 bdi = disk->queue->backing_dev_info;
638 bdi_register_owner(bdi, disk_to_dev(disk)); 617 bdi_register_owner(bdi, disk_to_dev(disk));
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index c7839f6c35cc..d277e8620e3e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3075,23 +3075,6 @@ static void sd_probe_async(void *data, async_cookie_t cookie)
3075 put_device(&sdkp->dev); 3075 put_device(&sdkp->dev);
3076} 3076}
3077 3077
3078struct sd_devt {
3079 int idx;
3080 struct disk_devt disk_devt;
3081};
3082
3083static void sd_devt_release(struct disk_devt *disk_devt)
3084{
3085 struct sd_devt *sd_devt = container_of(disk_devt, struct sd_devt,
3086 disk_devt);
3087
3088 spin_lock(&sd_index_lock);
3089 ida_remove(&sd_index_ida, sd_devt->idx);
3090 spin_unlock(&sd_index_lock);
3091
3092 kfree(sd_devt);
3093}
3094
3095/** 3078/**
3096 * sd_probe - called during driver initialization and whenever a 3079 * sd_probe - called during driver initialization and whenever a
3097 * new scsi device is attached to the system. It is called once 3080 * new scsi device is attached to the system. It is called once
@@ -3113,7 +3096,6 @@ static void sd_devt_release(struct disk_devt *disk_devt)
3113static int sd_probe(struct device *dev) 3096static int sd_probe(struct device *dev)
3114{ 3097{
3115 struct scsi_device *sdp = to_scsi_device(dev); 3098 struct scsi_device *sdp = to_scsi_device(dev);
3116 struct sd_devt *sd_devt;
3117 struct scsi_disk *sdkp; 3099 struct scsi_disk *sdkp;
3118 struct gendisk *gd; 3100 struct gendisk *gd;
3119 int index; 3101 int index;
@@ -3139,13 +3121,9 @@ static int sd_probe(struct device *dev)
3139 if (!sdkp) 3121 if (!sdkp)
3140 goto out; 3122 goto out;
3141 3123
3142 sd_devt = kzalloc(sizeof(*sd_devt), GFP_KERNEL);
3143 if (!sd_devt)
3144 goto out_free;
3145
3146 gd = alloc_disk(SD_MINORS); 3124 gd = alloc_disk(SD_MINORS);
3147 if (!gd) 3125 if (!gd)
3148 goto out_free_devt; 3126 goto out_free;
3149 3127
3150 do { 3128 do {
3151 if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) 3129 if (!ida_pre_get(&sd_index_ida, GFP_KERNEL))
@@ -3161,11 +3139,6 @@ static int sd_probe(struct device *dev)
3161 goto out_put; 3139 goto out_put;
3162 } 3140 }
3163 3141
3164 atomic_set(&sd_devt->disk_devt.count, 1);
3165 sd_devt->disk_devt.release = sd_devt_release;
3166 sd_devt->idx = index;
3167 gd->disk_devt = &sd_devt->disk_devt;
3168
3169 error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN); 3142 error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
3170 if (error) { 3143 if (error) {
3171 sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n"); 3144 sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n");
@@ -3205,12 +3178,11 @@ static int sd_probe(struct device *dev)
3205 return 0; 3178 return 0;
3206 3179
3207 out_free_index: 3180 out_free_index:
3208 put_disk_devt(&sd_devt->disk_devt); 3181 spin_lock(&sd_index_lock);
3209 sd_devt = NULL; 3182 ida_remove(&sd_index_ida, index);
3183 spin_unlock(&sd_index_lock);
3210 out_put: 3184 out_put:
3211 put_disk(gd); 3185 put_disk(gd);
3212 out_free_devt:
3213 kfree(sd_devt);
3214 out_free: 3186 out_free:
3215 kfree(sdkp); 3187 kfree(sdkp);
3216 out: 3188 out:
@@ -3271,7 +3243,10 @@ static void scsi_disk_release(struct device *dev)
3271 struct scsi_disk *sdkp = to_scsi_disk(dev); 3243 struct scsi_disk *sdkp = to_scsi_disk(dev);
3272 struct gendisk *disk = sdkp->disk; 3244 struct gendisk *disk = sdkp->disk;
3273 3245
3274 put_disk_devt(disk->disk_devt); 3246 spin_lock(&sd_index_lock);
3247 ida_remove(&sd_index_ida, sdkp->index);
3248 spin_unlock(&sd_index_lock);
3249
3275 disk->private_data = NULL; 3250 disk->private_data = NULL;
3276 put_disk(disk); 3251 put_disk(disk);
3277 put_device(&sdkp->device->sdev_gendev); 3252 put_device(&sdkp->device->sdev_gendev);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 796016e63c1d..5a7da607ca04 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -435,7 +435,6 @@ struct request_queue {
435 struct delayed_work delay_work; 435 struct delayed_work delay_work;
436 436
437 struct backing_dev_info *backing_dev_info; 437 struct backing_dev_info *backing_dev_info;
438 struct disk_devt *disk_devt;
439 438
440 /* 439 /*
441 * The queue owner gets to use this for whatever they like. 440 * The queue owner gets to use this for whatever they like.
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index a999d281a2f1..76f39754e7b0 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -167,13 +167,6 @@ struct blk_integrity {
167}; 167};
168 168
169#endif /* CONFIG_BLK_DEV_INTEGRITY */ 169#endif /* CONFIG_BLK_DEV_INTEGRITY */
170struct disk_devt {
171 atomic_t count;
172 void (*release)(struct disk_devt *disk_devt);
173};
174
175void put_disk_devt(struct disk_devt *disk_devt);
176void get_disk_devt(struct disk_devt *disk_devt);
177 170
178struct gendisk { 171struct gendisk {
179 /* major, first_minor and minors are input parameters only, 172 /* major, first_minor and minors are input parameters only,
@@ -183,7 +176,6 @@ struct gendisk {
183 int first_minor; 176 int first_minor;
184 int minors; /* maximum number of minors, =1 for 177 int minors; /* maximum number of minors, =1 for
185 * disks that can't be partitioned. */ 178 * disks that can't be partitioned. */
186 struct disk_devt *disk_devt;
187 179
188 char disk_name[DISK_NAME_LEN]; /* name of major driver */ 180 char disk_name[DISK_NAME_LEN]; /* name of major driver */
189 char *(*devnode)(struct gendisk *gd, umode_t *mode); 181 char *(*devnode)(struct gendisk *gd, umode_t *mode);