0

I am implementing a kernel module to handle power-off event. Our HW setup will emit an IRQ when power cut-off happens, and device can run 200ms more after that. During this time I have to close all rw-opened Fd to avoid file corruption. I am thinking of two options:

  1. Perform closing all Fds from within the interrupt context itself. It will mask all other interrupts and handle the event until device is off. It may cause freezing issue.
  2. Use Softirqs and do closing in the bottom half.

What would be the best way to implement this? thanks all.

Maluvel
  • 425
  • 1
  • 6
  • 13
  • 1
    bottom half. doing it in the isr can block other interrupts needed to do close. – stark Oct 23 '21 at 13:26
  • @stark: but when power is running out we no longer care about other interrupts? – Maluvel Oct 23 '21 at 13:53
  • You care about close completing? – stark Oct 23 '21 at 17:08
  • @stark: But the interrupt will get fd_table and do fd closing by itself, it does not need other interrupt to do it? or pls correct me if i am wrong – Maluvel Oct 23 '21 at 18:57
  • close flushes all buffered data to disk. disk writes are asynchronous and interrupt on completion. – stark Oct 23 '21 at 19:59
  • thanks stark, is there a way to clear buffered data before closing so I don't need other async action? and this flush takes long time so definitely i dont want to flush – Maluvel Oct 24 '21 at 05:52
  • If the file is opened with the O_SYNC flag, then there will be no buffered data. – stark Oct 25 '21 at 16:00

0 Answers0