From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev v2] [PATCH 2/4] f2fs: allow wrong configure dio to buffered write
Date: Thu, 12 Jul 2018 10:59:02 -0700 [thread overview]
Message-ID: <20180712175611.GA37244@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <af7e2fa5-b9e9-3090-7659-bd76585fd3aa@kernel.org>
This fixes to support dio having unaligned buffers as buffered writes.
xfs_io -f -d -c "pwrite 0 512" $testfile
-> okay
xfs_io -f -d -c "pwrite 1 512" $testfile
-> EINVAL
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
v2 from v1:
- return error depending on sector size
fs/f2fs/data.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8f931d699287..5e53d210e222 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2371,14 +2371,20 @@ static int f2fs_write_end(struct file *file,
static int check_direct_IO(struct inode *inode, struct iov_iter *iter,
loff_t offset)
{
- unsigned blocksize_mask = inode->i_sb->s_blocksize - 1;
-
- if (offset & blocksize_mask)
- return -EINVAL;
-
- if (iov_iter_alignment(iter) & blocksize_mask)
- return -EINVAL;
-
+ unsigned i_blkbits = READ_ONCE(inode->i_blkbits);
+ unsigned blkbits = i_blkbits;
+ unsigned blocksize_mask = (1 << blkbits) - 1;
+ unsigned long align = offset | iov_iter_alignment(iter);
+ struct block_device *bdev = inode->i_sb->s_bdev;
+
+ if (align & blocksize_mask) {
+ if (bdev)
+ blkbits = blksize_bits(bdev_logical_block_size(bdev));
+ blocksize_mask = (1 << blkbits) - 1;
+ if (align & blocksize_mask)
+ return -EINVAL;
+ return 1;
+ }
return 0;
}
@@ -2396,7 +2402,7 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
err = check_direct_IO(inode, iter, offset);
if (err)
- return err;
+ return err < 0 ? err : 0;
if (f2fs_force_buffered_io(inode, rw))
return 0;
--
2.17.0.441.gb46fe60e1d-goog
next prev parent reply other threads:[~2018-07-12 18:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 21:09 [PATCH 1/4] f2fs: flush journal nat entries for nat_bits during unmount Jaegeuk Kim
2018-07-06 21:09 ` [PATCH 2/4] f2fs: allow wrong configure dio to buffered write Jaegeuk Kim
2018-07-09 14:33 ` [f2fs-dev] " Chao Yu
2018-07-09 20:41 ` Jaegeuk Kim
2018-07-10 5:54 ` Chao Yu
2018-07-12 17:59 ` Jaegeuk Kim [this message]
2018-07-13 11:29 ` [f2fs-dev v2] " Chao Yu
2018-07-06 21:09 ` [PATCH 3/4] f2fs: indicate shutdown f2fs to allow unmount successfully Jaegeuk Kim
2018-07-09 14:42 ` [f2fs-dev] " Chao Yu
2018-07-06 21:09 ` [PATCH 4/4] f2fs: should check the type of end_io after pullback by fscrypto Jaegeuk Kim
2018-07-09 14:54 ` [f2fs-dev] " Chao Yu
2018-07-09 20:37 ` Jaegeuk Kim
2018-07-10 20:43 ` Jaegeuk Kim
2018-07-10 20:53 ` Jaegeuk Kim
2018-07-09 14:23 ` [f2fs-dev] [PATCH 1/4] f2fs: flush journal nat entries for nat_bits during unmount Chao Yu
2018-07-09 20:43 ` Jaegeuk Kim
2018-07-10 6:01 ` Chao Yu
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=20180712175611.GA37244@jaegeuk-macbookpro.roam.corp.google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--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
all inboxes | Powered by JetHome®