rbd: revalidate_disk upon rbd resize
Subsystems (2)
PATCH 1/1 rbd: revalidate_disk upon rbd resize
If rbd disk is open and rbd resize is done, new size is not visible by filesystem.
Like is done in virtio-blk and dm driver, revalidate_disk() permits to update the bd_inode size.
--- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+)
drivers/block/rbd.c +1 -0
@@ -2293,6 +2293,7 @@ static void rbd_update_mapping_size(struct rbd_device *rbd_dev)dout ("setting size to %llu sectors" , (unsigned long long ) size); rbd_dev->mapping.size = (u64 ) size;set_capacity (rbd_dev->disk, size); +revalidate_disk (rbd_dev->disk); }/*
Signature · 1 line
1.7.10.4
Quoted 4 lines · Laurent Barbe
If rbd disk is open and rbd resize is done, new size is not visible by filesystem.
Like is done in virtio-blk and dm driver,revalidate_disk()permits to update thebd_inodesize.
Looks good to me. I'll take this in via the ceph-client tree. Thanks a lot.
Quoted 18 lines
Signed-off-by Laurent Barbe <[email protected]>--- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+)drivers/block/rbd.c +1
-0@@ -2293,6 +2293,7 @@ static void rbd_update_mapping_size(struct rbd_device *rbd_dev)dout ("setting size to %llu sectors" , (unsigned long long ) size); rbd_dev->mapping.size = (u64 ) size;set_capacity (rbd_dev->disk, size); +revalidate_disk (rbd_dev->disk); }/*
Quoted 8 lines · Alex Elder
Quoted 4 lines · Laurent Barbe
If rbd disk is open and rbd resize is done, new size is not visible by filesystem.
Like is done in virtio-blk and dm driver,revalidate_disk()permits to update thebd_inodesize.Looks good to me. I'll take this in via the ceph-client tree. Thanks a lot.
Unfortunately this leads to a lock inversion. I'm going to think about how to go about resolving it, so I won't be committing it just yet.
-Alex
Quoted 22 lines
Reviewed-by Alex Elder <[email protected]>Quoted 18 lines
Signed-off-by Laurent Barbe <[email protected]>--- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+)drivers/block/rbd.c +1
-0@@ -2293,6 +2293,7 @@ static void rbd_update_mapping_size(struct rbd_device *rbd_dev)dout ("setting size to %llu sectors" , (unsigned long long ) size); rbd_dev->mapping.size = (u64 ) size;set_capacity (rbd_dev->disk, size); +revalidate_disk (rbd_dev->disk); }/*
A message that is not in the archive (sent off-list or not yet received): CADksbcpbhp8-Db2bqQc_fFwmT-iObYdjK+rXJF5DiZ9wu1sSQA@mail.gmail.com
Quoted 5 lines · Laurent Barbe
Thanks Alex,
What do you mean about "lock inversion", deadlock ?
Is it themutex_lockin block_dev.c:revalidate_disk() and the mutex inrbd_dev_refresh?
Yes.
When we refresh an rbd device we get the rbd device header semaphore, and with this patch we then acquire the bdev's mutex.
Meanhwhile, via blkdev_close() __blkdev_put() acquires the bdev->bd_mutex, and eventually we get down to creating an image object request. If it's a write, we need to get the snapshot context, and to do that we get the rbd device header mutex.
So we're acquiring the locks in two different orders, and that's what I meant by "lock inversion," and yes, that can lead to deadlock.
There may be a simple fix--like holding off calling revalidate_disk() until after we release the lock, most likely in rbd_dev_refresh(). But I just haven't really thought it through yet.
-Alex
Quoted 45 lines
2013/4/11 Alex Elder <[email protected]>
Quoted 41 lines · Alex Elder
Quoted 8 lines · Laurent Barbe
Quoted 4 lines
If rbd disk is open and rbd resize is done, new size is not visible by filesystem.
Like is done in virtio-blk and dm driver,revalidate_disk()permits to update thebd_inodesize.Looks good to me. I'll take this in via the ceph-client tree. Thanks a lot.
Unfortunately this leads to a lock inversion. I'm going to think about how to go about resolving it, so I won't be committing it just yet.
-Alex
Quoted 8 lines
Reviewed-by Alex Elder <[email protected]>Quoted 5 lines
Signed-off-by Laurent Barbe <[email protected]>--- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+)Quoted 5 lines
drivers/block/rbd.c static void rbd_update_mapping_size(struct
Quoted 5 lines
drivers/block/rbd.c +0
-0@@ -2293,6 +2293,7 @@ static void rbd_update_mapping_size(struct
rbd_device*rbd_dev)Quoted 9 lines
Quoted 8 lines
drivers/block/rbd.c +1
-0dout ("setting size to %llu sectors" , (unsigned long long ) size); rbd_dev->mapping.size = (u64 ) size;set_capacity (rbd_dev->disk, size); +revalidate_disk (rbd_dev->disk); }/*
Ok,
thank you for your explanation, I'll look a little later.
2013/4/11 Alex Elder <[email protected]>:
Quoted 76 lines · Laurent Barbe
Quoted 5 lines
Thanks Alex,
What do you mean about "lock inversion", deadlock ?
Is it themutex_lockin block_dev.c:revalidate_disk() and the mutex inrbd_dev_refresh?Yes.
When we refresh an rbd device we get the rbd device header semaphore, and with this patch we then acquire the bdev's mutex.
Meanhwhile, via
blkdev_close()__blkdev_put()acquires thebdev->bd_mutex, and eventually we get down to creating an image object request. If it's a write, we need to get the snapshot context, and to do that we get the rbd device header mutex.So we're acquiring the locks in two different orders, and that's what I meant by "lock inversion," and yes, that can lead to deadlock.
There may be a simple fix--like holding off calling
revalidate_disk()until after we release the lock, most likely inrbd_dev_refresh(). But I just haven't really thought it through yet.-Alex
Quoted 45 lines
2013/4/11 Alex Elder <[email protected]>
Quoted 41 lines · Alex Elder
Quoted 8 lines · Laurent Barbe
Quoted 4 lines
If rbd disk is open and rbd resize is done, new size is not visible by filesystem.
Like is done in virtio-blk and dm driver,revalidate_disk()permits to update thebd_inodesize.Looks good to me. I'll take this in via the ceph-client tree. Thanks a lot.
Unfortunately this leads to a lock inversion. I'm going to think about how to go about resolving it, so I won't be committing it just yet.
-Alex
Quoted 8 lines
Reviewed-by Alex Elder <[email protected]>Quoted 5 lines
Signed-off-by Laurent Barbe <[email protected]>--- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+)Quoted 5 lines
drivers/block/rbd.c static void rbd_update_mapping_size(struct
Quoted 5 lines
drivers/block/rbd.c +0
-0@@ -2293,6 +2293,7 @@ static void rbd_update_mapping_size(struct
rbd_device*rbd_dev)Quoted 9 lines
Quoted 8 lines
drivers/block/rbd.c +1
-0dout ("setting size to %llu sectors" , (unsigned long long ) size); rbd_dev->mapping.size = (u64 ) size;set_capacity (rbd_dev->disk, size); +revalidate_disk (rbd_dev->disk); }/*