cleanup,close, and lazy -writer

Hi,

We are writing a file system filter driver for en/decryption.
Our filter resides above the FSD.

We are confused at the sequence of
IRP_MJ_CLEANUP, IRP_MJ_CLOSE and the lazy writer.
The key for the file encryption must be on memory while the file is opend
and the key must be erased when the file is closed.
We are at a loss to decide when to erase the key because the key is
needed by the lazy writer.

We saw the sequence of

  1. IRP_MJ_CLEANUP
  2. the lazy writer
  3. IRP_MJ_CLOSE.

and also saw the sequence of

  1. IRP_MJ_CLOSE
  2. IRP_MJ_CLEANUP.

Are there any other kind of sequences?

Any help is greately appreciated.
Thanks in advance.

Takashi.