aboutsummaryrefslogtreecommitdiffstats
path: root/fs/autofs4/waitq.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-01-10 22:35:38 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2012-01-11 00:20:12 -0500
commitd668dc56631da067540b2494d2a1f29ff7b5f15a (patch)
tree303ad17208838e8b9b1752f9427d55c84555f0f0 /fs/autofs4/waitq.c
parent8753333266be67ff3a984ac1f6566d31c260bee4 (diff)
downloadkernel_goldelico_gta04-d668dc56631da067540b2494d2a1f29ff7b5f15a.zip
kernel_goldelico_gta04-d668dc56631da067540b2494d2a1f29ff7b5f15a.tar.gz
kernel_goldelico_gta04-d668dc56631da067540b2494d2a1f29ff7b5f15a.tar.bz2
autofs4: deal with autofs4_write/autofs4_write races
Just serialize the actual writing of packets into pipe on a new mutex, independent from everything else in the locking hierarchy. As soon as something has started feeding a piece of packet into the pipe to daemon, we *want* everything else about to try the same to wait until we are done. Acked-by: Ian Kent <raven@themaw.net> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/autofs4/waitq.c')
-rw-r--r--fs/autofs4/waitq.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
index 9a0256d..9ef5b29 100644
--- a/fs/autofs4/waitq.c
+++ b/fs/autofs4/waitq.c
@@ -56,26 +56,27 @@ void autofs4_catatonic_mode(struct autofs_sb_info *sbi)
mutex_unlock(&sbi->wq_mutex);
}
-static int autofs4_write(struct file *file, const void *addr, int bytes)
+static int autofs4_write(struct autofs_sb_info *sbi,
+ struct file *file, const void *addr, int bytes)
{
unsigned long sigpipe, flags;
mm_segment_t fs;
const char *data = (const char *)addr;
ssize_t wr = 0;
- /** WARNING: this is not safe for writing more than PIPE_BUF bytes! **/
-
sigpipe = sigismember(&current->pending.signal, SIGPIPE);
/* Save pointer to user space and point back to kernel space */
fs = get_fs();
set_fs(KERNEL_DS);
+ mutex_lock(&sbi->pipe_mutex);
while (bytes &&
(wr = file->f_op->write(file,data,bytes,&file->f_pos)) > 0) {
data += wr;
bytes -= wr;
}
+ mutex_lock(&sbi->pipe_mutex);
set_fs(fs);
@@ -179,7 +180,7 @@ static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
mutex_unlock(&sbi->wq_mutex);
- if (autofs4_write(pipe, &pkt, pktsz))
+ if (autofs4_write(sbi, pipe, &pkt, pktsz))
autofs4_catatonic_mode(sbi);
fput(pipe);
}