Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756888AbYFOHrW (ORCPT ); Sun, 15 Jun 2008 03:47:22 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755904AbYFOHrJ (ORCPT ); Sun, 15 Jun 2008 03:47:09 -0400 Received: from rv-out-0506.google.com ([209.85.198.238]:57077 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755803AbYFOHrF (ORCPT ); Sun, 15 Jun 2008 03:47:05 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=gsGv1ME8lyPzss9AyzNWGr0ZKvqmY4v96N56C/QILDpADm9XDJlqH6tidPL9vUzVzW 5TqPNv096L+SDF014tFYYhbLBv9fLDWOa8eYp6/NfUXPPYOQ26vFVHVbAl/dsEgWlJQb wP36+10x/h6AZ5UeUI06EsKqg+F4y+U/T3rpU= Message-ID: <19f34abd0806150047w4338502en9a75681fb0c95438@mail.gmail.com> Date: Sun, 15 Jun 2008 09:47:03 +0200 From: "Vegard Nossum" To: "Evgeniy Polyakov" Subject: Re: [3/3] POHMELFS high performance network filesystem. Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org In-Reply-To: <20080613164241.GC26166@2ka.mipt.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080613163700.GA25860@2ka.mipt.ru> <20080613164241.GC26166@2ka.mipt.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2980 Lines: 89 Hi, I have just one question yet :-) On Fri, Jun 13, 2008 at 6:42 PM, Evgeniy Polyakov wrote: > +int pohmelfs_copy_config(struct pohmelfs_sb *psb) > +{ > + struct pohmelfs_config *c, *dst; > + int err = -ENODEV; > + > + mutex_lock(&pohmelfs_config_lock); > + list_for_each_entry(c, &pohmelfs_config_list, config_entry) { > + if (c->state.ctl.idx != psb->idx) > + continue; > + > + err = 0; > + list_for_each_entry(dst, &psb->state_list, config_entry) { > + if (pohmelfs_config_eql(&dst->state.ctl, &c->state.ctl)) { > + err = -EEXIST; > + break; > + } > + } > + > + if (err) > + continue; > + > + dst = kzalloc(sizeof(struct pohmelfs_config), GFP_KERNEL); > + if (!dst) { > + err = -ENOMEM; > + goto err_out_unlock; > + } > + > + memcpy(&dst->state.ctl, &c->state.ctl, sizeof(struct pohmelfs_ctl)); > + > + list_add_tail(&dst->config_entry, &psb->state_list); > + > + err = pohmelfs_state_init_one(psb, dst); > + if (err) { > + list_del(&dst->config_entry); > + kfree(dst); > + } > + } > + mutex_unlock(&pohmelfs_config_lock); > + > + return err; > + > +err_out_unlock: > + mutex_unlock(&pohmelfs_config_lock); > + > + mutex_lock(&psb->state_lock); > + list_for_each_entry_safe(dst, c, &psb->state_list, config_entry) { > + list_del(&dst->config_entry); > + kfree(dst); > + } > + mutex_unlock(&psb->state_lock); > + > + return err; > +} I'm having a hard time convincing myself that the error handling here is correct. You have this kind of setup: 1. for each config in config list { 2. for each config in superblock state list { pohmelfs_config_eql(); ... } } And according to your code, if pohmelfs_config_eql returns non-zero in the last iteration of #1, then -EEXISTS will be the return value of the whole function (but the config _will_ be copied; it is not undone in this case). But if pohmenlfs_config_eql returns non-zero in any but the last iteration of #1, then 0 will be the return value. Is this your intention? Vegard -- "The animistic metaphor of the bug that maliciously sneaked in while the programmer was not looking is intellectually dishonest as it disguises that the error is the programmer's own creation." -- E. W. Dijkstra, EWD1036 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/