Skip to contentSkip to conversation

iscsi_truncate: ensure there are no requests in flight

PATCH Applied Peter Lieven 3 participants 10 messages Mar 11, 2013 – Mar 19, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 iscsi_truncate: ensure there are no requests in flight

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
 block/iscsi.c |    4 ++++
 1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs, int64_t offset)
         return -ENOTSUP;
     }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
     if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
         return ret;
     }
Signature · 1 line
1.7.9.5
#1 lore raw

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 26 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
 block/iscsi.c |    4 ++++
 1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
         return -ENOTSUP;
     }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
     if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
         return ret;
Quoted 1 line
     }

NACK to this patch. It would be a bug, let's fix it properly.

The other two are fine, however.

Paolo

#2 lore raw

Am 11.03.2013 um 11:16 schrieb Paolo Bonzini <[email protected]>:

Quoted 21 lines

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 20 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
block/iscsi.c | 4 ++++

1 file changed, 4 insertions(+)
block/iscsi.c +0 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
        return -ENOTSUP;
    }
 
Quoted 9 lines
Quoted 7 lines
block/iscsi.c +4 -0
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
    if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
        return ret;
    }

NACK to this patch. It would be a bug, let's fix it properly.

ok, are you sure that never ever will some new feature call bdrv_truncate() on an iscsi device?

otherwise the real fix would be to implement async read capacity commands like it the first patch version for iscsi_truncate().

Peter

Quoted 4 lines

The other two are fine, however.

Paolo

#3 lore raw

Il 11/03/2013 11:19, Peter Lieven ha scritto:

Quoted 34 lines

Am 11.03.2013 um 11:16 schrieb Paolo Bonzini <[email protected]>:

Quoted 21 lines

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 20 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
block/iscsi.c | 4 ++++

1 file changed, 4 insertions(+)
block/iscsi.c +0 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
        return -ENOTSUP;
    }
 
Quoted 9 lines
Quoted 7 lines
block/iscsi.c +4 -0
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
    if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
        return ret;
    }

NACK to this patch. It would be a bug, let's fix it properly.

Quoted 2 lines

ok, are you sure that never ever will some new feature call bdrv_truncate() on an iscsi device?

I'm sure some new feature _will_ call bdrv_truncate(). But as things stand now, it would be a bug to do so on an iSCSI device.

For example, qcow1 (and VHDX) will already call it, but that's a bug and should be fixed otherwise. Your patch will just cause an assertion failure.

Paolo

Quoted 11 lines

otherwise the real fix would be to implement async read capacity commands like it the first patch version for iscsi_truncate().

Peter

Quoted 4 lines

The other two are fine, however.

Paolo

#4 lore raw
Quoted 35 lines · Paolo Bonzini

Il 11/03/2013 11:19, Peter Lieven ha scritto:

Quoted 34 lines

Am 11.03.2013 um 11:16 schrieb Paolo Bonzini <[email protected]>:

Quoted 30 lines

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 26 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
block/iscsi.c | 4 ++++

1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
         return -ENOTSUP;
     }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
     if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
         return ret;
Quoted 1 line
     }

NACK to this patch. It would be a bug, let's fix it properly.

Quoted 8 lines
Quoted 2 lines

ok, are you sure that never ever will some new feature call bdrv_truncate() on an iscsi device?

I'm sure some new feature _will_ call bdrv_truncate(). But as things stand now, it would be a bug to do so on an iSCSI device.

For example, qcow1 (and VHDX) will already call it, but that's a bug and should be fixed otherwise. Your patch will just cause an assertion failure.

In which case can qcow1 (and VHDX) be used in conjunction with an iSCSI Target?

Would it be ok for you to assert if iscsi_truncate() is called when there are aio's in flight? How can this be checked?

I just want to make sure that nothing nasty happens in that case (such as nested event loops).

Peter

Quoted 15 lines

Paolo

Quoted 11 lines

otherwise the real fix would be to implement async read capacity commands like it the first patch version for iscsi_truncate().

Peter

Quoted 4 lines

The other two are fine, however.

Paolo

#5 lore raw

Il 11/03/2013 12:52, Peter Lieven ha scritto:

Quoted 7 lines
Quoted 4 lines

For example, qcow1 (and VHDX) will already call it, but that's a bug and should be fixed otherwise. Your patch will just cause an assertion failure.

In which case can qcow1 (and VHDX) be used in conjunction with an iSCSI Target?

No. It is a bug that they are accepted, but we have time to fix it before 1.5.

