lkml.org 
[lkml]   [2015]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 4/4] change thaw_super() to re-acquire s_writers.lock_map
Change thaw_super() to re-acquire the "write" locks we are going to
release. This way s_op->unfreeze_fs(sb) is called with these locks
held as it seen by lockdep, and this matches the reality. This adds
another trivial helper, sb_freeze_acquire().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
fs/super.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/fs/super.c b/fs/super.c
index e7ea9f1..b4db3ee 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1263,6 +1263,14 @@ static void sb_freeze_release(struct super_block *sb)
rwsem_release(sb->s_writers.lock_map + level, 1, _THIS_IP_);
}

+static void sb_freeze_acquire(struct super_block *sb)
+{
+ int level;
+
+ for (level = 0; level < SB_FREEZE_LEVELS; ++level)
+ rwsem_acquire(sb->s_writers.lock_map + level, 0, 1, _THIS_IP_);
+}
+
/**
* freeze_super - lock the filesystem and force it into a consistent state
* @sb: the super to lock
@@ -1386,16 +1394,20 @@ int thaw_super(struct super_block *sb)
if (sb->s_flags & MS_RDONLY)
goto out;

+ sb_freeze_acquire(sb);
+
if (sb->s_op->unfreeze_fs) {
error = sb->s_op->unfreeze_fs(sb);
if (error) {
printk(KERN_ERR
"VFS:Filesystem thaw failed\n");
+ sb_freeze_release(sb);
up_write(&sb->s_umount);
return error;
}
}

+ sb_freeze_release(sb);
out:
sb->s_writers.frozen = SB_UNFROZEN;
smp_wmb();
--
1.5.5.1


\
 
 \ /
  Last update: 2015-07-20 19:21    [W:0.118 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site