fat: make discard a mount option

Currently shipping discard capable SSDs and arrays have rather sub-optimal
implementations of the command and can the use of it can cause massive
slowdowns.  Make issueing these commands option as it's already in btrfs
and gfs2.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[hirofumi@mail.parknet.co.jp: tweaks, and add "discard" to fat_show_options]
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
This commit is contained in:
Christoph Hellwig
2009-11-21 20:28:52 +09:00
committed by OGAWA Hirofumi
parent a8a8a669ea
commit 681142f921
3 changed files with 23 additions and 11 deletions

View File

@@ -566,16 +566,21 @@ int fat_free_clusters(struct inode *inode, int cluster)
goto error;
}
/*
* Issue discard for the sectors we no longer care about,
* batching contiguous clusters into one request
*/
if (cluster != fatent.entry + 1) {
int nr_clus = fatent.entry - first_cl + 1;
if (sbi->options.discard) {
/*
* Issue discard for the sectors we no longer
* care about, batching contiguous clusters
* into one request
*/
if (cluster != fatent.entry + 1) {
int nr_clus = fatent.entry - first_cl + 1;
sb_issue_discard(sb, fat_clus_to_blknr(sbi, first_cl),
nr_clus * sbi->sec_per_clus);
first_cl = cluster;
sb_issue_discard(sb,
fat_clus_to_blknr(sbi, first_cl),
nr_clus * sbi->sec_per_clus);
first_cl = cluster;
}
}
ops->ent_put(&fatent, FAT_ENT_FREE);