From patchwork Thu Feb 27 21:10:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410121 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0AD1C92A for ; Thu, 27 Feb 2020 21:30:47 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7A5C20801 for ; Thu, 27 Feb 2020 21:30:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7A5C20801 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 943B33496D7; Thu, 27 Feb 2020 13:26:12 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 82C4E21FBBA for ; Thu, 27 Feb 2020 13:19:02 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 060861E86; Thu, 27 Feb 2020 16:18:15 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 047EA46D; Thu, 27 Feb 2020 16:18:15 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:10:16 -0500 Message-Id: <1582838290-17243-149-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 148/622] lustre: llite: optimize read on open pages X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jinshan Xiong , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Jinshan Xiong Current read-on-open implementation does allocate cl_page after data are piggied back by open request, which is expensive and not necessary. This patch improves the case by just adding the pages into page cache. As long as those pages will be discarded at lock revocation, there should be no concerns. WC-bug-id: https://jira.whamcloud.com/browse/LU-11427 Lustre-commit: 02e766f5ed95 ("LU-11427 llite: optimize read on open pages") Signed-off-by: Jinshan Xiong Reviewed-on: https://review.whamcloud.com/33234 Reviewed-by: Mike Pershin Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/llite/file.c | 58 +++++-------------------------------------------- fs/lustre/llite/namei.c | 7 +++++- 2 files changed, 11 insertions(+), 54 deletions(-) diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c index a46f5d3..2fd906f 100644 --- a/fs/lustre/llite/file.c +++ b/fs/lustre/llite/file.c @@ -420,14 +420,10 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, struct page *vmpage; struct niobuf_remote *rnb; char *data; - struct lu_env *env; - struct cl_io *io; - u16 refcheck; struct lustre_handle lockh; struct ldlm_lock *lock; unsigned long index, start; struct niobuf_local lnb; - int rc; bool dom_lock = false; if (!obj) @@ -440,37 +436,21 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, dom_lock = ldlm_has_dom(lock); LDLM_LOCK_PUT(lock); } - if (!dom_lock) return; - env = cl_env_get(&refcheck); - if (IS_ERR(env)) - return; - if (!req_capsule_has_field(&req->rq_pill, &RMF_NIOBUF_INLINE, - RCL_SERVER)) { - rc = -ENODATA; - goto out_env; - } + RCL_SERVER)) + return; rnb = req_capsule_server_get(&req->rq_pill, &RMF_NIOBUF_INLINE); - data = (char *)rnb + sizeof(*rnb); - - if (!rnb || rnb->rnb_len == 0) { - rc = 0; - goto out_env; - } + if (!rnb || rnb->rnb_len == 0) + return; CDEBUG(D_INFO, "Get data buffer along with open, len %i, i_size %llu\n", rnb->rnb_len, i_size_read(inode)); - io = vvp_env_thread_io(env); - io->ci_obj = obj; - io->ci_ignore_layout = 1; - rc = cl_io_init(env, io, CIT_MISC, obj); - if (rc) - goto out_io; + data = (char *)rnb + sizeof(*rnb); lnb.lnb_file_offset = rnb->rnb_offset; start = lnb.lnb_file_offset / PAGE_SIZE; @@ -478,8 +458,6 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, LASSERT(lnb.lnb_file_offset % PAGE_SIZE == 0); lnb.lnb_page_offset = 0; do { - struct cl_page *clp; - lnb.lnb_data = data + (index << PAGE_SHIFT); lnb.lnb_len = rnb->rnb_len - (index << PAGE_SHIFT); if (lnb.lnb_len > PAGE_SIZE) @@ -495,35 +473,9 @@ void ll_dom_finish_open(struct inode *inode, struct ptlrpc_request *req, PTR_ERR(vmpage)); break; } - lock_page(vmpage); - if (!vmpage->mapping) { - unlock_page(vmpage); - put_page(vmpage); - /* page was truncated */ - rc = -ENODATA; - goto out_io; - } - clp = cl_page_find(env, obj, vmpage->index, vmpage, - CPT_CACHEABLE); - if (IS_ERR(clp)) { - unlock_page(vmpage); - put_page(vmpage); - rc = PTR_ERR(clp); - goto out_io; - } - - /* export page */ - cl_page_export(env, clp, 1); - cl_page_put(env, clp); - unlock_page(vmpage); put_page(vmpage); index++; } while (rnb->rnb_len > (index << PAGE_SHIFT)); - rc = 0; -out_io: - cl_io_fini(env, io); -out_env: - cl_env_put(env, &refcheck); } static int ll_intent_file_open(struct dentry *de, void *lmm, int lmmsize, diff --git a/fs/lustre/llite/namei.c b/fs/lustre/llite/namei.c index 4ac62b2..530c2df 100644 --- a/fs/lustre/llite/namei.c +++ b/fs/lustre/llite/namei.c @@ -185,8 +185,13 @@ int ll_dom_lock_cancel(struct inode *inode, struct ldlm_lock *lock) int rc; u16 refcheck; - if (!lli->lli_clob) + if (!lli->lli_clob) { + /* Due to DoM read on open, there may exist pages for Lustre + * regular file even though cl_object is not set up yet. + */ + truncate_inode_pages(inode->i_mapping, 0); return 0; + } env = cl_env_get(&refcheck); if (IS_ERR(env))