Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4373019rdb; Mon, 11 Dec 2023 18:20:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPnCwLLZzV2xDfiYXbNv71zrZP7SjrSMkRu3Gg9ay4qCWqFY1fG9KPbzqvCGuG27tyBxho X-Received: by 2002:a05:6a20:1388:b0:187:5db4:1688 with SMTP id hn8-20020a056a20138800b001875db41688mr5642159pzc.18.1702347646549; Mon, 11 Dec 2023 18:20:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702347646; cv=none; d=google.com; s=arc-20160816; b=cG005yOV8+OUgYbkJAX15pZJlAjXU/j6i5lBXw8S1l9+G9E3IDzEoK5ROrBZ3hhDvv fgGI3gspmON6CUbiC2SZJn1NPy3XfwOItlx0X0drvgrym/NA9ewinEKMPdPpUHp72spQ mHvBhddp86uOtbUA3LOY/XHWeOgAkf+XyK29c7R0ZDOE/GpAYGRFO/D9FmIqL3RApfjL CsGe5JFW5sd8RxWIqzDmte2zr7VdiYc4XyOHrFEzfK0+FJQRJoziub25QhF9CMPde77s w/DOTkBsRMqXhdJpzPrTFquNXUahAkwplwc37+wZ/A/0PWJDalLXE6g9wzRmCWIkuEJC iHWA== 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=zgZ5loAc+27S6+h3Eq9D9aYSTwx+wNYY/PB5BEgxPSQ=; fh=JkrfyujbIDmycozXR7ZDiVuf6xBFur6C1+1NEIITJEI=; b=huEdzK68Sq32mrAjoy8D6p9KF62PKs6FscqvTkFqakxJYFwH8obBUq3SelESvJCWX1 N0BxwuDW+8oKjiTOCmur4UM3GYhjVcsCN33FfC6Oz5qMOItjNPn8jQUxyu4mAfmukMiO g9X3iN7ScgiuOIm6fuHSIkPEkdkRFO+J4HsQUhUrfHwTlGwrHrUnN48rWk3lkfSS8u1y +U/aEOrbDOCS58XHCwSrb5oFz5EBFYxV31Crj5PzgTalseVG63xpY4VQ89uOUhHVhJk3 yRu3V8SPeySiek2OaclHzZgoFjeEb2hI7DSBIsstIv4LYPxK678fhLdW8YBetYz8Q89U 7mRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id t9-20020a63eb09000000b005bd04d27b69si6868841pgh.725.2023.12.11.18.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:20:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 0B594804270A; Mon, 11 Dec 2023 18:20:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345674AbjLLCQ0 (ORCPT + 99 others); Mon, 11 Dec 2023 21:16:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345611AbjLLCQZ (ORCPT ); Mon, 11 Dec 2023 21:16:25 -0500 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48A4DE8 for ; Mon, 11 Dec 2023 18:16:30 -0800 (PST) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 3BC2FnBm016652; Tue, 12 Dec 2023 10:15:49 +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 4Sq2B56Myhz2Ngkwp; Tue, 12 Dec 2023 10:09:49 +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; Tue, 12 Dec 2023 10:15:47 +0800 From: Zhiguo Niu To: , CC: , , , , Subject: [PATCH V2] f2fs: fix to check return value of f2fs_recover_xattr_data Date: Tue, 12 Dec 2023 10:15:27 +0800 Message-ID: <1702347327-24181-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: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 3BC2FnBm016652 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:20:44 -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 --- changes of v2: move infor print to sutiable position according to Chao's suggestion. --- --- fs/f2fs/node.c | 6 +++--- fs/f2fs/xattr.c | 11 +++++++---- 2 files changed, 10 insertions(+), 7 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..b04b8fd 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -660,11 +660,14 @@ 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) { + error = f2fs_recover_xattr_data(inode, NULL); 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; + "recover xattr in inode (%lu), error(%d)", + inode->i_ino, error); + if (!error) { + kfree(base_addr); + goto retry; + } } f2fs_err(F2FS_I_SB(inode), "set inode (%lu) has corrupted xattr", inode->i_ino); -- 1.9.1