[BTRFS] Upgrade to 1.0.2
authorPierre Schweitzer <pierre@reactos.org>
Sat, 26 May 2018 08:44:36 +0000 (10:44 +0200)
committerPierre Schweitzer <pierre@reactos.org>
Sat, 26 May 2018 08:44:36 +0000 (10:44 +0200)
CORE-14655

13 files changed:
drivers/filesystems/btrfs/balance.c
drivers/filesystems/btrfs/btrfs.h
drivers/filesystems/btrfs/btrfs.rc
drivers/filesystems/btrfs/btrfs_drv.h
drivers/filesystems/btrfs/calcthread.c
drivers/filesystems/btrfs/create.c
drivers/filesystems/btrfs/fileinfo.c
drivers/filesystems/btrfs/flushthread.c
drivers/filesystems/btrfs/fsctl.c
drivers/filesystems/btrfs/read.c
drivers/filesystems/btrfs/registry.c
drivers/filesystems/btrfs/scrub.c
media/doc/README.FSD

index 9800896..3e36489 100644 (file)
@@ -1984,8 +1984,6 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, BOOL* change
                                    c, NULL, NULL, 0, FALSE, NormalPagePriority);
                 if (!NT_SUCCESS(Status)) {
                     ERR("read_data returned %08x\n", Status);
-                    ExFreePool(csum);
-                    ExFreePool(bmparr);
                     goto end;
                 }
 
@@ -1993,8 +1991,6 @@ static NTSTATUS balance_data_chunk(device_extension* Vcb, chunk* c, BOOL* change
                                              NULL, newchunk, FALSE, 0, NormalPagePriority);
                 if (!NT_SUCCESS(Status)) {
                     ERR("write_data_complete returned %08x\n", Status);
-                    ExFreePool(csum);
-                    ExFreePool(bmparr);
                     goto end;
                 }
 
