f2fs: allow f2fs_ioc_{,de}compress_file to be interrupted
authorChao Yu <chao@kernel.org>
Tue, 11 Jul 2023 20:08:05 +0000 (04:08 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 14 Aug 2023 20:41:08 +0000 (13:41 -0700)
This patch allows f2fs_ioc_{,de}compress_file() to be interrupted, so that,
userspace won't be blocked when manual {,de}compression on large file is
interrupted by signal.

Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/file.c

index d9073afe021fd43a39507ada34638acee66970a1..79cb6a41f128911705d8cfea00ff51ffed0dccdd 100644 (file)
@@ -4107,6 +4107,12 @@ static int f2fs_ioc_decompress_file(struct file *filp)
 
                count -= len;
                page_idx += len;
+
+               cond_resched();
+               if (fatal_signal_pending(current)) {
+                       ret = -EINTR;
+                       break;
+               }
        }
 
        if (!ret)
@@ -4181,6 +4187,12 @@ static int f2fs_ioc_compress_file(struct file *filp)
 
                count -= len;
                page_idx += len;
+
+               cond_resched();
+               if (fatal_signal_pending(current)) {
+                       ret = -EINTR;
+                       break;
+               }
        }
 
        if (!ret)