linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Shawn Lin <shawn.lin@rock-chips.com>
To: Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>,
	lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org,
	Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH] staging/lustre: avoid zero buf for the first time
Date: Mon, 22 Aug 2016 16:46:04 +0800	[thread overview]
Message-ID: <1471855564-15962-1-git-send-email-shawn.lin@rock-chips.com> (raw)

We only need to zero it when repeating in order to
avoid old garbage. Let's improve it by moving this
before we repeat the calculation to save some cpu
cycle.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---

 drivers/staging/lustre/lustre/obdclass/llog.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 1784ca0..923061f 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -248,8 +248,6 @@ repeat:
 		CDEBUG(D_OTHER, "index: %d last_index %d\n",
 		       index, last_index);
 
-		/* get the buf with our target record; avoid old garbage */
-		memset(buf, 0, LLOG_CHUNK_SIZE);
 		last_offset = cur_offset;
 		rc = llog_next_block(lpi->lpi_env, loghandle, &saved_index,
 				     index, &cur_offset, buf, LLOG_CHUNK_SIZE);
@@ -275,8 +273,11 @@ repeat:
 			if (rec->lrh_index == 0) {
 				/* probably another rec just got added? */
 				rc = 0;
-				if (index <= loghandle->lgh_last_idx)
+				if (index <= loghandle->lgh_last_idx) {
+					/* avoid old garbage */
+					memset(buf, 0, LLOG_CHUNK_SIZE);
 					goto repeat;
+				}
 				goto out; /* no more records */
 			}
 			if (rec->lrh_len == 0 ||
-- 
2.3.7

             reply	other threads:[~2016-08-22  8:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-22  8:46 Shawn Lin [this message]
2016-08-22 10:04 ` [PATCH] staging/lustre: avoid zero buf for the first time Greg Kroah-Hartman
2016-08-26 19:48   ` Oleg Drokin

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=1471855564-15962-1-git-send-email-shawn.lin@rock-chips.com \
    --to=shawn.lin@rock-chips.com \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.com \
    /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).