Skip to contentSkip to conversation

nilfs2_ss_manager: stop creating snapshot during shutdown

PATCH New Ryusuke Konishi 1 participant 2 messages Feb 6, 2011 1 message not in the archive NILFS2 filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 nilfs2_ss_manager: stop creating snapshot during shutdown

When the snapshot daemon shuts down by interrupt, it can failed to unmount a part of snapshots since snapshot can be created during shutdown the daemon.

This fixes the issue by disabling the snapshot creation when the daemon goes to shutdown state.

---
 nilfs2_ss_manager/nilfs2_ss_manager |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
nilfs2_ss_manager/nilfs2_ss_manager +9 -1
index 3056bcb..f19f6ba 100755
@@ -52,6 +52,7 @@ class NILFSSSManager:
         self.mp = mp
         self.logger = logger
         self.mounts = []
+        self.aborting = 0
 
     def create_dir(self, path):
         if os.path.exists(path):
@@ -71,6 +72,10 @@ class NILFSSSManager:
                 commands.getstatusoutput(cmd)
             self.logger.out(syslog.LOG_INFO, "unmounted %s" % mp)
 
+    def shutdown(self):
+        self.aborting = 1
+        self.do_unmount_all()
+
     def do_mount(self, cp, t='date'):
         target = self.mp
         if t == 'date':
@@ -88,9 +93,12 @@ class NILFSSSManager:
                         "mount ss = %d on %s" % (cp['cno'],target))
 
     def create_ss(self):
+        if self.aborting: return
         cps = self.ns.lscp()[:]
         cps.reverse()
         for cp in cps:
+            if self.aborting:
+                break
             if cp['ss']:
                 break
             self.logger.out(syslog.LOG_INFO,
@@ -122,7 +130,7 @@ class NODaemonContext:
 def register_sighandlers(managers, mainloop):
     def do_exit(a,b):
         for m in managers:
-            m.do_unmount_all()
+            m.shutdown()
         mainloop.quit()
     signal.signal(signal.SIGINT, do_exit)
     signal.signal(signal.SIGTERM, do_exit)
Signature · 6 lines
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 2/2 nilfs2_ss_manager: retry unmount for busy mount points

In reply to a message not in the archive

Busy mount points are left in the snapshots directory. This minimizes the issue by retrying unmount for the busy mount points.

---
 nilfs2_ss_manager/nilfs2_ss_manager |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)
nilfs2_ss_manager/nilfs2_ss_manager +30 -4
index f19f6ba..5821e2a 100755
@@ -63,18 +63,44 @@ class NILFSSSManager:
         else:
             os.mkdir(path)
 
-    def do_unmount_all(self):
+    def do_unmount_all(self, busy=[], failed=[]):
         for mp in self.mounts:
             cmd = 'umount %s' % mp
             result = commands.getstatusoutput(cmd)
             if result[0] == 0:
-                cmd = 'rmdir %s' %mp
+                cmd = 'rmdir %s' % mp
                 commands.getstatusoutput(cmd)
-            self.logger.out(syslog.LOG_INFO, "unmounted %s" % mp)
+                self.logger.out(syslog.LOG_INFO, "unmounted %s" % mp)
+            elif result[0] == 256:
+                self.logger.out(syslog.LOG_INFO,
+                                "failed to unmount %s (busy)" % mp)
+                busy.append(mp)
+            else:
+                self.logger.out(syslog.LOG_WARNING,
+                                "failed to unmount %s (status=%d)" %
+                                (mp, result[0]))
+                failed.append(mp)
+        self.mounts = busy
+
+    def unmount_all(self):
+        busy = []
+        failed = []
+        self.do_unmount_all(busy, failed)
+
+        retrycount = 2
+        interval = 1
+        while busy and retrycount > 0:
+            self.logger.out(syslog.LOG_INFO,
+                            "Retrying unmount (wait=%ds)" % interval)
+            time.sleep(interval)
+            busy = []
+            self.do_unmount_all(busy, failed)
+            interval <<= 1
+            retrycount -= 1
 
     def shutdown(self):
         self.aborting = 1
-        self.do_unmount_all()
+        self.unmount_all()
 
     def do_mount(self, cp, t='date'):
         target = self.mp
Signature · 6 lines
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html