STATUS_FILE_LOCK_CONFLICT?

I need to read open files. I don’t need to worry about file data
consistency (it’s a long story). I have switched to using a mini-filter so
I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
flag.

I think it is working with respect to ignoring the share flags, but I am
still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
FltReadFile call. How do I read from a locked file?

Here is my code. This works fine on non-locked files:

status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ, &attr,
&ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
IO_IGNORE_SHARE_ACCESS_CHECK );

status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
&ReadFileObj, NULL);

status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
&bytesRead, NULL, NULL );

I think this is in the OSR FAQ :slight_smile: So anyway the answer is page reads …

“Mark Hahn” wrote in message news:xxxxx@ntfsd…
>I need to read open files. I don’t need to worry about file data
>consistency (it’s a long story). I have switched to using a mini-filter so
>I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
>flag.
>
> I think it is working with respect to ignoring the share flags, but I am
> still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
> FltReadFile call. How do I read from a locked file?
>
> Here is my code. This works fine on non-locked files:
>
> status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
> &attr, &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ |
> FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
> FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
> IO_IGNORE_SHARE_ACCESS_CHECK );
>
> status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
> &ReadFileObj, NULL);
>
> status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
> &bytesRead, NULL, NULL );
>
>

Thanks.

I think this is in the OSR FAQ :slight_smile:

I had read that FAQ and thought it didn’t apply to my mini-filter.

So anyway the answer is page reads …

I thought that wouldn’t work because creating a section would get me back
into access problems. I have just noticed though that ZwCreateSection
accepts a file object as an input parameter so now I’m hoping that if the
file object was created with FltCreateFile and IO_IGNORE_SHARE_ACCESS_CHECK
that the resulting section will be impervious to both sharing problems and
locking problems.

Wish me luck…

“Lyndon J Clarke” wrote in message
news:xxxxx@ntfsd…
>I think this is in the OSR FAQ :slight_smile: So anyway the answer is page reads …
>
> “Mark Hahn” wrote in message news:xxxxx@ntfsd…
>>I need to read open files. I don’t need to worry about file data
>>consistency (it’s a long story). I have switched to using a mini-filter
>>so I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
>>flag.
>>
>> I think it is working with respect to ignoring the share flags, but I am
>> still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
>> FltReadFile call. How do I read from a locked file?
>>
>> Here is my code. This works fine on non-locked files:
>>
>> status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
>> &attr, &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ |
>> FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE
>> | FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
>> IO_IGNORE_SHARE_ACCESS_CHECK );
>>
>> status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
>> &ReadFileObj, NULL);
>>
>> status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
>> &bytesRead, NULL, NULL );
>>
>>
>
>
>

To bypass file record locks, you will need to memory map the file. You
cannot use sequential IO without more complexity in your filter than I think
your are will to do. (E.g.: Take over mangement of file locks in your
filter. Believe me, this is strategy is not easy.)

/ted

-----Original Message-----
From: Mark Hahn [mailto:xxxxx@hahnca.com]
Sent: Wednesday, April 06, 2005 3:27 PM
To: Windows File Systems Devs Interest List
Subject: [ntfsd] STATUS_FILE_LOCK_CONFLICT?

I need to read open files. I don’t need to worry about file data
consistency (it’s a long story). I have switched to using a mini-filter so
I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
flag.

I think it is working with respect to ignoring the share flags, but I am
still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
FltReadFile call. How do I read from a locked file?

Here is my code. This works fine on non-locked files:

status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ, &attr,

&ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
IO_IGNORE_SHARE_ACCESS_CHECK );

status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
&ReadFileObj, NULL);

status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
&bytesRead, NULL, NULL );


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@livevault.com To unsubscribe
send a blank email to xxxxx@lists.osr.com

Hey, here is a wild idea, roll an IRP_MJ_READ, with relevant paging io flags
set … :slight_smile:

