From: OGAWA Hirofumi Subject: Re: [PATCH 2/5] [FAT] Let the block device know when sectors can be discarded Date: Thu, 07 Aug 2008 01:40:44 +0900 Message-ID: <873aliqepf.fsf@devron.myhome.or.jp> References: <488B7281.4020007@gmail.com> <20080726130200.f541e604.akpm@linux-foundation.org> <1217900716.3454.667.camel@pmac.infradead.org> <20080805114210.GW20055@kernel.dk> <1217953741.3454.784.camel@pmac.infradead.org> <1217957140.3454.800.camel@pmac.infradead.org> <1218014720.5111.37.camel@pmac.infradead.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jens Axboe , Andrew Morton , Ric Wheeler , linux-fsdevel@vger.kernel.org, gilad@codefidence.com To: David Woodhouse Return-path: Received: from mail.parknet.ad.jp ([210.171.162.6]:56702 "EHLO mail.officemail.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754410AbYHFQks (ORCPT ); Wed, 6 Aug 2008 12:40:48 -0400 In-Reply-To: <1218014720.5111.37.camel@pmac.infradead.org> (David Woodhouse's message of "Wed, 06 Aug 2008 10:25:20 +0100") Sender: linux-fsdevel-owner@vger.kernel.org List-ID: David Woodhouse writes: > @@ -540,6 +541,11 @@ int fat_free_clusters(struct inode *inode, int cluster) > fatent_init(&fatent); > lock_fat(sbi); > do { > + /* Issue discard for the sectors we no longer care about */ > + blkdev_issue_discard(sb->s_bdev, > + fat_clus_to_blknr(sbi, cluster), > + sbi->sec_per_clus, NULL); > + > cluster = fat_ent_read(inode, &fatent, cluster); > if (cluster < 0) { > err = cluster; Perhaps, after checking cluster-chain corruption is better. Thanks. Signed-off-by: David Woodhouse [just tweak] Signed-off-by: OGAWA Hirofumi --- fs/fat/fatent.c | 5 +++++ 1 file changed, 5 insertions(+) diff -puN fs/fat/fatent.c~test fs/fat/fatent.c --- linux-2.6/fs/fat/fatent.c~test 2008-08-07 01:24:23.000000000 +0900 +++ linux-2.6-hirofumi/fs/fat/fatent.c 2008-08-07 01:33:07.000000000 +0900 @@ -551,6 +551,11 @@ int fat_free_clusters(struct inode *inod goto error; } + /* Issue discard for the sectors we no longer care about */ + blkdev_issue_discard(sb->s_bdev, + fat_clus_to_blknr(sbi, fatent.entry), + sbi->sec_per_clus, NULL); + ops->ent_put(&fatent, FAT_ENT_FREE); if (sbi->free_clusters != -1) { sbi->free_clusters++; _ -- OGAWA Hirofumi