reiser4 and swsusp2 (patch)
Hi,
This is my attempt at a patch to make reiser4 work with swsusp2. I made half a dozen suspend/resume operations under heavy disk activity and everything seems to be working. These tests were made with reiser4 as root filesystem.
I am neither familiar with reiser4 or swsusp internals, so there may be some obvious errors in the attached diff that I am unaware of.
This and the original swsusp/pmdisk patch are available here:
http://mega.ist.utl.pt/~filipe/patches/
Regards,
Filipe Almeida
http://mega.ist.utl.pt/~filipe/
fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +9 -9
@@ -53,11 +53,16 @@ {struct task_struct *me;ktxnmgrd_context *ctx; +DECLARE_SWSUSP_LOCAL_VAR ;/* standard kernel thread prologue */ me = current;/* reparent_to_init() is done by daemonize() */ daemonize (__FUNCTION__); + current->flags |=PF_SYNCTHREAD ; + +SWSUSP_THREAD_FLAGS_RESET ; +SWSUSP_ACTIVITY_START (PF_SYNCTHREAD );/* block all signals */ spin_lock_irq (&me->sighand->siglock);
@@ -79,11 +84,6 @@int result;txn_mgr *mgr; -/* software suspend support. Doesn't work currently -(kcond_timedwait), also refrigerator() may schedule */ -if (0 && (me->flags &PF_FREEZE )) -refrigerator (PF_IOTHREAD ); -set_comm ("wait" );/* wait for @ctx -> timeout or explicit wake up.
@@ -92,17 +92,16 @@load-average. This doesn't require any special handling, because all signals were blocked. */ +SWSUSP_ACTIVITY_SYNCTHREAD_PAUSING ; result =kcond_timedwait (&ctx->wait, &ctx->guard, ctx->timeout,1 ); +SWSUSP_ACTIVITY_RESTARTING (PF_SYNCTHREAD );/* wake up all threads doing umount. See ktxnmgrd_detach(). */ kcond_broadcast (&ctx->loop); -if (result != -ETIMEDOUT && result !=0 ) { -/* some other error */ -warning ("nikita-2443" ,"Error: %i" , result); +if (result != -ETIMEDOUT && result !=0 )continue ; - }/* we are asked to exit */ if (ctx->done)
@@ -132,6 +131,7 @@spin_unlock (&ctx->guard); +SWSUSP_ACTIVITY_END ;complete_and_exit (&ctx->finish,0 );/* not reached. */ return 0 ;
fs/reiser4/entd.c renamed from linux-2.6.2/fs/reiser4/entd.c +11 -6
@@ -44,12 +44,18 @@struct super_block *super;struct task_struct *me;entd_context *ctx; +DECLARE_SWSUSP_LOCAL_VAR ; super = arg;/* standard kernel thread prologue */ me = current;/* reparent_to_init() is done by daemonize() */ daemonize ("ent:%s" , super->s_id); + current->flags |=PF_SYNCTHREAD ; + +SWSUSP_THREAD_FLAGS_RESET ; +SWSUSP_ACTIVITY_START (PF_SYNCTHREAD ); +/* block all signals */ spin_lock_irq (&me->sighand->siglock);
@@ -72,13 +78,14 @@while (1 ) {int result; -if (me->flags &PF_FREEZE ) -refrigerator (PF_IOTHREAD ); +/* Chance for ktxnmgrd to refrigerate */ entd_set_comm ("." );spin_lock (&ctx->guard); ctx->kicks_pending =0 ; +SWSUSP_ACTIVITY_SYNCTHREAD_PAUSING ; result =kcond_wait (&ctx->wait, &ctx->guard,1 ); +SWSUSP_ACTIVITY_RESTARTING (PF_SYNCTHREAD );/* we are asked to exit */ if (ctx->done) {
@@ -90,11 +97,9 @@entd_set_comm ("!" );if (result ==0 )entd_flush (super); -else -/* some other error */ -warning ("nikita-3099" ,"Error: %i" , result); } - + +SWSUSP_ACTIVITY_END ;complete_and_exit (&ctx->finish,0 );/* not reached. */ return 0 ;
Quoted 10 lines · Filipe Almeida
Hi,
This is my attempt at a patch to make reiser4 work with swsusp2. I made half a dozen suspend/resume operations under heavy disk activity and everything seems to be working. These tests were made with reiser4 as root filesystem.I am neither familiar with reiser4 or swsusp internals, so there may be some obvious errors in the attached diff that I am unaware of.
This and the original swsusp/pmdisk patch are available here:
http://mega.ist.utl.pt/~filipe/patches/
Do they require some additional patches? I don't see SWSUSP_* macros in the stock 2.6.2.
Quoted 6 lines
Regards,
Filipe Almeida
http://mega.ist.utl.pt/~filipe/fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +0
-0
[...]
fs/reiser4/ktxnmgrd.c line 103
Quoted 7 lines
fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +0
-3/* wake up all threads doing umount. See ktxnmgrd_detach(). */ kcond_broadcast (&ctx->loop); -if (result != -ETIMEDOUT && result !=0 ) { -/* some other error */ -warning ("nikita-2443" ,"Error: %i" , result);
I don't quite understand why you are removing this warning. There is no way to tell normal wakeup from one caused by suspend or what?
fs/reiser4/ktxnmgrd.c line 105
Quoted 4 lines
fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +1
-1+if (result != -ETIMEDOUT && result !=0 )continue ; - }
Nikita.
Hi,
Quoted 9 lines · Nikita Danilov
Quoted 5 lines · Filipe Almeida
I am neither familiar with reiser4 or swsusp internals, so there may be some obvious errors in the attached diff that I am unaware of.
This and the original swsusp/pmdisk patch are available here:
http://mega.ist.utl.pt/~filipe/patches/Do they require some additional patches? I don't see SWSUSP_* macros in the stock 2.6.2.
Yes. this patches are for swsusp2 at swsusp.sourceforge.net. See my previous mail for the patches against the current 2.6 swsusp.
Quoted 13 lines
Quoted 7 lines
Regards,
Filipe Almeida
http://mega.ist.utl.pt/~filipe/
---old/linux-2.6.2/fs/reiser4/ktxnmgrd.c2004-02-10 17:15:43.910461848
+0000 +++linux-2.6.2/fs/reiser4/ktxnmgrd.c2004-02-10
17:18:58.319907120 +0000[...]
Quoted 3 lines
fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +0
-0/* wake up all threads doing umount. See ktxnmgrd_detach(). */ kcond_broadcast (&ctx->loop);
Quoted 7 lines
fs/reiser4/ktxnmgrd.c line 103
Quoted 3 lines
fs/reiser4/ktxnmgrd.c renamed from linux-2.6.2/fs/reiser4/ktxnmgrd.c +0
-3-if (result != -ETIMEDOUT && result !=0 ) { -/* some other error */ -warning ("nikita-2443" ,"Error: %i" , result);I don't quite understand why you are removing this warning. There is no way to tell normal wakeup from one caused by suspend or what?
Not that I know of. But the people at the swsusp ml should know if that is possible or not (CC'd).
My previous patch against current 2.6 pmdisk and swsusp doesnt remove this warnings. I havent figured out a way to do the same with swsusp2. Please check them at:
http://mega.ist.utl.pt/~filipe/patches/reiser4-2004.02.06-swsusp.diff
Regards,
Filipe Almeida
Hi,
Here are the revised patches following Nikita's sugestions.
Don't forget that nyou have to use:
reiser4-2004.02.06-swsusp1.diff - for current 2.6 pmdisk or swsusp kernels
reiser4-2004.02.06-swsusp2.diff - for the swsusp2 version
Regards,
Filipe Almeida
Add swsusp/pmdisk software suspend support to reiser4
Filipe Almeida <[email protected]>
fs/reiser4/ktxnmgrd.c +6 -4
@@ -79,10 +79,12 @@int result;txn_mgr *mgr; -/* software suspend support. Doesn't work currently -(kcond_timedwait), also refrigerator() may schedule */ -if (0 && (me->flags &PF_FREEZE )) +/* software suspend support. */ +if (me->flags &PF_FREEZE ) { +spin_unlock (&ctx->guard);refrigerator (PF_IOTHREAD ); +spin_lock (&ctx->guard); + }set_comm ("wait" );/* wait for @ctx -> timeout or explicit wake up.
@@ -98,7 +100,7 @@/* wake up all threads doing umount. See ktxnmgrd_detach(). */ kcond_broadcast (&ctx->loop); -if (result != -ETIMEDOUT && result !=0 ) { +if (result != -ETIMEDOUT && result != -EINTR && result !=0 ) {/* some other error */ warning ("nikita-2443" ,"Error: %i" , result);continue ;
fs/reiser4/entd.c +1 -1
@@ -90,7 +90,7 @@entd_set_comm ("!" );if (result ==0 )entd_flush (super); -else +else if (result != -EINTR )/* some other error */ warning ("nikita-3099" ,"Error: %i" , result); }
Add swsusp2 software suspend support to reiser4
Filipe Almeida <[email protected]>
fs/reiser4/ktxnmgrd.c +10 -6
@@ -53,11 +53,17 @@ {struct task_struct *me;ktxnmgrd_context *ctx; +DECLARE_SWSUSP_LOCAL_VAR ;/* standard kernel thread prologue */ me = current;/* reparent_to_init() is done by daemonize() */ daemonize (__FUNCTION__); + current->flags |=PF_SYNCTHREAD ; + +SWSUSP_THREAD_FLAGS_RESET ; +SWSUSP_ACTIVITY_START (PF_SYNCTHREAD ); +/* block all signals */ spin_lock_irq (&me->sighand->siglock);
@@ -79,11 +85,6 @@int result;txn_mgr *mgr; -/* software suspend support. Doesn't work currently -(kcond_timedwait), also refrigerator() may schedule */ -if (0 && (me->flags &PF_FREEZE )) -refrigerator (PF_IOTHREAD ); -set_comm ("wait" );/* wait for @ctx -> timeout or explicit wake up.
@@ -92,13 +93,15 @@load-average. This doesn't require any special handling, because all signals were blocked. */ +SWSUSP_ACTIVITY_SYNCTHREAD_PAUSING ; result =kcond_timedwait (&ctx->wait, &ctx->guard, ctx->timeout,1 ); +SWSUSP_ACTIVITY_RESTARTING (PF_SYNCTHREAD );/* wake up all threads doing umount. See ktxnmgrd_detach(). */ kcond_broadcast (&ctx->loop); -if (result != -ETIMEDOUT && result !=0 ) { +if (result != -ETIMEDOUT && result != -EINTR && result !=0 ) {/* some other error */ warning ("nikita-2443" ,"Error: %i" , result);continue ;
@@ -132,6 +135,7 @@spin_unlock (&ctx->guard); +SWSUSP_ACTIVITY_END ;complete_and_exit (&ctx->finish,0 );/* not reached. */ return 0 ;
fs/reiser4/entd.c +11 -4
@@ -44,12 +44,18 @@struct super_block *super;struct task_struct *me;entd_context *ctx; +DECLARE_SWSUSP_LOCAL_VAR ; super = arg;/* standard kernel thread prologue */ me = current;/* reparent_to_init() is done by daemonize() */ daemonize ("ent:%s" , super->s_id); + current->flags |=PF_SYNCTHREAD ; + +SWSUSP_THREAD_FLAGS_RESET ; +SWSUSP_ACTIVITY_START (PF_SYNCTHREAD ); +/* block all signals */ spin_lock_irq (&me->sighand->siglock);
@@ -72,13 +78,13 @@while (1 ) {int result; -if (me->flags &PF_FREEZE ) -refrigerator (PF_IOTHREAD ); -entd_set_comm ("." );spin_lock (&ctx->guard); ctx->kicks_pending =0 ; + +SWSUSP_ACTIVITY_SYNCTHREAD_PAUSING ; result =kcond_wait (&ctx->wait, &ctx->guard,1 ); +SWSUSP_ACTIVITY_RESTARTING (PF_SYNCTHREAD );/* we are asked to exit */ if (ctx->done) {
@@ -90,11 +96,12 @@entd_set_comm ("!" );if (result ==0 )entd_flush (super); -else +else if (result != -EINTR )/* some other error */ warning ("nikita-3099" ,"Error: %i" , result); } +SWSUSP_ACTIVITY_END ;complete_and_exit (&ctx->finish,0 );/* not reached. */ return 0 ;