Re:[PATCH 1/3] eCryptfs: Make truncate path killable

From: Li Wang
Date: Tue Jan 24 2012 - 20:50:33 EST


Hi Tyler,
Is it more polite to invoke cond_resched() at the beginning/end of the potentially long-time loop?

Cheers,
Li Wang





---------- Origin message ----------
>From:"Tyler Hicks" <tyhicks@xxxxxxxxxxxxx>
>To:ecryptfs@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, linux-fsdevel@xxxxxxxxxxxxxxx
>Subject:[PATCH 1/3] eCryptfs: Make truncate path killable
>Date:2012-01-21 06:35:05

ecryptfs_write() handles the truncation of eCryptfs inodes. It grabs a
page, zeroes out the appropriate portions, and then encrypts the page
before writing it to the lower filesystem. It was unkillable and due to
the lack of sparse file support could result in tying up a large portion
of system resources, while encrypting pages of zeros, with no way for
the truncate operation to be stopped from userspace.

This patch adds the ability for ecryptfs_write() to detect a pending
fatal signal and return as gracefully as possible. The intent is to
leave the lower file in a useable state, while still allowing a user to
break out of the encryption loop. If a pending fatal signal is detected,
the eCryptfs inode size is updated to reflect the modified inode size
and then -EINTR is returned.

Signed-off-by: Tyler Hicks <tyhicks@xxxxxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
---
fs/ecryptfs/read_write.c | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
韬{.n?壏煯壄?%娝lzwm呴b濍Р骒r笡zXЩ畐{ay?蕠跈?jf"穐殝鄗?畐ア?⒎:+v墾妛鑚豰稛?珣赙zZ+凒殠娸"濟!秈O曟瑉窔v豝?m?鹈 n茒帼Y&—