linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] f2fs: fix removing cache entry within proper lock
@ 2012-12-30  5:52 Namjae Jeon
  2013-01-02  2:18 ` Jaegeuk Kim
  0 siblings, 1 reply; 2+ messages in thread
From: Namjae Jeon @ 2012-12-30  5:52 UTC (permalink / raw)
  To: jaegeuk.kim
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Namjae Jeon, Amit Sahrawat

From: Namjae Jeon <namjae.jeon@samsung.com>

Cache entry for free NID, is not getting removed under proper
lock in case of error in add_free_nid. So, free the cache entry
first before releasing the spinlock.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
---
 fs/f2fs/node.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 5066bfd..09139fb 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1227,8 +1227,8 @@ retry:
 
 	spin_lock(&nm_i->free_nid_list_lock);
 	if (__lookup_free_nid_list(nid, &nm_i->free_nid_list)) {
-		spin_unlock(&nm_i->free_nid_list_lock);
 		kmem_cache_free(free_nid_slab, i);
+		spin_unlock(&nm_i->free_nid_list_lock);
 		return 0;
 	}
 	list_add_tail(&i->list, &nm_i->free_nid_list);
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 3/4] f2fs: fix removing cache entry within proper lock
  2012-12-30  5:52 [PATCH 3/4] f2fs: fix removing cache entry within proper lock Namjae Jeon
@ 2013-01-02  2:18 ` Jaegeuk Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Jaegeuk Kim @ 2013-01-02  2:18 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: linux-fsdevel, linux-kernel, linux-f2fs-devel, Namjae Jeon,
	Amit Sahrawat

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

NAK, we don't need to do this.
There is no relationship between kmem_cache_* and free_nid_list_lock.
Moreover, IMO, it would be better unlock free_nid_list_lock as quickly
as possible in order to reduce lock contention.

2012-12-30 (일), 14:52 +0900, Namjae Jeon:
> From: Namjae Jeon <namjae.jeon@samsung.com>
> 
> Cache entry for free NID, is not getting removed under proper
> lock in case of error in add_free_nid. So, free the cache entry
> first before releasing the spinlock.
> 
> Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
> Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
> ---
>  fs/f2fs/node.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 5066bfd..09139fb 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1227,8 +1227,8 @@ retry:
>  
>  	spin_lock(&nm_i->free_nid_list_lock);
>  	if (__lookup_free_nid_list(nid, &nm_i->free_nid_list)) {
> -		spin_unlock(&nm_i->free_nid_list_lock);
>  		kmem_cache_free(free_nid_slab, i);
> +		spin_unlock(&nm_i->free_nid_list_lock);
>  		return 0;
>  	}
>  	list_add_tail(&i->list, &nm_i->free_nid_list);

-- 
Jaegeuk Kim
Samsung

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-02  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-30  5:52 [PATCH 3/4] f2fs: fix removing cache entry within proper lock Namjae Jeon
2013-01-02  2:18 ` Jaegeuk Kim

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).