Re: [PATCH 2/7] revoke: add f_light flag for struct file

From: Eric Dumazet
Date: Fri Mar 09 2007 - 05:09:11 EST


On Friday 09 March 2007 09:14, Pekka J Enberg wrote:
> From: Pekka Enberg <penberg@xxxxxxxxxxxxxx>
>
> This adds a f_light flag to struct file to indicate that the file was
> looked up with fget_light(). Needed by revoke to ensure we don't
> close a file pointer while someone is using it without actually
> holding a reference.
>
> These bits were taken from the forced unmount patches by Tigran
> Aivazian.

Well, I disagree very much with this patch.

One of the interest of fget_light() is not dirtying file structure (avoiding
atomic changes to f_count).

You add a 'flag' (4 bytes !) at the end of the file structure (so in a
different cache line than the parts that are usually accessed in a fd_related
syscall) and dirty this part at syscall entry and exit. Thats really a heavy
price for supporting an unlikely revoke() syscall.

Also, the thing is racy.

( BTW, the whole revoke() concept is evil, especially if we want to avoid
using inodes/dentries for some kind of pseudo files like sockets / pipes)

Cannot we use a flag in 'struct files_struct', set to one when the task is
mono-thread (at task creation in fact), and set to 0 when it creates a new
thread (or when someone remotely access to this "struct files_struct"
in /proc/pid/fd/... )

No need to set back this flag to 1 when task revert to mono-threaded, since
this case is probably unlikely. This way we can be non racy.

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