linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haicheng Li <haicheng.li@linux.intel.com>
To: linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	Jaegeuk Kim <jaegeuk.kim@samsung.com>
Cc: huajun.li@intel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: optimize alloc_nid_failed()
Date: Mon, 6 May 2013 21:20:10 +0800	[thread overview]
Message-ID: <20130506132010.GA862@hli22-desktop> (raw)
In-Reply-To: <1367839506-30372-1-git-send-email-haicheng.li@linux.intel.com>

Just realized I should develop the patches against Kim's f2fs-dev branch
rather than the f2fs-master branch. (thanks to Huajun for the reminding).

Obviously on f2fs-dev branch, some optimizations of alloc_nid_failed() have
already been done.

Pls. ignore this patch, I'll send out the rebased version of my recent f2fs
patches soon later, which will be based on the f2fs-dev tree.

On Mon, May 06, 2013 at 07:25:06PM +0800, Haicheng Li wrote:
> Current alloc_nid_failed() has two issues:
> 1. unecessarily kmem_cache_free() the free_nid and then realloc a new
>    slab cache for it immediately;
> 2. needs to __lookup_free_nid_list() twice in order to find out the free_nid
>    from free_nid_list.
> 
> This patch fixes these issues.
> 
> Signed-off-by: Haicheng Li <haicheng.li@linux.intel.com>
> ---
>  fs/f2fs/node.c |   17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index e275218..7ce8e9f 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1403,8 +1403,21 @@ void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid)
>   */
>  void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
>  {
> -	alloc_nid_done(sbi, nid);
> -	add_free_nid(NM_I(sbi), nid);
> +	struct f2fs_nm_info *nm_i = NM_I(sbi);
> +	struct free_nid *i;
> +
> +	spin_lock(&nm_i->free_nid_list_lock);
> +	i = __lookup_free_nid_list(nid, &nm_i->free_nid_list);
> +	if (i) {
> +		BUG_ON(i->state != NID_ALLOC);
> +		if (nm_i->fcnt > 2 * MAX_FREE_NIDS)
> +			__del_from_free_nid_list(i);
> +		else {
> +			i->state = NID_NEW;
> +			nm_i->fcnt++;
> +		}
> +	}
> +	spin_unlock(&nm_i->free_nid_list_lock);
>  }
>  
>  void recover_node_page(struct f2fs_sb_info *sbi, struct page *page,
> -- 
> 1.7.9.5

      reply	other threads:[~2013-05-06 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-06 11:25 [PATCH] f2fs: optimize alloc_nid_failed() Haicheng Li
2013-05-06 13:20 ` Haicheng Li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130506132010.GA862@hli22-desktop \
    --to=haicheng.li@linux.intel.com \
    --cc=huajun.li@intel.com \
    --cc=jaegeuk.kim@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).