swsusp: Freeze filesystems during suspend
Subsystems (4)
PATCH 1/1 swsusp: Freeze filesystems during suspend
Freeze all filesystems during the suspend by calling freeze_bdev() for each of them and thaw them during the resume using thaw_bdev().
This is needed by swsusp, because some filesystems (eg. XFS) use work queues and worker_threads run with PF_NOFREEZE set, so they can cause some writes to be performed after the suspend image has been created which may corrupt the filesystem. The additional benefit of it is that if the resume fails, the filesystems will be in a consistent state and there won't be any journal replays needed.
The freezing of filesystems is carried out when processes are being frozen, so on the majority of architectures it also will happen during a suspend to RAM.
--- fs/buffer.c | 44 ++++++++++++++++++++++++++++++++++++++ include/linux/buffer_head.h | 2 + include/linux/fs.h | 1 kernel/power/process.c | 50 +++++++++++++++++++++++++++++--------------- 4 files changed, 80 insertions(+), 17 deletions(-)
kernel/power/process.c +33 -17
@@ -14,6 +14,7 @@#include <linux/module.h> #include <linux/syscalls.h> #include <linux/freezer.h> +#include <linux/buffer_head.h> /* * Timeout for stopping processes
@@ -119,7 +120,7 @@ int freeze_processes(void)read_unlock (&tasklist_lock); todo += nr_user;if (!user_frozen && !nr_user) { -sys_sync (); +freeze_filesystems (); start_time = jiffies; } user_frozen = !nr_user;
@@ -156,28 +157,43 @@ int freeze_processes(void)void thaw_some_processes (int all) {struct task_struct *g, *p; -int pass =0 ;/* Pass 0 = Kernel space, 1 = Userspace */ printk ("Restarting tasks... " );read_lock (&tasklist_lock); -do { - do_each_thread(g, p) { -/* -* is_user = 0 if kernel thread or borrowed mm, -* 1 otherwise. -*/ -int is_user = !!(p->mm && !(p->flags &PF_BORROWED_MM )); -if (!freezeable (p) || (is_user != pass)) -continue ; -if (!thaw_process (p)) -printk (KERN_INFO -"Strange, %s not stopped\n" , p->comm); - }while_each_thread (g, p); - pass++; - }while (pass <2 && all); + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Don't thaw userland processes, for now */ +if (p->mm && !(p->flags &PF_BORROWED_MM )) +continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p); + +read_unlock (&tasklist_lock); +if (!all) + goto Exit; + +thaw_filesystems (); +read_lock (&tasklist_lock); + + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Kernel threads should have been thawed already */ +if (!p->mm || (p->flags &PF_BORROWED_MM )) +continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p);read_unlock (&tasklist_lock); +Exit:schedule ();printk ("done.\n" ); }
include/linux/buffer_head.h +2 -0
@@ -170,6 +170,8 @@ wait_queue_head_t *bh_waitq_head(structint fsync_bdev (struct block_device *);struct super_block *freeze_bdev (struct block_device *);void thaw_bdev (struct block_device *,struct super_block *); +void freeze_filesystems (void ); +void thaw_filesystems (void );int fsync_super (struct super_block *);int fsync_no_super (struct block_device *);struct buffer_head *__find_get_block (struct block_device *,sector_t ,int );
include/linux/fs.h +1 -0
@@ -120,6 +120,7 @@ extern int dir_notify_enable;#define MS_PRIVATE (1<<18)/* change to private */ #define MS_SLAVE (1<<19)/* change to slave */ #define MS_SHARED (1<<20)/* change to shared */ +#define MS_FROZEN (1<<21)/* Frozen by freeze_filesystems() */ #define MS_ACTIVE (1<<30)#define MS_NOUSER (1<<31)
fs/buffer.c +44 -0
50 lines not on this page · raw message
Hi!
Quoted 16 lines
Freeze all filesystems during the suspend by calling
freeze_bdev()for each of them and thaw them during the resume usingthaw_bdev().This is needed by swsusp, because some filesystems (eg. XFS) use work queues and
worker_threadsrun withPF_NOFREEZEset, so they can cause some writes to be performed after the suspend image has been created which may corrupt the filesystem. The additional benefit of it is that if the resume fails, the filesystems will be in a consistent state and there won't be any journal replays needed.The freezing of filesystems is carried out when processes are being frozen, so on the majority of architectures it also will happen during a suspend to RAM.
kernel/power/process.c int freeze_processes(void) · line 126
Quoted 8 lines
kernel/power/process.c +1
-1@@ -119,7 +120,7 @@ int freeze_processes(void)read_unlock (&tasklist_lock); todo += nr_user;if (!user_frozen && !nr_user) { -sys_sync (); +freeze_filesystems (); start_time = jiffies; } user_frozen = !nr_user;
Do all filesystems implement freeze? If not, we may want to keep that sync...
Quoted 49 lines
kernel/power/process.c +25
-16@@ -156,28 +157,43 @@ int freeze_processes(void)void thaw_some_processes (int all) {struct task_struct *g, *p; -int pass =0 ;/* Pass 0 = Kernel space, 1 = Userspace */ printk ("Restarting tasks... " );read_lock (&tasklist_lock); -do { - do_each_thread(g, p) { -/* -* is_user = 0 if kernel thread or borrowed mm, -* 1 otherwise. -*/ -int is_user = !!(p->mm && !(p->flags &PF_BORROWED_MM )); -if (!freezeable (p) || (is_user != pass)) -continue ; -if (!thaw_process (p)) -printk (KERN_INFO -"Strange, %s not stopped\n" , p->comm); - }while_each_thread (g, p); - pass++; - }while (pass <2 && all); + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Don't thaw userland processes, for now */ +if (p->mm && !(p->flags &PF_BORROWED_MM )) +continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p); + +read_unlock (&tasklist_lock); +if (!all) + goto Exit; + +thaw_filesystems (); +read_lock (&tasklist_lock); + + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Kernel threads should have been thawed already */ +if (!p->mm || (p->flags &PF_BORROWED_MM ))
kernel/power/process.c int freeze_processes(void) · line 198
Quoted 10 lines
kernel/power/process.c +6
-0+continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p);read_unlock (&tasklist_lock); +Exit:schedule ();printk ("done.\n" );
Could we do without the code duplication?
fs/buffer.c void thaw_bdev(struct block_device *bdev · line 255
Quoted 10 lines
fs/buffer.c +9
-0+/** +* freeze_filesystems - lock all filesystems and force them into a consistent +* state +*/ +void freeze_filesystems (void ) +{ +struct super_block *sb; + +lockdep_off ();
You should not just turn off lockdep because you don't like its output.
Perhaps tasklist_lock does not nest with whatever freeze_bdev needs?
Pavel
Signature · 1 line
Thanks, Sharp!
Hi,
Quoted 17 lines · Pavel Machek
Hi!
Quoted 13 lines
Freeze all filesystems during the suspend by calling
freeze_bdev()for each of them and thaw them during the resume usingthaw_bdev().This is needed by swsusp, because some filesystems (eg. XFS) use work queues and
worker_threadsrun withPF_NOFREEZEset, so they can cause some writes to be performed after the suspend image has been created which may corrupt the filesystem. The additional benefit of it is that if the resume fails, the filesystems will be in a consistent state and there won't be any journal replays needed.The freezing of filesystems is carried out when processes are being frozen, so on the majority of architectures it also will happen during a suspend to RAM.
Quoted 12 lines
kernel/power/process.c int freeze_processes(void) · line 126
Quoted 9 lines
kernel/power/process.c +1
-1@@ -119,7 +120,7 @@ int freeze_processes(void)read_unlock (&tasklist_lock); todo += nr_user;if (!user_frozen && !nr_user) { -sys_sync (); +freeze_filesystems (); start_time = jiffies; } user_frozen = !nr_user;Do all filesystems implement freeze?
I think so.
Quoted 1 line
If not, we may want to keep that sync...
But the sync() won't hurt anyway I think.
Quoted 57 lines
Quoted 57 lines
kernel/power/process.c +30
-16@@ -156,28 +157,43 @@ int freeze_processes(void)void thaw_some_processes (int all) {struct task_struct *g, *p; -int pass =0 ;/* Pass 0 = Kernel space, 1 = Userspace */ printk ("Restarting tasks... " );read_lock (&tasklist_lock); -do { - do_each_thread(g, p) { -/* -* is_user = 0 if kernel thread or borrowed mm, -* 1 otherwise. -*/ -int is_user = !!(p->mm && !(p->flags &PF_BORROWED_MM )); -if (!freezeable (p) || (is_user != pass)) -continue ; -if (!thaw_process (p)) -printk (KERN_INFO -"Strange, %s not stopped\n" , p->comm); - }while_each_thread (g, p); - pass++; - }while (pass <2 && all); + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Don't thaw userland processes, for now */ +if (p->mm && !(p->flags &PF_BORROWED_MM )) +continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p); + +read_unlock (&tasklist_lock); +if (!all) + goto Exit; + +thaw_filesystems (); +read_lock (&tasklist_lock); + + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +/* Kernel threads should have been thawed already */ +if (!p->mm || (p->flags &PF_BORROWED_MM )) +continue ; + +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p);
Quoted 7 lines
kernel/power/process.c int freeze_processes(void) · line 198
Quoted 4 lines
kernel/power/process.c +1
-0read_unlock (&tasklist_lock); +Exit:schedule ();printk ("done.\n" );Could we do without the code duplication?
Okay, I'll move the loop(s) into a separate function.
Quoted 13 lines
fs/buffer.c void thaw_bdev(struct block_device *bdev · line 255
Quoted 9 lines
fs/buffer.c +9
-0+/** +* freeze_filesystems - lock all filesystems and force them into a consistent +* state +*/ +void freeze_filesystems (void ) +{ +struct super_block *sb; + +lockdep_off ();You should not just turn off lockdep because you don't like its output.
Quoted 1 line
Perhaps
tasklist_lockdoes not nest with whateverfreeze_bdevneeds?
The locks taken in one call to freeze_bdev() nest with analogous locks taken in the other calls to freeze_bdev(). Actually we take several locks of the same (I think) class in a row and keep them all until thaw_filesystems() is called, which is quite unusual. I don't think there's any way in which we can convince lockdep that it's all okay other than switching it off.
Greetings,
Rafael
Signature · 2 lines
You never change things by fighting the existing reality. R. Buckminster Fuller
PATCH 1/1 swsusp: Freeze filesystems during suspend (rev. 2)
In reply to Pavel MachekFreeze all filesystems during the suspend by calling freeze_bdev() for each of them and thaw them during the resume using thaw_bdev().
This is needed by swsusp, because some filesystems (eg. XFS) use work queues and worker_threads run with PF_NOFREEZE set, so if these filesystems are not frozen, they can cause some writes to be performed after the suspend image has been created which may corrupt lead to a filesystem corruption.
The additional benefit of it is that if the resume fails, the filesystems will be in a consistent state and there won't be any journal replays needed.
The freezing of filesystems is carried out when processes are being frozen, so on the majority of architectures it also will happen during a suspend to RAM.
--- fs/buffer.c | 44 +++++++++++++++++++++++++++++++++++ include/linux/buffer_head.h | 2 + include/linux/freezer.h | 7 +---- include/linux/fs.h | 1 kernel/power/process.c | 54 +++++++++++++++++++++++++++++--------------- 5 files changed, 85 insertions(+), 23 deletions(-)
kernel/power/process.c +36 -18
@@ -14,6 +14,7 @@#include <linux/module.h> #include <linux/syscalls.h> #include <linux/freezer.h> +#include <linux/buffer_head.h> /* * Timeout for stopping processes
@@ -120,6 +121,7 @@ int freeze_processes(void) todo += nr_user;if (!user_frozen && !nr_user) {sys_sync (); +freeze_filesystems (); start_time = jiffies; } user_frozen = !nr_user;
@@ -153,31 +155,47 @@ int freeze_processes(void)return 0 ; } -void thaw_some_processes (int all) +#define FREEZER_KERNEL_THREADS 0 +#define FREEZER_USER_SPACE 1 + +static void __thaw_tasks (int user_space) {struct task_struct *g, *p; -int pass =0 ;/* Pass 0 = Kernel space, 1 = Userspace */ -printk ("Restarting tasks... " );read_lock (&tasklist_lock); -do { - do_each_thread(g, p) { -/* -* is_user = 0 if kernel thread or borrowed mm, -* 1 otherwise. -*/ -int is_user = !!(p->mm && !(p->flags &PF_BORROWED_MM )); -if (!freezeable (p) || (is_user != pass)) + do_each_thread(g, p) { +if (!freezeable (p)) +continue ; + +if (p->mm && !(p->flags &PF_BORROWED_MM )) { +/* It's a user space process */ +if (!user_space)continue ; -if (!thaw_process (p)) -printk (KERN_INFO -"Strange, %s not stopped\n" , p->comm); - }while_each_thread (g, p); + }else { +/* It's a kernel thread */ +if (user_space) +continue ; + } +if (!thaw_process (p)) +printk (KERN_INFO " Strange, %s not stopped\n" , p->comm ); + }while_each_thread (g, p); +read_unlock (&tasklist_lock); +} - pass++; - }while (pass <2 && all); +void thaw_processes (void ) +{ +printk ("Restarting tasks ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS ); +thaw_filesystems (); +__thaw_tasks (FREEZER_USER_SPACE ); +schedule (); +printk ("done.\n" ); +} -read_unlock (&tasklist_lock); +void thaw_kernel_threads (void ) +{ +printk ("Restarting kernel threads ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS );schedule ();printk ("done.\n" ); }
include/linux/buffer_head.h +2 -0
@@ -170,6 +170,8 @@ wait_queue_head_t *bh_waitq_head(structint fsync_bdev (struct block_device *);struct super_block *freeze_bdev (struct block_device *);void thaw_bdev (struct block_device *,struct super_block *); +void freeze_filesystems (void ); +void thaw_filesystems (void );int fsync_super (struct super_block *);int fsync_no_super (struct block_device *);struct buffer_head *__find_get_block (struct block_device *,sector_t ,int );
include/linux/fs.h +1 -0
@@ -120,6 +120,7 @@ extern int dir_notify_enable;#define MS_PRIVATE (1<<18)/* change to private */ #define MS_SLAVE (1<<19)/* change to slave */ #define MS_SHARED (1<<20)/* change to shared */ +#define MS_FROZEN (1<<21)/* Frozen by freeze_filesystems() */ #define MS_ACTIVE (1<<30)#define MS_NOUSER (1<<31)
fs/buffer.c +44 -0
50 lines not on this page · raw message
include/linux/freezer.h +2 -5
@@ -1,8 +1,5 @@/* Freezer declarations */ -#define FREEZER_KERNEL_THREADS 0 -#define FREEZER_ALL_THREADS 1 -#ifdef CONFIG_PM /* * Check if a process has been frozen
@@ -60,8 +57,8 @@ static inline void frozen_process(structextern void refrigerator (void );extern int freeze_processes (void ); -#define thaw_processes () do { thaw_some_processes(FREEZER_ALL_THREADS); } while(0) -#define thaw_kernel_threads () do { thaw_some_processes(FREEZER_KERNEL_THREADS); } while(0) +extern void thaw_processes (void ); +extern void thaw_kernel_threads (void );static inline int try_to_freeze (void ) {
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
Quoted 8 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
kernel/power/process.c +8
-0+void thaw_processes (void ) +{ +printk ("Restarting tasks ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS ); +thaw_filesystems (); +__thaw_tasks (FREEZER_USER_SPACE ); +schedule (); +printk ("done.\n" );
kernel/power/process.c int freeze_processes(void) · line 201
Quoted 10 lines
kernel/power/process.c +5
-1+} -read_unlock (&tasklist_lock); +void thaw_kernel_threads (void ) +{ +printk ("Restarting kernel threads ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS );schedule ();printk ("done.\n" ); }
what do these random-looking schedule()s do??
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
Quoted 13 lines · Andrew Morton
Quoted 10 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
kernel/power/process.c +9
-0+void thaw_processes (void ) +{ +printk ("Restarting tasks ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS ); +thaw_filesystems (); +__thaw_tasks (FREEZER_USER_SPACE ); +schedule (); +printk ("done.\n" ); +}
Quoted 10 lines
kernel/power/process.c int freeze_processes(void) · line 201
Quoted 8 lines
kernel/power/process.c +4
-1-read_unlock (&tasklist_lock); +void thaw_kernel_threads (void ) +{ +printk ("Restarting kernel threads ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS );schedule ();printk ("done.\n" ); }what do these random-looking schedule()s do??
My understanding is that they allow the thawed tasks to actually exit the refrigerator, because __thaw_tasks() only changes their states.
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
Quoted 25 lines · On Wed, 1 Nov 2006 21:27:17 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 10 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
kernel/power/process.c +9
-0+void thaw_processes (void ) +{ +printk ("Restarting tasks ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS ); +thaw_filesystems (); +__thaw_tasks (FREEZER_USER_SPACE ); +schedule (); +printk ("done.\n" ); +}Quoted 10 lines
kernel/power/process.c int freeze_processes(void) · line 201
Quoted 8 lines
kernel/power/process.c +4
-1-read_unlock (&tasklist_lock); +void thaw_kernel_threads (void ) +{ +printk ("Restarting kernel threads ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS );schedule ();printk ("done.\n" ); }what do these random-looking schedule()s do??
Quoted 2 lines
My understanding is that they allow the thawed tasks to actually exit the refrigerator, because
__thaw_tasks()only changes their states.
I'd be surprised if this is doing what we thing it's doing. Calling schedule() in state TASK_RUNNING is usually a no-op. It'll only actually switch to another task if the scheduler decides that this task has expired its timeslice, or another higher-priority task has become runnable, etc.
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
Quoted 28 lines · Andrew Morton
Quoted 25 lines · On Wed, 1 Nov 2006 21:27:17 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
Quoted 23 lines · Andrew Morton
Quoted 8 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
kernel/power/process.c +8
-0+void thaw_processes (void ) +{ +printk ("Restarting tasks ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS ); +thaw_filesystems (); +__thaw_tasks (FREEZER_USER_SPACE ); +schedule (); +printk ("done.\n" );kernel/power/process.c int freeze_processes(void) · line 201
Quoted 10 lines
kernel/power/process.c +5
-1+} -read_unlock (&tasklist_lock); +void thaw_kernel_threads (void ) +{ +printk ("Restarting kernel threads ... " ); +__thaw_tasks (FREEZER_KERNEL_THREADS );schedule ();printk ("done.\n" ); }what do these random-looking schedule()s do??
Quoted 7 lines
Quoted 2 lines
My understanding is that they allow the thawed tasks to actually exit the refrigerator, because
__thaw_tasks()only changes their states.I'd be surprised if this is doing what we thing it's doing. Calling
schedule()in stateTASK_RUNNINGis usually a no-op. It'll only actually switch to another task if the scheduler decides that this task has expired its timeslice, or another higher-priority task has become runnable, etc.
This actually can happen, it seems, because __thaw_tasks() calls wake_up_process() for each frozen task which may call resched_task() for current.
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
In reply to Rafael J. WysockiQuoted 29 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
fs/buffer.c +29
-0+void freeze_filesystems (void ) +{ +struct super_block *sb; + +lockdep_off (); +/* +* Freeze in reverse order so filesystems dependant upon others are +* frozen in the right order (eg. loopback on ext3). +*/ +list_for_each_entry_reverse (sb, &super_blocks, s_list) { +if (!sb->s_root || !sb->s_bdev || + (sb->s_frozen ==SB_FREEZE_TRANS ) || + (sb->s_flags &MS_RDONLY ) || + (sb->s_flags &MS_FROZEN )) +continue ; + +freeze_bdev (sb->s_bdev); + sb->s_flags |=MS_FROZEN ; + } +lockdep_on (); +} + +/** +* thaw_filesystems - unlock all filesystems +*/ +void thaw_filesystems (void ) +{ +struct super_block *sb; +
fs/buffer.c void thaw_bdev(struct block_device *bdev · line 289
Quoted 10 lines
fs/buffer.c +10
-0+lockdep_off (); + +list_for_each_entry (sb, &super_blocks, s_list) +if (sb->s_flags &MS_FROZEN ) { + sb->s_flags &= ~MS_FROZEN ; +thaw_bdev (sb->s_bdev, sb); + } + +lockdep_on (); +}
argh.
The uncommented, unchangelogged lockdep_off() calls are completely mysterious right now, even before the patch is merged. They will not become less mysterious over time.
Please, take pity upon the readers of your code. Add a comment.
Re: [PATCH -mm] swsusp: Freeze filesystems during suspend (rev. 2)
Quoted 45 lines · Andrew Morton
Quoted 29 lines · On Wed, 1 Nov 2006 18:53:07 +0100 "Rafael J. Wysocki" <[email protected]> wrote:
(quoted diff) +29
-0+void freeze_filesystems(void) +{ + struct super_block *sb; + + lockdep_off(); + /* + * Freeze in reverse order so filesystems dependant upon others are + * frozen in the right order (eg. loopback on ext3). + */ + list_for_each_entry_reverse(sb, &super_blocks, s_list) { + if (!sb->s_root || !sb->s_bdev || + (sb->s_frozen == SB_FREEZE_TRANS) || + (sb->s_flags & MS_RDONLY) || + (sb->s_flags & MS_FROZEN)) + continue; + + freeze_bdev(sb->s_bdev); + sb->s_flags |= MS_FROZEN; + } + lockdep_on(); +} + +/** + * thaw_filesystems - unlock all filesystems + */ +void thaw_filesystems(void) +{ + struct super_block *sb; +Review
Quoted 10 lines
(quoted diff) +10
-0+ lockdep_off(); + + list_for_each_entry(sb, &super_blocks, s_list) + if (sb->s_flags & MS_FROZEN) { + sb->s_flags &= ~MS_FROZEN; + thaw_bdev(sb->s_bdev, sb); + } + + lockdep_on(); +}argh.
Quoted 3 lines
The uncommented, unchangelogged
lockdep_off()calls are completely mysterious right now, even before the patch is merged. They will not become less mysterious over time.
Of course. Sorry.
Quoted 1 line
Please, take pity upon the readers of your code. Add a comment.
OK (on top of the previous patch)
--- fs/buffer.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/buffer.c +9 -0
@@ -252,6 +252,11 @@ void freeze_filesystems(void) {struct super_block *sb; +/* +* We are going to take several locks of the same class in a row +* without releasing them until thaw_filesystems() is called and +* lockdep won't know this is all OK. +*/ lockdep_off ();/* * Freeze in reverse order so filesystems dependant upon others are
@@ -277,6 +282,10 @@ void thaw_filesystems(void) {struct super_block *sb; +/* +* We are going to release several locks of the same class in a row +* and lockdep would complain about it, unnecessarily. +*/ lockdep_off ();list_for_each_entry (sb, &super_blocks, s_list)