Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5092cee authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "f2fs: don't issue discard commands in online discard is on"

parents f045f0cb 30a1bcc1
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -2449,23 +2449,24 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
	if (err)
		goto out;

	start_block = START_BLOCK(sbi, start_segno);
	end_block = START_BLOCK(sbi, end_segno + 1);

	__init_discard_policy(sbi, &dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen);
	__issue_discard_cmd_range(sbi, &dpolicy, start_block, end_block);

	/*
	 * We filed discard candidates, but actually we don't need to wait for
	 * all of them, since they'll be issued in idle time along with runtime
	 * discard option. User configuration looks like using runtime discard
	 * or periodic fstrim instead of it.
	 */
	if (!test_opt(sbi, DISCARD)) {
	if (test_opt(sbi, DISCARD))
		goto out;

	start_block = START_BLOCK(sbi, start_segno);
	end_block = START_BLOCK(sbi, end_segno + 1);

	__init_discard_policy(sbi, &dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen);
	__issue_discard_cmd_range(sbi, &dpolicy, start_block, end_block);

	trimmed = __wait_discard_cmd_range(sbi, &dpolicy,
					start_block, end_block);
	range->len = F2FS_BLK_TO_BYTES(trimmed);
	}
out:
	return err;
}