From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F80E155757 for ; Mon, 15 Jun 2026 01:26:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781486788; cv=none; b=Uvwh39lyLjxczSECaAVJ8B9GIA2Ar0lCHC4ZhAhewZG+s1JBnBgqR4v6Y5eUrlUhpVx6HLiSPoxcrAxnUlfG50LVP2bCL+IwuF5/uTGLqGtGi5wHo0rikTEhUzjABCbufLFAOdiWvTLqDVSJU87LvlNM627g3iqi99O4LUnH0Ec= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781486788; c=relaxed/simple; bh=SjtRPrmjS32x6SvKtWYUxC8SwoAp7NWMDt4dHE82gW8=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=EcRMLmherxqbsLLvM+Om4HfVmtuUyLaDnHaQkSHkr9SJk3BNZcLc/Zvr4cvz1WPKQjbA3w8weyJBgw9EImhRHhG6NWmBBMYh/v/ujT4+vR52VHYXVRdpQQ0LXRj685Qsfr1JQbyTHAXyIgTiiMykgWKepaGJ0sEEYZiynSOQKpg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=B+zuHAA9; arc=none smtp.client-ip=113.46.200.226 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="B+zuHAA9" dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=tIUCnVj6NdE+05UAjJNPyabizqyUB0Qk7xKO+9pSNys=; b=B+zuHAA9hrVqGLRH1sovzRe30h42jjkMT/0SjUlD1m5flyS8d6NCFlKWYKDTI51uj88XH+8po VELHh9jP4zU8SuQ4s1rabJIH9OJndaUnrF3sv9UBVQcvdzZZWQWuocjbgsb3s6LtWaQK0JF1OxD 2qoIW1AZHYLwhtgwWy0wskY= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4gdsgr05QtzKm4v; Mon, 15 Jun 2026 09:18:16 +0800 (CST) Received: from kwepemr500015.china.huawei.com (unknown [7.202.195.162]) by mail.maildlp.com (Postfix) with ESMTPS id 903004048B; Mon, 15 Jun 2026 09:26:15 +0800 (CST) Received: from [10.67.111.104] (10.67.111.104) by kwepemr500015.china.huawei.com (7.202.195.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Mon, 15 Jun 2026 09:26:15 +0800 Message-ID: <51c13a05-a4f5-4bbe-ad1a-ba167fa2e76c@huawei.com> Date: Mon, 15 Jun 2026 09:26:14 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs: clean up erofs_ishare_fill_inode() To: Gao Xiang , CC: LKML , References: <20260607172132.2695176-1-hsiangkao@linux.alibaba.com> Content-Language: en-US From: Hongbo Li In-Reply-To: <20260607172132.2695176-1-hsiangkao@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemr500015.china.huawei.com (7.202.195.162) On 2026/6/8 1:21, Gao Xiang wrote: > - Use the shorthand `si` to replace the overly long `sharedinode`; > > - Introduce erofs_warn() and get rid of barely-used _erofs_printk(); > > - Get rid of the variable `hash`; > > - Simplify error paths. > > Cc: Hongbo Li > Signed-off-by: Gao Xiang Reviewed-by: Hongbo Li Thanks, Hongbo > --- > fs/erofs/internal.h | 2 ++ > fs/erofs/ishare.c | 45 +++++++++++++++++++-------------------------- > 2 files changed, 21 insertions(+), 26 deletions(-) > > diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h > index 4792490161ec..9e2ae7b61977 100644 > --- a/fs/erofs/internal.h > +++ b/fs/erofs/internal.h > @@ -23,6 +23,8 @@ > __printf(2, 3) void _erofs_printk(struct super_block *sb, const char *fmt, ...); > #define erofs_err(sb, fmt, ...) \ > _erofs_printk(sb, KERN_ERR fmt "\n", ##__VA_ARGS__) > +#define erofs_warn(sb, fmt, ...) \ > + _erofs_printk(sb, KERN_WARNING fmt "\n", ##__VA_ARGS__) > #define erofs_info(sb, fmt, ...) \ > _erofs_printk(sb, KERN_INFO fmt "\n", ##__VA_ARGS__) > > diff --git a/fs/erofs/ishare.c b/fs/erofs/ishare.c > index 6ed66b17359b..35cbd0bc04d7 100644 > --- a/fs/erofs/ishare.c > +++ b/fs/erofs/ishare.c > @@ -40,49 +40,42 @@ static int erofs_ishare_iget5_set(struct inode *inode, void *data) > bool erofs_ishare_fill_inode(struct inode *inode) > { > struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); > - struct erofs_inode *vi = EROFS_I(inode); > const struct address_space_operations *aops; > + struct erofs_inode *vi = EROFS_I(inode); > struct erofs_inode_fingerprint fp; > - struct inode *sharedinode; > - unsigned long hash; > + struct inode *si; > > aops = erofs_get_aops(inode, true); > if (IS_ERR(aops)) > return false; > if (erofs_xattr_fill_inode_fingerprint(&fp, inode, sbi->domain_id)) > return false; > - hash = xxh32(fp.opaque, fp.size, 0); > - sharedinode = iget5_locked(erofs_ishare_mnt->mnt_sb, hash, > - erofs_ishare_iget5_eq, erofs_ishare_iget5_set, > - &fp); > - if (!sharedinode) { > - kfree(fp.opaque); > - return false; > - } > > - if (inode_state_read_once(sharedinode) & I_NEW) { > - sharedinode->i_mapping->a_ops = aops; > - sharedinode->i_size = vi->vfs_inode.i_size; > - unlock_new_inode(sharedinode); > + si = iget5_locked(erofs_ishare_mnt->mnt_sb, > + xxh32(fp.opaque, fp.size, 0), > + erofs_ishare_iget5_eq, erofs_ishare_iget5_set, &fp); > + if (si && (inode_state_read_once(si) & I_NEW)) { > + si->i_mapping->a_ops = aops; > + si->i_size = inode->i_size; > + unlock_new_inode(si); > } else { > kfree(fp.opaque); > - if (aops != sharedinode->i_mapping->a_ops) { > - iput(sharedinode); > + if (!si || aops != si->i_mapping->a_ops) { > + iput(si); > return false; > } > - if (sharedinode->i_size != vi->vfs_inode.i_size) { > - _erofs_printk(inode->i_sb, KERN_WARNING > - "size(%lld:%lld) not matches for the same fingerprint\n", > - vi->vfs_inode.i_size, sharedinode->i_size); > - iput(sharedinode); > + if (si->i_size != inode->i_size) { > + erofs_warn(inode->i_sb, "i_size mismatch (%lld != %lld) for the same fingerprint", > + inode->i_size, si->i_size); > + iput(si); > return false; > } > } > - vi->sharedinode = sharedinode; > + vi->sharedinode = si; > INIT_LIST_HEAD(&vi->ishare_list); > - spin_lock(&EROFS_I(sharedinode)->ishare_lock); > - list_add(&vi->ishare_list, &EROFS_I(sharedinode)->ishare_list); > - spin_unlock(&EROFS_I(sharedinode)->ishare_lock); > + spin_lock(&EROFS_I(si)->ishare_lock); > + list_add(&vi->ishare_list, &EROFS_I(si)->ishare_list); > + spin_unlock(&EROFS_I(si)->ishare_lock); > return true; > } >