[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

sync writes - was Re: how to counteract slowdown



On Tuesday November 13, akpm zip com au wrote:
> > 
> > After the fsync call, where is the content of buffer? Is it:
> > (a) in the journal only
> > (b) in the journal and on disk
> > 
> > This is the one bit that confuses me from your answer.
> 
> After the fsync that data is in the journal, and it is
> in memory.  Once the in-memory copy has been written out
> to the main filesystem, its journal space can be recycled.
>  

I thought I would double check this.  So I watched the number of SCSI
operations on my scsi drives while doing various sorts of sync writes
to variously mounted filesystems.
In each case, the filesystem was on one drive (sdc) and the journal
was on a different drive (sdd).

I include the output and the script that generated it below.

As the script shows, each test involved writing the first 40000 bytes
of a file 100 times. For "fsync" I do an fsync() after each write. For
"osync" I open with O_SYNC.  I did this for ext2 and ext3 with various
mount options.

Some results are surprising.  See the annotation on the output.
This is with 2.4.14 plus the corresponding ext3 patch.

The first column of numbers is scsi operations to the filesystem
The second column is scsi operations to the journal

NeilBrown

---------output-----------------annotations----------
ext2 sync
     async         0    0	sync mount option ignored!
     fsync       200    0
     osync       101    0
ext2 async
     async         0    0
     fsync       200    0
     osync       101    0
ext3 sync,data=journal
     async         0  200       sync mount option now honoured!
     fsync         0  300
     osync         0    2       but O_SYNC negates effect of -o sync!!
ext3 async,data=journal
     async         0    0
     fsync         0  200
     osync         0    2       O_SYNC is still ignored
ext3 sync,data=ordered
     async       100  200
     fsync       100  300	
     osync         0    0
ext3 async,data=ordered
     async         0    0
     fsync       100  200
     osync         1    2
ext3 sync,data=writeback
     async         0  200
     fsync         0  300        The data isn't being synced??
     osync       100    2        Now O_SYNC is being honoured
ext3 async,data=writeback
     async         0    0
     fsync         0  200        Again, the data isn't being synced.
     osync       100    2
------------------script----------------------

#
# Test actual number of scsi IOs with various flavours of sync writes.
#
dev=/dev/sdc
mp=/mnt/1
tmpdir=/tmp

cat > $tmpdir/async.c <<END
#include <sys/file.h>
main()
{
char buffer[40000];
int file = open("blah", O_WRONLY);
write(file, buffer, 40000);
}
END
cat > $tmpdir/fsync.c <<END
#include <sys/file.h>
main()
{
char buffer[40000];
int file = open("blah", O_WRONLY);
write(file, buffer, 40000);
fsync(file);
}
END
cat > $tmpdir/osync.c <<END
#include <sys/file.h>
main()
{
char buffer[40000];
int file = open("blah", O_WRONLY|O_SYNC);
write(file, buffer, 40000);
}
END

( cd $tmpdir 
  for i in async fsync osync
  do cc -o $i $i.c
  done
)

procfile=/proc/scsi/aic7xxx/1
awkcmd='$0 ~ /Commands Queued/ { print $3 ; if (++n == 2) exit;}' 

for mount in "ext2 sync" "ext2 async" \
	     "ext3 sync,data=journal" "ext3 async,data=journal" \
	     "ext3 sync,data=ordered" "ext3 async,data=ordered" \
	     "ext3 sync,data=writeback" "ext3 async,data=writeback"
do
  set $mount
  echo $mount
  mount -t $1 -o $2 $dev $mp
  (
    cd $mp
    > blah ; $tmpdir/fsync  # create file
    for write in async fsync osync
    do
     before=`awk "$awkcmd" $procfile`
     for c in 0 1 2 3 4 5 6 7 8 9
       do for d in 0 1 2 3 4 5 6 7 8 9
          do
             $tmpdir/$write
          done
       done
      after=`awk "$awkcmd" $procfile`
      echo -n "     $write      "
      echo $before $after | awk '{printf "%4d %4d\n", $3-$1, $4-$2}'
     done
   )
   umount $mp
done





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]