Problem about making kernel dll shared data segment safe

I’m writing a kernel-mode dll hash table. And I want to use data_segment to share data between two filter drivers.
There is a file system filter and a volume filter. When the file system driver get an important irp, it will put the
irp pointer into the shared hash table. The volume filter will check if the irp it filtered is in the hash table, if
it is, volume filter will delete it from table.

To keep it safe, I used a spin_lock like below:

#pragma data_seg("SharedHashSet")
    HashSet set;
    KSPIN_LOCK PLock;
#pragma data_seg

And the operation method for hash table is like this:

//Node
typedef struct _ENTRY {
PIRP key;
struct _ENTRY* next;
}Entry , *PEntry;

//Node array
typedef struct _HASHSET {
PEntry bucket[BUCKETCAPICITY];
}HashSet, *PHashSet;

void insertValue(PIRP key)
{
    KIRQL irql;
    KeAcquireSpinLock(&PLock, &irql);

    PEntry mEntry;
    INT i = getLocation(key);
    PEntry entry = set.bucket[i];

    //head insert
    if (entry == NULL) {
        mEntry = newEntry(key, NULL);
    }
    else {
        mEntry = newEntry(key, entry);
    }
    set.bucket[i] = mEntry;

    KeReleaseSpinLock(&PLock, irql);

}

Now two filter drivers share a table and a lock. But, I find that volume filter may not find the irp
which file system filter already put into the table sometimes.

Could somebody tell me what is the problem?

Could somebody tell me what is the problem?

Hmmmm… You have a bug in your code??

Just guessin’

Peter

@“Peter_Viscarola_(OSR)” said:

Could somebody tell me what is the problem?

Hmmmm… You have a bug in your code??

Just guessin’

Peter

I’ve solved this problem. It’s not the problem of my code, but I didn’t realize that
some Irp will complete in file system because they are written in page buffer and a new
Irp will be created later. That’s the reason why I can not catch the Irp that I have put
int the table.