提交 28060d5d 编写于 作者: A Al Viro

btrfs: switch check_direct_IO() to iov_iter

... and don't open-code iov_iter_alignment() there
Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
上级 91f79c43
...@@ -7391,39 +7391,30 @@ static void btrfs_submit_direct(int rw, struct bio *dio_bio, ...@@ -7391,39 +7391,30 @@ static void btrfs_submit_direct(int rw, struct bio *dio_bio,
} }
static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *iocb, static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t offset, const struct iov_iter *iter, loff_t offset)
unsigned long nr_segs)
{ {
int seg; int seg;
int i; int i;
size_t size;
unsigned long addr;
unsigned blocksize_mask = root->sectorsize - 1; unsigned blocksize_mask = root->sectorsize - 1;
ssize_t retval = -EINVAL; ssize_t retval = -EINVAL;
loff_t end = offset;
if (offset & blocksize_mask) if (offset & blocksize_mask)
goto out; goto out;
/* Check the memory alignment. Blocks cannot straddle pages */ if (iov_iter_alignment(iter) & blocksize_mask)
for (seg = 0; seg < nr_segs; seg++) { goto out;
addr = (unsigned long)iov[seg].iov_base;
size = iov[seg].iov_len;
end += size;
if ((addr & blocksize_mask) || (size & blocksize_mask))
goto out;
/* If this is a write we don't need to check anymore */
if (rw & WRITE)
continue;
/* /* If this is a write we don't need to check anymore */
* Check to make sure we don't have duplicate iov_base's in this if (rw & WRITE)
* iovec, if so return EINVAL, otherwise we'll get csum errors return 0;
* when reading back. /*
*/ * Check to make sure we don't have duplicate iov_base's in this
for (i = seg + 1; i < nr_segs; i++) { * iovec, if so return EINVAL, otherwise we'll get csum errors
if (iov[seg].iov_base == iov[i].iov_base) * when reading back.
*/
for (seg = 0; seg < iter->nr_segs; seg++) {
for (i = seg + 1; i < iter->nr_segs; i++) {
if (iter->iov[seg].iov_base == iter->iov[i].iov_base)
goto out; goto out;
} }
} }
...@@ -7443,8 +7434,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb, ...@@ -7443,8 +7434,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
bool relock = false; bool relock = false;
ssize_t ret; ssize_t ret;
if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iter->iov, if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iter, offset))
offset, iter->nr_segs))
return 0; return 0;
atomic_inc(&inode->i_dio_count); atomic_inc(&inode->i_dio_count);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册