Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1136450ybg; Tue, 2 Jun 2020 02:14:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJymZqmGX3wnWMPmwfKbZ5l5pB0uicm7cQFbIFktirZTaQxJcjv7OOGcrhIbs1D9Wp8IZXa8 X-Received: by 2002:a17:906:da1e:: with SMTP id fi30mr23576996ejb.80.1591089268563; Tue, 02 Jun 2020 02:14:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591089268; cv=none; d=google.com; s=arc-20160816; b=w90Jw09kZwJFbHAHk8bUsUu3xv8k6DzGtYJouRK/b1xusYQ/oZJmiHb5z5087ACopc t5+NaRSOcB6acOOvkoluL9BLQ6cowDDTr0zHPTtwpBGDRY2ZcwJkb22IOFHQB8/bVfkj ZFQU279FPOFPeJZV32joVVoGZYEXLG4R9zsHGp8N3Bh9N5T4lYfvkAezFI6xTP4yS0Lo L8GB0CCn1nUbdHL8UFvLmi8SeYExBuR3OUEBw4WNUUIfOSL7ggppJuSxHJpj+nhdfg53 XWEEN7vhBB69+jvZd5KbQscLjhR2xMyKj9wirp/R6FTwpvWUomjjbAC78tBbx+dNV1dv ZAlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=i+YmGRN7636iI5JJc66Vbw+oIgUd8+8phYCpJr1ZGyg=; b=KlJmJOKCa8E+PB9qQWRbfubsbK3Iit0qMt1D4u0vE0BDroEQB6G90P3gNgAa9/cYGr 0iccQv41y7zQxIPGyXXolXsvOktI9i9vK4iqXcVwtTQDaMVSMyCoZONklEZTUYIW2V8c Ys4WDh45xMUvy1CY6fjHdHuYWqxw+QzcjhUOqKZvPZbtvqnrJRCcam5JxRhVvwgyMuNJ Idh2wv29IPeVHLpHT8FrolFYZ16lcfqoCvgDoNq0U8WOJY2YtwIrqfyWKZD7MPL5QGo/ 0BMm0Kdoxh0b/z45Cxc6wAFW+50rhs4EESVc4W+gmyowhR8Enu0QaCxSQOtMzcNlA6lk hLJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l10si1336541edi.562.2020.06.02.02.13.57; Tue, 02 Jun 2020 02:14:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726139AbgFBJNx (ORCPT + 99 others); Tue, 2 Jun 2020 05:13:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:45296 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725811AbgFBJNw (ORCPT ); Tue, 2 Jun 2020 05:13:52 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1B677AB64; Tue, 2 Jun 2020 09:13:54 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 509481E1282; Tue, 2 Jun 2020 11:13:51 +0200 (CEST) Date: Tue, 2 Jun 2020 11:13:51 +0200 From: Jan Kara To: "zhangyi (F)" Cc: linux-ext4@vger.kernel.org, jack@suse.cz Subject: Re: [PATCH] ext2: propagate errors up to ext2_find_entry()'s callers Message-ID: <20200602091351.GD19165@quack2.suse.cz> References: <20200601134222.37235-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200601134222.37235-1-yi.zhang@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 01-06-20 21:42:22, zhangyi (F) wrote: > The same to commit <36de928641ee4> (ext4: propagate errors up to > ext4_find_entry()'s callers') in ext4, also return error instead of NULL > pointer in case of some error happens in ext2_find_entry() (e.g. -ENOMEM > or -EIO). This could avoid a negative dentry cache entry installed even > it failed to read directory block due to IO error. > > Signed-off-by: zhangyi (F) > --- > fs/ext2/dir.c | 62 +++++++++++++++++++++++++------------------------ > fs/ext2/ext2.h | 3 ++- > fs/ext2/namei.c | 28 ++++++++++++++++++---- > 3 files changed, 58 insertions(+), 35 deletions(-) > > diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c > index 13318e255ebf..1c3ab60890b1 100644 > --- a/fs/ext2/dir.c > +++ b/fs/ext2/dir.c > @@ -347,8 +347,7 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir, > unsigned long npages = dir_pages(dir); > struct page *page = NULL; > struct ext2_inode_info *ei = EXT2_I(dir); > - ext2_dirent * de; > - int dir_has_error = 0; > + ext2_dirent *de, *ret = NULL; I don't think you need additional 'ret' variable and it does not improve the readability of the code either... You can just use 'de' all the time. Otherwise the patch looks good. I'd also note that all callers of ext2_find_entry() except for ext2_inode_by_name() transform de == NULL to -ENOENT so it would be a good followup cleanup to return -ENOENT directly from ext2_find_entry(). Also ext2_inode_by_name() could just pass -ENOENT further since only ext2_lookup() needs to actually transform this -ENOENT to calling d_splice_alias() with NULL inode. Thanks for the patch! Honza -- Jan Kara SUSE Labs, CR