From patchwork Fri Jun 3 03:55:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 9151683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4F2A660221 for ; Fri, 3 Jun 2016 03:57:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4318F254F7 for ; Fri, 3 Jun 2016 03:57:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3832D281F9; Fri, 3 Jun 2016 03:57:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7CEC254F7 for ; Fri, 3 Jun 2016 03:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751231AbcFCDzo (ORCPT ); Thu, 2 Jun 2016 23:55:44 -0400 Received: from mail.kernel.org ([198.145.29.136]:36995 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751175AbcFCDzn (ORCPT ); Thu, 2 Jun 2016 23:55:43 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9DB4E2021F; Fri, 3 Jun 2016 03:55:41 +0000 (UTC) Received: from localhost (107-1-141-74-ip-static.hfc.comcastbusiness.net [107.1.141.74]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C65182021B; Fri, 3 Jun 2016 03:55:40 +0000 (UTC) From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Cc: Jaegeuk Kim Subject: [PATCH 1/8] f2fs: reuse nid if it was cached only Date: Thu, 2 Jun 2016 20:55:32 -0700 Message-Id: <1464926139-58252-1-git-send-email-jaegeuk@kernel.org> X-Mailer: git-send-email 2.6.3 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If nid's block address is assigned as: NULL_ADDR -> NEW_ADDR -> NULL_ADDR, we can reset this nid, since its node page has never written back. Signed-off-by: Jaegeuk Kim --- fs/f2fs/node.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 16532b3..15f55ae 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -317,10 +317,16 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni, } /* change address */ - nat_set_blkaddr(e, new_blkaddr); - if (new_blkaddr == NEW_ADDR || new_blkaddr == NULL_ADDR) - set_nat_flag(e, IS_CHECKPOINTED, false); - __set_nat_cache_dirty(nm_i, e); + if (nat_get_blkaddr(e) == NEW_ADDR && new_blkaddr == NULL_ADDR) { + nat_set_blkaddr(e, new_blkaddr); + nat_reset_flag(e); + __clear_nat_cache_dirty(nm_i, e); + } else { + nat_set_blkaddr(e, new_blkaddr); + if (new_blkaddr == NEW_ADDR || new_blkaddr == NULL_ADDR) + set_nat_flag(e, IS_CHECKPOINTED, false); + __set_nat_cache_dirty(nm_i, e); + } /* update fsync_mark if its inode nat entry is still alive */ if (ni->nid != ni->ino)