[BTRFS]
authorPierre Schweitzer <pierre@reactos.org>
Wed, 27 Jul 2016 19:32:05 +0000 (19:32 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 27 Jul 2016 19:32:05 +0000 (19:32 +0000)
Import three fixes from my local GitHub repository:
- Don't attempt to remove Vcb from list twice on shutdown
- Properly add CCB to root_file
- Init cache for root_file so that cache uninit on shutdown isn't problematic

This fixes BTRFS in ReactOS.
These fixes have already been submitted upstream (https://github.com/maharmstone/btrfs/pull/23).

CORE-11674

svn path=/trunk/; revision=72024

reactos/drivers/filesystems/btrfs/btrfs.c

index 54723e2..190db9c 100644 (file)
@@ -1935,7 +1935,9 @@ void STDCALL uninit(device_extension* Vcb, BOOL flush) {
     LIST_ENTRY* le;
     LARGE_INTEGER time;
     
+#ifndef __REACTOS__
     RemoveEntryList(&Vcb->list_entry);
+#endif
     
     Status = registry_mark_volume_unmounted(&Vcb->superblock.uuid);
     if (!NT_SUCCESS(Status))
@@ -3762,12 +3764,27 @@ static NTSTATUS STDCALL mount_vol(PDEVICE_OBJECT DeviceObject, PIRP Irp) {
     
     Vcb->root_file = IoCreateStreamFileObject(NULL, DeviceToMount);
     Vcb->root_file->FsContext = root_fcb;
+#ifdef __REACTOS__
+    Vcb->root_file->SectionObjectPointer = &root_fcb->nonpaged->segment_object;
+    Vcb->root_file->Vpb = DeviceObject->Vpb;
+#endif
     
     RtlZeroMemory(root_ccb, sizeof(ccb));
     root_ccb->NodeType = BTRFS_NODE_TYPE_CCB;
     root_ccb->NodeSize = sizeof(ccb);
     
+#ifndef __REACTOS__
     Vcb->root_file->FsContext = root_ccb;
+#else
+    Vcb->root_file->FsContext2 = root_ccb;
+    
+    _SEH2_TRY {
+        CcInitializeCacheMap(Vcb->root_file, (PCC_FILE_SIZES)(&root_fcb->Header.AllocationSize), FALSE, cache_callbacks, Vcb->root_file);
+    } _SEH2_EXCEPT (EXCEPTION_EXECUTE_HANDLER) {
+        Status = _SEH2_GetExceptionCode();
+        goto exit;
+    } _SEH2_END;
+#endif
     
     for (i = 0; i < Vcb->superblock.num_devices; i++) {
         Status = find_disk_holes(Vcb, &Vcb->devices[i]);