linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org
Cc: Sergey Meirovich <rathamahata@gmail.com>
Subject: [PATCH 1/3] direct-io: add flag to allow aio writes beyond i_size
Date: Tue, 04 Feb 2014 09:24:03 -0800	[thread overview]
Message-ID: <20140204172516.456901390@bombadil.infradead.org> (raw)
In-Reply-To: 20140204172402.380571745@bombadil.infradead.org

[-- Attachment #1: 0001-direct-io-add-flag-to-allow-aio-writes-beyond-i_size.patch --]
[-- Type: text/plain, Size: 1701 bytes --]

Some filesystems can handle direct I/O writes beyond i_size safely,
so allow them to opt into receiving them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/direct-io.c     |   18 ++++++++++++------
 include/linux/fs.h |    3 +++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 0e04142..11882e8 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1194,13 +1194,19 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
 	}
 
 	/*
-	 * For file extending writes updating i_size before data
-	 * writeouts complete can expose uninitialized blocks. So
-	 * even for AIO, we need to wait for i/o to complete before
-	 * returning in this case.
+	 * For file extending writes updating i_size before data writeouts
+	 * complete can expose uninitialized blocks in dumb filesystems.
+	 * In that case we need to wait for I/O completion even if asked
+	 * for an asynchronous write.
 	 */
-	dio->is_async = !is_sync_kiocb(iocb) && !((rw & WRITE) &&
-		(end > i_size_read(inode)));
+	if (is_sync_kiocb(iocb))
+		dio->is_async = false;
+	else if (!(dio->flags & DIO_ASYNC_EXTEND) &&
+            (rw & WRITE) && end > i_size_read(inode))
+		dio->is_async = false;
+	else
+		dio->is_async = true;
+
 	dio->inode = inode;
 	dio->rw = rw;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 121f11f..f8416fd 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2526,6 +2526,9 @@ enum {
 
 	/* filesystem does not support filling holes */
 	DIO_SKIP_HOLES	= 0x02,
+
+	/* filesystem can handle aio writes beyond i_size */
+	DIO_ASYNC_EXTEND = 0x04,
 };
 
 void dio_end_io(struct bio *bio, int error);
-- 
1.7.10.4



  reply	other threads:[~2014-02-04 17:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 17:24 [PATCH 0/3] support appending AIO writes Christoph Hellwig
2014-02-04 17:24 ` Christoph Hellwig [this message]
2014-02-04 17:24 ` [PATCH 2/3] xfs: always use unwritten extents for direct I/O writes Christoph Hellwig
2014-02-04 17:24 ` [PATCH 3/3] xfs: allow appending aio writes Christoph Hellwig
2014-02-04 22:29 ` [PATCH 0/3] support appending AIO writes Dave Chinner
2014-02-05  6:57   ` Christoph Hellwig
2014-02-05  7:59     ` Dave Chinner
2014-02-05 13:55     ` Al Viro
2014-02-05 14:52 ` Sergey Meirovich
2014-02-06 16:29   ` Sergey Meirovich
2014-02-06 22:51     ` Dave Chinner
2014-02-07  9:40       ` Sergey Meirovich

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=20140204172516.456901390@bombadil.infradead.org \
    --to=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=rathamahata@gmail.com \
    --cc=xfs@oss.sgi.com \
    /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).