Author Topic: Pdaxi13 : Safer Apm Suspend On Akita  (Read 2609 times)

ulutte

  • Newbie
  • *
  • Posts: 6
    • View Profile
Pdaxi13 : Safer Apm Suspend On Akita
« on: July 31, 2007, 04:52:50 pm »
Hi,

I have modified the scripts in /etc/apm in order to :

1. umount the swap on /dev/mmcda3
2. stop the processes accessing /mnt/card and /mnt/card2 on the SD card
2 remount /mnt/card and /mnt/card2 RO
 ... when suspending

and doing the opposite when resuming.

My config :

SD card : partition 1 DOS partition 2 ext2 partition 3 swap
pdaxii13 on C1000 "ipk-batch-install.tgz" install method.

I added the script "fs" in  /etc/apm/scripts.d/ :

#! /bin/bash
#
# fd
#
# Ensures there is no IO on the SD card before suspending
# in order to avoid data dorruption

DOS_MNTPT_ON_SD=/mnt/card
DOS_DEVICE_ON_SD=/dev/mmcda1
EXT2_MNTPT_ON_SD=/mnt/card2
EXT2_DEVICE_ON_SD=/dev/mmcda2
SWAP_DEVICE_ON_SD=/dev/mmcda3

# See how we were called.
 
suspend() {
  # Turn swap off.
  swapoff $SWAP_DEVICE_ON_SD >/dev/null 2>/dev/null
 
  # Remount dos data partition RO.
  fuser -k -SIGSTOP -m $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
  mount -o remount,ro $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
 
  # Remount ext2 data partition RO.
  fuser -k -SIGSTOP -m $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null
  mount -t ext2 -o remount,ro $EXT2_DEVICE_ON_SD $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null

  # Syncing all devices
  sync
  sleep 2
 
  return 0
}

resume() {
  # Turn swap on.
  swapon $SWAP_DEVICE_ON_SD >/dev/null 2>/dev/null
 
  # Remount dos data partition RW.
  mount -o remount,rw $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
 
  # Remount ext2 data partition RW.
  mount -t ext2 -o remount,rw $EXT2_DEVICE_ON_SD $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null
 
   # Syncing all devices
  sync
  sleep 2
 
  # Resuming all processes
  fuser -k -SIGCONT -m $DOS_MNTPT_ON_SD >/dev/null 2>/dev/null
  fuser -k -SIGCONT -m $EXT2_MNTPT_ON_SD >/dev/null 2>/dev/null
 
  return 0
}


case "$1" in
  suspend)
        suspend
        ;;
  resume)
        resume
        ;;
  *)
        echo "Usage: $0 {suspend|resume}"
        exit 1
esac

exit $?

I put these two links pointing to "fs"

In /etc/apm/suspend.d : 920fs
In /etc/apm/resume.d : 001fs

Seems to work reliabely. Needs to be tested and adapted to your config. It is not very generic but gives some hints to avoid these nasty IO errors on the filesystem when resuming.

Best,
Ulutte

daniel3000

  • Hero Member
  • *****
  • Posts: 1003
    • View Profile
    • http://
Pdaxi13 : Safer Apm Suspend On Akita
« Reply #1 on: August 01, 2007, 05:38:05 am »
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
SL-C3200 with weeXpc, based on pdaXrom 1.1.0beta3
HP 200LX with MS-DOS 5.0

InSearchOf

  • Administrator
  • Hero Member
  • *****
  • Posts: 1144
    • View Profile
    • http://
Pdaxi13 : Safer Apm Suspend On Akita
« Reply #2 on: August 01, 2007, 08:34:06 am »
Quote
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
[div align=\"right\"][a href=\"index.php?act=findpost&pid=165612\"][{POST_SNAPBACK}][/a][/div]

I agree... and if there aren't issues... suspends will become VERY lengthy...

Late
Sharp Zaurus SL-C3100 and SL-6000L
pdaXrom Developer
Please visit pdaXrom.org for updates
My Blog
IRC #pdaxrom @ FreeNode

ulutte

  • Newbie
  • *
  • Posts: 6
    • View Profile
Pdaxi13 : Safer Apm Suspend On Akita
« Reply #3 on: August 01, 2007, 03:11:30 pm »
Quote
Quote
Isn't this dangerous when swap is heavily used?
I have heard and experiences myself that when unmounting a used swap, not all contents can be swapped back into memory and the system hangs.

daniel
[div align=\"right\"][a href=\"index.php?act=findpost&pid=165612\"][{POST_SNAPBACK}][/a][/div]

I agree... and if there aren't issues... suspends will become VERY lengthy...

Late
[div align=\"right\"][a href=\"index.php?act=findpost&pid=165616\"][{POST_SNAPBACK}][/a][/div]

Yes, your are right, turning off the swap might not be a good idea in case of heavy load. But suspending in this situation is in general not a good idea...

From a general point of view, I prefer a lengthy suspend than a buggy resume. When there is heavy traffic on the SD card while suspending, I experimented some timeout issues from the SD driver that yield I/O errors on the ext2 filesystem. This is very bad and could corrupt the data. Of course, the real culprit is the proprietary SD driver that is apm unaware. The best solution would be to have a better driver. I suggest here only a quickand dirty workaround.

Of course other suggestions are welcome ...