reiserfs support for laptop_mode
PATCH 1/1 reiserfs support for laptop_mode
I've been using this since 2.4.22 and since laptop_mode is in the kernel since 2.4.23-pre<something> and I haven't seen that anyone else has implemented this so I decided to post it on the list in case anyone is interested.
It a patch to modify the journal flush time of reiserfs to support laptop_mode (same functionality as ext3 has already).
The times are taken from bdflush.
fs/reiserfs/journal.c +7 -2
@@ -58,6 +58,7 @@#include <linux/stat.h> #include <linux/string.h> #include <linux/smp_lock.h> +#include <linux/fs.h> /* the number of mounted filesystems. This is used to decide when to ** start and kill the commit thread
@@ -2659,8 +2660,12 @@/* starting with oldest, loop until we get to the start */ i = (SB_JOURNAL_LIST_INDEX (p_s_sb) +1 ) %JOURNAL_LIST_COUNT ;while (i != start) { -if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >SB_JOURNAL_MAX_COMMIT_AGE (p_s_sb) || - immediate)) { +/* get_buffer_age() / HZ is used since the time returned by +* get_buffer_age is in sec * HZ and the journal time is taken in seconds. +*/ +if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && + ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >get_buffer_age () /HZ + || immediate)) {/* we have to check again to be sure the current transaction did not change */ if (i !=SB_JOURNAL_LIST_INDEX (p_s_sb)) {flush_commit_list (p_s_sb,SB_JOURNAL_LIST (p_s_sb) + i,1 ) ;
fs/reiserfs/procfs.c +6 -1
@@ -18,6 +18,7 @@#include <linux/locks.h> #include <linux/init.h> #include <linux/proc_fs.h> +#include <linux/fs.h> #if defined(REISERFS_PROC_INFO )
@@ -528,7 +529,11 @@DJP ( jp_journal_trans_max ),DJP ( jp_journal_magic ),DJP ( jp_journal_max_batch ), -DJP ( jp_journal_max_commit_age ), +/* get_buffer_age() / HZ is used since the +* time returned by get_buffer_age is in sec * HZ +* and the journal time is in seconds. +*/ +get_buffer_age ()/HZ ,DJP ( jp_journal_max_trans_age ), JF( j_1st_reserved_block ),
fs/buffer.c +6 -0
@@ -1128,6 +1128,12 @@ }EXPORT_SYMBOL (get_buffer_flushtime); +inline int get_buffer_age (void ) +{ +return bdf_prm.b_un.age_buffer; +} +EXPORT_SYMBOL (get_buffer_age); +/* * A buffer may need to be moved from one buffer list to another * (e.g. in case it is not shared any more). Handle this.
include/linux/fs.h +1 -0
@@ -1260,6 +1260,7 @@extern void set_buffer_flushtime (struct buffer_head *);extern inline int get_buffer_flushtime (void ); +extern inline int get_buffer_age (void );extern void balance_dirty (void );extern int check_disk_change (kdev_t );extern int invalidate_inodes (struct super_block *);
Quoted 7 lines · Micha Feigin
I've been using this since 2.4.22 and since
laptop_modeis in the kernel since 2.4.23-pre<something> and I haven't seen that anyone else has implemented this so I decided to post it on the list in case anyone is interested.
It a patch to modify the journal flush time of reiserfs to supportlaptop_mode(same functionality as ext3 has already).
The times are taken from bdflush.
Support for reiserfs laptop mode is in 2.6 now. It is done by adding new mount option "commit=N" that sets commit interval in seconds.
It doesn't look right to just plainly set reiserfs commit interval to be the same as the ext3 commit interval.
Quoted 13 lines
fs/reiserfs/journal.c +1
-0@@ -58,6 +58,7 @@#include <linux/stat.h> #include <linux/string.h> #include <linux/smp_lock.h> +#include <linux/fs.h> /* the number of mounted filesystems. This is used to decide when to ** start and kill the commit thread @@ -2659,8 +2660,12 @@/* starting with oldest, loop until we get to the start */
fs/reiserfs/journal.c line 2668
Quoted 10 lines
fs/reiserfs/journal.c +6
-2i = (SB_JOURNAL_LIST_INDEX (p_s_sb) +1 ) %JOURNAL_LIST_COUNT ;while (i != start) { -if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >SB_JOURNAL_MAX_COMMIT_AGE (p_s_sb) || - immediate)) { +/* get_buffer_age() / HZ is used since the time returned by +* get_buffer_age is in sec * HZ and the journal time is taken in seconds. +*/ +if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && + ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >get_buffer_age () /HZ + || immediate)) {
Nikita.
Quoted 9 lines · Nikita Danilov
Quoted 7 lines · Micha Feigin
I've been using this since 2.4.22 and since
laptop_modeis in the kernel since 2.4.23-pre<something> and I haven't seen that anyone else has implemented this so I decided to post it on the list in case anyone is interested.
It a patch to modify the journal flush time of reiserfs to supportlaptop_mode(same functionality as ext3 has already).
The times are taken from bdflush.
Quoted 3 lines
Support for reiserfs laptop mode is in 2.6 now. It is done by adding new mount option "commit=N" that sets commit interval in seconds.
First of all its nice to know that laptop mode has finally made it into 2.6. On the other hand setting commit=N on mount is not a good solution since you want different flush times for when laptop mode is activated and when it is disabled.
When laptop mode is disabled the default of 5 seconds is good since the disk is always spinning. When laptop mode is enabled you want to change the journal flush time to the linux buffer flush time so that the journal won't keep waking up the disk. Its a bigger risk of loosing the data so you don't want the longer journal flush time when laptop mode isn't activated.
Quoted 2 lines
It doesn't look right to just plainly set reiserfs commit interval to be the same as the ext3 commit interval.
I am not setting it to the same value as ext3. When laptop mode isn't activated it is set to the default value used by reiserfs if bdflush isn't modified (it does give you the ability to play with the flush interval if you want even when reiserfs isn't activated). If laptop mode is activated the flush time is set to the linux buffer flush time so that the journal won't wake up the disk.
Quoted 27 lines
Quoted 14 lines
fs/reiserfs/journal.c +1
-0@@ -58,6 +58,7 @@#include <linux/stat.h> #include <linux/string.h> #include <linux/smp_lock.h> +#include <linux/fs.h> /* the number of mounted filesystems. This is used to decide when to ** start and kill the commit thread @@ -2659,8 +2660,12 @@/* starting with oldest, loop until we get to the start */ fs/reiserfs/journal.c line 2668
Quoted 10 lines
fs/reiserfs/journal.c +6
-2i = (SB_JOURNAL_LIST_INDEX (p_s_sb) +1 ) %JOURNAL_LIST_COUNT ;while (i != start) { -if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >SB_JOURNAL_MAX_COMMIT_AGE (p_s_sb) || - immediate)) { +/* get_buffer_age() / HZ is used since the time returned by +* get_buffer_age is in sec * HZ and the journal time is taken in seconds. +*/ +if (SB_JOURNAL_LIST (p_s_sb)[i].j_len >0 && + ((now -SB_JOURNAL_LIST (p_s_sb)[i].j_timestamp) >get_buffer_age () /HZ + || immediate)) {Nikita.
Quoted 32 lines · Micha Feigin
Quoted 9 lines · Nikita Danilov
Quoted 7 lines · Micha Feigin
I've been using this since 2.4.22 and since
laptop_modeis in the kernel since 2.4.23-pre<something> and I haven't seen that anyone else has implemented this so I decided to post it on the list in case anyone is interested.
It a patch to modify the journal flush time of reiserfs to supportlaptop_mode(same functionality as ext3 has already).
The times are taken from bdflush.Quoted 3 lines
Support for reiserfs laptop mode is in 2.6 now. It is done by adding new mount option "commit=N" that sets commit interval in seconds.
First of all its nice to know that laptop mode has finally made it into 2.6. On the other hand setting commit=N on mount is not a good solution since you want different flush times for when laptop mode is activated and when it is disabled.
When laptop mode is disabled the default of 5 seconds is good since the disk is always spinning. When laptop mode is enabled you want to change the journal flush time to the linux buffer flush time so that the journal won't keep waking up the disk. Its a bigger risk of loosing the data so you don't want the longer journal flush time when laptop mode isn't activated.Quoted 2 lines
It doesn't look right to just plainly set reiserfs commit interval to be the same as the ext3 commit interval.
Quoted 6 lines
I am not setting it to the same value as ext3. When laptop mode isn't activated it is set to the default value used by reiserfs if bdflush isn't modified (it does give you the ability to play with the flush interval if you want even when reiserfs isn't activated). If laptop mode is activated the flush time is set to the linux buffer flush time so that the journal won't wake up the disk.
A couple of comments:
* You might want to take a look at Hugang's patch to support laptop mode on reiserfs in 2.6. This patch was posted somewhere last month. It adds a "commit=" option to reiserfs, so that you can change this externally by remounting. I think this solution is a lot cleaner than to have reiserfs code directly depend on laptop mode.
* If you decide to port that patch, you might want to look at the documentation for laptop mode in 2.6. The control script that's in there works for both 2.4 and 2.6, and it automatically remounts your ext3 and reiserfs filesystems with the appropriate commit options (and remounts them without the commit options when laptop mode is stopped). (There is also some ACPI event binding code in the documentation, which automatically enables laptop_mode when using battery power and disables it when your laptop is plugged in. I don't know if that works with 2.4 though.)
-- Bart
Quoted 1 line · Bart Samwel
[...]
Quoted 7 lines
A couple of comments:
* You might want to take a look at Hugang's patch to support laptop mode on reiserfs in 2.6. This patch was posted somewhere last month. It adds a "commit=" option to reiserfs, so that you can change this externally by remounting. I think this solution is a lot cleaner than to have reiserfs code directly depend on laptop mode.
This patch was merged into mainline.
Quoted 3 lines
-- Bart
Nikita.