lustre-devel-lustre.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection
Date: Sun, 13 Dec 2015 14:58:33 +0100	[thread overview]
Message-ID: <566D7989.6090205@users.sourceforge.net> (raw)
In-Reply-To: <566D7733.1030102@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 13:03:58 +0100

A few checks would be performed by the mgc_process_recover_log() function
even if it was determined that a call of the alloc_page() function failed.

* This implementation detail could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* Move the assignment for the variable "eof" behind the memory allocation.

* Delete another sanity check then.

* The variable "req" will eventually be set to an appropriate pointer
  from a call of the ptlrpc_request_alloc() function.
  Thus let us omit the explicit initialisation before.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 32 +++++++++++--------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index f3b4c30..7048722 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1312,17 +1312,15 @@ static int mgc_process_recover_log(struct obd_device *obd,
 	if (!pages)
 		return -ENOMEM;
 
-	req = NULL;
-	eof = true;
-
 	for (i = 0; i < nrpages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
 		if (pages[i] == NULL) {
 			rc = -ENOMEM;
-			goto out;
+			goto free_pages;
 		}
 	}
 
+	eof = true;
 again:
 	LASSERT(cld_is_recover(cld));
 	LASSERT(mutex_is_locked(&cld->cld_lock));
@@ -1330,12 +1328,12 @@ again:
 				   &RQF_MGS_CONFIG_READ);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto free_pages;
 	}
 
 	rc = ptlrpc_request_pack(req, LUSTRE_MGS_VERSION, MGS_CONFIG_READ);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	/* pack request */
 	body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
@@ -1344,7 +1342,7 @@ again:
 	if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
 	    >= sizeof(body->mcb_name)) {
 		rc = -E2BIG;
-		goto out;
+		goto finish_request;
 	}
 	body->mcb_offset = cfg->cfg_last_idx + 1;
 	body->mcb_type   = cld->cld_type;
@@ -1356,7 +1354,7 @@ again:
 				    MGS_BULK_PORTAL);
 	if (desc == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	for (i = 0; i < nrpages; i++)
@@ -1365,12 +1363,12 @@ again:
 	ptlrpc_request_set_replen(req);
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	res = req_capsule_server_get(&req->rq_pill, &RMF_MGS_CONFIG_RES);
 	if (res->mcr_size < res->mcr_offset) {
 		rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	/* always update the index even though it might have errors with
@@ -1384,18 +1382,18 @@ again:
 	ealen = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, 0);
 	if (ealen < 0) {
 		rc = ealen;
-		goto out;
+		goto finish_request;
 	}
 
 	if (ealen > nrpages << PAGE_CACHE_SHIFT) {
 		rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	if (ealen == 0) { /* no logs transferred */
 		if (!eof)
 			rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	mne_swab = !!ptlrpc_rep_need_swab(req);
@@ -1425,14 +1423,12 @@ again:
 
 		ealen -= PAGE_CACHE_SIZE;
 	}
-
-out:
-	if (req)
-		ptlrpc_req_finished(req);
+finish_request:
+	ptlrpc_req_finished(req);
 
 	if (rc == 0 && !eof)
 		goto again;
-
+free_pages:
 	for (i = 0; i < nrpages; i++) {
 		if (pages[i] == NULL)
 			break;
-- 
2.6.3

  parent reply	other threads:[~2015-12-13 13:58 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-13 13:48 ` [lustre-devel] [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
2015-12-13 13:52   ` [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
2015-12-15 14:27     ` Joe Perches
2015-12-15 14:41       ` Dan Carpenter
2015-12-15 15:02         ` Joe Perches
2015-12-15 17:48           ` Dan Carpenter
2015-12-15 18:10             ` Joe Perches
2015-12-15 18:26               ` [lustre-devel] " SF Markus Elfring
2015-12-15 18:34                 ` Joe Perches
2015-12-15 18:49                   ` SF Markus Elfring
2015-12-15 18:55                     ` Joe Perches
2015-12-15 18:02           ` SF Markus Elfring
2015-12-15 18:22             ` Joe Perches
2015-12-13 13:54   ` [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
2015-12-14  6:53     ` Dan Carpenter
2015-12-14  9:08       ` SF Markus Elfring
2015-12-14  9:31         ` Dan Carpenter
2015-12-14 10:03           ` [lustre-devel] " SF Markus Elfring
2015-12-13 13:55   ` [lustre-devel] [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring
2015-12-13 13:56   ` [lustre-devel] [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
2015-12-13 13:57   ` [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
2015-12-14 11:00     ` Dan Carpenter
2015-12-14 12:04       ` SF Markus Elfring
2015-12-14 12:38         ` Dan Carpenter
2015-12-14 12:45           ` [lustre-devel] " SF Markus Elfring
2015-12-14 13:57             ` Dan Carpenter
2015-12-14 17:43               ` SF Markus Elfring
2015-12-15 11:42                 ` Dan Carpenter
2015-12-15 15:00                   ` SF Markus Elfring
2015-12-13 13:58   ` SF Markus Elfring [this message]
2015-12-13 14:00   ` [lustre-devel] [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring
     [not found]   ` <56784D83.7080108@users.sourceforge.net>
     [not found]     ` <56784F0C.6040007@users.sourceforge.net>
     [not found]       ` <20151221234857.GA27079@kroah.com>
2016-07-26 18:54         ` [lustre-devel] [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
2016-07-26 18:56           ` [lustre-devel] [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
2016-07-26 19:00           ` [lustre-devel] [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put" SF Markus Elfring
2016-07-26 19:02           ` [lustre-devel] [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
2016-07-26 19:08             ` Oleg Drokin
2016-07-26 19:56               ` [lustre-devel] " SF Markus Elfring
2016-07-26 21:49                 ` Oleg Drokin
2016-07-28  5:53                   ` SF Markus Elfring
2016-07-29 15:28                     ` Oleg Drokin
2016-07-30  6:24                       ` SF Markus Elfring
2016-07-26 19:04           ` [lustre-devel] [PATCH 04/12] staging: lustre: Split a condition check in class_register_type() SF Markus Elfring
2016-07-26 19:05           ` [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
2016-07-26 19:11             ` Oleg Drokin
2016-07-26 19:16               ` Oleg Drokin
2016-07-26 20:11               ` [lustre-devel] " SF Markus Elfring
2016-07-26 19:07           ` [lustre-devel] [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log() SF Markus Elfring
2016-07-26 19:08           ` [lustre-devel] [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() " SF Markus Elfring
2016-07-26 19:09           ` [lustre-devel] [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() " SF Markus Elfring
2016-07-26 19:10           ` [lustre-devel] [PATCH 09/12] staging: lustre: Delete a check for the variable "req" " SF Markus Elfring
2016-07-26 19:12           ` [lustre-devel] [PATCH 10/12] staging: lustre: Rename jump labels " SF Markus Elfring
2016-07-26 19:13           ` [lustre-devel] [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" " SF Markus Elfring
2016-07-26 19:14           ` [lustre-devel] [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-08-21  9:45 ` [lustre-devel] [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation SF Markus Elfring

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=566D7989.6090205@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --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;
as well as URLs for NNTP newsgroup(s).