From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xishi Qiu Subject: [PATCH V2] fs: don't write pages when receiving a pending SIGKILL in __get_user_pages() Date: Sat, 18 Jan 2014 09:20:50 +0800 Message-ID: <52D9D6F2.2030003@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: , LKML To: , David Rientjes , Return-path: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org In the process IO direction, dio_refill_pages will call get_user_pages_= fast=20 to map the page from user space. If ret is less than 0 and IO is write,= the=20 function will create a zero page to fill data. This may work for some f= ile=20 system, but in some device operate we prefer whole write or fail, not h= alf=20 data half zero, e.g. fs metadata, like inode, identy. This happens often when kill a process which is doing direct IO. Consid= er=20 the following cases, the process A is doing IO process, may enter __get= _user_pages=20 function, if other processes send process A SIG_KILL, A will enter the=20 following branches=20 /* * If we have a pending SIGKILL, don't keep faulting * pages and potentially allocating memory. */ if (unlikely(fatal_signal_pending(current))) return i ? i : -ERESTARTSYS; Return current pages. direct IO will write the pages, the subsequent pa= ges=20 which can=92t get will use zero page instead.=20 Signed-off-by: Xishi Qiu Signed-off-by: Bin Yang --- fs/direct-io.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/fs/direct-io.c b/fs/direct-io.c index 0e04142..b74d565 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -174,6 +174,9 @@ static inline int dio_refill_pages(struct dio *dio,= struct dio_submit *sdio) &dio->pages[0]); /* Put results here */ =20 if (ret < 0 && sdio->blocks_available && (dio->rw & WRITE)) { + /* If task is killed, do not write anymore */ + if (ret =3D=3D -ERESTARTSYS) + goto out; struct page *page =3D ZERO_PAGE(0); /* * A memory fault, but the filesystem has some outstanding --=20 1.7.1