public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Jan Kara <jack@suse.cz>
Cc: Roman Peniaev <r.peniaev@gmail.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH 1/1] fs/mpage.c: forgotten WRITE_SYNC in case of data integrity write
Date: Thu, 13 Mar 2014 14:34:56 -0700	[thread overview]
Message-ID: <20140313143456.157404fd7f208638ca70e317@linux-foundation.org> (raw)
In-Reply-To: <20140313200119.GB504@quack.suse.cz>

On Thu, 13 Mar 2014 21:01:19 +0100 Jan Kara <jack@suse.cz> wrote:

>   Hello,
> 
> On Wed 12-03-14 23:29:04, Roman Peniaev wrote:
> > could you please explain the real purpose of WAIT_SYNC?
> > In case of wbc->sync_mode == WB_SYNC_ALL.
> > Because my current understanding is if writeback control has
> > WB_SYNC_ALL everything
> > should be submitted with WAIT_SYNC.
>   So AFAIK the idea is that REQ_SYNC flag should indicate the IO is
> synchronous - i.e., someone is waiting for it to complete. This is opposed
> to asynchronous writeback done by flusher threads where noone waits for
> particular write to complete. Subsequently, IO scheduler is expected (but
> not required to - only CFQ honors REQ_SYNC AFAIK) to treat sync requests
> with higher priority than async onces.
> 
> When to set REQ_SYNC is not an obvious question. If we set it for too much
> IO, it has no effect. If we don't set it for some IO we risk that someone
> waiting for that IO to complete will be starved by others setting REQ_SYNC.
> 
> So all in all I think that using WRITE_SYNC iff we are doing WB_SYNC_ALL
> writeback is a reasonable choice.

I added this to the changelog:

: akpm: afaict this change will cause the data integrity write bios to be
: placed onto the second queue in cfq_io_cq.cfqq[], which presumably results
: in special treatment.  The documentation for REQ_SYNC is horrid.

Which is pretty pathetic.

Jens isn't talking to us.  Tejun, are you able explain REQ_SYNC?

I just don't know about this patch.  It will presumably have some
effect on data-integrity writes.  But is that a good effect or a bad
one?  Will it result in a sys_sync() starving out other IO for ages in
an undesirable fashion?  It might well do!  Will it prioritize those
writes, resulting in overall less efficient IO patterns?  It might well
do!

I don't see how we can proceed without understanding the tradeoffs and
deciding that the overall effect is a desirable one.




From: Roman Pen <r.peniaev@gmail.com>
Subject: fs/mpage.c: forgotten WRITE_SYNC in case of data integrity write

In case of wbc->sync_mode == WB_SYNC_ALL we need to do data integrity
write, thus mark request as WRITE_SYNC.

akpm: afaict this change will cause the data integrity write bios to be
placed onto the second queue in cfq_io_cq.cfqq[], which presumably results
in special treatment.  The documentation for REQ_SYNC is horrid.

Signed-off-by: Roman Pen <r.peniaev@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/mpage.c |   23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff -puN fs/mpage.c~fs-mpagec-forgotten-write_sync-in-case-of-data-integrity-write fs/mpage.c
--- a/fs/mpage.c~fs-mpagec-forgotten-write_sync-in-case-of-data-integrity-write
+++ a/fs/mpage.c
@@ -462,6 +462,7 @@ static int __mpage_writepage(struct page
 	struct buffer_head map_bh;
 	loff_t i_size = i_size_read(inode);
 	int ret = 0;
+	int wr = (wbc->sync_mode == WB_SYNC_ALL ?  WRITE_SYNC : WRITE);
 
 	if (page_has_buffers(page)) {
 		struct buffer_head *head = page_buffers(page);
@@ -570,7 +571,7 @@ page_is_mapped:
 	 * This page will go to BIO.  Do we need to send this BIO off first?
 	 */
 	if (bio && mpd->last_block_in_bio != blocks[0] - 1)
-		bio = mpage_bio_submit(WRITE, bio);
+		bio = mpage_bio_submit(wr, bio);
 
 alloc_new:
 	if (bio == NULL) {
@@ -587,7 +588,7 @@ alloc_new:
 	 */
 	length = first_unmapped << blkbits;
 	if (bio_add_page(bio, page, length, 0) < length) {
-		bio = mpage_bio_submit(WRITE, bio);
+		bio = mpage_bio_submit(wr, bio);
 		goto alloc_new;
 	}
 
@@ -620,7 +621,7 @@ alloc_new:
 	set_page_writeback(page);
 	unlock_page(page);
 	if (boundary || (first_unmapped != blocks_per_page)) {
-		bio = mpage_bio_submit(WRITE, bio);
+		bio = mpage_bio_submit(wr, bio);
 		if (boundary_block) {
 			write_boundary_block(boundary_bdev,
 					boundary_block, 1 << blkbits);
@@ -632,7 +633,7 @@ alloc_new:
 
 confused:
 	if (bio)
-		bio = mpage_bio_submit(WRITE, bio);
+		bio = mpage_bio_submit(wr, bio);
 
 	if (mpd->use_writepage) {
 		ret = mapping->a_ops->writepage(page, wbc);
@@ -688,8 +689,11 @@ mpage_writepages(struct address_space *m
 		};
 
 		ret = write_cache_pages(mapping, wbc, __mpage_writepage, &mpd);
-		if (mpd.bio)
-			mpage_bio_submit(WRITE, mpd.bio);
+		if (mpd.bio) {
+			int wr = (wbc->sync_mode == WB_SYNC_ALL ?
+				  WRITE_SYNC : WRITE);
+			mpage_bio_submit(wr, mpd.bio);
+		}
 	}
 	blk_finish_plug(&plug);
 	return ret;
@@ -706,8 +710,11 @@ int mpage_writepage(struct page *page, g
 		.use_writepage = 0,
 	};
 	int ret = __mpage_writepage(page, wbc, &mpd);
-	if (mpd.bio)
-		mpage_bio_submit(WRITE, mpd.bio);
+	if (mpd.bio) {
+		int wr = (wbc->sync_mode == WB_SYNC_ALL ?
+			  WRITE_SYNC : WRITE);
+		mpage_bio_submit(wr, mpd.bio);
+	}
 	return ret;
 }
 EXPORT_SYMBOL(mpage_writepage);
_


  reply	other threads:[~2014-03-13 21:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-16  2:54 [PATCH 1/1] fs/mpage.c: forgotten WRITE_SYNC in case of data integrity write Roman Pen
2014-02-18 23:59 ` Andrew Morton
2014-02-19  1:38   ` Roman Peniaev
2014-03-12 14:29     ` Roman Peniaev
2014-03-13 20:01       ` Jan Kara
2014-03-13 21:34         ` Andrew Morton [this message]
2014-03-14 13:07           ` Tejun Heo
2014-03-14 14:07             ` Roman Peniaev
2014-03-14 14:11               ` Tejun Heo
2014-03-14 14:15                 ` Jan Kara
2014-03-14 14:23                   ` Roman Peniaev
2014-03-14 14:52                     ` Jan Kara
2014-03-14 14:54                       ` Tejun Heo
2014-03-14 15:08                         ` Jan Kara
2014-03-15  9:09                         ` Christoph Hellwig
2014-03-14 14:17                 ` Roman Peniaev
2014-03-14 14:20                   ` Tejun Heo
2014-03-14 14:29                     ` Roman Peniaev
2014-03-14 15:36                 ` Roman Peniaev
2014-03-13 20:21 ` Jan Kara

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=20140313143456.157404fd7f208638ca70e317@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=r.peniaev@gmail.com \
    --cc=tj@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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