Paolo

Quoted 5 lines

Would it be ok for you to assert if iscsi_truncate() is called when there are aio's in flight? How can this be checked?

I just want to make sure that nothing nasty happens in that case (such as nested event loops).

#6 lore raw
In reply to Peter Lieven

Am 11.03.2013 um 12:52 hat Peter Lieven geschrieben:

Quoted 45 lines · Paolo Bonzini
Quoted 35 lines

Il 11/03/2013 11:19, Peter Lieven ha scritto:

Quoted 34 lines

Am 11.03.2013 um 11:16 schrieb Paolo Bonzini <[email protected]>:

Quoted 30 lines

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 26 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
block/iscsi.c | 4 ++++

1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
        return -ENOTSUP;
    }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
    if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
        return ret;
Quoted 1 line
    }

NACK to this patch. It would be a bug, let's fix it properly.

Quoted 8 lines
Quoted 2 lines

ok, are you sure that never ever will some new feature call bdrv_truncate() on an iscsi device?

I'm sure some new feature _will_ call bdrv_truncate(). But as things stand now, it would be a bug to do so on an iSCSI device.

For example, qcow1 (and VHDX) will already call it, but that's a bug and should be fixed otherwise. Your patch will just cause an assertion failure.

Quoted 7 lines

In which case can qcow1 (and VHDX) be used in conjunction with an iSCSI Target?

Would it be ok for you to assert if iscsi_truncate() is called when there are aio's in flight? How can this be checked?

I just want to make sure that nothing nasty happens in that case (such as nested event loops).

Isn't the real problem that I/O requests for _this_specific_ iscsi BDS must not be in flight? So what you reall need is bdrv_drain(iscsi_bs)?

If I understand the code correctly, this boils down to:

    while (iscsi_process_flush(iscsilun)) {
        qemu_aio_wait();
    }

Kevin

#7 lore raw

Il 13/03/2013 10:31, Kevin Wolf ha scritto:

Quoted 8 lines

Isn't the real problem that I/O requests for _this_specific_ iscsi BDS must not be in flight? So what you reall need is bdrv_drain(iscsi_bs)?

If I understand the code correctly, this boils down to:

    while (iscsi_process_flush(iscsilun)) {
        qemu_aio_wait();
    }

Yes, but this function is not doing a truncate at all. It is simply updating the cached result of bdrv_getlength. I think it makes sense that this function (which should not be truncate, but something else) expects to be called with no pending requests. It shouldn't be its task to drain them.

I'll look at fixing this as mentioned in the earlier thread.

Paolo

#8 lore raw
In reply to Paolo Bonzini
Quoted 31 lines · Paolo Bonzini

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 26 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
  block/iscsi.c |    4 ++++
  1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
          return -ENOTSUP;
      }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
      if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
          return ret;
Quoted 1 line
      }

NACK to this patch. It would be a bug, let's fix it properly.

Quoted 1 line

The other two are fine, however.

Paolo, can you ensure that Patch 1+2 get merged before qemu 1.5.0 to fix the regression.

Thanks,
Peter

Quoted 3 lines

Paolo

#9 lore raw

Il 19/03/2013 08:29, Peter Lieven ha scritto:

Quoted 32 lines · Paolo Bonzini
Quoted 31 lines

Il 11/03/2013 11:05, Peter Lieven ha scritto:

Quoted 26 lines

ensure that there are no pending I/Os before calling the sync readcapacity commands. the block_resize monitor command will also flush all I/O, but double check in case iscsi_truncate() is called from elsewhere in the future.

---
  block/iscsi.c |    4 ++++
  1 file changed, 4 insertions(+)
block/iscsi.c +4 -0
index 3d52921..de20d53 100644
@@ -1167,6 +1167,10 @@ static int iscsi_truncate(BlockDriverState *bs,
 int64_t offset)
          return -ENOTSUP;
      }
 
+    /* ensure all async requests are completed before executing
+     * a sync readcapacity */
+    bdrv_drain_all();
+
      if ((ret = iscsi_readcapacity_sync(iscsilun)) != 0) {
          return ret;
Quoted 1 line
      }

NACK to this patch. It would be a bug, let's fix it properly.

Quoted 4 lines
Quoted 1 line

The other two are fine, however.

Paolo, can you ensure that Patch 1+2 get merged before qemu 1.5.0 to fix the regression.

No, I cannot :) because I'm not the block maintainer. But I'm sure that they are on Kevin and Jeff's radar.

Paolo