mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
Let the block device know when sectors can be discarded
[hirofumi@mail.parknet.co.jp: discard _after_ checking for corrupt chains] Signed-off-by: David Woodhouse <David.Woodhouse@intel.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
This commit is contained in:
parent
fb2dce862d
commit
8c540a96c1
1 changed files with 14 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/msdos_fs.h>
|
#include <linux/msdos_fs.h>
|
||||||
|
#include <linux/blkdev.h>
|
||||||
|
|
||||||
struct fatent_operations {
|
struct fatent_operations {
|
||||||
void (*ent_blocknr)(struct super_block *, int, int *, sector_t *);
|
void (*ent_blocknr)(struct super_block *, int, int *, sector_t *);
|
||||||
|
@ -535,6 +536,7 @@ int fat_free_clusters(struct inode *inode, int cluster)
|
||||||
struct fat_entry fatent;
|
struct fat_entry fatent;
|
||||||
struct buffer_head *bhs[MAX_BUF_PER_PAGE];
|
struct buffer_head *bhs[MAX_BUF_PER_PAGE];
|
||||||
int i, err, nr_bhs;
|
int i, err, nr_bhs;
|
||||||
|
int first_cl = cluster;
|
||||||
|
|
||||||
nr_bhs = 0;
|
nr_bhs = 0;
|
||||||
fatent_init(&fatent);
|
fatent_init(&fatent);
|
||||||
|
@ -551,6 +553,18 @@ int fat_free_clusters(struct inode *inode, int cluster)
|
||||||
goto error;
|
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;
|
||||||
|
|
||||||
|
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);
|
ops->ent_put(&fatent, FAT_ENT_FREE);
|
||||||
if (sbi->free_clusters != -1) {
|
if (sbi->free_clusters != -1) {
|
||||||
sbi->free_clusters++;
|
sbi->free_clusters++;
|
||||||
|
|
Loading…
Reference in a new issue