[driver] using InterlockedIncrement64 for xid

This commit is contained in:
Olga Kornievskaia 2011-12-21 17:19:38 -05:00
parent 4511dec4b7
commit 9efa410e5a
6 changed files with 16 additions and 26 deletions

View file

@ -128,7 +128,7 @@ static unsigned int WINAPI thread_main(void *args)
status = upcall_handle(&upcall); status = upcall_handle(&upcall);
write_downcall: write_downcall:
dprintf(1, "writing downcall: xid=%d opcode=%s status=%d " dprintf(1, "writing downcall: xid=%lld opcode=%s status=%d "
"get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode), "get_last_error=%d\n", upcall.xid, opcode2string(upcall.opcode),
upcall.status, upcall.last_error); upcall.status, upcall.last_error);
@ -138,7 +138,7 @@ write_downcall:
status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE, status = DeviceIoControl(pipe, IOCTL_NFS41_WRITE,
inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL); inbuf, inbuf_len, NULL, 0, (LPDWORD)&outbuf_len, NULL);
if (!status) { if (!status) {
eprintf("IOCTL_NFS41_WRITE failed with %d xid=%d opcode=%s\n", eprintf("IOCTL_NFS41_WRITE failed with %d xid=%lld opcode=%s\n",
GetLastError(), upcall.xid, opcode2string(upcall.opcode)); GetLastError(), upcall.xid, opcode2string(upcall.opcode));
upcall_cancel(&upcall); upcall_cancel(&upcall);
} }

View file

