Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2201964rdb; Fri, 8 Dec 2023 00:52:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaAhVVP9+f2v+k1N25gkVY6IZsgsX9YnGrrsao69dSzpCBbVD4Kcse9Ry0kwkZmftGcOEN X-Received: by 2002:a17:902:d501:b0:1d0:4cde:6e33 with SMTP id b1-20020a170902d50100b001d04cde6e33mr4419854plg.56.1702025559824; Fri, 08 Dec 2023 00:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702025559; cv=none; d=google.com; s=arc-20160816; b=YxtlIOnCEXdFALQ7W609kOwztZwoW6D6tJRQGRH3VlYJn68PuhZ8YaV8otlLvlczgO 75yIBrgRQEV7Ju9QutTobV82ad11QbBqZh6qfk9Xi+6VVHsWbrZmHitKqJItnlWx1b6q 5cMn3crN4AogMDse9MWbAjf+A5PcbqHu/ouDBbQ8L4nLQ65WqDL6W4FMutBPLHwO7Atq 8pq3R5veC97XXxIgr/pWX5Dg5gEABnNTW02t2K0uc4xHuJ7hEBCb+QsoUmIFEr4BpnlM soLt1LTdgnjLswfrbj2QDrSjTBMqNPAPDwerTiP4HhHC5ppM776CVHpN9lFc2Z3xfjj4 1wYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=8DMWOhAUdaqeHH4nSC7+MNYiSfyh0fu2NqFG1FVS5qI=; fh=JkrfyujbIDmycozXR7ZDiVuf6xBFur6C1+1NEIITJEI=; b=Nk0UKsLKKcIJrtjLWCYtia3iIH/b1+6rzWFwyCVA/oMCUeTiU/dExQGQvDFnrVaRJw ZBkxkUvtNqbwPi5EdUjYwHFInlOZec7Wy9jelO8FzT9P6I5DdHlBj84MK8G559Cnl93w nmT8zpXShOstgRPI9U+SIAa6I6ujFfn7AbrPwrmmG6bPHIPZsH1j6RONZ2Hh4/zT1ZKw 3hH0RcLXCId+mkDFNSd38VG2eXXFhvRCrLQTpgdmNC+7ttINSNl0RnQSymbpUDJfyO0n ZK0CLKhC3sKYnKP8ogxfPu6pNef+JXjF7Kcpx3jB7D2daaPxMgkbC2VnTSX9ZEBR0SZG l7cw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id a6-20020a1709027d8600b001d08c079196si1236102plm.36.2023.12.08.00.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 00:52:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4BE0480EA8D3; Fri, 8 Dec 2023 00:52:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233227AbjLHIw2 (ORCPT + 99 others); Fri, 8 Dec 2023 03:52:28 -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 Content-Type: text/plain 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 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 00:52:38 -0800 (PST) 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 online 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, struct page *page) f2fs_update_inode_page(inode); /* 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); 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 index, here = __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 = 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); -- 1.9.1