reiserfs-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ivan Shapovalov <intelfx100@gmail.com>
To: reiserfs-devel@vger.kernel.org
Cc: Ivan Shapovalov <intelfx100@gmail.com>
Subject: [PATCHv2 2/3] reiser4: block_alloc: sanitize grab_enabled modifications.
Date: Thu, 23 Oct 2014 11:18:04 +0400	[thread overview]
Message-ID: <1414048685-4224-3-git-send-email-intelfx100@gmail.com> (raw)
In-Reply-To: <1414048685-4224-1-git-send-email-intelfx100@gmail.com>

- check and modify ctx->grab_enabled in reiser4_grab_space(), not reiser4_grab()
- do not re-enable grab before doing second attempt in BA_CAN_COMMIT sequence
  (it is unneeded given the first change)

Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
---
 fs/reiser4/block_alloc.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/fs/reiser4/block_alloc.c b/fs/reiser4/block_alloc.c
index 7f9f910..9339de7 100644
--- a/fs/reiser4/block_alloc.c
+++ b/fs/reiser4/block_alloc.c
@@ -270,12 +270,6 @@ reiser4_grab(reiser4_context * ctx, __u64 count, reiser4_ba_flags_t flags)
 
 	assert("vs-1276", ctx == get_current_context());
 
-	/* Do not grab anything on ro-mounted fs. */
-	if (rofs_super(ctx->super)) {
-		ctx->grab_enabled = 0;
-		return 0;
-	}
-
 	sbinfo = get_super_private(ctx->super);
 
 	spin_lock_reiser4_super(sbinfo);
@@ -300,9 +294,6 @@ reiser4_grab(reiser4_context * ctx, __u64 count, reiser4_ba_flags_t flags)
 
 	assert("nikita-2986", reiser4_check_block_counters(ctx->super));
 
-	/* disable grab space in current context */
-	ctx->grab_enabled = 0;
-
 unlock_and_ret:
 	spin_unlock_reiser4_super(sbinfo);
 
@@ -321,6 +312,12 @@ int reiser4_grab_space(__u64 count, reiser4_ba_flags_t flags)
 	if (!(flags & BA_FORCE) && !is_grab_enabled(ctx))
 		return 0;
 
+	/* Do not grab anything on ro-mounted fs. */
+	if (rofs_super(ctx->super)) {
+		ctx->grab_enabled = 0;
+		return 0;
+	}
+
 	ret = reiser4_grab(ctx, count, flags);
 	if (ret == -ENOSPC) {
 
@@ -328,10 +325,15 @@ int reiser4_grab_space(__u64 count, reiser4_ba_flags_t flags)
 		   present */
 		if (flags & BA_CAN_COMMIT) {
 			txnmgr_force_commit_all(ctx->super, 0);
-			ctx->grab_enabled = 1;
 			ret = reiser4_grab(ctx, count, flags);
 		}
 	}
+
+	if (ret == 0) {
+		/* disable grab space in current context */
+		ctx->grab_enabled = 0;
+	}
+
 	/*
 	 * allocation from reserved pool cannot fail. This is severe error.
 	 */
-- 
2.1.2


  parent reply	other threads:[~2014-10-23  7:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-23  7:18 [PATCHv2 0/3] reiser4: space grabbing fixes Ivan Shapovalov
2014-10-23  7:18 ` [PATCHv2 1/3] reiser4: block_alloc: improve error handling in reiser4_grab_reserved() Ivan Shapovalov
2014-10-23  7:18 ` Ivan Shapovalov [this message]
2014-11-16  5:38   ` [PATCHv2 2/3] reiser4: block_alloc: sanitize grab_enabled modifications Ivan Shapovalov
2014-11-16  9:53     ` Edward Shishkin
2014-11-16 10:45       ` Edward Shishkin
2014-11-16 11:49         ` Edward Shishkin
2014-11-16 10:45       ` Edward Shishkin
2014-11-19  1:39         ` Ivan Shapovalov
2014-10-23  7:18 ` [PATCHv2 3/3] reiser4: do not mess with grab_enabled; instead, use BA_FORCE Ivan Shapovalov
2014-10-23  7:20 ` [PATCHv2 0/3] reiser4: space grabbing fixes Ivan Shapovalov
2014-12-10 12:27 ` Ivan Shapovalov
2014-12-10 12:52   ` Edward Shishkin
2014-12-10 13:30     ` Ivan Shapovalov
2014-12-10 21:51       ` Edward Shishkin
2014-12-12 22:19         ` Ivan Shapovalov
2014-12-13 23:41           ` Edward Shishkin

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=1414048685-4224-3-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).