|
16 | 16 | #include <linux/slab.h>
|
17 | 17 | #include <linux/nospec.h>
|
18 | 18 | #include <linux/backing-dev.h>
|
| 19 | +#include <linux/freezer.h> |
19 | 20 | #include <trace/events/ext4.h>
|
20 | 21 |
|
21 | 22 | /*
|
@@ -6916,6 +6917,11 @@ static ext4_grpblk_t ext4_last_grp_cluster(struct super_block *sb,
|
6916 | 6917 | EXT4_CLUSTER_BITS(sb);
|
6917 | 6918 | }
|
6918 | 6919 |
|
| 6920 | +static bool ext4_trim_interrupted(void) |
| 6921 | +{ |
| 6922 | + return fatal_signal_pending(current) || freezing(current); |
| 6923 | +} |
| 6924 | + |
6919 | 6925 | static int ext4_try_to_trim_range(struct super_block *sb,
|
6920 | 6926 | struct ext4_buddy *e4b, ext4_grpblk_t start,
|
6921 | 6927 | ext4_grpblk_t max, ext4_grpblk_t minblocks)
|
@@ -6949,8 +6955,8 @@ __releases(ext4_group_lock_ptr(sb, e4b->bd_group))
|
6949 | 6955 | free_count += next - start;
|
6950 | 6956 | start = next + 1;
|
6951 | 6957 |
|
6952 |
| - if (fatal_signal_pending(current)) |
6953 |
| - return -ERESTARTSYS; |
| 6958 | + if (ext4_trim_interrupted()) |
| 6959 | + return count; |
6954 | 6960 |
|
6955 | 6961 | if (need_resched()) {
|
6956 | 6962 | ext4_unlock_group(sb, e4b->bd_group);
|
@@ -7072,6 +7078,8 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
|
7072 | 7078 | end = EXT4_CLUSTERS_PER_GROUP(sb) - 1;
|
7073 | 7079 |
|
7074 | 7080 | for (group = first_group; group <= last_group; group++) {
|
| 7081 | + if (ext4_trim_interrupted()) |
| 7082 | + break; |
7075 | 7083 | grp = ext4_get_group_info(sb, group);
|
7076 | 7084 | if (!grp)
|
7077 | 7085 | continue;
|
|
0 commit comments