From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753066AbcHVIuf (ORCPT ); Mon, 22 Aug 2016 04:50:35 -0400 Received: from lucky1.263xmail.com ([211.157.147.134]:36931 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751287AbcHVIue (ORCPT ); Mon, 22 Aug 2016 04:50:34 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: oleg.drokin@intel.com X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <90d56d206c34b46c66eaccb418c13f70> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Shawn Lin To: Oleg Drokin , Andreas Dilger , lustre-devel@lists.lustre.org, devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Shawn Lin Subject: [PATCH] staging/lustre: avoid zero buf for the first time Date: Mon, 22 Aug 2016 16:46:04 +0800 Message-Id: <1471855564-15962-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.8.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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