LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-19-2010, 01:11 PM   #1
mvorlov
LQ Newbie
 
Registered: Nov 2005
Posts: 11

Rep: Reputation: 0
Weird filesystem behavior, please help.


I am trying to figure out a totally odd behavior of the ext3 filesystem mounted in Ubuntu 9.10

There is a Korn Shell script, part of which does the following in the loop:

while ((1)); do

mv dir1/file dir2;
if [[ ! -r dir2/file ]]; then
echo "ERROR"
ls -l dir1/* dir2/*
exit 1
elif
echo "OK"
fi

done


Given that dir2/file always exists and that I do not move it asynchronously with "&", my script should never hit the "ERROR" statement. The odd thing is that it does, and quite randomly (no pattern at all). However when it does hit the ERROR case, ls -l prints that file is in dir2 and it is readable! I tried using "-e" instead of "-r" test - no luck.

I never seen anything like this in 10 years of my programming experience. Same script worked fine on Fedora 11, and yet it wouldn't work on Ubuntu.

Any ideas how to solve this would be greatly appreciated.
 
Old 04-19-2010, 01:17 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It may be its telling you its done when it schedules the write and doing the error check before it has actually synced to disk (i.e. it's still in the buffer).

Try adding a "sleep 1" between the mv line and the if line so it pauses a second before checking for the file's existence.
 
Old 04-19-2010, 01:57 PM   #3
mvorlov
LQ Newbie
 
Registered: Nov 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MensaWater View Post
It may be its telling you its done when it schedules the write and doing the error check before it has actually synced to disk (i.e. it's still in the buffer).

Try adding a "sleep 1" between the mv line and the if line so it pauses a second before checking for the file's existence.
I could use something like this. Though I'd still like to get to the core of the problem rather then sticking "sleep 1" between every other line to handle potentially related cases.
 
Old 04-19-2010, 03:29 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
The core of the problem may be the difference in hardware for you Fedora and Ubuntu systems causing slower writes on the latter. (e.g. does one have SCSI and the other ATA or a USB external drive?)

Or it could be an I/O workload - if you had one that was doing heavy reads/writes of disk for some reason (e.g. a database) and the other wasn't then I/O might be blocked.

The thing is ext3 is a "cooked" filesystem so any write you do is going into a buffer before it is actually on disk. The point I was trying to make is that your script may be getting to the read line before the data is actually flushed to disk from the buffer. That would explain the randomness you mentioned.
 
1 members found this post helpful.
Old 04-19-2010, 04:04 PM   #5
mvorlov
LQ Newbie
 
Registered: Nov 2005
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by MensaWater View Post
The core of the problem may be the difference in hardware for you Fedora and Ubuntu systems causing slower writes on the latter. (e.g. does one have SCSI and the other ATA or a USB external drive?)

Or it could be an I/O workload - if you had one that was doing heavy reads/writes of disk for some reason (e.g. a database) and the other wasn't then I/O might be blocked.

The thing is ext3 is a "cooked" filesystem so any write you do is going into a buffer before it is actually on disk. The point I was trying to make is that your script may be getting to the read line before the data is actually flushed to disk from the buffer. That would explain the randomness you mentioned.
This makes sense, although I am using the same hardware except video card.
Do you know if ext4 is any better in this regard?
Thanks for taking your time to explain!
 
Old 04-20-2010, 07:12 AM   #6
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
It's not really a matter of which filesystem you use - they're all buffered (unless you use something like OCFS2 which is designed for Oracle Databases and does direct I/O instead). In general buffering is a good thing as it allows you to complete most tasks more quickly by reporting the write when it gets to the buffer in memory (very fast) rather than waiting until it flushes the buffer to disk (slow comparatively due to the need to go from electronic speed to mechanical speed). For most purposes this is a desirable behavior.

ext4 actually has a delayed commit built into it for performance reasons so it wouldn't be "better" in the sense you meant - in fact there is a chance of data loss if you lose power to the system before the write. However, there are other reasons why people think ext4 is "better" that deal with performance and scalability.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Weird Yast2 Behavior sandman_max Linux - Newbie 0 11-19-2009 09:33 AM
Weird Console Behavior georgejc Slackware 9 07-09-2006 11:10 AM
Weird behavior!! surfer41 Linux - Networking 1 04-25-2006 07:53 AM
Weird behavior Bassy Linux - Software 2 10-20-2005 01:32 PM
iptables ... weird behavior, please help! matrixcubed Linux - Networking 0 05-09-2005 09:44 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:23 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