Commit 960edbe3 authored by Peng Tao's avatar Peng Tao Committed by Greg Kroah-Hartman

staging/lustre/llite: remove ll_file_get_iov_count

It exactly copies generic_segment_checks() except wrongly calling
access_ok(VERIFY_READ) for aio read range. Drop it and just call
generic_segment_checks() instead.
Signed-off-by: default avatarPeng Tao <bergwolf@gmail.com>
Signed-off-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 284c145e
...@@ -1148,38 +1148,6 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args, ...@@ -1148,38 +1148,6 @@ ll_file_io_generic(const struct lu_env *env, struct vvp_io_args *args,
return result; return result;
} }
/*
* XXX: exact copy from kernel code (__generic_file_aio_write_nolock)
*/
static int ll_file_get_iov_count(const struct iovec *iov,
unsigned long *nr_segs, size_t *count)
{
size_t cnt = 0;
unsigned long seg;
for (seg = 0; seg < *nr_segs; seg++) {
const struct iovec *iv = &iov[seg];
/*
* If any segment has a negative length, or the cumulative
* length ever wraps negative then return -EINVAL.
*/
cnt += iv->iov_len;
if (unlikely((ssize_t)(cnt|iv->iov_len) < 0))
return -EINVAL;
if (access_ok(VERIFY_READ, iv->iov_base, iv->iov_len))
continue;
if (seg == 0)
return -EFAULT;
*nr_segs = seg;
cnt -= iv->iov_len; /* This segment is no good */
break;
}
*count = cnt;
return 0;
}
static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos) unsigned long nr_segs, loff_t pos)
{ {
...@@ -1189,7 +1157,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -1189,7 +1157,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
ssize_t result; ssize_t result;
int refcheck; int refcheck;
result = ll_file_get_iov_count(iov, &nr_segs, &count); result = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE);
if (result) if (result)
return result; return result;
...@@ -1248,7 +1216,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -1248,7 +1216,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
ssize_t result; ssize_t result;
int refcheck; int refcheck;
result = ll_file_get_iov_count(iov, &nr_segs, &count); result = generic_segment_checks(iov, &nr_segs, &count, VERIFY_READ);
if (result) if (result)
return result; return result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment