From patchwork Thu Nov 16 06:25:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13457633 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A9547C54FB9 for ; Thu, 16 Nov 2023 06:26:20 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r3VpV-0004v5-8Z; Thu, 16 Nov 2023 06:26:20 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r3VpL-0004ux-8u for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=g1hZefIHY8SFwKkLVv2TQxgJr4q8W7A1nr2ia8yTO8Q=; b=EseMPVbCswoXhNHxUM4Vw8za3c UFbyskDtiFK7zsk34YvKu4PxahzMVkeoUmQ8pFokmUd+fl+Kv0dqgOjoi9IeiW0DGydKLIyxveu7Q hGoNBjd9r2iTAIB8m5OKBh3bySZpsnMfcxWeZZcvv9yVijkJW3dWkFAlE+/Hcmgyx/ZI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=g1hZefIHY8SFwKkLVv2TQxgJr4q8W7A1nr2ia8yTO8Q=; b=L N+ggidB0kJJqpsXrol1bw/8PVccNDHFgOuJAMw2mOXLz+3i79Y14e4nFK8hA56ig3uxeUftQDeWiW uuS/pRAnRS2wbMvLbl5n165pcLid+tYuOA3NuLQile4VPB04ArFHndcCYtDPeXV5YFDx73WNYIkUo KAYw3dq6odTQ3wnA=; Received: from ams.source.kernel.org ([145.40.68.75]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1r3VpJ-0077Dl-K5 for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 5B382B81C85 for ; Thu, 16 Nov 2023 06:26:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A5B1C433C7; Thu, 16 Nov 2023 06:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700115962; bh=LdQ7fpYx4XjHDzsyZXb0qCihyPciooXY4TAlO70WFe0=; h=From:To:Cc:Subject:Date:From; b=tjzg/XJu3pN7sLj7482nvRPWD4ZfXv+y3cwgmIn6dzesDklcub5lzV2vPAqSnq+xi 5sZ7lQgMTzc2xmxBS6TyyrrJiYgw14NCfohsaxtFcZyGBdtI2aepFCjc6SiL1R5AWa 7qSuKpJq3NNgR4vN4xPVMO2APRWkFgIiSBIrB0vXvcKmhfTw/bwSbELJZgnigeMgtH ojsdDCKgTnsOmXziWm7yNe61anSBtCITcLPKy1/W1jbUrXpqBaA6KMid+xG/03Gg7S vcvqH0+aXghk7vYHW3L9C9998PKLak/kDOGlwGBodDMS4ztHxM7QyZ4VgE36uIgXuP JognBF4pI0rWw== From: Chao Yu To: jaegeuk@kernel.org Date: Thu, 16 Nov 2023 14:25:54 +0800 Message-Id: <20231116062556.2451839-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Headers-End: 1r3VpJ-0077Dl-K5 Subject: [f2fs-dev] [PATCH 1/3] f2fs: clean up w/ dotdot_name X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Just cleanup, no logic changes. Signed-off-by: Chao Yu --- fs/f2fs/namei.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index d0053b0284d8..a9360ee02da1 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -459,7 +459,6 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino) { struct f2fs_sb_info *sbi = F2FS_I_SB(dir); struct qstr dot = QSTR_INIT(".", 1); - struct qstr dotdot = QSTR_INIT("..", 2); struct f2fs_dir_entry *de; struct page *page; int err = 0; @@ -497,13 +496,13 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino) goto out; } - de = f2fs_find_entry(dir, &dotdot, &page); + de = f2fs_find_entry(dir, &dotdot_name, &page); if (de) f2fs_put_page(page, 0); else if (IS_ERR(page)) err = PTR_ERR(page); else - err = f2fs_do_add_link(dir, &dotdot, NULL, pino, S_IFDIR); + err = f2fs_do_add_link(dir, &dotdot_name, NULL, pino, S_IFDIR); out: if (!err) clear_inode_flag(dir, FI_INLINE_DOTS); From patchwork Thu Nov 16 06:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13457632 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E6335C197A0 for ; Thu, 16 Nov 2023 06:26:18 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r3VpP-0005Mz-Qp; Thu, 16 Nov 2023 06:26:15 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r3VpK-0005Ms-Qb for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Iirx9aZ1jQB9H5aHSLV9cAcubZwnik+/CrJ/R53I8XA=; b=IV8FDQiDIV7/cyIDL2ZTwOaLkI 7R4xLbyRI0ZWTfJG6e8fVQ9k8LHQMmRgdtV2f4THkqbX+Ogh3poewSaujALCuJ8WP7P7a1Ys9IbVt qR+MBRHpsOVnhCkVmW6is9WXXNLbU8wY5bzlvU9aF/kAr1Vjrst3vzZcvurNoYIPCXUY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Iirx9aZ1jQB9H5aHSLV9cAcubZwnik+/CrJ/R53I8XA=; b=FlBv7eqfnT4Z+fcu5e3CqSL4G7 zk5JfGqunBJBRx+hmVJ/ewWR13hmRdfJDUP2Y+egE0mP593hBLVCGPAz5SAQd6zKc+niQSLZWOLcw tKZ3JfMX0F5CHocFte2i0jSOgIXT3QtOigzfwP7JZb1ZaMDMnvqyFb26sgeRmCTpJPWM=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1r3VpK-0077Dm-AN for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E3E186188D for ; Thu, 16 Nov 2023 06:26:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 458B6C433C9; Thu, 16 Nov 2023 06:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700115964; bh=6rwiQ68wHhdsE6vY/Y31nFsyaYQ2rLgqDwN+2WxChEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIuPwVvk8OAAiglh4l+yrHMbH+U1E4tlFGpj6dqWYdv6FlT3GEmLUnBx6u5qaJL8e 8iiU1S03QdgwgH67BEn0CunhA2O/7XGyO+TJLDVXrS0Ql3NY3m1Cof+SADxmK+nv5d emPwLN/XIwrNwUkAvFbD9iuFt+Ki6Ba2hjNFIZ9cHqYYj/NKt1EafCbhU1bK5soqrD Ea2mNSi+m8H8h4HhaA7ikBwdDtfafQXtAvValMHkzvU3shabOifFaNoJHC+9wZ/0HY be8J/dOOZP8Db6Y33jBnwR5mM/h0WUtCm6gc5qZaHorKuzRJrCbxpj4bW6Z7b7T7G/ Gc2skX6crDrYQ== From: Chao Yu To: jaegeuk@kernel.org Date: Thu, 16 Nov 2023 14:25:55 +0800 Message-Id: <20231116062556.2451839-2-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231116062556.2451839-1-chao@kernel.org> References: <20231116062556.2451839-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1r3VpK-0077Dm-AN Subject: [f2fs-dev] [PATCH 2/3] f2fs: use shared inode lock during f2fs_fiemap() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net f2fs_fiemap() will only traverse metadata of inode, let's use shared inode lock for it to avoid unnecessary race on inode lock. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 4e42b5f24deb..42f0f6184f73 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1992,7 +1992,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (ret) return ret; - inode_lock(inode); + inode_lock_shared(inode); maxbytes = max_file_blocks(inode) << F2FS_BLKSIZE_BITS; if (start > maxbytes) { @@ -2112,7 +2112,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (ret == 1) ret = 0; - inode_unlock(inode); + inode_unlock_shared(inode); return ret; } From patchwork Thu Nov 16 06:25:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13457634 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B01EC47071 for ; Thu, 16 Nov 2023 06:26:23 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r3VpV-000085-26; Thu, 16 Nov 2023 06:26:21 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r3VpT-00007y-0G for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=5iXeEcEqiRYpmeSIt8aCITFPceGAZWzrZRvTG0xcYrI=; b=A5QXm2ls9Uog2bpSQQFq4NS3OD zHljvDxaIbFvUj5Q06a045gtTd4q8+3BtvKic+ZXx1cCxTGsb7z4cWjlzFSwUJqtpQ+1pzVJUedRI hiHJRxTYndDqvVyxvOUkkxWxzjlOu1bRrK6vjgFBmpPYGoqIILSOCWX2qGEVyBxS5P0E=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=5iXeEcEqiRYpmeSIt8aCITFPceGAZWzrZRvTG0xcYrI=; b=gp1s116E29H219FTY8g+0AVIKZ Q/zupuJ0S1KazUe950Dm1bFzTrjWA0XCVTNKtLDrsyF2/NYJ2gqBl0MJ86Bt9E+IQ//hgWIA18VIV LV4xXy7lmuX8gCXQWkQWimTFBxq8wYg7yOCxU7epTW8WDd0vE0xAxE3C4hiPOT9sextM=; Received: from ams.source.kernel.org ([145.40.68.75]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1r3VpN-0004aq-Mr for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Nov 2023 06:26:19 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 0A6AAB81C8A for ; Thu, 16 Nov 2023 06:26:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E298C433CA; Thu, 16 Nov 2023 06:26:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700115966; bh=4ui5+7aVz7Gqv0sQoth9MwnoQqqjL6flt9PtV4MBJnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jHDeTQZSCIyaqUr9vYjCrR938zf9P6Ll63wLDGPERCA0VvpwEVjIIG0g0icc4cZLO TTnT/WcHrP2GHjvkhHL+gPcvgoyuuVypIAHkfs4Sj5R1afufTAaJ1rxCgIfAH9oOBq PJCzQdFVSDGtt9mHy59T4+sLSw1pa+CAqjwXze80vBsBJ1pwUjaO5BEDxp3Cje+UXk wYHj0HcvrNTY7iPM8CbPqNQTu59+WLXrvsVoyqmFMnVNVBGKdcS86byQg1img9iYd0 NZmqmjR9LhTa/lcfhJ3NbXUgZPUkuKPOsDIqhRC9Le8sCPORXc+2MGRMOlyGJOVedu Lkc9Lbou9tu7A== From: Chao Yu To: jaegeuk@kernel.org Date: Thu, 16 Nov 2023 14:25:56 +0800 Message-Id: <20231116062556.2451839-3-chao@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231116062556.2451839-1-chao@kernel.org> References: <20231116062556.2451839-1-chao@kernel.org> MIME-Version: 1.0 X-Headers-End: 1r3VpN-0004aq-Mr Subject: [f2fs-dev] [PATCH 3/3] f2fs: fix to check return value of f2fs_reserve_new_block() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Let's check return value of f2fs_reserve_new_block() in do_recover_data() rather than letting it fails silently. Also refactoring check condition on return value of f2fs_reserve_new_block() as below: - trigger f2fs_bug_on() only for ENOSPC case; - use do-while statement to avoid redundant codes; Signed-off-by: Chao Yu --- fs/f2fs/recovery.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c index b56d0f1078a7..16415c770b45 100644 --- a/fs/f2fs/recovery.c +++ b/fs/f2fs/recovery.c @@ -712,7 +712,16 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, */ if (dest == NEW_ADDR) { f2fs_truncate_data_blocks_range(&dn, 1); - f2fs_reserve_new_block(&dn); + do { + err = f2fs_reserve_new_block(&dn); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); + if (err) + goto err; continue; } @@ -720,12 +729,14 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, if (f2fs_is_valid_blkaddr(sbi, dest, META_POR)) { if (src == NULL_ADDR) { - err = f2fs_reserve_new_block(&dn); - while (err && - IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)) + do { err = f2fs_reserve_new_block(&dn); - /* We should not get -ENOSPC */ - f2fs_bug_on(sbi, err); + if (err == -ENOSPC) { + f2fs_bug_on(sbi, 1); + break; + } + } while (err && + IS_ENABLED(CONFIG_F2FS_FAULT_INJECTION)); if (err) goto err; }