From c85b281070f5530448eff463f9c1e3a56ffa7f10 Mon Sep 17 00:00:00 2001 From: Frederic Weisbecker Date: Tue, 14 Apr 2009 05:34:23 +0200 Subject: [PATCH] --- yaml --- r: 173157 b: refs/heads/master c: daf88c898312a22b5385655bc6e0b064eaa2efba h: refs/heads/master i: 173155: 7f72d61ed8f6fd078aeda2dd8d9d89cedaf084b3 v: v3 --- [refs] | 2 +- trunk/fs/reiserfs/lock.c | 26 ++++++++++++++++++++++++++ trunk/include/linux/reiserfs_fs.h | 2 ++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 817f3bc7c322..42721a4f2745 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a412f9efdd6424bf4bf28c8e8c92060b5e975482 +refs/heads/master: daf88c898312a22b5385655bc6e0b064eaa2efba diff --git a/trunk/fs/reiserfs/lock.c b/trunk/fs/reiserfs/lock.c index cdd8d9ef048e..cb1bba3802dd 100644 --- a/trunk/fs/reiserfs/lock.c +++ b/trunk/fs/reiserfs/lock.c @@ -49,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() diff --git a/trunk/include/linux/reiserfs_fs.h b/trunk/include/linux/reiserfs_fs.h index e47328f51801..4a2df57c8b1d 100644 --- a/trunk/include/linux/reiserfs_fs.h +++ b/trunk/include/linux/reiserfs_fs.h @@ -59,6 +59,8 @@ */ void reiserfs_write_lock(struct super_block *s); void reiserfs_write_unlock(struct super_block *s); +int reiserfs_write_lock_once(struct super_block *s); +void reiserfs_write_unlock_once(struct super_block *s, int lock_depth); struct fid;