Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / cc / sharedcachemap-priv.h
index 0d69717..7a7cf07 100644 (file)
@@ -42,15 +42,35 @@ struct _CaptiveSharedCacheMapObject {
 
        gint w32_ref_count;
        FILE_OBJECT *FileObject;
-       SECTION_OBJECT_POINTERS *SectionObjectPointers;
+       SECTION_OBJECT_POINTERS *SectionObjectPointer;
        /* ValidDataLength<=FileSize<=AllocationSize */
+       /* 'AllocationSize' sets the mmap(2)ed area of buffers of this SharedCacheMap.
+        * We must reallocate this area if 'AllocationSize' changes and in such case
+        * there must exist no map-Bcb or pin-Bcbs for it.
+        * We would cope with 'buffer' change with existing Bcbs but W32 client could not.
+        */
        guint64 AllocationSize; /* ==CC_FILE_SIZES.AllocationSize.QuadPart */
+       /* We generally check against CAPTIVE_ROUND_UP64(FileSize,PAGE_SIZE)
+        * as the offsets are usually PAGE_SIZE aligned due to pin-Bcb expectations.
+        */
        guint64 FileSize;       /* ==CC_FILE_SIZES.FileSize.QuadPart */
+       /* We use do not use 'ValidDataLength' as I assume W32
+        * automatically increases 'ValidDataLength' during Cache Manager write operations.
+        * We do not increase it and therefore it is mostly useless for us.
+        * In some cases (during NTFS mount) there may be also invalid 'ValidDataLength' at all:
+        *      CcSetFileSizes(AllocationSize=0x1000000,FileSize=0xf80208,ValidDataLength=0x23b801a0)
+        */
        guint64 ValidDataLength;        /* ==CC_FILE_SIZES.ValidDataLength.QuadPart */
+       /* The real allocation size of 'buffer' and 'pages'.
+        * Maintained by captive_shared_cache_map_object_FileSizes_changed()
+        * to prevent continous reallocation to (n+1) size.
+        * We use (n*2) sizes for logaritmic time complexity.
+        */
+       guint64 alloc_length;
        CACHE_MANAGER_CALLBACKS CallBacks;
        VOID *LazyWriterContext;
        gboolean PinAccess;
-       CaptivePrivateBcbMapObject *map;
+       CaptivePrivateBcbMapObject *map;        /* 'map' will g_object_ref(CaptiveSharedCacheMapObject). */
        GHashTable *pin_hash;   /* map: (guint64 *) -> (CaptivePrivateBcbPinObject *) */
        gboolean LogHandle_set;
        gboolean FlushToLsnRoutine_set;