public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Peng Tao <bergwolf@gmail.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH 7/9] staging/lustre/llite: remove ll_file_get_iov_count
Date: Tue,  3 Dec 2013 22:42:06 +0800	[thread overview]
Message-ID: <1386081729-9481-10-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1386081729-9481-1-git-send-email-bergwolf@gmail.com>

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: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
 drivers/staging/lustre/lustre/llite/file.c |   36 ++--------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 8f03eb0..25442ac 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -1148,38 +1148,6 @@ out:
 	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,
 				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,
 	ssize_t	     result;
 	int		 refcheck;
 
-	result = ll_file_get_iov_count(iov, &nr_segs, &count);
+	result = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_WRITE);
 	if (result)
 		return result;
 
@@ -1248,7 +1216,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 	ssize_t	     result;
 	int		 refcheck;
 
-	result = ll_file_get_iov_count(iov, &nr_segs, &count);
+	result = generic_segment_checks(iov, &nr_segs, &ocount, VERIFY_READ);
 	if (result)
 		return result;
 
-- 
1.7.9.5


  parent reply	other threads:[~2013-12-03 14:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03 14:41 [PATCH 0/9] staging/lustre: minor cleanups and CONFIG_PROC_FS fix up Peng Tao
2013-12-03 14:41 ` [PATCH 1/9] staging/lustre/obdclass: fix false used uninitialized warning Peng Tao
2013-12-03 14:41 ` [PATCH 2/9] staging/lustre/obdclass: lprocfs_{alloc_stats,register} always defined Peng Tao
2013-12-03 14:42 ` Peng Tao
2013-12-03 14:42 ` [PATCH 3/9] staging/lustre/ldlm: inline ldlm_proc_setup Peng Tao
2013-12-03 14:42 ` [PATCH 4/9] staging/lustre/obdclass: move obd_sysctl_init out of class_procfs_init Peng Tao
2013-12-03 14:42 ` Peng Tao
2013-12-03 14:42 ` [PATCH 5/9] staging/lustre: fix defined not used warning Peng Tao
2013-12-03 14:42 ` [PATCH 6/9] staging/lustre/llite: fix used uninitialized warning Peng Tao
2013-12-03 14:42 ` Peng Tao [this message]
2013-12-03 17:00   ` [PATCH 7/9] staging/lustre/llite: remove ll_file_get_iov_count Greg Kroah-Hartman
2013-12-03 17:26     ` Peng Tao
2013-12-03 14:42 ` [PATCH 8/9] staging/lustre: fix undefined reference if CONFIG_PROC_FS is off Peng Tao
2013-12-03 14:42 ` Peng Tao
2013-12-03 14:42 ` [PATCH 9/9] staging/lustre: don't compile procfs code when " Peng Tao

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=1386081729-9481-10-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --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