Skip to content

Commit 32621ad

Browse files
Christoph Hellwigaxboe
authored andcommitted
ubd: remove the ubd_gendisk array
And add a disk pointer to the ubd structure instead to keep all the per-device information together. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Richard Weinberger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent ba3f67c commit 32621ad

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

arch/um/drivers/ubd_kern.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ static const struct block_device_operations ubd_blops = {
125125
.getgeo = ubd_getgeo,
126126
};
127127

128-
/* Protected by ubd_lock */
129-
static struct gendisk *ubd_gendisk[MAX_DEV];
130-
131128
#ifdef CONFIG_BLK_DEV_UBD_SYNC
132129
#define OPEN_FLAGS ((struct openflags) { .r = 1, .w = 1, .s = 1, .c = 0, \
133130
.cl = 1 })
@@ -165,6 +162,7 @@ struct ubd {
165162
unsigned no_trim:1;
166163
struct cow cow;
167164
struct platform_device pdev;
165+
struct gendisk *disk;
168166
struct request_queue *queue;
169167
struct blk_mq_tag_set tag_set;
170168
spinlock_t lock;
@@ -922,7 +920,6 @@ static int ubd_add(int n, char **error_out)
922920
if (err)
923921
goto out_cleanup_disk;
924922

925-
ubd_gendisk[n] = disk;
926923
return 0;
927924

928925
out_cleanup_disk:
@@ -1014,7 +1011,6 @@ static int ubd_id(char **str, int *start_out, int *end_out)
10141011

10151012
static int ubd_remove(int n, char **error_out)
10161013
{
1017-
struct gendisk *disk = ubd_gendisk[n];
10181014
struct ubd *ubd_dev;
10191015
int err = -ENODEV;
10201016

@@ -1030,10 +1026,9 @@ static int ubd_remove(int n, char **error_out)
10301026
if(ubd_dev->count > 0)
10311027
goto out;
10321028

1033-
ubd_gendisk[n] = NULL;
1034-
if(disk != NULL){
1035-
del_gendisk(disk);
1036-
put_disk(disk);
1029+
if (ubd_dev->disk) {
1030+
del_gendisk(ubd_dev->disk);
1031+
put_disk(ubd_dev->disk);
10371032
}
10381033

10391034
err = 0;

0 commit comments

Comments
 (0)