Re: [PATCH] Improving read/write/close system call reliability when used with pthreads

From: Fredrik Noring
Date: Sun Aug 12 2007 - 14:31:58 EST


Paul,

Paul Jackson wrote:
You suspected correctly - Apple Mail line wrapped it at 72 columns
(added newlines in any line going past column 72.) This makes it
impossible to apply the patch without alot of hand editing.

Of course, sorry about that. New try!

Regarding the FIXME: Marking bad fd:s in close currently walks all tasks, but it ought to be possible to do this much more efficiently. For example only tasks that actually use the file table in question. Alternatively, only tasks that are waiters in the pipe_inode_info- >wait queue (they are the ones that are woken up to handle the close anyway; the wake up btw can perhaps also be more fine-grained).

I have a feeling that the latter is the most efficient, but perhaps a bit more tricky regarding races. Plus, this puts the burden of marking bad fd:s onto all the implementations of the f_op->closing_fd file operation.

The rest of the bookkeeping to handle required_fds should be efficient, I believe.

Regarding generality: For maximum benefit of being able to close all kinds even non-pipe fd:s reliably, a lot of places need to be updated. This is not a requirement though, as current behaviour is maintained otherwise. (It might however be worthwhile to have sys_read/sys_write etc. refuse -ERESTARTSYS when its fd apparently is bad.)

Cheers,
Fredrik

Attachment: required-fds.patch
Description: Binary data