Skip to content

Commit 0a3d571

Browse files
ezequielgarciadedekind
authored andcommitted
UBI: block: Set disk_capacity out of the mutex
There's no need to set the disk capacity with the mutex held, so this commit takes the variable setting out of the mutex. This simplifies the disk capacity fix for very large volumes in a follow up commit. Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
1 parent 495f2bf commit 0a3d571

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎drivers/mtd/ubi/block.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
378378
{
379379
struct ubiblock *dev;
380380
struct gendisk *gd;
381-
int disk_capacity;
381+
int disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
382382
int ret;
383383

384384
/* Check that the volume isn't already handled */
@@ -412,7 +412,6 @@ int ubiblock_create(struct ubi_volume_info *vi)
412412
gd->first_minor = dev->ubi_num * UBI_MAX_VOLUMES + dev->vol_id;
413413
gd->private_data = dev;
414414
sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id);
415-
disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
416415
set_capacity(gd, disk_capacity);
417416
dev->gd = gd;
418417

@@ -501,7 +500,7 @@ int ubiblock_remove(struct ubi_volume_info *vi)
501500
static int ubiblock_resize(struct ubi_volume_info *vi)
502501
{
503502
struct ubiblock *dev;
504-
int disk_capacity;
503+
int disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
505504

506505
/*
507506
* Need to lock the device list until we stop using the device,
@@ -516,7 +515,6 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
516515
}
517516

518517
mutex_lock(&dev->dev_mutex);
519-
disk_capacity = (vi->size * vi->usable_leb_size) >> 9;
520518
set_capacity(dev->gd, disk_capacity);
521519
ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size);
522520
mutex_unlock(&dev->dev_mutex);

0 commit comments

Comments
 (0)