summaryrefslogtreecommitdiff
path: root/pm
diff options
context:
space:
mode:
authorVictor Lowther <victor.lowther@gmail.com>2008-06-27 20:02:58 -0500
committerVictor Lowther <victor.lowther@gmail.com>2010-06-05 13:32:49 -0500
commit1ab9f81812861c9fbab59c53a1fd50b3077d6a0f (patch)
tree473236d1f11a0b424cf01e855159c9c9702c826b /pm
parent9612398e36335b0358b4585ab6edd5589f9d129e (diff)
Added basic laptop mode support to power.d
Diffstat (limited to 'pm')
-rw-r--r--pm/power.d/Makefile.am6
-rw-r--r--pm/power.d/harddrive25
-rw-r--r--pm/power.d/laptop-mode29
-rw-r--r--pm/power.d/readahead17
-rw-r--r--pm/power.d/xfs_buffer27
5 files changed, 103 insertions, 1 deletions
diff --git a/pm/power.d/Makefile.am b/pm/power.d/Makefile.am
index 53eea54..157e794 100644
--- a/pm/power.d/Makefile.am
+++ b/pm/power.d/Makefile.am
@@ -1,7 +1,11 @@
powerdir = $(libdir)/pm-utils/power.d
power_SCRIPTS = \
- sched-powersave
+ sched-powersave \
+ harddrive \
+ laptop-mode \
+ xfs_buffer \
+ readahead
EXTRA_DIST=$(power_SCRIPTS)
diff --git a/pm/power.d/harddrive b/pm/power.d/harddrive
new file mode 100644
index 0000000..cdfa637
--- /dev/null
+++ b/pm/power.d/harddrive
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+[ -x /sbin/hdparm ] || exit $NA
+
+harddrive_ac () {
+ for dev in /dev/[hs]d[a-z]; do
+ #enable write caching, do not spin down the drive.
+ hdparm -W 1 -S 0 $dev
+ done
+}
+
+harddrive_battery() {
+ for dev in /dev/[hs]d[a-z]; do
+ # disable write caching, spin down after 30 seconds
+ hdparm -W 0 -S 6 $dev
+ done
+}
+
+case $1 in
+ true) harddrive_battery ;;
+ false) harddrive_ac ;;
+ *) exit $NA ;;
+esac
+
+exit 0
diff --git a/pm/power.d/laptop-mode b/pm/power.d/laptop-mode
new file mode 100644
index 0000000..8e0fbdf
--- /dev/null
+++ b/pm/power.d/laptop-mode
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+VM="/proc/sys/vm"
+
+[ -f $VM/laptop_mode -a -f $VM/dirty_ratio ] || exit $NA
+
+laptop_mode_ac() {
+ echo 0 >$VM/laptop_mode
+ echo 5 >$VM/dirty_background_ratio
+ echo 2999 >$VM/dirty_expire_centisecs
+ echo 10 >$VM/dirty_ratio
+ echo 499 >$VM/dirty_writeback_centisecs
+}
+
+laptop_mode_battery() {
+ echo 1 >$VM/laptop_mode
+ echo 1 >$VM/dirty_background_ratio
+ echo 60000 >$VM/dirty_expire_centisecs
+ echo 60 >$VM/dirty_ratio
+ echo 60000 >$VM/dirty_writeback_centisecs
+}
+
+case $1 in
+ true) laptop_mode_battery ;;
+ false) laptop_mode_ac ;;
+ *) exit $NA ;;
+esac
+
+exit 0
diff --git a/pm/power.d/readahead b/pm/power.d/readahead
new file mode 100644
index 0000000..4247217
--- /dev/null
+++ b/pm/power.d/readahead
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+[ -x /sbin/blockdev ] || exit $NA
+
+readahead() {
+ for dev in $(awk '/^\/dev\// {print $1}'</etc/mtab); do
+ /sbin/blockdev --setfra $1 "$dev"
+ done
+}
+
+case $1 in
+ true) readahead 3072 ;;
+ false) readahead 256 ;;
+ *) exit $NA ;;
+esac
+
+exit 0
diff --git a/pm/power.d/xfs_buffer b/pm/power.d/xfs_buffer
new file mode 100644
index 0000000..7510e68
--- /dev/null
+++ b/pm/power.d/xfs_buffer
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+. "${PM_FUNCTIONS}"
+
+XFS="/proc/sys/fs/xfs"
+[ -f $XFS/age_buffer_centisecs ] || exit $NA
+
+
+xfs_ac() {
+ echo 1500 >$XFS/age_buffer_centisecs
+ echo 3000 >$XFS/xfssyncd_centisecs
+ echo 100 >$XFS/xfsbufd_centisecs
+}
+
+xfs_battery() {
+ echo 60000 >$XFS/age_buffer_centisecs
+ echo 60000 >$XFS/xfssyncd_centisecs
+ echo 3000 >$XFS/xfsbufd_centisecs
+}
+
+case $1 in
+ true) xfs_battery ;;
+ false) xfs_ac ;;
+ *) exit $NA ;;
+esac
+
+exit 0 \ No newline at end of file