@ -95,7 +95,7 @@ int upcall_parse(
/* parse common elements */ /* parse common elements */
status = safe_read(&buffer, &length, &version, sizeof(uint32_t)); status = safe_read(&buffer, &length, &version, sizeof(uint32_t));
if (status) goto out; if (status) goto out;
status = safe_read(&buffer, &length, &upcall->xid, sizeof(uint32_t)); status = safe_read(&buffer, &length, &upcall->xid, sizeof(uint64_t));
if (status) goto out; if (status) goto out;
status = safe_read(&buffer, &length, &upcall->opcode, sizeof(uint32_t)); status = safe_read(&buffer, &length, &upcall->opcode, sizeof(uint32_t));
if (status) goto out; if (status) goto out;

View file

@ -184,7 +184,7 @@ typedef union __upcall_args {
} upcall_args; } upcall_args;
typedef struct __nfs41_upcall { typedef struct __nfs41_upcall {
uint32_t xid; uint64_t xid;
uint32_t opcode; uint32_t opcode;
uint32_t status; uint32_t status;
uint32_t last_error; uint32_t last_error;

View file

@ -666,12 +666,12 @@ void print_open_error(int on, int status)
} }
void print_wait_status(int on, const char *prefix, NTSTATUS status, void print_wait_status(int on, const char *prefix, NTSTATUS status,
const char *opcode, PVOID entry, int xid) const char *opcode, PVOID entry, LONGLONG xid)
{ {
switch (status) { switch (status) {
case STATUS_SUCCESS: case STATUS_SUCCESS:
if (opcode) if (opcode)
DbgP("%s Got a wakeup call, finishing %s entry=%p xid=%d\n", DbgP("%s Got a wakeup call, finishing %s entry=%p xid=%lld\n",
prefix, opcode, entry, xid); prefix, opcode, entry, xid);
else else
DbgP("%s Got a wakeup call\n", prefix); DbgP("%s Got a wakeup call\n", prefix);

View file

@ -56,7 +56,7 @@ void print_caching_level(int on, ULONG flag);
const char *opcode2string(int opcode); const char *opcode2string(int opcode);
void print_open_error(int on, int status); void print_open_error(int on, int status);
void print_wait_status(int on, const char *str, NTSTATUS status, void print_wait_status(int on, const char *str, NTSTATUS status,
const char *opcode, PVOID entry, int xid); const char *opcode, PVOID entry, LONGLONG xid);
void print_acl_args(SECURITY_INFORMATION info); void print_acl_args(SECURITY_INFORMATION info);
#define DbgEn() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \ #define DbgEn() DbgPrintEx(DPFLTR_IHVNETWORK_ID, DPFLTR_ERROR_LEVEL, \

View file

@ -70,7 +70,7 @@ FAST_MUTEX upcallLock, downcallLock;
FAST_MUTEX xidLock; FAST_MUTEX xidLock;
FAST_MUTEX openOwnerLock; FAST_MUTEX openOwnerLock;
ULONG xid = 0; LONGLONG xid = 0;
ULONG open_owner_id = 1; ULONG open_owner_id = 1;
#define DECLARE_CONST_ANSI_STRING(_var, _string) \ #define DECLARE_CONST_ANSI_STRING(_var, _string) \
@ -122,7 +122,7 @@ typedef enum _nfs41_updowncall_state {
typedef struct _updowncall_entry { typedef struct _updowncall_entry {
DWORD version; DWORD version;
DWORD xid; LONGLONG xid;
DWORD opcode; DWORD opcode;
NTSTATUS status; NTSTATUS status;
nfs41_updowncall_state state; nfs41_updowncall_state state;
@ -420,15 +420,6 @@ nfs41_start_driver_state nfs41_start_state = NFS41_START_DRIVER_STARTABLE;
NTSTATUS map_readwrite_errors(DWORD status); NTSTATUS map_readwrite_errors(DWORD status);
ULONG get_next_xid()
{
ULONG x;
ExAcquireFastMutex(&xidLock);
x = ++xid;
ExReleaseFastMutex(&xidLock);
return x;
}
ULONG get_next_open_owner() ULONG get_next_open_owner()
{ {
ULONG x; ULONG x;
@ -525,7 +516,7 @@ NTSTATUS marshal_nfs41_header(
RtlCopyMemory(tmp, &entry->open_state, sizeof(HANDLE)); RtlCopyMemory(tmp, &entry->open_state, sizeof(HANDLE));
tmp += sizeof(HANDLE); tmp += sizeof(HANDLE);
DbgP("[upcall] entry=%p xid=%d opcode=%d version=%d session=0x%x " DbgP("[upcall] entry=%p xid=%lld opcode=%d version=%d session=0x%x "
"open_state=0x%x\n", entry, entry->xid, entry->opcode, entry->version, "open_state=0x%x\n", entry, entry->xid, entry->opcode, entry->version,
entry->session, entry->open_state); entry->session, entry->open_state);
out: out:
@ -1348,7 +1339,7 @@ NTSTATUS nfs41_UpcallCreate(
} }
RtlZeroMemory(entry, sizeof(nfs41_updowncall_entry)); RtlZeroMemory(entry, sizeof(nfs41_updowncall_entry));
entry->xid = get_next_xid(); entry->xid = InterlockedIncrement64(&xid);
entry->opcode = opcode; entry->opcode = opcode;
entry->state = NFS41_WAITING_FOR_UPCALL; entry->state = NFS41_WAITING_FOR_UPCALL;
entry->session = session; entry->session = session;
@ -1391,7 +1382,7 @@ NTSTATUS nfs41_UpcallWaitForReply(
nfs41_AddEntry(upcallLock, upcall, entry); nfs41_AddEntry(upcallLock, upcall, entry);
KeSetEvent(&upcallEvent, 0, FALSE); KeSetEvent(&upcallEvent, 0, FALSE);
DbgP("@@@ Creating %s upcall entry=%p xid=%d\n", opstring, entry, entry->xid); DbgP("@@@ Creating %s upcall entry=%p xid=%lld\n", opstring, entry, entry->xid);
if (!entry->async_op) { if (!entry->async_op) {
/* 02/03/2011 AGLO: it is not clear what the "right" waiting design /* 02/03/2011 AGLO: it is not clear what the "right" waiting design
* should be. Having non-interruptable waiting seems to be the right * should be. Having non-interruptable waiting seems to be the right
@ -1428,12 +1419,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
default: default:
ExAcquireFastMutex(&entry->lock); ExAcquireFastMutex(&entry->lock);
if (entry->state == NFS41_DONE_PROCESSING) { if (entry->state == NFS41_DONE_PROCESSING) {
DbgP("[downcall] finish processing %s entry=%p xid=%d\n", DbgP("[downcall] finish processing %s entry=%p xid=%lld\n",
opcode2string(entry->opcode), entry, entry->xid); opcode2string(entry->opcode), entry, entry->xid);
ExReleaseFastMutex(&entry->lock); ExReleaseFastMutex(&entry->lock);
break; break;
} }
DbgP("[upcall] abandoning %s entry=%p xid=%d\n", DbgP("[upcall] abandoning %s entry=%p xid=%lld\n",
opcode2string(entry->opcode), entry, entry->xid); opcode2string(entry->opcode), entry, entry->xid);
entry->state = NFS41_NOT_WAITING; entry->state = NFS41_NOT_WAITING;
ExReleaseFastMutex(&entry->lock); ExReleaseFastMutex(&entry->lock);
@ -1520,7 +1511,7 @@ NTSTATUS nfs41_downcall(
buf += sizeof(tmp->status); buf += sizeof(tmp->status);
RtlCopyMemory(&tmp->errno, buf, sizeof(tmp->errno)); RtlCopyMemory(&tmp->errno, buf, sizeof(tmp->errno));
buf += sizeof(tmp->errno); buf += sizeof(tmp->errno);
DbgP("[downcall] xid=%d opcode=%d status=%d errno=%d\n", tmp->xid, DbgP("[downcall] xid=%lld opcode=%d status=%d errno=%d\n", tmp->xid,
tmp->opcode, tmp->status, tmp->errno); tmp->opcode, tmp->status, tmp->errno);
ExAcquireFastMutex(&downcallLock); ExAcquireFastMutex(&downcallLock);
@ -1529,7 +1520,6 @@ NTSTATUS nfs41_downcall(
while (pEntry != NULL) { while (pEntry != NULL) {
cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry, cur = (nfs41_updowncall_entry *)CONTAINING_RECORD(pEntry,
nfs41_updowncall_entry, next); nfs41_updowncall_entry, next);
DbgP("nfs41_downcall: comparing %d %d\n", cur->xid, tmp->xid);
if (cur->xid == tmp->xid) { if (cur->xid == tmp->xid) {
found = 1; found = 1;
break; break;
@ -1543,7 +1533,7 @@ NTSTATUS nfs41_downcall(
ExReleaseFastMutex(&downcallLock); ExReleaseFastMutex(&downcallLock);
SeStopImpersonatingClient(); SeStopImpersonatingClient();
if (!found) { if (!found) {
print_error("Didn't find xid=%d entry\n", tmp->xid); print_error("Didn't find xid=%lld entry\n", tmp->xid);
goto out_free; goto out_free;
} }