Skip to content

Commit 8a6f7bb

Browse files
Christoph Hellwigaxboe
authored andcommitted
aoe: don't call set_capacity from irq context
Updating the block device size from irq context can lead to torn writes of the 64-bit value, and prevents us from using normal process context locking primitives to serialize access to the 64-bit nr_sectors value. Defer the set_capacity to the already existing workqueue handler, where it can be merged with the update of the block device size by using set_capacity_and_notify. As an extra bonus this also adds proper uevent notifications for the resize. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 2ebcabf commit 8a6f7bb

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

drivers/block/aoe/aoecmd.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -890,19 +890,13 @@ void
890890
aoecmd_sleepwork(struct work_struct *work)
891891
{
892892
struct aoedev *d = container_of(work, struct aoedev, work);
893-
struct block_device *bd;
894-
u64 ssize;
895893

896894
if (d->flags & DEVFL_GDALLOC)
897895
aoeblk_gdalloc(d);
898896

899897
if (d->flags & DEVFL_NEWSIZE) {
900-
ssize = get_capacity(d->gd);
901-
bd = bdget_disk(d->gd, 0);
902-
if (bd) {
903-
bd_set_nr_sectors(bd, ssize);
904-
bdput(bd);
905-
}
898+
set_capacity_and_notify(d->gd, d->ssize);
899+
906900
spin_lock_irq(&d->lock);
907901
d->flags |= DEVFL_UP;
908902
d->flags &= ~DEVFL_NEWSIZE;
@@ -971,10 +965,9 @@ ataid_complete(struct aoedev *d, struct aoetgt *t, unsigned char *id)
971965
d->geo.start = 0;
972966
if (d->flags & (DEVFL_GDALLOC|DEVFL_NEWSIZE))
973967
return;
974-
if (d->gd != NULL) {
975-
set_capacity(d->gd, ssize);
968+
if (d->gd != NULL)
976969
d->flags |= DEVFL_NEWSIZE;
977-
} else
970+
else
978971
d->flags |= DEVFL_GDALLOC;
979972
schedule_work(&d->work);
980973
}

0 commit comments

Comments
 (0)