Skip to contentSkip to conversation

rbd: revalidate_disk upon rbd resize

PATCH In review Laurent Barbe 2 participants 5 messages Apr 10, 2013 – Apr 11, 2013 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index f556f8a..1963025 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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 the bd_inode size.

Looks good to me. I'll take this in via the ceph-client tree. Thanks a lot.

Quoted 18 lines
---
 drivers/block/rbd.c |    1 +
 1 file changed, 1 insertion(+)
drivers/block/rbd.c +1 -0
index f556f8a..1963025 100644
@@ -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);
 }
 
 /*
#2 lore raw
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 the bd_inode size.

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
Quoted 18 lines
---
 drivers/block/rbd.c |    1 +
 1 file changed, 1 insertion(+)
drivers/block/rbd.c +1 -0
index f556f8a..1963025 100644
@@ -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

#4 lore raw
Quoted 5 lines · Laurent Barbe

Thanks Alex,

What do you mean about "lock inversion", deadlock ?
Is it the mutex_lock in block_dev.c:revalidate_disk() and the mutex in rbd_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 the bd_inode size.

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
Quoted 5 lines
---
 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
index f556f8a..1963025 100644
@@ -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 -0
     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);
 }
 
 /*
#5 lore raw

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 the mutex_lock in block_dev.c:revalidate_disk() and the mutex in rbd_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 the bd_inode size.

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
Quoted 5 lines
---
 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
index f556f8a..1963025 100644
@@ -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 -0
     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);
 }
 
 /*