* fsync and journal_async_commit mount options
@ 2015-08-16 11:42 Alexey Skidanov
2015-08-16 12:24 ` Theodore Ts'o
0 siblings, 1 reply; 5+ messages in thread
From: Alexey Skidanov @ 2015-08-16 11:42 UTC (permalink / raw)
To: linux-fsdevel@vger.kernel.org; +Cc: alexey.skidanov@gmail.com
Hi,
Some partition on my device is mounted with journal_async_commit option. I paid attention that fsync() system call doesn't cause to flush request to be sent. Looking in the source code of ext4_sync_file I understand that only if the barrier option is on the flush request will be issued:
if (journal->j_flags & JBD2_BARRIER &&
!jbd2_trans_will_send_data_barrier(journal, commit_tid))
needs_barrier = true;
...
if (needs_barrier) {
err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
...
}
The fsync mainly used to ensure the data is actually written on backing device. The man page says:
fsync() transfers ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the file referred to by the file descriptor fd to the disk device (or other permanent storage device) so that all changed information can be retrieved even after the system crashed or was rebooted. This includes writing through or flushing a disk cache if present.
The barrier is a mount option imposing some ordering on journaling transactions - journaling content and journaling commit. So why the flush request is issued only if the journal ordering is imposed by barrier option?
Thanks
Alexey
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: fsync and journal_async_commit mount options
2015-08-16 11:42 fsync and journal_async_commit mount options Alexey Skidanov
@ 2015-08-16 12:24 ` Theodore Ts'o
2015-08-18 9:59 ` Alexey Skidanov
0 siblings, 1 reply; 5+ messages in thread
From: Theodore Ts'o @ 2015-08-16 12:24 UTC (permalink / raw)
To: Alexey Skidanov; +Cc: linux-fsdevel@vger.kernel.org, alexey.skidanov@gmail.com
On Sun, Aug 16, 2015 at 11:42:23AM +0000, Alexey Skidanov wrote:
> The barrier is a mount option imposing some ordering on journaling
> transactions - journaling content and journaling commit. So why the
> flush request is issued only if the journal ordering is imposed by
> barrier option?
The barrier option is on by default. Users have to explicitly turn
off the barrier option using the nobarrier mount option. The main
reason why you might want to turn off the flush request is if you have
a UPS and are confident that the you don't need to worry about power
drop. (For example, if you have a data center with say, system or
rack level battery backups, plus a diesel generator, maybe you might
be willing make the engineering trade off to disable the barrier
option.)
I could imagine a scheme where if you had a mobile handset without a
removable battery, the handset manufacturer could implement a power
fail interrupt so that when the battery drops below 5 minutes worth of
runtime, the kernel shuts down the system cleanly which includes an
explicit flush before the power down.
Cheers,
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: fsync and journal_async_commit mount options
2015-08-16 12:24 ` Theodore Ts'o
@ 2015-08-18 9:59 ` Alexey Skidanov
2015-08-18 16:25 ` tytso
0 siblings, 1 reply; 5+ messages in thread
From: Alexey Skidanov @ 2015-08-18 9:59 UTC (permalink / raw)
To: Theodore Ts'o
Cc: linux-fsdevel@vger.kernel.org, alexey.skidanov@gmail.com
I think I didn't explain myself well.
My question is regarding the barrier=0/1 mount option.
On the one hand, the "mount" man page says "This enables/disables the use of write barriers in the jbd code". From there I understand that this option changes the behaviour of journalling code only. But on the other hand, this option change the the behaviour of fsync() (at least in case of ext4): the flush request is issued only if barrier mount option is 1.
Thanks,
Alexey
________________________________________
From: Theodore Ts'o [tytso@mit.edu]
Sent: Sunday, August 16, 2015 3:24 PM
To: Alexey Skidanov
Cc: linux-fsdevel@vger.kernel.org; alexey.skidanov@gmail.com
Subject: Re: fsync and journal_async_commit mount options
On Sun, Aug 16, 2015 at 11:42:23AM +0000, Alexey Skidanov wrote:
> The barrier is a mount option imposing some ordering on journaling
> transactions - journaling content and journaling commit. So why the
> flush request is issued only if the journal ordering is imposed by
> barrier option?
The barrier option is on by default. Users have to explicitly turn
off the barrier option using the nobarrier mount option. The main
reason why you might want to turn off the flush request is if you have
a UPS and are confident that the you don't need to worry about power
drop. (For example, if you have a data center with say, system or
rack level battery backups, plus a diesel generator, maybe you might
be willing make the engineering trade off to disable the barrier
option.)
I could imagine a scheme where if you had a mobile handset without a
removable battery, the handset manufacturer could implement a power
fail interrupt so that when the battery drops below 5 minutes worth of
runtime, the kernel shuts down the system cleanly which includes an
explicit flush before the power down.
Cheers,
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: fsync and journal_async_commit mount options
2015-08-18 9:59 ` Alexey Skidanov
@ 2015-08-18 16:25 ` tytso
0 siblings, 0 replies; 5+ messages in thread
From: tytso @ 2015-08-18 16:25 UTC (permalink / raw)
To: Alexey Skidanov; +Cc: linux-fsdevel@vger.kernel.org, alexey.skidanov@gmail.com
On Tue, Aug 18, 2015 at 09:59:58AM +0000, Alexey Skidanov wrote:
>
> My question is regarding the barrier=0/1 mount option. On the one
> hand, the "mount" man page says "This enables/disables the use of
> write barriers in the jbd code". From there I understand that this
> option changes the behaviour of journalling code only. But on the
> other hand, this option change the the behaviour of fsync() (at
> least in case of ext4): the flush request is issued only if barrier
> mount option is 1.
The bug is in the mount man page. It may have been true for ext3 oh,
a decade or more ago when we didn't have an optimized fdatasync(2)
implementation. (Ext4 may have predated Linux *having* fdatasync(2)
support.) But no one has bothered to update documentation, because
all of the people who care knew what it meant, and most users don't
bother changing the defaults.
Cheers,
- Ted
^ permalink raw reply [flat|nested] 5+ messages in thread
* fsync and journal_async_commit mount options
@ 2015-08-13 13:47 Alexey Skidanov
0 siblings, 0 replies; 5+ messages in thread
From: Alexey Skidanov @ 2015-08-13 13:47 UTC (permalink / raw)
To: linux-ext4@vger.kernel.org; +Cc: alexey.skidanov@gmail.com
Hi,
Some partition on my device is mounted with journal_async_commit option. I paid attention that fsync() system call doesn't cause to flush request to be sent. Looking in the source code of ext4_sync_file I understand that only if the barrier option is on the flush request will be issued:
if (journal->j_flags & JBD2_BARRIER &&
!jbd2_trans_will_send_data_barrier(journal, commit_tid))
needs_barrier = true;
...
if (needs_barrier) {
err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
...
}
The fsync mainly used to ensure the data is actually written on backing device. The man page says:
fsync() transfers ("flushes") all modified in-core data of (i.e., modified buffer cache pages for) the file referred to by the file descriptor fd to the disk device (or other permanent storage device) so that all changed information can be retrieved even after the system crashed or was rebooted. This includes writing through or flushing a disk cache if present.
The barrier is a mount option imposing some ordering on journaling transactions - journaling content and journaling commit. So why the flush request is issued only if the journal ordering is imposed by barrier option?
Thanks
Alexey
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-08-18 16:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-16 11:42 fsync and journal_async_commit mount options Alexey Skidanov
2015-08-16 12:24 ` Theodore Ts'o
2015-08-18 9:59 ` Alexey Skidanov
2015-08-18 16:25 ` tytso
-- strict thread matches above, loose matches on Subject: below --
2015-08-13 13:47 Alexey Skidanov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.