[PATCH 3/4] introduce sb_lockdep_release()
From: Oleg Nesterov
Date: Mon Jul 13 2015 - 17:27:42 EST
Move the "fool the lockdep" code from sb_wait_write() into the new
simple helper, sb_lockdep_release().
This makes sense in any case afaics, this way s_op->freeze_fs(sb) is
called with these write locks held as it seen by lockdep.
---
fs/super.c | 16 +++++++++++-----
1 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/super.c b/fs/super.c
index c23bafc..94303fc 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1229,12 +1229,7 @@ static void sb_wait_write(struct super_block *sb, int level)
{
s64 writers;
- /*
- * We just cycle-through lockdep here so that it does not complain
- * about returning with lock to userspace
- */
rwsem_acquire(&sb->s_writers.lock_map[level-1], 0, 0, _THIS_IP_);
- rwsem_release(&sb->s_writers.lock_map[level-1], 1, _THIS_IP_);
do {
DEFINE_WAIT(wait);
@@ -1254,6 +1249,16 @@ static void sb_wait_write(struct super_block *sb, int level)
} while (writers);
}
+/* Avoid the warning from lockdep_sys_exit() */
+static void sb_lockdep_release(struct super_block *sb)
+{
+ int level;
+
+ for (level = 0; level < SB_FREEZE_LEVELS; ++level) {
+ rwsem_release(&sb->s_writers.lock_map[level-1], 1, _THIS_IP_);
+ }
+}
+
static void sb_unlock_frozen(struct super_block *sb)
{
smp_wmb();
@@ -1356,6 +1361,7 @@ int freeze_super(struct super_block *sb)
* sees write activity when frozen is set to SB_FREEZE_COMPLETE.
*/
sb->s_writers.frozen = SB_FREEZE_COMPLETE;
+ sb_lockdep_release(sb);
up_write(&sb->s_umount);
return 0;
}
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/