From nobody Mon Jun 8 04:24:54 2026 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (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 2D5A529E0F6 for ; Sun, 7 Jun 2026 17:27:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780853226; cv=none; b=FupsQhvGD+EFXWE6tlTdzEFLGGXnzpea/uC/HVOqkpgFQamHQGaBcTxl87D0kGDnu1O3o7LYF9Oje3zQ5/SVIBspD3+AG4tM7cQwdMmMlCFDLORPOcrlAeLeWVEi7pVQytG2lNLFPe+ioMNl4NHzqpJoICTEyDdQqJc93KqdkPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780853226; c=relaxed/simple; bh=EzEa0Vbt7/NkTw70xSQHoCMhyt6Fqyno2dWNcwuAa0s=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ji8B5Zk2Ud1t130wvyfGjdFo1+6m95wsalZTMTG81sjPJpEVliz7Eg6cImqGj1o/1pp/UFEe/nfgyqC1ti+CBZRu68UqZkFc1ypUA9hQ1lG0IFFRiEEqrxaOcmn0Dm/OhPOf56giKKAZpl/aYaaG7iXZvkHCZNhOKJgj719cOmg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=R4z7ichG; arc=none smtp.client-ip=115.124.30.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="R4z7ichG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1780853215; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=qhImzRXmhei5Lr7a0pQpo3qVbnwWVnRGJ4t5QvDiQqk=; b=R4z7ichG0LHOmCOSNcDeJL906fAh+f0OLC+yJRDl1PhB7ZnADY4EBREn+ERKlgFcXQMXkZzPeakRb7mtw3GIDL5ASCn6dGY6PZtCumQb9fWCQpNZWi+lZwe01dZ+btCgII0aJ0NJ3C1ru4JSKolsoSgRSSSCXkTSHqe0MJ3MfBE= X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037033178;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0X4IBbZn_1780852893; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X4IBbZn_1780852893 cluster:ay36) by smtp.aliyun-inc.com; Mon, 08 Jun 2026 01:21:37 +0800 From: Gao Xiang To: linux-erofs@lists.ozlabs.org Cc: LKML , oliver.yang@linux.alibaba.com, Gao Xiang , Hongbo Li Subject: [PATCH] erofs: clean up erofs_ishare_fill_inode() Date: Mon, 8 Jun 2026 01:21:32 +0800 Message-ID: <20260607172132.2695176-1-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.43.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" - 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 --- 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__) =20 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 =3D EROFS_SB(inode->i_sb); - struct erofs_inode *vi =3D EROFS_I(inode); const struct address_space_operations *aops; + struct erofs_inode *vi =3D EROFS_I(inode); struct erofs_inode_fingerprint fp; - struct inode *sharedinode; - unsigned long hash; + struct inode *si; =20 aops =3D 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 =3D xxh32(fp.opaque, fp.size, 0); - sharedinode =3D iget5_locked(erofs_ishare_mnt->mnt_sb, hash, - erofs_ishare_iget5_eq, erofs_ishare_iget5_set, - &fp); - if (!sharedinode) { - kfree(fp.opaque); - return false; - } =20 - if (inode_state_read_once(sharedinode) & I_NEW) { - sharedinode->i_mapping->a_ops =3D aops; - sharedinode->i_size =3D vi->vfs_inode.i_size; - unlock_new_inode(sharedinode); + si =3D 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 =3D aops; + si->i_size =3D inode->i_size; + unlock_new_inode(si); } else { kfree(fp.opaque); - if (aops !=3D sharedinode->i_mapping->a_ops) { - iput(sharedinode); + if (!si || aops !=3D si->i_mapping->a_ops) { + iput(si); return false; } - if (sharedinode->i_size !=3D 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 !=3D inode->i_size) { + erofs_warn(inode->i_sb, "i_size mismatch (%lld !=3D %lld) for the same = fingerprint", + inode->i_size, si->i_size); + iput(si); return false; } } - vi->sharedinode =3D sharedinode; + vi->sharedinode =3D 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; } =20 --=20 2.43.5