mirror of https://github.com/OpenIPC/firmware.git
122 lines
4.4 KiB
Diff
122 lines
4.4 KiB
Diff
diff -drupN a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
|
|
--- a/fs/ext4/mballoc.c 2018-08-06 17:23:04.000000000 +0300
|
|
+++ b/fs/ext4/mballoc.c 2022-06-12 05:28:14.000000000 +0300
|
|
@@ -2773,7 +2773,8 @@ int ext4_mb_release(struct super_block *
|
|
}
|
|
|
|
static inline int ext4_issue_discard(struct super_block *sb,
|
|
- ext4_group_t block_group, ext4_grpblk_t cluster, int count)
|
|
+ ext4_group_t block_group, ext4_grpblk_t cluster, int count,
|
|
+ unsigned long flags)
|
|
{
|
|
ext4_fsblk_t discard_block;
|
|
|
|
@@ -2782,7 +2783,7 @@ static inline int ext4_issue_discard(str
|
|
count = EXT4_C2B(EXT4_SB(sb), count);
|
|
trace_ext4_discard_blocks(sb,
|
|
(unsigned long long) discard_block, count);
|
|
- return sb_issue_discard(sb, discard_block, count, GFP_NOFS, 0);
|
|
+ return sb_issue_discard(sb, discard_block, count, GFP_NOFS, flags);
|
|
}
|
|
|
|
/*
|
|
@@ -2804,7 +2805,7 @@ static void ext4_free_data_callback(stru
|
|
if (test_opt(sb, DISCARD)) {
|
|
err = ext4_issue_discard(sb, entry->efd_group,
|
|
entry->efd_start_cluster,
|
|
- entry->efd_count);
|
|
+ entry->efd_count, 0);
|
|
if (err && err != -EOPNOTSUPP)
|
|
ext4_msg(sb, KERN_WARNING, "discard request in"
|
|
" group:%d block:%d count:%d failed"
|
|
@@ -4863,7 +4864,8 @@ do_more:
|
|
* them with group lock_held
|
|
*/
|
|
if (test_opt(sb, DISCARD)) {
|
|
- err = ext4_issue_discard(sb, block_group, bit, count);
|
|
+ err = ext4_issue_discard(sb, block_group, bit, count,
|
|
+ 0);
|
|
if (err && err != -EOPNOTSUPP)
|
|
ext4_msg(sb, KERN_WARNING, "discard request in"
|
|
" group:%d block:%d count:%lu failed"
|
|
@@ -5059,13 +5061,15 @@ error_return:
|
|
* @count: number of blocks to TRIM
|
|
* @group: alloc. group we are working with
|
|
* @e4b: ext4 buddy for the group
|
|
+ * @blkdev_flags: flags for the block device
|
|
*
|
|
* Trim "count" blocks starting at "start" in the "group". To assure that no
|
|
* one will allocate those blocks, mark it as used in buddy bitmap. This must
|
|
* be called with under the group lock.
|
|
*/
|
|
static int ext4_trim_extent(struct super_block *sb, int start, int count,
|
|
- ext4_group_t group, struct ext4_buddy *e4b)
|
|
+ ext4_group_t group, struct ext4_buddy *e4b,
|
|
+ unsigned long blkdev_flags)
|
|
__releases(bitlock)
|
|
__acquires(bitlock)
|
|
{
|
|
@@ -5086,7 +5090,7 @@ __acquires(bitlock)
|
|
*/
|
|
mb_mark_used(e4b, &ex);
|
|
ext4_unlock_group(sb, group);
|
|
- ret = ext4_issue_discard(sb, group, start, count);
|
|
+ ret = ext4_issue_discard(sb, group, start, count, blkdev_flags);
|
|
ext4_lock_group(sb, group);
|
|
mb_free_blocks(NULL, e4b, start, ex.fe_len);
|
|
return ret;
|
|
@@ -5099,6 +5103,7 @@ __acquires(bitlock)
|
|
* @start: first group block to examine
|
|
* @max: last group block to examine
|
|
* @minblocks: minimum extent block count
|
|
+ * @blkdev_flags: flags for the block device
|
|
*
|
|
* ext4_trim_all_free walks through group's buddy bitmap searching for free
|
|
* extents. When the free block is found, ext4_trim_extent is called to TRIM
|
|
@@ -5113,7 +5118,7 @@ __acquires(bitlock)
|
|
static ext4_grpblk_t
|
|
ext4_trim_all_free(struct super_block *sb, ext4_group_t group,
|
|
ext4_grpblk_t start, ext4_grpblk_t max,
|
|
- ext4_grpblk_t minblocks)
|
|
+ ext4_grpblk_t minblocks, unsigned long blkdev_flags)
|
|
{
|
|
void *bitmap;
|
|
ext4_grpblk_t next, count = 0, free_count = 0;
|
|
@@ -5146,7 +5151,8 @@ ext4_trim_all_free(struct super_block *s
|
|
|
|
if ((next - start) >= minblocks) {
|
|
ret = ext4_trim_extent(sb, start,
|
|
- next - start, group, &e4b);
|
|
+ next - start, group, &e4b,
|
|
+ blkdev_flags);
|
|
if (ret && ret != -EOPNOTSUPP)
|
|
break;
|
|
ret = 0;
|
|
@@ -5188,6 +5194,7 @@ out:
|
|
* ext4_trim_fs() -- trim ioctl handle function
|
|
* @sb: superblock for filesystem
|
|
* @range: fstrim_range structure
|
|
+ * @blkdev_flags: flags for the block device
|
|
*
|
|
* start: First Byte to trim
|
|
* len: number of Bytes to trim from start
|
|
@@ -5196,7 +5203,8 @@ out:
|
|
* start to start+len. For each such a group ext4_trim_all_free function
|
|
* is invoked to trim all free space.
|
|
*/
|
|
-int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
|
|
+int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range,
|
|
+ unsigned long blkdev_flags)
|
|
{
|
|
struct ext4_group_info *grp;
|
|
ext4_group_t group, first_group, last_group;
|
|
@@ -5252,7 +5260,7 @@ int ext4_trim_fs(struct super_block *sb,
|
|
|
|
if (grp->bb_free >= minlen) {
|
|
cnt = ext4_trim_all_free(sb, group, first_cluster,
|
|
- end, minlen);
|
|
+ end, minlen, blkdev_flags);
|
|
if (cnt < 0) {
|
|
ret = cnt;
|
|
break;
|