https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0e61b570e78c7490d36ae…
commit 0e61b570e78c7490d36ae2dc573e6af9c1b226d2
Author: Victor Perevertkin <victor(a)perevertkin.ru>
AuthorDate: Sun Aug 12 19:31:15 2018 +0300
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Aug 20 08:26:56 2018 +0200
[BTRFS] Applied upstream pull-requests before they are merged
---
drivers/filesystems/btrfs/btrfs.c | 69 +++++++++++++++++++++++++++++++++++++
drivers/filesystems/btrfs/dirctrl.c | 4 +++
2 files changed, 73 insertions(+)
diff --git a/drivers/filesystems/btrfs/btrfs.c b/drivers/filesystems/btrfs/btrfs.c
index c4960cd421..05db8c0e29 100644
--- a/drivers/filesystems/btrfs/btrfs.c
+++ b/drivers/filesystems/btrfs/btrfs.c
@@ -4892,6 +4892,9 @@ static NTSTATUS drv_shutdown(_In_ PDEVICE_OBJECT DeviceObject, _In_
PIRP Irp) {
NTSTATUS Status;
BOOL top_level;
device_extension* Vcb = DeviceObject->DeviceExtension;
+#ifdef __REACTOS__
+ LIST_ENTRY *Vcble, *le;
+#endif
FsRtlEnterFileSystem();
@@ -4909,6 +4912,7 @@ static NTSTATUS drv_shutdown(_In_ PDEVICE_OBJECT DeviceObject, _In_
PIRP Irp) {
shutting_down = TRUE;
KeSetEvent(&mountmgr_thread_event, 0, FALSE);
+#ifndef __REACTOS__
while (!IsListEmpty(&VcbList)) {
Vcb = CONTAINING_RECORD(VcbList.Flink, device_extension, list_entry);
@@ -4916,6 +4920,71 @@ static NTSTATUS drv_shutdown(_In_ PDEVICE_OBJECT DeviceObject, _In_
PIRP Irp) {
uninit(Vcb, TRUE);
}
+#else
+ Vcble = VcbList.Flink;
+ while (Vcble != &VcbList) {
+ Vcb = CONTAINING_RECORD(Vcble, device_extension, list_entry);
+
+ TRACE("shutting down Vcb %p\n", Vcb);
+
+ if (Vcb->balance.thread) {
+ Vcb->balance.paused = FALSE;
+ Vcb->balance.stopping = TRUE;
+ KeSetEvent(&Vcb->balance.event, 0, FALSE);
+ KeWaitForSingleObject(&Vcb->balance.finished, Executive, KernelMode,
FALSE, NULL);
+ }
+
+ if (Vcb->scrub.thread) {
+ Vcb->scrub.paused = FALSE;
+ Vcb->scrub.stopping = TRUE;
+ KeSetEvent(&Vcb->scrub.event, 0, FALSE);
+ KeWaitForSingleObject(&Vcb->scrub.finished, Executive, KernelMode,
FALSE, NULL);
+ }
+
+ if (Vcb->running_sends != 0) {
+ BOOL send_cancelled = FALSE;
+
+ ExAcquireResourceExclusiveLite(&Vcb->send_load_lock, TRUE);
+
+ le = Vcb->send_ops.Flink;
+ while (le != &Vcb->send_ops) {
+ send_info* send = CONTAINING_RECORD(le, send_info, list_entry);
+
+ if (!send->cancelling) {
+ send->cancelling = TRUE;
+ send_cancelled = TRUE;
+ send->ccb = NULL;
+ KeSetEvent(&send->cleared_event, 0, FALSE);
+ }
+
+ le = le->Flink;
+ }
+
+ ExReleaseResourceLite(&Vcb->send_load_lock);
+
+ if (send_cancelled) {
+ while (Vcb->running_sends != 0) {
+ ExAcquireResourceExclusiveLite(&Vcb->send_load_lock, TRUE);
+ ExReleaseResourceLite(&Vcb->send_load_lock);
+ }
+ }
+ }
+
+ ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
+
+ if (Vcb->need_write && !Vcb->readonly) {
+ Status = do_write(Vcb, Irp);
+
+ if (!NT_SUCCESS(Status))
+ ERR("do_write returned %08x\n", Status);
+ }
+
+ Vcb->removing = TRUE;
+
+ ExReleaseResourceLite(&Vcb->tree_lock);
+ Vcble = Vcble->Flink;
+ }
+#endif
#ifdef _DEBUG
if (comfo) {
diff --git a/drivers/filesystems/btrfs/dirctrl.c b/drivers/filesystems/btrfs/dirctrl.c
index 0ae95d636c..25c9e9cc83 100644
--- a/drivers/filesystems/btrfs/dirctrl.c
+++ b/drivers/filesystems/btrfs/dirctrl.c
@@ -675,7 +675,11 @@ static NTSTATUS query_directory(PIRP Irp) {
if (IrpSp->Parameters.QueryDirectory.FileName &&
IrpSp->Parameters.QueryDirectory.FileName->Length > 1) {
TRACE("QD filename: %.*S\n",
IrpSp->Parameters.QueryDirectory.FileName->Length / sizeof(WCHAR),
IrpSp->Parameters.QueryDirectory.FileName->Buffer);
+#ifndef __REACTOS__
if (IrpSp->Parameters.QueryDirectory.FileName->Buffer[0] != '*') {
+#else
+ if (IrpSp->Parameters.QueryDirectory.FileName->Length > sizeof(WCHAR) ||
IrpSp->Parameters.QueryDirectory.FileName->Buffer[0] != L'*') {
+#endif
specific_file = TRUE;
if
(FsRtlDoesNameContainWildCards(IrpSp->Parameters.QueryDirectory.FileName)) {