All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix race in ext4_mb_add_n_trim()
@ 2013-01-07  6:09 Niu Yawei
  2013-02-02  2:32 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Niu Yawei @ 2013-01-07  6:09 UTC (permalink / raw)
  To: linux-ext4, yawei.niu, Alex Zhuravlev

>From 020243735e97f327ecba729ec05d4e3facdddc78 Mon Sep 17 00:00:00 2001
From: Niu Yawei <niu@whamcloud.com>
Date: Mon, 7 Jan 2013 01:03:26 -0500
Subject: [PATCH] Fix race in ext4_mb_add_n_trim()

In ext4_mb_add_n_trim(), lg_prealloc_lock should be taken when
changing the lg_prealloc_list.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
---
 fs/ext4/mballoc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 1bf6fe7..45d3527 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4136,7 +4136,7 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
                /* The max size of hash table is PREALLOC_TB_SIZE */
                order = PREALLOC_TB_SIZE - 1;
        /* Add the prealloc space to lg */
-       rcu_read_lock();
+       spin_lock(&lg->lg_prealloc_lock);
        list_for_each_entry_rcu(tmp_pa, &lg->lg_prealloc_list[order],
                                                pa_inode_list) {
                spin_lock(&tmp_pa->pa_lock);
@@ -4160,7 +4160,7 @@ static void ext4_mb_add_n_trim(struct ext4_allocation_context *ac)
        if (!added)
                list_add_tail_rcu(&pa->pa_inode_list,
                                        &lg->lg_prealloc_list[order]);
-       rcu_read_unlock();
+       spin_unlock(&lg->lg_prealloc_lock);

        /* Now trim the list to be not more than 8 elements */
        if (lg_prealloc_count > 8) {
--
1.7.1


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

* Re: Fix race in ext4_mb_add_n_trim()
  2013-01-07  6:09 [PATCH] Fix race in ext4_mb_add_n_trim() Niu Yawei
@ 2013-02-02  2:32 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-02-02  2:32 UTC (permalink / raw)
  To: Niu Yawei; +Cc: linux-ext4, yawei.niu, Alex Zhuravlev

On Sun, Jan 06, 2013 at 08:09:34PM -0000, Niu Yawei wrote:
> >From 020243735e97f327ecba729ec05d4e3facdddc78 Mon Sep 17 00:00:00 2001
> From: Niu Yawei <niu@whamcloud.com>
> Date: Mon, 7 Jan 2013 01:03:26 -0500
> Subject: [PATCH] Fix race in ext4_mb_add_n_trim()
> 
> In ext4_mb_add_n_trim(), lg_prealloc_lock should be taken when
> changing the lg_prealloc_list.
> 
> Signed-off-by: Niu Yawei <yawei.niu@intel.com>

Applied, thanks!

						- Ted

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-07  6:09 [PATCH] Fix race in ext4_mb_add_n_trim() Niu Yawei
2013-02-02  2:32 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.