Skip to content

Commit

Permalink
Retry when attaching if there is a sharing violation.
Browse files Browse the repository at this point in the history
Sometimes drbdadm attach on booting fails when running the simple
I/O stress HLK test and tests around there, this patch might fix that.
  • Loading branch information
johannesthoma committed May 20, 2022
1 parent 7c1461d commit cd76af0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions windrbd/src/drbd_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -3164,12 +3164,19 @@ static struct _DEVICE_OBJECT *find_windows_device(UNICODE_STRING *path, struct _
struct _DEVICE_OBJECT *windows_device;
struct _FILE_OBJECT *FileObject;
NTSTATUS status;
int tries = 10;

status = IoGetDeviceObjectPointer(path, STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS, &FileObject, &windows_device);
do {
status = IoGetDeviceObjectPointer(path, STANDARD_RIGHTS_ALL | FILE_ALL_ACCESS, &FileObject, &windows_device);
if (status != STATUS_SHARING_VIOLATION)
break;
printk(KERN_WARNING, "Sharing violation on %S somebody is using it right now (tries = %d)?\n", path->Buffer, tries);
msleep(1000);
} while (--tries > 0);

if (!NT_SUCCESS(status))
{
printk(KERN_ERR "Cannot get device object for %s status: %x, does it exist?\n", path, status);
printk(KERN_ERR "Cannot get device object for %S status: %x, does it exist?\n", path->Buffer, status);
return NULL;
}
printk("IoGetDeviceObjectPointer %S succeeded, targetdev is %p\n", path->Buffer, windows_device);
Expand Down

0 comments on commit cd76af0

Please sign in to comment.