From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: Dmitry Monakhov <dmonakhov@openvz.org>, linux-ext4@vger.kernel.org
Subject: [PATCH 3/4] ext4: cleanup data integrity sync fo nonjournal mode
Date: Tue, 14 Oct 2014 14:03:54 +0400 [thread overview]
Message-ID: <1413281035-6483-4-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1413281035-6483-1-git-send-email-dmonakhov@openvz.org>
There are several rules we must follows during data integrity
1) barrier MUST being sent if barrier_opt is enabled (and must not otherwise)
2) If we can guarantee that barrier will be sent for us,
we can skip explicit barrier.
Change log:
- Fix needs_barrier var initialization according to rule (1)
- Avoid barriers if barrier_opt was not enabled for non-journal mode
according to rule (1)
- Style cleanup flush optimization according to rule (2)
CC: linux-ext4@vger.kernel.org
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ext4/fsync.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
index a8bc47f..2b0fd69 100644
--- a/fs/ext4/fsync.c
+++ b/fs/ext4/fsync.c
@@ -92,7 +92,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
journal_t *journal = EXT4_SB(inode->i_sb)->s_journal;
int ret = 0, err;
tid_t commit_tid;
- bool needs_barrier = false;
+ bool needs_barrier = test_opt(inode->i_sb, BARRIER);
J_ASSERT(ext4_journal_current_handle() == NULL);
@@ -107,10 +107,10 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
}
if (!journal) {
- ret = generic_file_fsync(file, start, end, datasync);
+ ret = __generic_file_fsync(file, start, end, datasync);
if (!ret && !hlist_empty(&inode->i_dentry))
ret = ext4_sync_parent(inode);
- goto out;
+ goto out_flush;
}
ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
@@ -136,10 +136,11 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
}
commit_tid = datasync ? ei->i_datasync_tid : ei->i_sync_tid;
- if (journal->j_flags & JBD2_BARRIER &&
- !jbd2_trans_will_send_data_barrier(journal, commit_tid))
- needs_barrier = true;
+ if (needs_barrier &&
+ jbd2_trans_will_send_data_barrier(journal, commit_tid))
+ needs_barrier = false;
ret = jbd2_complete_transaction(journal, commit_tid);
+out_flush:
if (needs_barrier) {
err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL, NULL);
if (!ret)
--
1.7.1
next parent reply other threads:[~2014-10-14 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1413281035-6483-1-git-send-email-dmonakhov@openvz.org>
2014-10-14 10:03 ` Dmitry Monakhov [this message]
2014-10-14 10:03 ` [PATCH 4/4] ext4: Add fdatasync scalability optimization Dmitry Monakhov
2014-10-14 10:57 ` Christoph Hellwig
2014-10-14 11:25 ` Dmitry Monakhov
2014-10-14 11:35 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413281035-6483-4-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).