index 01d2c3b..27e9b63 100644 (file)
@@ -562,7 +562,7 @@ typedef struct {
 #define BTRFS_SEND_TLV_CLONE_OFFSET    23
 #define BTRFS_SEND_TLV_CLONE_LENGTH    24
 
-#define BTRFS_SEND_MAGIC "btrfs-stream\0"
+#define BTRFS_SEND_MAGIC "btrfs-stream"
 
 typedef struct {
     UINT8 magic[13];
index d79da1a..50f7463 100644 (file)
@@ -53,8 +53,8 @@ END
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,1,0
- PRODUCTVERSION 1,0,1,0
+ FILEVERSION 1,0,2,0
+ PRODUCTVERSION 1,0,2,0
  FILEFLAGSMASK 0x17L
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -70,12 +70,12 @@ BEGIN
         BLOCK "080904b0"
         BEGIN
             VALUE "FileDescription", "WinBtrfs"
-            VALUE "FileVersion", "1.0.1"
+            VALUE "FileVersion", "1.0.2"
             VALUE "InternalName", "btrfs"
-            VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-17"
+            VALUE "LegalCopyright", "Copyright (c) Mark Harmstone 2016-18"
             VALUE "OriginalFilename", "btrfs.sys"
             VALUE "ProductName", "WinBtrfs"
-            VALUE "ProductVersion", "1.0.1"
+            VALUE "ProductVersion", "1.0.2"
         END
     END
     BLOCK "VarFileInfo"
index 1cb50cb..e5efc86 100644 (file)
@@ -427,12 +427,7 @@ typedef struct _root {
 } root;
 
 enum batch_operation {
-    Batch_Insert,
     Batch_Delete,
-    Batch_SetXattr,
-    Batch_DirItem,
-    Batch_InodeRef,
-    Batch_InodeExtRef,
     Batch_DeleteInode,
     Batch_DeleteDirItem,
     Batch_DeleteInodeRef,
@@ -440,6 +435,11 @@ enum batch_operation {
     Batch_DeleteXattr,
     Batch_DeleteExtentData,
     Batch_DeleteFreeSpace,
+    Batch_Insert,
+    Batch_SetXattr,
+    Batch_DirItem,
+    Batch_InodeRef,
+    Batch_InodeExtRef,
 };
 
 typedef struct {
index 2b6da81..9bfb45a 100644 (file)
@@ -37,12 +37,14 @@ NTSTATUS add_calc_job(device_extension* Vcb, UINT8* data, UINT32 sectors, UINT32
     KeInitializeEvent(&cj->event, NotificationEvent, FALSE);
 
     ExAcquireResourceExclusiveLite(&Vcb->calcthreads.lock, TRUE);
+
     InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
-    ExReleaseResourceLite(&Vcb->calcthreads.lock);
 
     KeSetEvent(&Vcb->calcthreads.event, 0, FALSE);
     KeClearEvent(&Vcb->calcthreads.event);
 
+    ExReleaseResourceLite(&Vcb->calcthreads.lock);
+
     *pcj = cj;
 
     return STATUS_SUCCESS;
index 191bf63..cd11064 100644 (file)
@@ -3103,7 +3103,7 @@ static NTSTATUS open_file(PDEVICE_OBJECT DeviceObject, _Requires_lock_held_(_Cur
                 allowed |= DELETE;
 
             if (fileref->fcb != Vcb->dummy_fcb && !is_subvol_readonly(fileref->fcb->subvol, Irp) && !Vcb->readonly) {
-                allowed |= WRITE_OWNER | WRITE_DAC | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES;
+                allowed |= DELETE | WRITE_OWNER | WRITE_DAC | FILE_WRITE_EA | FILE_WRITE_ATTRIBUTES;
 
                 if (!fileref->fcb->ads && fileref->fcb->type == BTRFS_TYPE_DIRECTORY)
                     allowed |= FILE_ADD_SUBDIRECTORY | FILE_ADD_FILE | FILE_DELETE_CHILD;
index 9f73667..9588ea1 100644 (file)
@@ -2064,6 +2064,9 @@ static NTSTATUS set_end_of_file_information(device_extension* Vcb, PIRP Irp, PFI
             ERR("error - extend_file failed\n");
             goto end;
         }
+    } else if ((UINT64)feofi->EndOfFile.QuadPart == fcb->inode_item.st_size && advance_only) {
+        Status = STATUS_SUCCESS;
+        goto end;
     }
 
     ccfs.AllocationSize = fcb->Header.AllocationSize;
index ceb37c5..9e95f82 100644 (file)
@@ -4254,8 +4254,9 @@ NTSTATUS insert_tree_item_batch(LIST_ENTRY* batchlist, device_extension* Vcb, ro
     le = br->items.Blink;
     while (le != &br->items) {
         batch_item* bi2 = CONTAINING_RECORD(le, batch_item, list_entry);
+        int cmp = keycmp(bi2->key, bi->key);
 
-        if (keycmp(bi2->key, bi->key) != 1) {
+        if (cmp == -1 || (cmp == 0 && bi->operation >= bi2->operation)) {
             InsertHeadList(&bi2->list_entry, &bi->list_entry);
             return STATUS_SUCCESS;
         }
index 87556c4..6cc0f45 100644 (file)
@@ -5065,7 +5065,7 @@ NTSTATUS fsctl_request(PDEVICE_OBJECT DeviceObject, PIRP* Pirp, UINT32 type) {
             Status = STATUS_INVALID_DEVICE_REQUEST;
             break;
 
-#if WIN32_WINNT >= 0x0600
+#if _WIN32_WINNT >= 0x0600
         case FSCTL_MAKE_MEDIA_COMPATIBLE:
             WARN("STUB: FSCTL_MAKE_MEDIA_COMPATIBLE\n");
             Status = STATUS_INVALID_DEVICE_REQUEST;
index ddeea66..81fbec3 100644 (file)
@@ -2093,7 +2093,6 @@ NTSTATUS read_data(_In_ device_extension* Vcb, _In_ UINT64 addr, _In_ UINT32 len
             if (!dummy_mdl) {
                 ERR("IoAllocateMdl failed\n");
                 Status = STATUS_INSUFFICIENT_RESOURCES;
-                ExFreePool(dummypage);
                 goto exit;
             }
 
@@ -2347,7 +2346,6 @@ NTSTATUS read_data(_In_ device_extension* Vcb, _In_ UINT64 addr, _In_ UINT32 len
             if (!dummy_mdl) {
                 ERR("IoAllocateMdl failed\n");
                 Status = STATUS_INSUFFICIENT_RESOURCES;
-                ExFreePool(dummypage);
                 goto exit;
             }
 
index 9e4d9ea..05f66f5 100644 (file)
@@ -923,21 +923,27 @@ void read_registry(PUNICODE_STRING regpath, BOOL refresh) {
                 ERR("LogFile was type %u, length %u\n", kvfi->Type, kvfi->DataLength);
 
                 Status = ZwDeleteValueKey(h, &us);
-                if (!NT_SUCCESS(Status)) {
+                if (!NT_SUCCESS(Status))
                     ERR("ZwDeleteValueKey returned %08x\n", Status);
-                }
+
+                log_file.Length = 0;
             }
+        } else {
+            ERR("ZwQueryValueKey returned %08\n", Status);
+            log_file.Length = 0;
         }
 
         ExFreePool(kvfi);
     } else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) {
         Status = ZwSetValueKey(h, &us, 0, REG_SZ, def_log_file, (ULONG)(wcslen(def_log_file) + 1) * sizeof(WCHAR));
 
-        if (!NT_SUCCESS(Status)) {
+        if (!NT_SUCCESS(Status))
             ERR("ZwSetValueKey returned %08x\n", Status);
-        }
+
+        log_file.Length = 0;
     } else {
         ERR("ZwQueryValueKey returned %08x\n", Status);
+        log_file.Length = 0;
     }
 
     if (log_file.Length == 0) {
index bab1241..9dd7c20 100644 (file)
@@ -2113,10 +2113,10 @@ static void scrub_raid6_stripe(device_extension* Vcb, chunk* c, scrub_context_ra
                 }
 
                 do_xor(scratch, &context->stripes[parity2].buf[(num * c->chunk_item->stripe_length) + (i * Vcb->superblock.sector_size)], len);
-            }
 
-            if (bad_stripe_num != 0)
-                galois_divpower(scratch, (UINT8)bad_stripe_num, len);
+                if (bad_stripe_num != 0)
+                    galois_divpower(scratch, (UINT8)bad_stripe_num, len);
+            }
 
             if (RtlCheckBit(&context->is_tree, bad_off1)) {
                 tree_header *th1 = NULL, *th2 = NULL;
index 8cb1f12..e0faa84 100644 (file)
@@ -3,7 +3,7 @@
 
 The following FSD are shared with: https://github.com/maharmstone/btrfs.
 
-reactos/drivers/filesystems/btrfs           # Synced to 1.0.1
+reactos/drivers/filesystems/btrfs           # Synced to 1.0.2
 reactos/dll/shellext/shellbtrfs             # Synced to 1.0.1
 reactos/sdk/lib/fslib/btrfslib              # Synced to 1.0.1