On Thu, May 04, 2006 at 12:08:23PM +0100, Darren J Moffat wrote: > I've just resync'd my zfs-crypto workspace to onnv_39 and started some > more serious work on this.
Excellent. I can hardly wait to use this. > I need some help with the ZIO pipeline. I think my code should be > getting called but it doesn't appear to be (viewing with the attached > dtrace script). > > ... > > The updates to zio_write() have this in them: > > zio->io_checksum = checksum; > zio->io_compress = compress; > zio->io_ndvas = ncopies; > zio->io_crypt = crypt; > > if (compress != ZIO_COMPRESS_OFF) > zio->io_async_stages |= 1U << ZIO_STAGE_WRITE_COMPRESS; > > if (crypt != ZIO_CRYPT_OFF) > zio->io_async_stages |= 1U << ZIO_STAGE_WRITE_ENCRYPT; > > so with crypt being "3" we should be adding encryption into the pipeline. > > See the patch for the full set of changes that show where things > like ZIO_STAGE_WRITE_ENCRYPT are set up. > > So what am I missing, I feel like it is something really obvious but > I just can't see it. You shouldn't need anything in zio_write() to get going, although the above code you have will make us dispatch one less thing to a taskq when compression is off. In any case, simply add ZIO_STAGE_WRITE_CRYPT to the definitions for ZIO_WRITE_PHYS_PIPELINE in zio_impl.h (and the same goes for adding ZIO_STAGE_READ_DECRYPT to ZIO_READ_PHYS_PIPELINE). Also, if you don't want to put that code in zio_write(), just add ZIO_STAGE_WRITE_CRYPT and ZIO_STAGE_READ_DECRYPT to the definition for ZIO_ASYNC_PIPELINE_STAGES. The explanation for the above is that io_pipeline defines the stages that a given zio goes through. So in order for your encryption stuff to get called, it must be part of that. The io_async_stages simply defines which of the pipeline stages should be asynchronous - that is, not done in the context of the zio_write() caller. You don't want the I/O issue rate of the caller to be limited by how fast you can do encryption. In the zio code, compression is a slightly funny guy, so you should instead model your changes after how checksums are done. I think you should always execute your zio_write_crypt() function since it needs to set some fields in the bp. The routine you call to actually do the encryption will key off of ZIO_CRYPT_OFF and just do no work in that case. Does that help? --Bill
