mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org,
	Andreas Dilger <andreas.dilger@intel.com>,
	James Simmons <jsimmons@infradead.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Lustre Development List <lustre-devel@lists.lustre.org>,
	Andrew Perepechko <andrew.perepechko@seagate.com>,
	Oleg Drokin <green@linuxhacker.ru>
Subject: [PATCH 06/14] staging/lustre/llite: drop_caches hangs in cl_inode_fini()
Date: Wed,  2 Nov 2016 21:24:56 -0400	[thread overview]
Message-ID: <1478136304-867780-7-git-send-email-green@linuxhacker.ru> (raw)
In-Reply-To: <1478136304-867780-1-git-send-email-green@linuxhacker.ru>

From: Andrew Perepechko <andrew.perepechko@seagate.com>

This patch releases cl_pages on error in ll_write_begin()
to avoid memory and object reference leaks. Also, it
reuses per-cpu lu_env in ll_invalidatepage() in the same
way as done in ll_releasepage().

Signed-off-by: Andrew Perepechko <andrew.perepechko@seagate.com>
Seagate-bug-id: MRP-3504
Reviewed-on: http://review.whamcloud.com/22745
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8509
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
---
 drivers/staging/lustre/lustre/llite/rw26.c | 36 ++++++++++++++++--------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index 1a08a9d..ca45b44 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -71,8 +71,6 @@ static void ll_invalidatepage(struct page *vmpage, unsigned int offset,
 	struct cl_page   *page;
 	struct cl_object *obj;
 
-	int refcheck;
-
 	LASSERT(PageLocked(vmpage));
 	LASSERT(!PageWriteback(vmpage));
 
@@ -82,21 +80,21 @@ static void ll_invalidatepage(struct page *vmpage, unsigned int offset,
 	 * happening with locked page too
 	 */
 	if (offset == 0 && length == PAGE_SIZE) {
-		env = cl_env_get(&refcheck);
-		if (!IS_ERR(env)) {
-			inode = vmpage->mapping->host;
-			obj = ll_i2info(inode)->lli_clob;
-			if (obj) {
-				page = cl_vmpage_page(vmpage, obj);
-				if (page) {
-					cl_page_delete(env, page);
-					cl_page_put(env, page);
-				}
-			} else {
-				LASSERT(vmpage->private == 0);
+		/* See the comment in ll_releasepage() */
+		env = cl_env_percpu_get();
+		LASSERT(!IS_ERR(env));
+		inode = vmpage->mapping->host;
+		obj = ll_i2info(inode)->lli_clob;
+		if (obj) {
+			page = cl_vmpage_page(vmpage, obj);
+			if (page) {
+				cl_page_delete(env, page);
+				cl_page_put(env, page);
 			}
-			cl_env_put(env, &refcheck);
+		} else {
+			LASSERT(vmpage->private == 0);
 		}
+		cl_env_percpu_put(env);
 	}
 }
 
@@ -466,9 +464,9 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 			  struct page **pagep, void **fsdata)
 {
 	struct ll_cl_context *lcc;
-	const struct lu_env  *env;
+	const struct lu_env *env = NULL;
 	struct cl_io   *io;
-	struct cl_page *page;
+	struct cl_page *page = NULL;
 	struct cl_object *clob = ll_i2info(mapping->host)->lli_clob;
 	pgoff_t index = pos >> PAGE_SHIFT;
 	struct page *vmpage = NULL;
@@ -556,6 +554,10 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
 			unlock_page(vmpage);
 			put_page(vmpage);
 		}
+		if (!IS_ERR_OR_NULL(page)) {
+			lu_ref_del(&page->cp_reference, "cl_io", io);
+			cl_page_put(env, page);
+		}
 	} else {
 		*pagep = vmpage;
 		*fsdata = lcc;
-- 
2.7.4

  parent reply	other threads:[~2016-11-03  1:26 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-03  1:24 [PATCH 00/14] Lustre fixes Oleg Drokin
2016-11-03  1:24 ` [PATCH 01/14] staging/lustre/ldlm: Drop unused blocking_refs flock field Oleg Drokin
2016-11-07  1:38   ` James Simmons
2016-11-03  1:24 ` [PATCH 02/14] staging/lustre/ldlm: fix export reference problem Oleg Drokin
2016-11-07  1:37   ` James Simmons
2016-11-03  1:24 ` [PATCH 03/14] staging/lustre: conflicting PW & PR extent locks on a client Oleg Drokin
2016-11-07  1:52   ` James Simmons
2016-11-03  1:24 ` [PATCH 04/14] staging/lustre/llite: clear inode timestamps after losing UPDATE lock Oleg Drokin
2016-11-07  1:38   ` James Simmons
2016-11-03  1:24 ` [PATCH 05/14] staging/lustre: Get rid of cl_env hash table Oleg Drokin
2016-11-07  1:53   ` James Simmons
2016-11-03  1:24 ` Oleg Drokin [this message]
2016-11-07  1:54   ` [PATCH 06/14] staging/lustre/llite: drop_caches hangs in cl_inode_fini() James Simmons
2016-11-03  1:24 ` [PATCH 07/14] staging/lustre/ldlm: Reinstate ldlm_enqueue_pack() Oleg Drokin
2016-11-07  1:53   ` James Simmons
2016-11-03  1:24 ` [PATCH 08/14] staging/lustre/ldlm: engage ELC for all ldlm enqueue req Oleg Drokin
2016-11-07  1:55   ` James Simmons
2016-11-03  1:24 ` [PATCH 09/14] staging/lustre/ptlrpc: Suppress error for flock requests Oleg Drokin
2016-11-07  1:57   ` James Simmons
2016-11-03  1:25 ` [PATCH 10/14] staging/lustre/llite: protect from accessing NULL lli_clob Oleg Drokin
2016-11-07  1:55   ` James Simmons
2016-11-03  1:25 ` [PATCH 11/14] staging/lustre/ptlrpc: Correctly calculate hrp->hrp_nthrs Oleg Drokin
2016-11-07  1:58   ` James Simmons
2016-11-03  1:25 ` [PATCH 12/14] staging/lustre/llite: update ras window correctly Oleg Drokin
2016-11-07  1:57   ` James Simmons
2016-11-03  1:25 ` [PATCH 13/14] staging/lustre/llite: do not clear uptodate bit in page delete Oleg Drokin
2016-11-07  1:56   ` James Simmons
2016-11-03  1:25 ` [PATCH 14/14] staging/lustre: Get rid of LIBLUSTRE_CLIENT and its users Oleg Drokin
2016-11-07  1:56   ` James Simmons

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=1478136304-867780-7-git-send-email-green@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=andreas.dilger@intel.com \
    --cc=andrew.perepechko@seagate.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.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

Powered by JetHome