CcUnpinRepinnedBcb(): Flush 'Bcb' if 'WriteThrough' parameter specified
authorshort <>
Sat, 5 Jul 2003 19:50:02 +0000 (19:50 +0000)
committershort <>
Sat, 5 Jul 2003 19:50:02 +0000 (19:50 +0000)
 - fixes DISMOUNT_VOLUME of fastfat.sys

src/libcaptive/cc/map.c

index 17b0883..9ca726e 100644 (file)
@@ -159,6 +159,9 @@ BOOLEAN captive_cc_FileObject_delete(FILE_OBJECT *FileObject);
  * Close the cachine facilities from CcInitializeCacheMap().
  * It is valid to pass @FileObject without being registered by CcInitializeCacheMap().
  *
+ * FIXME; What to do with files with dirty blocks? Currently we fail assertion on them
+ * although I think W32 would drop such buffers (purge them - not flush them).
+ *
  * Returns: %TRUE if the caching was closed successfuly.
  * %FALSE if @FileObject wasn't registered by CcInitializeCacheMap().
  */
@@ -174,6 +177,11 @@ BOOLEAN r;
                        G_STRLOC,FileObject,(guint64)(!TruncateSize ? -1 : TruncateSize->QuadPart),UninitializeCompleteEvent);
 
        /* TODO:thread */
+       /* Here it will check for any dirty blocks and it will fail g_assert() on them.
+        * I think it may happen for BCBs to exist dirty for 'FileObject' and they
+        * should be silently discarded if CcUninitializeCacheMap() but currently
+        * the assertion is left here as some debugging aid.
+        */
        r=captive_cc_FileObject_delete(FileObject);
 
        /* FIXME: should we do KePulseEvent? Are we allowed to signal from inside CcUninitializeCacheMap() ? */
@@ -1402,6 +1410,12 @@ struct private_bcb *privbcb;
        g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: Bcb=%p,WriteThrough=%d,IoStatus=%p; privbcb->FileObject=%p",G_STRLOC,
                        Bcb,(gint)WriteThrough,IoStatus,privbcb->FileObject);
 
+       /* FIXME: Should we really flush the whole 'Bcb'?
+        * Or maybe just some writes between CcRepinBcb(Bcb) and now? Who knows?
+        */
+       if (WriteThrough)
+               captive_privbcb_flush(privbcb);
+
        IoStatus->Status=STATUS_SUCCESS;
        IoStatus->Information=privbcb->MappedLength;