aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/reiserfs/lock.c26
-rw-r--r--include/linux/reiserfs_fs.h2
2 files changed, 28 insertions, 0 deletions
diff --git a/fs/reiserfs/lock.c b/fs/reiserfs/lock.c
index cdd8d9ef048e..cb1bba3802dd 100644
--- a/fs/reiserfs/lock.c
+++ b/fs/reiserfs/lock.c
@@ -50,6 +50,32 @@ void reiserfs_write_unlock(struct super_block *s)
50} 50}
51 51
52/* 52/*
53 * If we already own the lock, just exit and don't increase the depth.
54 * Useful when we don't want to lock more than once.
55 *
56 * We always return the lock_depth we had before calling
57 * this function.
58 */
59int reiserfs_write_lock_once(struct super_block *s)
60{
61 struct reiserfs_sb_info *sb_i = REISERFS_SB(s);
62
63 if (sb_i->lock_owner != current) {
64 mutex_lock(&sb_i->lock);
65 sb_i->lock_owner = current;
66 return sb_i->lock_depth++;
67 }
68
69 return sb_i->lock_depth;
70}
71
72void reiserfs_write_unlock_once(struct super_block *s, int lock_depth)
73{
74 if (lock_depth == -1)
75 reiserfs_write_unlock(s);
76}
77
78/*
53 * Utility function to force a BUG if it is called without the superblock 79 * Utility function to force a BUG if it is called without the superblock
54 * write lock held. caller is the string printed just before calling BUG() 80 * write lock held. caller is the string printed just before calling BUG()
55 */ 81 */
diff --git a/include/linux/reiserfs_fs.h b/include/linux/reiserfs_fs.h
index e47328f51801..4a2df57c8b1d 100644
--- a/include/linux/reiserfs_fs.h
+++ b/include/linux/reiserfs_fs.h
@@ -59,6 +59,8 @@
59 */ 59 */
60void reiserfs_write_lock(struct super_block *s); 60void reiserfs_write_lock(struct super_block *s);
61void reiserfs_write_unlock(struct super_block *s); 61void reiserfs_write_unlock(struct super_block *s);
62int reiserfs_write_lock_once(struct super_block *s);
63void reiserfs_write_unlock_once(struct super_block *s, int lock_depth);
62 64
63struct fid; 65struct fid;
64 66