From: Jan Kara Subject: [PATCH 2/2] fs: Make write(2) interruptible by a signal Date: Mon, 14 Nov 2011 12:10:30 +0100 Message-ID: <1321269030-6019-3-git-send-email-jack@suse.cz> References: <1321269030-6019-1-git-send-email-jack@suse.cz> Cc: Wu Fengguang , Al Viro , k-mio@sx.jp.nec.com, Andrew Morton , Christoph Hellwig , Jan Kara To: linux-fsdevel@vger.kernel.org Return-path: Received: from cantor2.suse.de ([195.135.220.15]:47452 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755086Ab1KNLLF (ORCPT ); Mon, 14 Nov 2011 06:11:05 -0500 In-Reply-To: <1321269030-6019-1-git-send-email-jack@suse.cz> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Currently write(2) to a file is not interruptible by a signal. Sometimes this is desirable (e.g. when you want to quickly kill a process hogging your disk or when some process gets blocked in balance_dirty_pages() indefinitely due to a filesystem being in an error condition). Reported-by: Kazuya Mio Tested-by: Kazuya Mio Signed-off-by: Jan Kara --- mm/filemap.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c0018f2..6b01d2f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2407,6 +2407,10 @@ static ssize_t generic_perform_write(struct file *file, iov_iter_count(i)); again: + if (signal_pending(current)) { + status = -EINTR; + break; + } /* * Bring in the user page that we will copy from _first_. -- 1.7.1