Re: [rfc] Ignore Fsync Calls in Laptop_Mode

From: D. Jansen
Date: Thu May 19 2011 - 11:03:09 EST

On Thu, May 19, 2011 at 3:43 PM, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx> wrote:
>> Problem: laptop_mode wants to keep applications from waking the hard
>> disks but fsync calls can "sneak through". (IMHO this is a bug.)
> Its a standards requirement and thing many apps rely on. Also you can do
> it perfectly well in user space for all apps. Thats why you can
> preconfigure preloads and it's why you have glic library source code!

Yes, it's another possibility I've considered. So then the patch
should go into glibc and glibc check for active laptop_mode? But if
implement it inside a library won't I get the same ordering guarantee
>> Proposed solution: Pretend the fsync was executed and successful.
>> Insert two lines into the fsync and fdatasync calls in fs/sync.c:
>> if (unlikely(laptop_mode))
>> return 0;
> Whoops you've just risked corrupting any app which relies on fsync for
> ordering if there is a crash.
> The "right" way to do this is more complicated by far. An fsync is an
> ordering guarantee so you need to implement that ordering guarantee even
> if you don't force writes to physical media.

Ok. No problem, so the exit point would be a different one.

> That at least cuts down most failures (but not all - eg commits with a network
> component such as email receives)

I don't understand your email example.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at