From nobody Tue Dec 16 18:34:43 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4FB2C4167B for ; Fri, 8 Dec 2023 08:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573372AbjLHIw3 (ORCPT ); Fri, 8 Dec 2023 03:52:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232892AbjLHIw1 (ORCPT ); Fri, 8 Dec 2023 03:52:27 -0500 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EADBA10FC for ; Fri, 8 Dec 2023 00:52:29 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3B88pNQw053793; Fri, 8 Dec 2023 16:51:23 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Sml8W4CP1z2PBfby; Fri, 8 Dec 2023 16:45:31 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 8 Dec 2023 16:51:21 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH] f2fs: fix to check return value of f2fs_recover_xattr_data Date: Fri, 8 Dec 2023 16:50:33 +0800 Message-ID: <1702025433-5860-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [10.0.73.87] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 3B88pNQw053793 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Should check return value of f2fs_recover_xattr_data in __f2fs_setxattr rather than doing invalid retry if error happen. Also just do set_page_dirty in f2fs_recover_xattr_data when page is changed really. Fixes: 50a472bbc79f ("f2fs: do not return EFSCORRUPTED, but try to run onli= ne repair") Signed-off-by: Zhiguo Niu --- fs/f2fs/node.c | 6 +++--- fs/f2fs/xattr.c | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index e50a093..93bf724 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2754,11 +2754,11 @@ int f2fs_recover_xattr_data(struct inode *inode, st= ruct page *page) f2fs_update_inode_page(inode); =20 /* 3: update and set xattr node page dirty */ - if (page) + if (page) { memcpy(F2FS_NODE(xpage), F2FS_NODE(page), VALID_XATTR_BLOCK_SIZE); - - set_page_dirty(xpage); + set_page_dirty(xpage); + } f2fs_put_page(xpage, 1); =20 return 0; diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 47e88b4..de92891 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -660,11 +660,13 @@ static int __f2fs_setxattr(struct inode *inode, int i= ndex, here =3D __find_xattr(base_addr, last_base_addr, NULL, index, len, name); if (!here) { if (!F2FS_I(inode)->i_xattr_nid) { - f2fs_notice(F2FS_I_SB(inode), - "recover xattr in inode (%lu)", inode->i_ino); - f2fs_recover_xattr_data(inode, NULL); - kfree(base_addr); - goto retry; + error =3D f2fs_recover_xattr_data(inode, NULL); + if (!error) { + f2fs_notice(F2FS_I_SB(inode), + "recover xattr in inode (%lu)", inode->i_ino); + kfree(base_addr); + goto retry; + } } f2fs_err(F2FS_I_SB(inode), "set inode (%lu) has corrupted xattr", inode->i_ino); --=20 1.9.1