From: Sagi Grimberg <sagig@dev.mellanox.co.il>
To: Christoph Hellwig <hch@lst.de>, Al Viro <viro@zeniv.linux.org.uk>
Cc: Jens Axboe <axboe@fb.com>,
Nicholas Bellinger <nab@linux-iscsi.org>,
Ming Lei <ming.lei@canonical.com>,
linux-fsdevel@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH 3/3] target: use vfs_bvec_read/write
Date: Sun, 18 Jan 2015 17:37:41 +0200 [thread overview]
Message-ID: <54BBD345.7070103@dev.mellanox.co.il> (raw)
In-Reply-To: <1421593624-4462-4-git-send-email-hch@lst.de>
On 1/18/2015 5:07 PM, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/target/target_core_file.c | 29 ++++++++++++-----------------
> 1 file changed, 12 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
> index d836de2..63ca7d5 100644
> --- a/drivers/target/target_core_file.c
> +++ b/drivers/target/target_core_file.c
> @@ -331,36 +331,31 @@ static int fd_do_rw(struct se_cmd *cmd, struct scatterlist *sgl,
> struct fd_dev *dev = FD_DEV(se_dev);
> struct file *fd = dev->fd_file;
> struct scatterlist *sg;
> - struct iovec *iov;
> - mm_segment_t old_fs;
> + struct bio_vec *bvec;
> + ssize_t len = 0;
> loff_t pos = (cmd->t_task_lba * se_dev->dev_attrib.block_size);
> int ret = 0, i;
>
> - iov = kzalloc(sizeof(struct iovec) * sgl_nents, GFP_KERNEL);
> - if (!iov) {
> + bvec = kzalloc(sizeof(struct bio_vec) * sgl_nents, GFP_KERNEL);
> + if (!bvec) {
Can you make that kcalloc so checkpatch would be happy?
Otherwise, Looks good to me.
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
> pr_err("Unable to allocate fd_do_readv iov[]\n");
> return -ENOMEM;
> }
>
> for_each_sg(sgl, sg, sgl_nents, i) {
> - iov[i].iov_len = sg->length;
> - iov[i].iov_base = kmap(sg_page(sg)) + sg->offset;
> - }
> + bvec[i].bv_page = sg_page(sg);
> + bvec[i].bv_len = sg->length;
> + bvec[i].bv_offset = sg->offset;
>
> - old_fs = get_fs();
> - set_fs(get_ds());
> + len += sg->length;
> + }
>
> if (is_write)
> - ret = vfs_writev(fd, &iov[0], sgl_nents, &pos);
> + ret = vfs_bvec_write(fd, bvec, sgl_nents, len, &pos);
> else
> - ret = vfs_readv(fd, &iov[0], sgl_nents, &pos);
> -
> - set_fs(old_fs);
> -
> - for_each_sg(sgl, sg, sgl_nents, i)
> - kunmap(sg_page(sg));
> + ret = vfs_bvec_read(fd, bvec, sgl_nents, len, &pos);
>
> - kfree(iov);
> + kfree(bvec);
>
> if (is_write) {
> if (ret < 0 || ret != cmd->data_length) {
>
next prev parent reply other threads:[~2015-01-18 15:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-18 15:07 switch loop and target to use ITER_BVEC iov_iter Christoph Hellwig
2015-01-18 15:07 ` [PATCH 1/3] fs: add vfs_bvec_{read,write} helpers Christoph Hellwig
2015-01-23 6:00 ` Al Viro
2015-01-18 15:07 ` [PATCH 2/3] loop: convert to vfs_bvec_write Christoph Hellwig
2015-01-18 15:07 ` [PATCH 3/3] target: use vfs_bvec_read/write Christoph Hellwig
2015-01-18 15:37 ` Sagi Grimberg [this message]
2015-01-20 23:32 ` Nicholas A. Bellinger
2015-01-23 14:08 ` Ming Lei
2015-01-25 13:43 ` Christoph Hellwig
2015-01-26 2:02 ` Ming Lei
2015-01-26 16:59 ` Christoph Hellwig
2015-01-27 5:14 ` Ming Lei
2015-01-22 4:11 ` switch loop and target to use ITER_BVEC iov_iter Ming Lei
2015-01-25 13:45 ` Christoph Hellwig
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=54BBD345.7070103@dev.mellanox.co.il \
--to=sagig@dev.mellanox.co.il \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ming.lei@canonical.com \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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.