[BTRFS][UBTRFS][SHELLBTRFS] Upgrade to 1.7.6 (#4417)
[reactos.git] / drivers / filesystems / btrfs / write.c
index 0d63ac0..f466159 100644 (file)
@@ -3476,7 +3476,7 @@ NTSTATUS extend_file(fcb* fcb, file_ref* fileref, uint64_t end, bool prealloc, P
 
                         Status = insert_prealloc_extent(fcb, oldalloc, newalloc - oldalloc, rollback);
 
-                        if (!NT_SUCCESS(Status)) {
+                        if (!NT_SUCCESS(Status) && Status != STATUS_DISK_FULL) {
                             ERR("insert_prealloc_extent returned %08lx\n", Status);
                             return Status;
                         }
@@ -3503,7 +3503,7 @@ NTSTATUS extend_file(fcb* fcb, file_ref* fileref, uint64_t end, bool prealloc, P
                 if (prealloc) {
                     Status = insert_prealloc_extent(fcb, 0, newalloc, rollback);
 
-                    if (!NT_SUCCESS(Status)) {
+                    if (!NT_SUCCESS(Status) && Status != STATUS_DISK_FULL) {
                         ERR("insert_prealloc_extent returned %08lx\n", Status);
                         return Status;
                     }
@@ -4285,16 +4285,19 @@ NTSTATUS write_file2(device_extension* Vcb, PIRP Irp, LARGE_INTEGER offset, void
                 Status = Irp->IoStatus.Status;
                 goto end;
             } else {
+                /* We have to wait in CcCopyWrite - if we return STATUS_PENDING and add this to the work queue,
+                 * it can result in CcFlushCache being called before the job has run. See ifstest ReadWriteTest. */
+
                 if (fCcCopyWriteEx) {
-                    TRACE("CcCopyWriteEx(%p, %I64x, %lx, %u, %p, %p)\n", FileObject, off64, *length, wait, buf, Irp->Tail.Overlay.Thread);
-                    if (!fCcCopyWriteEx(FileObject, &offset, *length, wait, buf, Irp->Tail.Overlay.Thread)) {
+                    TRACE("CcCopyWriteEx(%p, %I64x, %lx, %u, %p, %p)\n", FileObject, off64, *length, true, buf, Irp->Tail.Overlay.Thread);
+                    if (!fCcCopyWriteEx(FileObject, &offset, *length, true, buf, Irp->Tail.Overlay.Thread)) {
                         Status = STATUS_PENDING;
                         goto end;
                     }
                     TRACE("CcCopyWriteEx finished\n");
                 } else {
-                    TRACE("CcCopyWrite(%p, %I64x, %lx, %u, %p)\n", FileObject, off64, *length, wait, buf);
-                    if (!CcCopyWrite(FileObject, &offset, *length, wait, buf)) {
+                    TRACE("CcCopyWrite(%p, %I64x, %lx, %u, %p)\n", FileObject, off64, *length, true, buf);
+                    if (!CcCopyWrite(FileObject, &offset, *length, true, buf)) {
                         Status = STATUS_PENDING;
                         goto end;
                     }