mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.com>
To: "Eremin\, Dmitry" <dmitry.eremin@intel.com>, "Drokin\,
	Oleg" <oleg.drokin@intel.com>,
	"James Simmons" <jsimmons@infradead.org>, "Dilger\,
	Andreas" <andreas.dilger@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
	lustre <lustre-devel@lists.lustre.org>
Subject: RE: [lustre-devel] [PATCH 14/21] staging: lustre: fix assorted checkpatch errors
Date: Tue, 20 Feb 2018 19:55:30 +1100	[thread overview]
Message-ID: <87lgfojb0d.fsf@notabene.neil.brown.name> (raw)
In-Reply-To: <9FC73D3DBECE0941BD2ED069D26863425CE8FF1E@irsmsx110.ger.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2202 bytes --]

On Tue, Feb 20 2018, Eremin, Dmitry wrote:

> Hello Neil,
>
>> diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> index ab48746ce433..bde27acb0dd3 100644
>> --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
>> @@ -1060,8 +1060,10 @@ static void mdc_adjust_dirpages(struct page
>> **pages, int cfs_pgs, int lu_pgs)
>> 
>>  		while (--lu_pgs > 0) {
>>  			ent = lu_dirent_start(dp);
>> -			for (end_dirent = ent; ent;
>> -			     end_dirent = ent, ent = lu_dirent_next(ent));
>> +			while (ent) {
>> +				end_dirent = ent;
>> +				ent = lu_dirent_next(ent);
>> +			}
>> 
>>  			/* Advance dp to next lu_dirpage. */
>>  			dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
>
> I doubt this is correct replacement. In original code end_dirent is
> set always in the begin of outer loop (while (--lu_pgs > 0)). But in
> new code this is missed. Therefore in case of second iteration and
> (ent = lu_dirent_start(dp)) == NULL the end_dirent will contain a
> value from previous iteration which is not correct.

Thanks for the review.  Yes, you are correct.
I had seen that end_dirent was initialized to NULL, and let myself
believe that would make the transformation safe.
In fact, that initialization to NULL is pointless as it is never used.

Maybe this would be better

@@ -1055,13 +1055,14 @@ static void mdc_adjust_dirpages(struct page **pages, int cfs_pgs, int lu_pgs)
 		__u64 hash_end = le64_to_cpu(dp->ldp_hash_end);
 		__u32 flags = le32_to_cpu(dp->ldp_flags);
 		struct lu_dirpage *first = dp;
-		struct lu_dirent *end_dirent = NULL;
-		struct lu_dirent *ent;
 
 		while (--lu_pgs > 0) {
-			ent = lu_dirent_start(dp);
-			for (end_dirent = ent; ent;
-			     end_dirent = ent, ent = lu_dirent_next(ent));
+			struct lu_dirent *end_dirent = NULL;
+			struct lu_dirent *ent;
+
+			for (ent = lu_dirent_start(dp); ent;
+			     ent = lu_dirent_next(ent))
+				end_dirent = ent;
 
 			/* Advance dp to next lu_dirpage. */
 			dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);


??

Thanks,
NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

  reply	other threads:[~2018-02-20  8:55 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  2:23 [PATCH 00/21] staging: assorted lustre clean-up NeilBrown
2018-02-20  2:23 ` [PATCH 08/21] staging: lustre: make signal-blocking functions inline NeilBrown
2018-02-20  2:23 ` [PATCH 05/21] staging: lustre: lnet: remove cfs_block_allsigs calls NeilBrown
2018-02-20  2:23 ` [PATCH 09/21] staging: lustre: discard libcfs_kvzalloc_cpt() NeilBrown
2018-02-20  2:23 ` [PATCH 06/21] staging: lustre: simplify linux-prim.c NeilBrown
2018-02-20  2:23 ` [PATCH 11/21] staging: lustre: improve some libcfs_kvzalloc calls NeilBrown
2018-02-20  2:23 ` [PATCH 10/21] staging: lustre: discard lu_buf allocation library NeilBrown
2018-02-20  2:23 ` [PATCH 01/21] staging: lustre: replace all CFS_CAP_* macros with CAP_* NeilBrown
2018-02-20  2:23 ` [PATCH 03/21] staging: lustre: remove linux-curproc.c NeilBrown
2018-02-20  2:23 ` [PATCH 12/21] staging: lustre: discard libcfs_kvzalloc and linux-mem.c NeilBrown
2018-02-20  2:23 ` [PATCH 04/21] staging: lustre: remove unnecessary cfs_block_allsigs() calls NeilBrown
2018-02-20  2:23 ` [PATCH 07/21] staging: lustre: improve API and implementation of blocking signals NeilBrown
2018-02-20  2:23 ` [PATCH 02/21] staging: lustre: opencode cfs_cap_{raise, lower, raised} NeilBrown
2018-02-20  2:23 ` [PATCH 19/21] staging: lustre: fid: fix up debugfs access to ->lcs_space NeilBrown
2018-02-20  2:23 ` [PATCH 20/21] staging: lustre: fid: perform sanity checks before commiting NeilBrown
2018-02-20  2:23 ` [PATCH 16/21] staging: lustre: fid: convert lcs_mutex to a spinlock NeilBrown
2018-02-20  2:23 ` [PATCH 14/21] staging: lustre: fix assorted checkpatch errors NeilBrown
2018-02-20  8:07   ` [lustre-devel] " Eremin, Dmitry
2018-02-20  8:55     ` NeilBrown [this message]
2018-02-20 10:50       ` Eremin, Dmitry
2018-02-20 20:42   ` [PATCH 14/21 - v2] " NeilBrown
2018-02-20  2:23 ` [PATCH 21/21] staging: lustre: socklnd: simplify ksnc_rx_iov_space NeilBrown
2018-02-20  2:23 ` [PATCH 18/21] staging: lustre: fid: remove seq_fid_alloc_fini() and simplify NeilBrown
2018-02-20  2:23 ` [PATCH 17/21] staging: lustre: fid: use wait_event_cmd() NeilBrown
2018-02-20  2:23 ` [PATCH 13/21] staging: lustre: remove phantom struct cfs_crypto_hash_desc NeilBrown
2018-02-20  2:23 ` [PATCH 15/21] staging: lustre: ptlrpc: list_for_each improvements NeilBrown
2018-02-20  4:18 ` [lustre-devel] [PATCH 00/21] staging: assorted lustre clean-up Patrick Farrell

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=87lgfojb0d.fsf@notabene.neil.brown.name \
    --to=neilb@suse.com \
    --cc=andreas.dilger@intel.com \
    --cc=dmitry.eremin@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jsimmons@infradead.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

all inboxes | Powered by JetHome®