vfs: get_sb_single() - do not pass options twice
[safe/jmp/linux-2.6] / fs / reiserfs / lock.c
index cdd8d9e..ee2cfc0 100644 (file)
@@ -37,11 +37,10 @@ void reiserfs_write_unlock(struct super_block *s)
 
        /*
         * Are we unlocking without even holding the lock?
-        * Such a situation could even raise a BUG() if we don't
-        * want the data become corrupted
+        * Such a situation must raise a BUG() if we don't want
+        * to corrupt the data.
         */
-       WARN_ONCE(sb_i->lock_owner != current,
-                 "Superblock write lock imbalance");
+       BUG_ON(sb_i->lock_owner != current);
 
        if (--sb_i->lock_depth == -1) {
                sb_i->lock_owner = NULL;
@@ -50,6 +49,32 @@ void reiserfs_write_unlock(struct super_block *s)
 }
 
 /*
+ * If we already own the lock, just exit and don't increase the depth.
+ * Useful when we don't want to lock more than once.
+ *
+ * We always return the lock_depth we had before calling
+ * this function.
+ */
+int reiserfs_write_lock_once(struct super_block *s)
+{
+       struct reiserfs_sb_info *sb_i = REISERFS_SB(s);
+
+       if (sb_i->lock_owner != current) {
+               mutex_lock(&sb_i->lock);
+               sb_i->lock_owner = current;
+               return sb_i->lock_depth++;
+       }
+
+       return sb_i->lock_depth;
+}
+
+void reiserfs_write_unlock_once(struct super_block *s, int lock_depth)
+{
+       if (lock_depth == -1)
+               reiserfs_write_unlock(s);
+}
+
+/*
  * Utility function to force a BUG if it is called without the superblock
  * write lock held.  caller is the string printed just before calling BUG()
  */