public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [EXT2] Discard unused sectors
@ 2008-08-14  8:59 David Woodhouse
  2008-08-14  9:05 ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: David Woodhouse @ 2008-08-14  8:59 UTC (permalink / raw)
  To: linux-ext4

When a file is deleted, tell the block device that we don't care about
its blocks any more.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
For linux-next, where sb_issue_discard() has been implemented.
http://git.kernel.dk/?p=linux-2.6-block.git;a=shortlog;h=refs/heads/for-next

 fs/ext2/balloc.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
index 10bb02c..03fc2dc 100644
--- a/fs/ext2/balloc.c
+++ b/fs/ext2/balloc.c
@@ -16,6 +16,7 @@
 #include <linux/sched.h>
 #include <linux/buffer_head.h>
 #include <linux/capability.h>
+#include <linux/blkdev.h>
 
 /*
  * balloc.c contains the blocks allocation and deallocation routines
@@ -478,13 +479,13 @@ void ext2_discard_reservation(struct inode *inode)
 }
 
 /**
- * ext2_free_blocks_sb() -- Free given blocks and update quota and i_blocks
+ * ext2_free_blocks() -- Free given blocks and update quota and i_blocks
  * @inode:		inode
  * @block:		start physcial block to free
  * @count:		number of blocks to free
  */
-void ext2_free_blocks (struct inode * inode, unsigned long block,
-		       unsigned long count)
+void ext2_free_blocks(struct inode * inode, unsigned long block,
+		      unsigned long count)
 {
 	struct buffer_head *bitmap_bh = NULL;
 	struct buffer_head * bh2;
@@ -555,6 +556,8 @@ do_more:
 		}
 	}
 
+	sb_issue_discard(sb, block, count);
+
 	mark_buffer_dirty(bitmap_bh);
 	if (sb->s_flags & MS_SYNCHRONOUS)
 		sync_dirty_buffer(bitmap_bh);
-- 
1.5.5.1


-- 
David Woodhouse                            Open Source Technology Centre
David.Woodhouse@intel.com                              Intel Corporation




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-08-15 18:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-14  8:59 [EXT2] Discard unused sectors David Woodhouse
2008-08-14  9:05 ` David Woodhouse
2008-08-15 12:02   ` Theodore Tso
2008-08-15 18:18     ` Aneesh Kumar K.V

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox