Re: [patch-2.4.0-test5-pre1] nullfs and forced umount

From: Tigran Aivazian (tigran@veritas.com)
Date: Tue Jul 18 2000 - 16:37:00 EST


On Tue, 18 Jul 2000, Manfred Spraul wrote:
> <<<<<<<<<<
> repeat:
> read_lock(&task_lock);
> for_each_task(p) {
> task_lock(p);
> /* Now dereferencing p->mm, p->fs and p->files is safe,
> they won't be destroyed while we look at them.
> */
> tsk_mm = p->mm;
> tsk_fs = p->fs;
> atomic_inc(&tsk_mm->mm_users);
> atomic_inc(&tsk_fs->count);
> task_unlock(p);
> if(I_must_block) {
> read_unlock(&task_lock);
> /* you cannot touch tsk from this line on,
> but tsk_fs and tsk_mm are safe */
> put_fs_struct(tsk_fs);
> mmput(tsk_mm);
> goto repeat;
> }
> }
> >>>>>>>>>>>

ok, that is much better and clearer. I see files_struct->count field so I
 assume the same idea as for p->mm and p->fs applies (assuming
p->alloc_lock is guarding p->files as well, which is confirmed by the
comment in task_struct).

>
> You can find sample code in kernel/ptrace.c + arch/i386/kernel/ptrace.c
> or fs/proc/{base,array}.c.
> If you must access a field in tsk after the read_unlock(task_lock), then
> you must use get_task_struct() + free_task_struct().

Thanks, I will redo the patch with all the above in mind. Tomorrow I will
be thinking about heavier issues you discovered.

Thanks,
Tigran

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Jul 23 2000 - 21:00:11 EST