From: Ivan Shapovalov <intelfx100@gmail.com>
To: reiserfs-devel@vger.kernel.org
Cc: edward.shishkin@gmail.com, Ivan Shapovalov <intelfx100@gmail.com>
Subject: [RFC] [PATCH 4/7] reiser4: txnmgr: add reiser4_create_atom() which creates an empty atom without capturing any nodes.
Date: Sun, 17 Aug 2014 19:43:23 +0400 [thread overview]
Message-ID: <1408290206-7427-5-git-send-email-intelfx100@gmail.com> (raw)
In-Reply-To: <1408290206-7427-1-git-send-email-intelfx100@gmail.com>
Signed-off-by: Ivan Shapovalov <intelfx100@gmail.com>
---
fs/reiser4/txnmgr.c | 24 ++++++++++++++++++++++++
fs/reiser4/txnmgr.h | 2 ++
2 files changed, 26 insertions(+)
diff --git a/fs/reiser4/txnmgr.c b/fs/reiser4/txnmgr.c
index 68070a9..2862940 100644
--- a/fs/reiser4/txnmgr.c
+++ b/fs/reiser4/txnmgr.c
@@ -2050,6 +2050,30 @@ int reiser4_try_capture(jnode *node, znode_lock_mode lock_mode,
return ret;
}
+/* This function ensures that the current transcrash has an atom without
+ * capturing anything. If needed, an empty atom is created and assigned.
+ */
+int reiser4_create_atom(void)
+{
+ txn_atom *atom_alloc = NULL;
+ txn_handle *txnh = get_current_context()->trans;
+ int ret;
+
+ do {
+ spin_lock_txnh(txnh);
+ if (txnh->atom == NULL) {
+ spin_unlock_txnh(txnh);
+ /* assign empty atom to the txnh and repeat */
+ ret = atom_begin_and_assign_to_txnh(&atom_alloc, txnh);
+ } else {
+ spin_unlock_txnh(txnh);
+ ret = 0;
+ }
+ } while (ret == -E_REPEAT);
+
+ return ret;
+}
+
static void release_two_atoms(txn_atom *one, txn_atom *two)
{
spin_unlock_atom(one);
diff --git a/fs/reiser4/txnmgr.h b/fs/reiser4/txnmgr.h
index 72b84a2..50a1f54 100644
--- a/fs/reiser4/txnmgr.h
+++ b/fs/reiser4/txnmgr.h
@@ -437,6 +437,8 @@ extern void reiser4_uncapture_jnode(jnode *);
extern int reiser4_capture_inode(struct inode *);
extern int reiser4_uncapture_inode(struct inode *);
+extern int reiser4_create_atom(void);
+
extern txn_atom *get_current_atom_locked_nocheck(void);
#if REISER4_DEBUG
--
2.0.4
next prev parent reply other threads:[~2014-08-17 15:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-17 15:43 [RFC] [PATCH 0/7] reiser4: batch discard support (FITRIM ioctl): initial implementation Ivan Shapovalov
2014-08-17 15:43 ` [RFC] [PATCH 1/7] reiser4: block_alloc: add BA_SOME_SPACE flag for grabbing a fixed amount of space Ivan Shapovalov
2014-08-17 15:43 ` [RFC] [PATCH 2/7] reiser4: block_alloc: add a "forward" parameter to reiser4_blocknr_hint to allocate blocks only in forward direction Ivan Shapovalov
2014-08-17 15:43 ` [RFC] [PATCH 3/7] reiser4: txnmgr: free allocated but unneeded atom in atom_begin_and_assign_to_txnh() Ivan Shapovalov
2014-08-17 15:43 ` Ivan Shapovalov [this message]
2014-08-17 15:43 ` [RFC] [PATCH 5/7] reiser4: txnmgr: call reiser4_post_write_back_hook() for empty atoms Ivan Shapovalov
2014-08-17 15:59 ` Ivan Shapovalov
2014-08-17 16:28 ` Ivan Shapovalov
2014-08-17 15:43 ` [RFC] [PATCH 6/7] reiser4: batch discard support: add a dummy FITRIM ioctl handler for directories Ivan Shapovalov
2014-08-17 15:43 ` [RFC] [PATCH 7/7] reiser4: batch discard support: actually implement the FITRIM ioctl handler Ivan Shapovalov
[not found] ` <CADW=+3kCURR6UB5Tm8OcJnSYV1cNcYtTmbNNrv_QCO3o1RzwDQ@mail.gmail.com>
2014-08-17 16:18 ` [RFC] [PATCH 0/7] reiser4: batch discard support (FITRIM ioctl): initial implementation Ivan Shapovalov
[not found] ` <CADW=+3=B_3pKNzph7EtfXNLbVxxn4dxsykm_RF+ayce9RsoVUQ@mail.gmail.com>
2014-08-17 16:38 ` 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=1408290206-7427-5-git-send-email-intelfx100@gmail.com \
--to=intelfx100@gmail.com \
--cc=edward.shishkin@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).