linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Gruenbacher <agruenba@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: cluster-devel@redhat.com, linux-ext4@vger.kernel.org,
	linux-fsdevel@vger.kernel.org,
	Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH 1/1] iomap: Direct I/O for inline data
Date: Wed, 27 Jun 2018 02:39:06 +0200	[thread overview]
Message-ID: <20180627003906.15571-2-agruenba@redhat.com> (raw)
In-Reply-To: <20180627003906.15571-1-agruenba@redhat.com>

Add support for reading from and writing to inline data to iomap_dio_rw.
This saves filesystems from having to implement fallback code for this
case.

The inline data is actually cached in the inode, so the I/O is only
direct in the sense that it doesn't go through the page cache.  The same
alignment restrictions as to non-inline data apply.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 fs/iomap.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/fs/iomap.c b/fs/iomap.c
index d393bb0c7384..74668b3ca2ed 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1231,6 +1231,32 @@ iomap_dio_zero(struct iomap_dio *dio, struct iomap *iomap, loff_t pos,
 	return submit_bio(bio);
 }
 
+static loff_t iomap_dio_actor_inline(struct inode *inode, struct iomap_dio *dio,
+		struct iomap *iomap, loff_t pos, loff_t length)
+{
+	struct iov_iter *iter = dio->submit.iter;
+	size_t copied;
+
+	BUG_ON(pos + length > PAGE_SIZE - offset_in_page(iomap->inline_data));
+
+	if (dio->flags & IOMAP_DIO_WRITE) {
+		loff_t size = inode->i_size;
+
+		if (pos > size)
+			memset(iomap->inline_data + size, 0, pos - size);
+		copied = copy_from_iter(iomap->inline_data + pos, length, iter);
+		if (copied) {
+			if (pos + copied > size)
+				i_size_write(inode, pos + copied);
+			mark_inode_dirty(inode);
+		}
+	} else {
+		copied = copy_to_iter(iomap->inline_data + pos, length, iter);
+	}
+	dio->size += copied;
+	return copied;
+}
+
 static loff_t
 iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 		void *data, struct iomap *iomap)
@@ -1281,6 +1307,8 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 				use_fua = true;
 		}
 		break;
+	case IOMAP_INLINE:
+		return iomap_dio_actor_inline(inode, dio, iomap, pos, length);
 	default:
 		WARN_ON_ONCE(1);
 		return -EIO;
-- 
2.17.1

  reply	other threads:[~2018-06-27  0:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27  0:39 [PATCH 0/1] iomap: Direct I/O for inline data Andreas Gruenbacher
2018-06-27  0:39 ` Andreas Gruenbacher [this message]
2018-06-27  1:44   ` [PATCH 1/1] " kbuild test robot
2018-06-29  8:56   ` Christoph Hellwig
2018-06-29 14:40     ` Andreas Gruenbacher
2018-06-29 16:01       ` Christoph Hellwig
2018-06-29 17:02         ` Andreas Gruenbacher
2018-07-01  6:13           ` Christoph Hellwig
2018-07-01  6:29       ` Christoph Hellwig
2018-07-01 21:44         ` Andreas Gruenbacher
2018-06-27 11:14 ` [PATCH 0/1] " Andreas Gruenbacher
2018-06-29  8:43   ` Christoph Hellwig
2018-06-29 11:01     ` Andreas Gruenbacher

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=20180627003906.15571-2-agruenba@redhat.com \
    --to=agruenba@redhat.com \
    --cc=cluster-devel@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@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).