“Ted Hess” wrote in message news:xxxxx@ntfsd…
> To bypass file record locks, you will need to memory map the file. You
> cannot use sequential IO without more complexity in your filter than I
> think
> your are will to do. (E.g.: Take over mangement of file locks in your
> filter. Believe me, this is strategy is not easy.)
>
> /ted
>
> -----Original Message-----
> From: Mark Hahn [mailto:xxxxx@hahnca.com]
> Sent: Wednesday, April 06, 2005 3:27 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] STATUS_FILE_LOCK_CONFLICT?
>
>
> I need to read open files. I don’t need to worry about file data
> consistency (it’s a long story). I have switched to using a mini-filter
> so
> I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
> flag.
>
> I think it is working with respect to ignoring the share flags, but I am
> still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
> FltReadFile call. How do I read from a locked file?
>
> Here is my code. This works fine on non-locked files:
>
> status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
> &attr,
>
> &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
> FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
> FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
> IO_IGNORE_SHARE_ACCESS_CHECK );
>
> status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
> &ReadFileObj, NULL);
>
> status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
> &bytesRead, NULL, NULL );
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@livevault.com To
> unsubscribe
> send a blank email to xxxxx@lists.osr.com
>

Or, if you prefer an idea not quite so wild, set the
FLTFL_IO_OPERATION_PAGING flag in your FltReadFile call.

At 11:32 PM 4/6/2005 +0100, you wrote:

Hey, here is a wild idea, roll an IRP_MJ_READ, with relevant paging io flags
set … :slight_smile:

“Ted Hess” wrote in message news:xxxxx@ntfsd…
> > To bypass file record locks, you will need to memory map the file. You
> > cannot use sequential IO without more complexity in your filter than I
> > think
> > your are will to do. (E.g.: Take over mangement of file locks in your
> > filter. Believe me, this is strategy is not easy.)
> >
> > /ted
> >
> > -----Original Message-----
> > From: Mark Hahn [mailto:xxxxx@hahnca.com]
> > Sent: Wednesday, April 06, 2005 3:27 PM
> > To: Windows File Systems Devs Interest List
> > Subject: [ntfsd] STATUS_FILE_LOCK_CONFLICT?
> >
> >
> > I need to read open files. I don’t need to worry about file data
> > consistency (it’s a long story). I have switched to using a mini-filter
> > so
> > I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
> > flag.
> >
> > I think it is working with respect to ignoring the share flags, but I am
> > still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
> > FltReadFile call. How do I read from a locked file?
> >
> > Here is my code. This works fine on non-locked files:
> >
> > status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
> > &attr,
> >
> > &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
> > FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
> > FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
> > IO_IGNORE_SHARE_ACCESS_CHECK );
> >
> > status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
> > &ReadFileObj, NULL);
> >
> > status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
> > &bytesRead, NULL, NULL );
> >
> >
> >
> > —
> > Questions? First check the IFS FAQ at
> > https://www.osronline.com/article.cfm?id=17
> >
> > You are currently subscribed to ntfsd as: xxxxx@livevault.com To
> > unsubscribe
> > send a blank email to xxxxx@lists.osr.com
> >
>
>
>
>—
>Questions? First check the IFS FAQ at
>https://www.osronline.com/article.cfm?id=17
>
>You are currently subscribed to ntfsd as: xxxxx@privtek.com
>To unsubscribe send a blank email to xxxxx@lists.osr.com

You need to deal with cache consistency problem if you roll your own PadingIO
read IRP. When handling such IRP file system driver assumes that the page is
not in the cache and reads data directly from disk without flashing cache
first. If the data you are reading is in the cache and dirty you end up
reading stale data.

Alexei.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Lyndon J Clarke
Sent: Wednesday, April 06, 2005 3:32 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] STATUS_FILE_LOCK_CONFLICT?

Hey, here is a wild idea, roll an IRP_MJ_READ, with relevant paging io flags
set … :slight_smile:

