All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: okozina@redhat.com, hch@lst.de
Subject: [RFC PATCH] iomap: Enable alignment check for iomap DIO in holes
Date: Fri,  5 Oct 2018 15:03:16 +0200	[thread overview]
Message-ID: <20181005130316.4869-1-cmaiolino@redhat.com> (raw)

Commit 09230435dffdb13de507e5e40b524b0069fc5c7b refactor iomap_dio_actor
into two different helpers for bio based IO and hole IO, although, the
latter doesn't check for IO alignment anymore.

Move the DIO alignment check up into the caller, so all iomap DIO has
alignment checked.

Fixes: 09230435d iomap: refactor iomap_dio_actor
Reported-by: Ondrej Kozina <okozina@redhat.com>
Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---

Christoph, I tagged this patch as RFC, because I couldn't really identify if you
intentionally dropped the alignment check for holes and inline actors, if you
didn't drop the alignment check intentionally, please consider it as a normal
patch.

 fs/iomap.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/iomap.c b/fs/iomap.c
index 90c2febc93ac..347e31512268 100644
--- a/fs/iomap.c
+++ b/fs/iomap.c
@@ -1574,9 +1574,7 @@ static loff_t
 iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
 		struct iomap_dio *dio, struct iomap *iomap)
 {
-	unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev));
 	unsigned int fs_block_size = i_blocksize(inode), pad;
-	unsigned int align = iov_iter_alignment(dio->submit.iter);
 	struct iov_iter iter;
 	struct bio *bio;
 	bool need_zeroout = false;
@@ -1584,9 +1582,6 @@ iomap_dio_bio_actor(struct inode *inode, loff_t pos, loff_t length,
 	int nr_pages, ret;
 	size_t copied = 0;
 
-	if ((pos | length | align) & ((1 << blkbits) - 1))
-		return -EINVAL;
-
 	if (iomap->type == IOMAP_UNWRITTEN) {
 		dio->flags |= IOMAP_DIO_UNWRITTEN;
 		need_zeroout = true;
@@ -1726,6 +1721,11 @@ iomap_dio_actor(struct inode *inode, loff_t pos, loff_t length,
 		void *data, struct iomap *iomap)
 {
 	struct iomap_dio *dio = data;
+	unsigned int blkbits = blksize_bits(bdev_logical_block_size(iomap->bdev));
+	unsigned int align = iov_iter_alignment(dio->submit.iter);
+
+	if ((pos | length | align) & ((1 << blkbits) - 1))
+		return -EINVAL;
 
 	switch (iomap->type) {
 	case IOMAP_HOLE:
-- 
2.17.1

             reply	other threads:[~2018-10-05 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-05 13:03 Carlos Maiolino [this message]
2018-10-06  9:59 ` [RFC PATCH] iomap: Enable alignment check for iomap DIO in holes Christoph Hellwig
2018-10-08  7:24   ` Carlos Maiolino

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=20181005130316.4869-1-cmaiolino@redhat.com \
    --to=cmaiolino@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=okozina@redhat.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 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.