Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4357417rdb; Mon, 11 Dec 2023 17:39:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6xh+j0ZkQhxU8yVbZbQxPpA8UkYLCouI54EIKHK6xVloUZlX6ter4Oz/y3maBGoxuxTrv X-Received: by 2002:a05:6a20:bb04:b0:181:fe7f:836b with SMTP id fc4-20020a056a20bb0400b00181fe7f836bmr5001751pzb.7.1702345160471; Mon, 11 Dec 2023 17:39:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702345160; cv=none; d=google.com; s=arc-20160816; b=t5y7yOt1SuroTwIb4EnZ0sgs4m3QCd1JjH3ocTfIU7da+7b9f3gtVLp62xJKanjXTl ssCNdNGPklRVdVsXBW07/2QZDQwvNY3xUPthp+N7Z5ynQECTW9dUtnDolhaXjDdO17Fj BU998O3z/1RAt3Qthpui+QZl235QyGb1Oi1OCzcsAP2FTfP/cbLepMuiDxJOT8P1DBZV zW0W5dAUOtx+k141bhP/EgWcPKG6Hih6uTVrs0LlbcQqHD7WSnpUtI+tnhVaddP+te/4 51aqe/SKvrllMBvF7xGKBDEM40tEpamD/r6oTBRh29N/guFyAF5/SY5uAYGEPYWvRfxq 4lEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=REmuB76sDGLztG8A2JZ4H5kWO1gjpn+LDRx+sWI+lko=; fh=zQ4KyqolXqQO+yNFGVuXxCeSvQq3rubOak+k9IB2PKU=; b=OVtwiksyrILpgNOF0mfNKQaSefEQ60h/fvsJK0OdWuvJ6aoBXtYbJoMJ5FaQFaJjOS KkavbiwbzG7ixUvkDmAilazetZqSlnXZSLwoy9LaTaOnr02ASKePR3O9NAIPOLjVgjjg m7gv2ja+oHVhulpkDl1d/qphU/2kZj2L/Z1uowRWSUkJAYfE/9qrUDlXMEdL4TMxD/UP JatwIPMkMRl/Eke0h7KPfzTlrow8vYwblZS0s/HIwwTQGWK2npUjArStiX/J7t8uD2VG RtsRV/MAZLb/jETS8W2FfO7VpXtGAAReK0M//pI0OIc3hst07tnwLLgFK0qCX9giirk4 cCWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=loDQXDK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id gv6-20020a17090b11c600b0028647ec59c3si8260373pjb.85.2023.12.11.17.39.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 17:39:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=loDQXDK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4398A80D290C; Mon, 11 Dec 2023 17:39:18 -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 S1345670AbjLLBjB (ORCPT + 99 others); Mon, 11 Dec 2023 20:39:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbjLLBjA (ORCPT ); Mon, 11 Dec 2023 20:39:00 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE54CF for ; Mon, 11 Dec 2023 17:39:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47166C433C8; Tue, 12 Dec 2023 01:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702345146; bh=TeIu+bH7xeWWjKF8B1+cGXjZicTzj7xMKbF2/jnTZ2M=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=loDQXDK05uWNQeoH1AEDOy1imWruiJEWZStOtDJukZcRHzpIv/S7837qsuctYeuPP +MaVlDRQlGG5WLQJX1HuUP61rFck97nhULJSlHq91KJFG0x1IaN3WahKFFtbCxcF06 jL6hG5hc8Nvg+C4Tp4uteWYfKtTpieabVw3TYKx+n5oEODrfML2KuVnDQ/4gyq+5dp Y9ERMajnwbgdYgtRm2/egQNZETX97gs/zr98kt/sYDOt+cMyGh0u8RSpZiJTF+ohYu 9Yn2qpLxjpoQYe2xOtd8+PUDA875+V0oWyOXDuLlhmh5hH7/9ITlLW62PktpgitH5R Xu3H5aKhkalXg== Message-ID: <3478e715-3fe2-4686-aa9d-8fa2f4083dac@kernel.org> Date: Tue, 12 Dec 2023 09:39:00 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] f2fs: fix to check return value of f2fs_recover_xattr_data To: Zhiguo Niu , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, niuzhiguo84@gmail.com, ke.wang@unisoc.com References: <1702025433-5860-1-git-send-email-zhiguo.niu@unisoc.com> Content-Language: en-US From: Chao Yu In-Reply-To: <1702025433-5860-1-git-send-email-zhiguo.niu@unisoc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 17:39:18 -0800 (PST) On 2023/12/8 16:50, Zhiguo Niu wrote: > 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); How about printing here? f2fs_notice(F2FS_I_SB(inode), "recover xattr in inode (%lu), error: %d", inode->i_ino, error); Thanks, > + 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);