“Ted Hess” wrote in message news:xxxxx@ntfsd…
> To bypass file record locks, you will need to memory map the file. You
> cannot use sequential IO without more complexity in your filter than I
> think
> your are will to do. (E.g.: Take over mangement of file locks in your
> filter. Believe me, this is strategy is not easy.)
>
> /ted
>
> -----Original Message-----
> From: Mark Hahn [mailto:xxxxx@hahnca.com]
> Sent: Wednesday, April 06, 2005 3:27 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] STATUS_FILE_LOCK_CONFLICT?
>
>
> I need to read open files. I don’t need to worry about file data
> consistency (it’s a long story). I have switched to using a mini-filter
> so
> I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
> flag.
>
> I think it is working with respect to ignoring the share flags, but I am
> still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
> FltReadFile call. How do I read from a locked file?
>
> Here is my code. This works fine on non-locked files:
>
> status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
> &attr,
>
> &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
> FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
> FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
> IO_IGNORE_SHARE_ACCESS_CHECK );
>
> status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
> &ReadFileObj, NULL);
>
> status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
> &bytesRead, NULL, NULL );
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@livevault.com To
> unsubscribe
> send a blank email to xxxxx@lists.osr.com
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@vmware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

It turns out that for my needs, consistency of the cache is no problem.

So am I to understand that if I turn on the paging_io bit in a normal read,
ntfs will blindly do a read directly from the disk without causing any side
effects? That would be simple and wouldn’t really hurt perfromance much.

“Alexei Jelvis” wrote in message news:xxxxx@ntfsd…
You need to deal with cache consistency problem if you roll your own
PadingIO
read IRP. When handling such IRP file system driver assumes that the page is
not in the cache and reads data directly from disk without flashing cache
first. If the data you are reading is in the cache and dirty you end up
reading stale data.

Alexei.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Lyndon J Clarke
Sent: Wednesday, April 06, 2005 3:32 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] STATUS_FILE_LOCK_CONFLICT?

Hey, here is a wild idea, roll an IRP_MJ_READ, with relevant paging io flags
set … :slight_smile:

“Ted Hess” wrote in message news:xxxxx@ntfsd…
> To bypass file record locks, you will need to memory map the file. You
> cannot use sequential IO without more complexity in your filter than I
> think
> your are will to do. (E.g.: Take over mangement of file locks in your
> filter. Believe me, this is strategy is not easy.)
>
> /ted
>
> -----Original Message-----
> From: Mark Hahn [mailto:xxxxx@hahnca.com]
> Sent: Wednesday, April 06, 2005 3:27 PM
> To: Windows File Systems Devs Interest List
> Subject: [ntfsd] STATUS_FILE_LOCK_CONFLICT?
>
>
> I need to read open files. I don’t need to worry about file data
> consistency (it’s a long story). I have switched to using a mini-filter
> so
> I can do this using FltCreateFile with the IO_IGNORE_SHARE_ACCESS_CHECK
> flag.
>
> I think it is working with respect to ignoring the share flags, but I am
> still getting a STATUS_FILE_LOCK_CONFLICT status returned from my
> FltReadFile call. How do I read from a locked file?
>
> Here is my code. This works fine on non-locked files:
>
> status = FltCreateFile( gFilter, Instance, &ReadHandle, GENERIC_READ,
> &attr,
>
> &ioStatus, 0, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE |
> FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE |
> FILE_SYNCHRONOUS_IO_NONALERT | FILE_SEQUENTIAL_ONLY, NULL, 0,
> IO_IGNORE_SHARE_ACCESS_CHECK );
>
> status = ObReferenceObjectByHandle( ReadHandle, 0, NULL, KernelMode,
> &ReadFileObj, NULL);
>
> status = FltReadFile( Instance, ReadFileObj, NULL, dataBufLen, data, 0,
> &bytesRead, NULL, NULL );
>
>
>
> —
> Questions? First check the IFS FAQ at
> https://www.osronline.com/article.cfm?id=17
>
> You are currently subscribed to ntfsd as: xxxxx@livevault.com To
> unsubscribe
> send a blank email to xxxxx@lists.osr.com
>


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@vmware.com
To unsubscribe send a blank email to xxxxx@lists.osr.com