Re: submit_bio() flush to disk immediately
On Tue, Aug 6, 2013 at 1:20 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Hi,
On Tue, Aug 6, 2013 at 1:15 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
How are you reading and writing? What is your test utility? 'dd' has an option to specify iflag/oflag=direct, which would bypass buffer cache. But anyways this problem should not happen even if data is written to cache, you should read it back from cache.
I am using cat command. Its a block that belongs to a file and I am directly writing to the block. On reading the file I am getting stale data.
Most likely you are getting stale data from filesystem page-cache. Please don't use cat, use dd with iflag/oflag=direct.
Regards.
-Rajat
Hi, On Tue, Aug 6, 2013 at 1:23 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
Most likely you are getting stale data from filesystem page-cache. Please don't use cat, use dd with iflag/oflag=direct.
I have no control over how users will read it :( Regards
On Tue, Aug 6, 2013 at 1:27 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Hi,
On Tue, Aug 6, 2013 at 1:23 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
Most likely you are getting stale data from filesystem page-cache. Please don't use cat, use dd with iflag/oflag=direct.
I have no control over how users will read it :(
Why do you want to modify blocks of a file, without filesystem knowing about it? What are you trying to achieve here?
Regards
Hi,
Why do you want to modify blocks of a file, without filesystem knowing about it? What are you trying to achieve here?
Its some shutdown - restart logic that I am working on :) I am sure doing it is not that complicated. I tried setting the page flags and marking it dirty. Even doing a sync doesnt work. Regards.
On Tue, Aug 6, 2013 at 2:23 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Hi,
Why do you want to modify blocks of a file, without filesystem knowing about it? What are you trying to achieve here?
Its some shutdown - restart logic that I am working on :)
I am sure doing it is not that complicated. I tried setting the page flags and marking it dirty. Even doing a sync doesnt work.
sync does not purge page-cache. I think you need to place some filesystem hooks to purge-cache and make sure nobody else reads the file while you update the block, because it will again populate filesystem page-cache. Purging cache might be tricky.
Regards.
Hi, On Tue, Aug 6, 2013 at 4:14 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
sync does not purge page-cache. I think you need to place some filesystem hooks to purge-cache and make sure nobody else reads the file while you update the block, because it will again populate filesystem page-cache. Purging cache might be tricky.
This does the trick on the user side but for once only. I want to do something similar just after the bio write within the module itself. echo 1 > /proc/sys/vm/drop_caches
Hi,
This does the trick on the user side but for once only. I want to do something similar just after the bio write within the module itself.
echo 1 > /proc/sys/vm/drop_caches
Also I dont want to flush the entire cache but just for that block if possible. Regards.
On Tue, Aug 6, 2013 at 4:20 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Hi,
On Tue, Aug 6, 2013 at 4:14 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
sync does not purge page-cache. I think you need to place some filesystem hooks to purge-cache and make sure nobody else reads the file while you update the block, because it will again populate filesystem page-cache. Purging cache might be tricky.
This does the trick on the user side but for once only. I want to do something similar just after the bio write within the module itself.
echo 1 > /proc/sys/vm/drop_caches
so has penalty on all files and hence applications. Are you okay with it? You need it just for one file. purge cache of just one file from your module. Also there could be open file mappings, you might have to wait for them to close first.
Hi, On Tue, Aug 6, 2013 at 4:33 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
so has penalty on all files and hence applications. Are you okay with it? You need it just for one file. purge cache of just one file from your module. Also there could be open file mappings, you might have to wait for them to close first.
Its ok, the writes happens early on before the shell is started so there are no applications using the file. I stumbled upon invalidate_inode_pages() - testing it right now. Regards.
On Tue, Aug 6, 2013 at 4:37 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Hi,
On Tue, Aug 6, 2013 at 4:33 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
so has penalty on all files and hence applications. Are you okay with it? You need it just for one file. purge cache of just one file from your module. Also there could be open file mappings, you might have to wait for them to close first.
Its ok, the writes happens early on before the shell is started so there are no applications using the file.
I stumbled upon invalidate_inode_pages() - testing it right now.
At the same time, following proc interface, I stumbled upon invalidate_mapping_pages() to purge cache of desired inode. Try this one if invalidate_inode_pages() does not work.
Regards.
Hi, On Tue, Aug 6, 2013 at 4:40 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
I stumbled upon invalidate_inode_pages() - testing it right now.
At the same time, following proc interface, I stumbled upon invalidate_mapping_pages() to purge cache of desired inode. Try this one if invalidate_inode_pages() does not work.
Tried invalidate_inode_pages() and it works. Also, invalidate_inode_pages() internally calls invalidate_inode_pages() so both should work :) Problem solved. Thanks. Regards.
Hi, On Tue, Aug 6, 2013 at 4:59 PM, Prashant Shah <pshah.mumbai@gmail.com> wrote:
Tried invalidate_inode_pages() and it works. Also, invalidate_inode_pages() internally calls invalidate_inode_pages() so both should work :)
Sorry I mean invalidate_mapping_pages() internally calls invalidate_inode_pages() so both should work :)
participants (2)
-
Prashant Shah -
Rajat Sharma