Re: [RFC] [PATCHv3 0/9] reiser4: batch discard support (FITRIM ioctl): initial implementation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Monday 18 August 2014 at 01:52:50, Ivan Shapovalov wrote:	
> [...]
> 
> Ivan Shapovalov (9):
>   reiser4: block_alloc: add BA_SOME_SPACE flag for grabbing a fixed amount of space.
>   reiser4: block_alloc: add a "forward" parameter to reiser4_blocknr_hint to allocate blocks only in forward direction.
>   reiser4: txnmgr: free allocated but unneeded atom in atom_begin_and_assign_to_txnh().
>   reiser4: txnmgr: add reiser4_create_atom() which creates an empty atom without capturing any nodes.
>   reiser4: txnmgr: call reiser4_post_write_back_hook() for empty atoms.
>   reiser4: batch discard support: add a dummy FITRIM ioctl handler for directories.
>   reiser4: batch discard support: actually implement the FITRIM ioctl handler.
>   reiser4: block_alloc: add a "min_len" parameter to reiser4_blocknr_hint to limit allocated extent length from below.
>   reiser4: batch discard support: honor minimal extent length passed from the userspace.
> 
>  [...]

This is a diff between v2 and v3, for ease of reviewing.

diff --git a/fs/reiser4/block_alloc.c b/fs/reiser4/block_alloc.c
index 8797b43..9eed7fc 100644
--- a/fs/reiser4/block_alloc.c
+++ b/fs/reiser4/block_alloc.c
@@ -278,8 +278,7 @@ reiser4_grab(reiser4_context * ctx, __u64 count, reiser4_ba_flags_t flags)
 
 	if (flags & BA_SOME_SPACE) {
 		/* Reserve 25% of all free space. */
-		count = free_blocks;
-		do_div(count, 4);
+		count = free_blocks >> 2;
 	}
 
 	if ((use_reserved && free_blocks < count) ||
diff --git a/fs/reiser4/block_alloc.h b/fs/reiser4/block_alloc.h
index 08b3941..16f9810 100644
--- a/fs/reiser4/block_alloc.h
+++ b/fs/reiser4/block_alloc.h
@@ -45,6 +45,8 @@ struct reiser4_blocknr_hint {
 	reiser4_block_nr blk;
 	/* if not zero, it is a region size we search for free blocks in */
 	reiser4_block_nr max_dist;
+	/* if not zero, minimal length of an extent to allocate */
+	reiser4_block_nr min_len;
 	/* level for allocation, may be useful have branch-level and higher
 	   write-optimized. */
 	tree_level level;
diff --git a/fs/reiser4/plugin/space/bitmap.c b/fs/reiser4/plugin/space/bitmap.c
index 9beaf66..8309cf9 100644
--- a/fs/reiser4/plugin/space/bitmap.c
+++ b/fs/reiser4/plugin/space/bitmap.c
@@ -1101,7 +1101,7 @@ static int alloc_blocks_forward(reiser4_blocknr_hint *hint, int needed,
 				reiser4_block_nr *start, reiser4_block_nr *len)
 {
 	struct super_block *super = get_current_context()->super;
-	int actual_len;
+	int min_len, actual_len;
 
 	reiser4_block_nr search_start;
 	reiser4_block_nr search_end;
@@ -1117,12 +1117,17 @@ static int alloc_blocks_forward(reiser4_blocknr_hint *hint, int needed,
 		    LIMIT(hint->blk + hint->max_dist,
 			  reiser4_block_count(super));
 
+	if (hint->min_len == 0)
+		min_len = 1;
+	else
+		min_len = (int)hint->min_len;
+
 	/* We use @hint -> blk as a search start and search from it to the end
 	   of the disk or in given region if @hint -> max_dist is not zero */
 	search_start = hint->blk;
 
 	actual_len =
-	    bitmap_alloc_forward(&search_start, &search_end, 1, needed);
+	    bitmap_alloc_forward(&search_start, &search_end, min_len, needed);
 
 	/* There is only one bitmap search if max_dist was specified or first
 	   pass was from the beginning of the bitmap. We also do one pass for
@@ -1150,7 +1155,7 @@ static int alloc_blocks_backward(reiser4_blocknr_hint * hint, int needed,
 {
 	reiser4_block_nr search_start;
 	reiser4_block_nr search_end;
-	int actual_len;
+	int min_len, actual_len;
 
 	ON_DEBUG(struct super_block *super = reiser4_get_current_sb());
 
@@ -1164,8 +1169,13 @@ static int alloc_blocks_backward(reiser4_blocknr_hint * hint, int needed,
 	else
 		search_end = search_start - hint->max_dist;
 
+	if (hint->min_len == 0)
+		min_len = 1;
+	else
+		min_len = (int)hint->min_len;
+
 	actual_len =
-	    bitmap_alloc_backward(&search_start, &search_end, 1, needed);
+	    bitmap_alloc_backward(&search_start, &search_end, min_len, needed);
 	if (actual_len == 0)
 		return RETERR(-ENOSPC);
 	if (actual_len < 0)
diff --git a/fs/reiser4/super_ops.c b/fs/reiser4/super_ops.c
index 0048e83..f4cf0ff 100644
--- a/fs/reiser4/super_ops.c
+++ b/fs/reiser4/super_ops.c
@@ -14,7 +14,6 @@
 #include <linux/debugfs.h>
 #include <linux/backing-dev.h>
 #include <linux/module.h>
-#include <linux/delay.h>
 
 /* slab cache for inodes */
 static struct kmem_cache *inode_cache;
@@ -482,28 +481,25 @@ static int reiser4_show_options(struct seq_file *m, struct dentry *dentry)
 int reiser4_trim_fs(struct super_block *super, struct fstrim_range* range)
 {
 	reiser4_blocknr_hint hint;
-	reiser4_block_nr start, end, len, minlen, discarded_count = 0;
+	reiser4_block_nr start, end, len, discarded_count = 0;
 	reiser4_context *ctx;
-	struct super_block *sb;
 	txn_atom *atom;
 	int ret, finished = 0;
 
 	reiser4_blocknr_hint_init(&hint);
 	ctx = get_current_context();
-	sb = ctx->super;
 
 	/*
 	 * Configure the hint for block allocator.
 	 * We will allocate in forward direction only.
 	 */
-
-	hint.blk = range->start >> sb->s_blocksize_bits;
-	hint.max_dist = range->len >> sb->s_blocksize_bits;
+	hint.blk = range->start >> super->s_blocksize_bits;
+	hint.max_dist = range->len >> super->s_blocksize_bits;
+	hint.min_len = range->minlen >> super->s_blocksize_bits;
 	hint.block_stage = BLOCK_GRABBED;
 	hint.forward = 1;
 
 	end = hint.blk + hint.max_dist;
-	minlen = range->minlen >> sb->s_blocksize_bits;
 
 	/*
 	 * We will perform the process in iterations in order not to starve
@@ -536,7 +532,6 @@ int reiser4_trim_fs(struct super_block *super, struct fstrim_range* range)
 		while (ctx->grabbed_blocks != 0) {
 			/*
 			 * Allocate no more than is grabbed.
-			 * FIXME: use minlen.
 			 */
 			len = ctx->grabbed_blocks;
 			ret = reiser4_alloc_blocks(&hint, &start, &len, 0 /* flags */);
@@ -597,7 +592,7 @@ out:
 	/*
 	 * Update the statistics.
 	 */
-	range->len = discarded_count << sb->s_blocksize_bits;
+	range->len = discarded_count << super->s_blocksize_bits;
 
 	return ret;
 }

Thanks,
-- 
Ivan Shapovalov / intelfx /

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux File System Development]     [Linux BTRFS]     [Linux NFS]     [Linux Filesystems]     [Ext4 Filesystem]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Resources]

  Powered by Linux