From: Ivan Shapovalov <intelfx100@gmail.com>
To: reiserfs-devel@vger.kernel.org
Cc: Ivan Shapovalov <intelfx100@gmail.com>
Subject: [PATCHv4 09/10] reiser4: block_alloc: add a "min_len" parameter to reiser4_blocknr_hint to limit allocated extent length from below.
Date: Sat, 13 Dec 2014 00:00:45 +0300 [thread overview]
Message-ID: <1418418046-10933-10-git-send-email-intelfx100@gmail.com> (raw)
In-Reply-To: <1418418046-10933-1-git-send-email-intelfx100@gmail.com>
The default has been 1, that is, the first encountered free extent with any length
from 1 to requested is allocated and returned.
So, allow changing minimal extent length to allocate.
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
---
fs/reiser4/block_alloc.h | 2 ++
fs/reiser4/plugin/space/bitmap.c | 20 +++++++++++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/fs/reiser4/block_alloc.h b/fs/reiser4/block_alloc.h
index 903bc8f..ac1a747 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 0ce07da..7c0a1e4 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, first
pass was from the beginning of the bitmap, or if the monotonic flag
@@ -1134,7 +1139,7 @@ static int alloc_blocks_forward(reiser4_blocknr_hint *hint, int needed,
search_end = search_start;
search_start = 0;
actual_len =
- bitmap_alloc_forward(&search_start, &search_end, 1, needed);
+ bitmap_alloc_forward(&search_start, &search_end, min_len, needed);
}
if (actual_len == 0)
return RETERR(-ENOSPC);
@@ -1151,7 +1156,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());
@@ -1165,8 +1170,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)
--
2.1.3
next prev parent reply other threads:[~2014-12-12 21:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-12 21:00 [PATCHv4 00/10] reiser4: batch discard support (FITRIM ioctl): initial implementation Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 01/10] reiser4: block_alloc: add BA_SOME_SPACE flag for grabbing a fixed amount of space Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 02/10] reiser4: block_alloc: add a "monotonic_forward" parameter to reiser4_blocknr_hint to allocate blocks only in forward direction Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 03/10] reiser4: block_alloc: move block accounting by pre-commit hook into block_alloc.c and document BA_DEFER behavior Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 04/10] reiser4: txnmgr: free allocated but unneeded atom in atom_begin_and_assign_to_txnh() Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 05/10] reiser4: txnmgr: add reiser4_create_atom() which creates an empty atom without capturing any nodes Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 06/10] reiser4: txnmgr: move "empty atom" shortcut slightly below Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 07/10] reiser4: batch discard support: add a dummy FITRIM ioctl handler for directories Ivan Shapovalov
2014-12-12 21:00 ` [PATCHv4 08/10] reiser4: batch discard support: actually implement the FITRIM ioctl handler Ivan Shapovalov
2014-12-12 21:00 ` Ivan Shapovalov [this message]
2014-12-12 21:00 ` [PATCHv4 10/10] reiser4: batch discard support: honor minimal extent length passed from the userspace Ivan Shapovalov
2014-12-12 21:02 ` [PATCHv4 00/10] reiser4: batch discard support (FITRIM ioctl): initial implementation Ivan Shapovalov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418418046-10933-10-git-send-email-intelfx100@gmail.com \
--to=intelfx100@gmail.com \
--cc=reiserfs-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).