Signed-off-by: Ivan Shapovalov <intelfx100@xxxxxxxxx> --- 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.3.0 -- To unsubscribe from this list: send the line "unsubscribe reiserfs-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html