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 07-31-2018, 08:20 AM   #1
wonkite
LQ Newbie
 
Registered: May 2018
Posts: 3

Rep: Reputation: Disabled
fsync() in the latest kernel (4.15.x ) Broken ????


So this is a simple one, if I run the following code on Ubuntu 18.04 (4.15.0-29-generic ) and against Ubuntu 16.04 ( 4.4.0-87-generic) I get two different results ; The question is why? It seems that fsync may be broken in the latest kernel and may well be broken as early as 4.10 ? This has huge implications around performance sensitive applications like mysql. (Yes I know it can be turned off in mysql but thats only any good if you like your databases corrupted).


4.4.0-87-generic - # time ./fsync
real 0m7.537s <-----
user 0m0.000s
sys 0m1.060s <-----


4.15.0-29-generic - # time ./fsync
real 1m38.299s <-----
user 0m0.013s
sys 0m0.893s <-----


Source stolen from else where. ;-)

#include <stdio.h>
#include <fcntl.h>
#include <time.h>
#include <unistd.h>


void withSync() {
int f = open( "/tmp/t8" , O_RDWR | O_CREAT );
lseek (f, 0, SEEK_SET );
int records = 10*1000;
clock_t ustart = clock();
for(int i = 0; i < records; i++) {
write(f, "012345678901234567890123456789" , 30);
fsync(f);
}
clock_t uend = clock();
close (f);
printf(" sync() seconds:%lf writes per second:%lf\n", ((double)(uend-ustart))/(CLOCKS_PER_SEC), ((double)records)/((double)(uend-ustart))/(CLOCKS_PER_SEC));
}


void withoutSync() {
int f = open( "/tmp/t10" , O_RDWR | O_CREAT );
lseek (f, 0, SEEK_SET );
int records = 10*1000;
clock_t ustart = clock();
for(int i = 0; i < records; i++) {
write(f, "012345678901234567890123456789" , 30 );
}
clock_t uend = clock();
close (f);
printf("no sync() seconds:%lf writes per second:%lf \n", ((double)(uend-ustart))/(CLOCKS_PER_SEC), ((double)records)/((double)(uend-ustart))/(CLOCKS_PER_SEC));
}


int main(int argc, const char * argv[])
{
/* withoutSync();*/
withSync();
return 0;
}

Last edited by wonkite; 07-31-2018 at 08:21 AM.
 
Old 07-31-2018, 05:14 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
You haven't said what filesystem or what mount flags you are using. Specifically barrier.
 
Old 08-01-2018, 02:43 AM   #3
wonkite
LQ Newbie
 
Registered: May 2018
Posts: 3

Original Poster
Rep: Reputation: Disabled
So this is using ext4 with the following mount options rw,noatime,nodiratime,nobarrier,data=ordered
 
  


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
[Slackware64 14.2] Loading error of ath10k firmware with latest kernel-firmware and latest kernel-huge pensador_13 Slackware 3 06-16-2018 12:31 PM
Latest Xorg in -current seems to be broken Lenard Spencer Slackware 50 11-19-2015 05:28 PM
LXer: Latest and Greatest or Broken at Best? LXer Syndicated Linux News 0 04-09-2015 11:21 AM
Latest update to -Current has broken X - again! BobNutfield Slackware 18 02-07-2011 09:34 PM
Sax2 now broken after latest updates The PIT SUSE / openSUSE 5 09-10-2007 01:59 PM

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

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