From: hch@lst.de (Christoph Hellwig)
Subject: [PATCH 05/20] nvmet: add NVMe I/O command handlers for file
Date: Tue, 24 Apr 2018 19:29:25 +0200 [thread overview]
Message-ID: <20180424172925.GC30391@lst.de> (raw)
In-Reply-To: <20180418190011.3973-6-chaitanya.kulkarni@wdc.com>
> +#define NR_BVEC(req) (req->data_len / PAGE_SIZE)
Don't we need to round up here instead of rounding down for
transfers that aren't a multiple of PAGE_SIZE?
Also given that there is a single user only it might make more sense
to just open code it.
> +static void nvmet_file_io_complete(struct kiocb *iocb, long ret, long ret2)
> +{
> + struct nvmet_req *req = container_of(iocb, struct nvmet_req, iocb);
> +
> + kfree(req->bvec);
> + req->bvec = NULL;
There should be no need to set req->bvec to NULL there.
> +static void nvmet_execute_rw_file(struct nvmet_req *req)
> +{
> + struct iov_iter iter;
> + struct sg_mapping_iter miter;
> + loff_t pos;
> + ssize_t len = 0, ret;
> + int ki_flags = IOCB_DIRECT;
> + int bv_cnt = 0, rw = READ;
Maybe do a simple bool is_write instead of using the nasty
legacy READ/WRITE defines?
> + req->bvec = kmalloc_array(NR_BVEC(req), sizeof(struct bio_vec),
> + GFP_KERNEL);
> + if (!req->bvec)
> + goto out;
Any chance to reuse the inline_bvec for small requests?
> +
> + sg_miter_start(&miter, req->sg, req->sg_cnt, SG_MITER_FROM_SG);
> + while (sg_miter_next(&miter)) {
> + req->bvec[bv_cnt].bv_page = miter.page;
> + req->bvec[bv_cnt].bv_offset = miter.__offset;
>From scatterlist.h:
/* these are internal states, keep away */
unsigned int __offset; /* offset within page */
But given that the nvmet code allocated the scatterlist we already know
each element is only a page long at maximum. So a simple for_each_sg
loop as for the block backend will probably do it.
> + pos = le64_to_cpu(req->cmd->rw.slba) * (1 << (req->ns->blksize_shift));
The block backend does:
sector = le64_to_cpu(req->cmd->rw.slba);
sector <<= (req->ns->blksize_shift - 9);
which should be more efficient as it avoids the multiplication.
> + if (rw == WRITE)
> + ret = call_write_iter(req->ns->filp, &req->iocb, &iter);
> + else
> + ret = call_read_iter(req->ns->filp, &req->iocb, &iter);
Please call the read_iter/write_iter methods directly.
> +static void nvmet_execute_flush_file(struct nvmet_req *req)
> +{
> + int ret = vfs_fsync(req->ns->filp, 1);
> +
> + nvmet_req_complete(req, ret);
> +}
This will work ok but block the caller frontend thread for possibly
a long time. Offloading this to a simple schedule_work might be
beneficial.
next prev parent reply other threads:[~2018-04-24 17:29 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 18:59 [PATCH 00/19] nvmet: add support for file backed namespaces Chaitanya Kulkarni
2018-04-18 18:59 ` [PATCH 01/20] nvmet: add block device guard for smart-log Chaitanya Kulkarni
2018-04-18 18:59 ` [PATCH 02/20] nvmet: add a wrapper for ns handlers Chaitanya Kulkarni
2018-04-18 18:59 ` [PATCH 03/20] nvmet: add structure members for file I/O Chaitanya Kulkarni
2018-04-24 17:18 ` Christoph Hellwig
2018-04-18 18:59 ` [PATCH 04/20] nvmet: initialize file handle and req fields Chaitanya Kulkarni
2018-04-24 17:22 ` Christoph Hellwig
2018-04-18 18:59 ` [PATCH 05/20] nvmet: add NVMe I/O command handlers for file Chaitanya Kulkarni
2018-04-24 17:29 ` Christoph Hellwig [this message]
2018-04-18 18:59 ` [PATCH 06/20] nvmet: add new members for sync file I/O Chaitanya Kulkarni
2018-04-24 17:30 ` Christoph Hellwig
2018-04-18 18:59 ` [PATCH 07/20] nvmet: add sync I/O configfs attr for ns Chaitanya Kulkarni
2018-04-18 18:59 ` [PATCH 08/20] nvmet: configure file backed ns for sync IO Chaitanya Kulkarni
2018-04-24 17:41 ` Christoph Hellwig
2018-05-04 2:36 ` chaitany kulkarni
2018-04-18 19:00 ` [PATCH 09/20] nvmet: use workqueue for sync I/O Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 10/20] nvmet: isolate id ctrl/ns field initialization Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 11/20] nvmet: introduce new members for ns-mgmt Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 12/20] nvmet: add a configfs entry for subsys mount path Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 13/20] nvmet: initialize new ns and subsys members Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 14/20] nvmet: add and restructure ns mgmt helpers Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 15/20] fs: export kern_path_locked() to reuse the code Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 16/20] nvmet: add ns-mgmt command handlers Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 17/20] nvmet: override identify for file backed ns Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 18/20] nvmet: allow host to configure sync vs direct IO Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 19/20] nvmet: add check for ctrl processing paused status Chaitanya Kulkarni
2018-04-18 19:00 ` [PATCH 20/20] nvmet: use processing paused state for VWC Chaitanya Kulkarni
2018-04-24 17:33 ` [PATCH 00/19] nvmet: add support for file backed namespaces Christoph Hellwig
2018-04-26 16:53 ` chaitany kulkarni
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=20180424172925.GC30391@lst.de \
--to=hch@lst.de \
/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.