From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Woodhouse Subject: Re: [PATCH 2/5] [FAT] Let the block device know when sectors can be discarded Date: Thu, 07 Aug 2008 17:09:05 +0100 Message-ID: <1218125345.12232.65.camel@pmac.infradead.org> 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> <873aliqepf.fsf@devron.myhome.or.jp> <1218046269.5111.120.camel@pmac.infradead.org> <87promot6v.fsf@devron.myhome.or.jp> <1218058669.5111.150.camel@pmac.infradead.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: Jens Axboe , Andrew Morton , Ric Wheeler , linux-fsdevel@vger.kernel.org, gilad@codefidence.com To: OGAWA Hirofumi Return-path: Received: from bombadil.infradead.org ([18.85.46.34]:38760 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755179AbYHGQJV (ORCPT ); Thu, 7 Aug 2008 12:09:21 -0400 In-Reply-To: <1218058669.5111.150.camel@pmac.infradead.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed, 2008-08-06 at 22:37 +0100, David Woodhouse wrote: > > Yes and no. I guess bytes or _fs_-blocksize is good interface for fs. > > OK. I'll do the latter; thank you. Incremental patch over what I posted before... diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c index 5970fd6..a8b10ac 100644 --- a/fs/fat/fatent.c +++ b/fs/fat/fatent.c @@ -541,11 +541,6 @@ 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; @@ -557,6 +552,10 @@ int fat_free_clusters(struct inode *inode, int cluster) goto error; } + /* Issue discard for the sectors we no longer care about */ + sb_issue_discard(sb, 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++; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 3f077a5..9b33909 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -840,6 +840,15 @@ extern int blkdev_issue_flush(struct block_device *, sector_t *); extern int blkdev_issue_discard(struct block_device *, sector_t sector, unsigned nr_sects, bio_end_io_t *); +static inline int sb_issue_discard(struct super_block *sb, + sector_t block, unsigned nr_blocks, + bio_end_io_t *endio) +{ + block <<= (sb->s_blocksize_bits - 9); + nr_blocks <<= (sb->s_blocksize_bits - 9); + return blkdev_issue_discard(sb->s_bdev, block, nr_blocks, endio); +} + /* * command filter functions */ diff --git a/mm/bounce.c b/mm/bounce.c index b6d2d0f..1cfe193 100644 --- a/mm/bounce.c +++ b/mm/bounce.c @@ -267,7 +267,7 @@ void blk_queue_bounce(struct request_queue *q, struct bio **bio_orig) /* * Data-less bio, nothing to bounce */ - if (bio_empty_barrier(*bio_orig)) + if (bio_dataless(*bio_orig)) return; /* -- David Woodhouse Open Source Technology Centre David.Woodhouse@intel.com Intel Corporation