From patchwork Thu Dec 15 22:13:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9477001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EA12C607EE for ; Thu, 15 Dec 2016 22:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB89A2885C for ; Thu, 15 Dec 2016 22:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D067728862; Thu, 15 Dec 2016 22:14:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B0952885C for ; Thu, 15 Dec 2016 22:14:19 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cHeI6-0007vO-Lp; Thu, 15 Dec 2016 22:14:18 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1cHeI5-0007vJ-FC for v9fs-developer@lists.sourceforge.net; Thu, 15 Dec 2016 22:14:17 +0000 X-ACL-Warn: Received: from mail.kernel.org ([198.145.29.136]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1cHeI4-0003qf-HD for v9fs-developer@lists.sourceforge.net; Thu, 15 Dec 2016 22:14:17 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F2C6920520; Thu, 15 Dec 2016 22:14:09 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4157820522; Thu, 15 Dec 2016 22:14:08 +0000 (UTC) From: Stefano Stabellini To: v9fs-developer@lists.sourceforge.net Date: Thu, 15 Dec 2016 14:13:54 -0800 Message-Id: <1481840034-2113-7-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481840034-2113-1-git-send-email-sstabellini@kernel.org> References: <1481840034-2113-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP X-Headers-End: 1cHeI4-0003qf-HD Cc: ericvh@gmail.com, rminnich@sandia.gov, sstabellini@kernel.org, linux-kernel@vger.kernel.org, lucho@ionkov.net Subject: [V9fs-developer] [PATCH v2 7/7] 9p: handle large aio write requests X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Virus-Scanned: ClamAV using ClamSMTP When an async write larger then msize-P9_IOHDRSZ is issued, do not limit the write size to msize-P9_IOHDRSZ. Instead, keep sending write requests from the completion function, until the original write is completed. Signed-off-by: Stefano Stabellini --- Is there a better way to reconstruct the from iov_iter? --- net/9p/client.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/net/9p/client.c b/net/9p/client.c index 8d2f8f7..89b2fee 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1806,7 +1806,6 @@ int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags) if (count > req->rsize) count = req->rsize; - err = count; file = req->kiocb->ki_filp; inode = file_inode(file); pg_start = req->kiocb->ki_pos >> PAGE_SHIFT; @@ -1821,9 +1820,73 @@ int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags) inode_add_bytes(inode, req->kiocb->ki_pos - i_size); i_size_write(inode, req->kiocb->ki_pos); } + + req->completed += count; + req->file_offset += count; + req->page_offset += count; + err = req->completed; + if (req->tot_size - req->completed > 0 && count == req->rsize) { + struct p9_req_t *req2; + struct iov_iter from; + struct kvec v[(clnt->msize - P9_IOHDRSZ + PAGE_SIZE) / PAGE_SIZE]; + u64 rsize = req->tot_size - req->completed; + u64 offset = req->page_offset % PAGE_SIZE; + u32 total = 0, n = 0; + int i, j; + + if (rsize > req->fid->iounit) + rsize = req->fid->iounit; + if (rsize > clnt->msize-P9_IOHDRSZ) + rsize = clnt->msize - P9_IOHDRSZ; + + for (j = 0, i = req->page_offset / PAGE_SIZE; + total < rsize; i++, j++) { + v[j].iov_base = kmap(req->pagevec[i]) + offset; + n = PAGE_SIZE - offset; + if (n > rsize - total) + n = rsize - total; + else + offset = 0; + v[j].iov_len = n; + total += n; + } + iov_iter_kvec(&from, WRITE|ITER_KVEC, v, i, rsize); + + req2 = p9_client_get_req(clnt, P9_TWRITE, "dqV", req->fid->fid, + req->file_offset, rsize, &from); + if (IS_ERR(req2)) { + err = PTR_ERR(req2); + goto out; + } + req2->fid = req->fid; + req2->rsize = rsize; + req2->completed = req->completed; + req2->tot_size = req->tot_size; + req2->file_offset = req->file_offset; + req2->page_offset = req->page_offset; + req2->kiocb = req->kiocb; + req2->pagevec = req->pagevec; + INIT_WORK(&req2->work, p9_client_write_complete); + + err = clnt->trans_mod->request(clnt, req2); + + for (i -= j; j > 0; i++, j--) + kunmap(req2->pagevec[i]); + + if (err < 0) { + clnt->status = Disconnected; + p9_free_req(clnt, req2); + goto out; + } + goto out2; + } + out: req->kiocb->ki_complete(req->kiocb, err, 0); + release_pages(req->pagevec, (req->tot_size + PAGE_SIZE - 1) / PAGE_SIZE, false); + kvfree(req->pagevec); +out2: p9_free_req(clnt, req); } @@ -1833,7 +1896,7 @@ int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags) { struct p9_client *clnt = fid->clnt; struct p9_req_t *req; - int total = 0; + int total = 0, i; *err = 0; p9_debug(P9_DEBUG_9P, ">>> TWRITE fid %d offset %llu count %zd\n", @@ -1868,14 +1931,22 @@ int p9_client_unlinkat(struct p9_fid *dfid, const char *name, int flags) } req->fid = fid; req->rsize = rsize; - req->tot_size = count; req->file_offset = offset; req->kiocb = iocb; INIT_WORK(&req->work, p9_client_write_complete); + req->tot_size = iov_iter_get_pages_alloc(from, &req->pagevec, + (size_t)count, &req->page_offset); + for (i = 0; i < req->tot_size; i += PAGE_SIZE) + page_cache_get_speculative(req->pagevec[i/PAGE_SIZE]); + *err = clnt->trans_mod->request(clnt, req); if (*err < 0) { clnt->status = Disconnected; + release_pages(req->pagevec, + (req->tot_size + PAGE_SIZE - 1) / PAGE_SIZE, + true); + kvfree(req->pagevec); p9_free_req(clnt, req); break; }