Re: [PATCH 1/1] fs-writeback: Using spin_lock to check for work_list empty

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Kamezawa,

I noticed that you are responding to emails right now.

Can you please review the patch below and tell me whether it is
technically correct ?

Or, can you please suggest a suitable change for solving this ?

Thanks.
Kautuk

On Wed, Aug 31, 2011 at 10:41 AM, Rajan Aggarwal
<rajan.aggarwal85@xxxxxxxxx> wrote:
> The bdi_writeback_thread function does not use spin_lock to
> see if the work_list is empty.
>
> If the list is not empty, and if an interrupt happens before we
> set the current->state to TASK_RUNNING then we could be stuck in
> a schedule() due to kernel preemption.
>
> This patch acquires and releases the wb_lock to avoid this scenario.
>
> Signed-off-by: Rajan Aggarwal <rajan.aggarwal85@xxxxxxxxx>
> ---
>  fs/fs-writeback.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 04cf3b9..e333898 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -936,11 +936,14 @@ int bdi_writeback_thread(void *data)
>                if (pages_written)
>                        wb->last_active = jiffies;
>
> +               spin_lock_bh(&bdi->wb_lock);
>                set_current_state(TASK_INTERRUPTIBLE);
>                if (!list_empty(&bdi->work_list) || kthread_should_stop()) {
>                        __set_current_state(TASK_RUNNING);
> +                       spin_unlock_bh(&bdi->wb_lock);
>                        continue;
>                }
> +               spin_unlock_bh(&bdi->wb_lock);
>
>                if (wb_has_dirty_io(wb) && dirty_writeback_interval)
>                        schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
> --
> 1.7.4.1
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux