[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

libdiskfs sync issue at shutdown

From: Samuel Thibault
Subject: libdiskfs sync issue at shutdown
Date: Wed, 10 Aug 2011 02:10:22 +0200
User-agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30)


I've digged a bit in the libdiskfs syncing issue at shutdown. The
scenario is the following:

- halt or reboot is issued
- S_startup_reboot() gets called in init which
  - calls reboot_system(), which
    - calls notify_shutdown(), which for each diskfs which registered itself
      - calls startup_dosync() with a 1m grace period
- diskfs_S_startup_dosync() thus gets called in e.g. ext2fs, which
  - syncs everything and marks hypermetadata as dirty
  - inhibits RPCs
  - syncs everything again and marks hypermetadata as clean
  - resume RPCs
- init takes back hand, and eventually tells mach to hang or reboot.

But since RPCs are resumed, processes can continue writing to files,
which makes ext2fs re-mark hypermetadata as dirty, and thus an
"unclean!" message from ext2fs at reboot.

I've tested the patch below with success.  Since we are shutting down,
it sets the diskfs as readonly, thus preventing from subsequent writes
and unwanted dirtyness.

I understand that the name "startup_dosync" only talks about sync, but
the documentation says it is called at system shutdown and the fs should
be set as readonly in that case.

Is there a reason why that was not done already?

diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c
index bf1acf2..700a26e 100644
--- a/libdiskfs/init-startup.c
+++ b/libdiskfs/init-startup.c
@@ -148,6 +148,9 @@ diskfs_S_startup_dosync (mach_port_t handle)
          diskfs_set_hypermetadata (1, 1);
          _diskfs_diskdirty = 0;
+         diskfs_readonly = 1;
+         diskfs_readonly_changed (1);
          ports_resume_class_rpcs (diskfs_protid_class);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]