LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 10-17-2006, 03:34 AM   #1
Bill Door
LQ Newbie
 
Registered: Oct 2006
Location: Russia
Distribution: Slackware, Mandrake
Posts: 2

Rep: Reputation: 0
How switch off caching in file system?


I use different distributives (Mandrake, Slackware, ASP. Kernel version is 2.4.??) and mount my file system (e2fs) with sync key. I create a small file (512 bytes< filesize< blocksize), look its i-node and the number of its block. Then I use dd, bpe, lde to look my file's data. OK! I delete the file (rm myfile) and create a new one. The new file occupies old file's block. cat newfile shows new data but dd, bpe, lde show old file's data even 1 hour later (sync and mount with remount key don't change anything)! Why? I disconnect (plug off) my computer from electric power, restart... Wow! dd, bpe, lde show new (real) data! I think caching is guilty of this situation. Can I turn off (temporarily) caching in my file system?
PS. I did't have this trouble with old versions of kernel (2.2.??)

Last edited by Bill Door; 10-17-2006 at 03:39 AM.
 
Old 10-17-2006, 10:25 AM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
A few suggestions:

Did you try actually remounting ro and then remounting (again) rw (or if you are able to, unmount completely and then mount)?

I can't tell from your comment, did you try using the sync(1) command?

Also, can you provide in detail how you did what you did, so it may be easier to reproduce.
 
Old 10-22-2006, 11:19 PM   #3
Bill Door
LQ Newbie
 
Registered: Oct 2006
Location: Russia
Distribution: Slackware, Mandrake
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks!
I did'n remount the filesystem because it was mounted as /
I used only mount with 'remount' option.
The sequence of my actions:
#fillfile 900 a //my program to create a file with a homogeneous content (900 characters 'a')
#ls -li a //get the file's i-node (INODENUMBER)
#lde -i INODENUMBER /dev/hda3 //get the file's data block (DATABLOCK)
#lde -b DATABLOCK /dev/hda3|less //ok! data are present
#rm a //delete the file
#fillfile 900 b //create a file (900 characters 'b')
#sync //from 3 to 5 attempts of synchronization
... //or remounting
#sync
#ls -li b //the same i-node (usually)
#lde -i INODENUMBER /dev/hda3 //the same data block (usually)
#lde -b DATABLOCK /dev/hda3|less //OLD data are present! bpe, dd show the same too
#cat b //I see NEW data!!!
lde, bpe, dd ... //OLD data again

fillfile is a simple program. It uses open (fname, O_WRONLY|O_CREAT|O_TRUNC|O_SYNC) to create and write(...) to write data. Other version of fillfile uses fopen, setvbuf(fs,NULL,_IONBF,0), fwrite, fflush, sync. But there are no differences between the end results.

Now I have solved the problem. I use #hdparm -f /dev/hda3 instead of sequence of sync!

Last edited by Bill Door; 10-23-2006 at 12:33 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
when does linux switch from realmode file system to protectedmode file system sitthar Linux - General 3 04-08-2006 08:05 AM
Turning off file caching jdt Linux - General 0 11-12-2003 11:11 PM
DNS Caching file? WeNdeL Linux - Networking 2 01-14-2003 01:08 PM
caching samba file trees?? acid_kewpie Linux - Networking 0 11-04-2001 04:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 09:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration