Re: [PATCH] fs: Make write(2) interruptible by a fatal signal

From: Matthew Wilcox
Date: Thu Dec 01 2011 - 09:27:08 EST


On Thu, Dec 01, 2011 at 08:24:25PM +0800, Wu Fengguang wrote:
> > This patch makes write interruptible by SIGKILL.
>
> Let me try to summarize the objective impacts of (not) merging this
> patch, and would like to hear more opinions from experienced users.
>
> - w/o patch
>
> BEHAVIOR:
> write(2) insists to complete even when the user really wants to stop it.
>
> IMPACT:
> It could be annoying to experience slow responses to "kill -9" when
> it's a large write to a slow device, for example,
>
> dd if=/dev/zero of=/mnt/nokia/zero bs=100M

Another problem scenario is an NFS mounted file going away while the
user is writing to it. The user should be able to kill the stuck process
without rebooting their machine.

> - w/ patch
>
> BEHAVIOR:
> write(2) aborts quickly with possible partial write on SIGKILL
>
> IMPACT:
> The partial write might lead to data corruption somewhere, sometime
> (the possibility is low but real) and bring trouble to some users.

Let's examine these cases. We've already written at least some of the
data into the page cache (and updated i_size for extending writes in the
call to ->write_end). It's just not hit the backing store yet. That means
that this state of affairs is already *visible* to another process on the
same machine, it's just not *durable* (eg in the event of power failure).

I think in the worst case, we've simply extended the window of opportunity
for another process to see the partial write.

So, please add

Acked-by: Matthew Wilcox <matthew.r.wilcox@xxxxxxxxx>

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
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/