]> git.neil.brown.name Git - LaFS.git/commitdiff
Make sure we retry orphan handling if mutex unavailable.
authorNeilBrown <neilb@suse.de>
Fri, 9 Jul 2010 12:02:50 +0000 (22:02 +1000)
committerNeilBrown <neilb@suse.de>
Fri, 9 Jul 2010 21:32:01 +0000 (07:32 +1000)
We cannot arrange for a wakeup when i_mutex is dropped,
so we need to set a short timeout when i_mutex cannot be
claimed.

Signed-off-by: NeilBrown <neilb@suse.de>
orphan.c

index 69464d042f725a4fea00e18df407297000283c74..1abe64384bdb4608da95dbd8b209b12d75bb61b5 100644 (file)
--- a/orphan.c
+++ b/orphan.c
@@ -460,6 +460,8 @@ long lafs_run_orphans(struct fs *fs)
 {
        struct datablock *db;
        struct list_head done;
+       long timeout = MAX_SCHEDULE_TIMEOUT;
+
        if (list_empty_careful(&fs->pending_orphans))
                return MAX_SCHEDULE_TIMEOUT;
 
@@ -480,8 +482,14 @@ long lafs_run_orphans(struct fs *fs)
                mx = orphan_mutex(db);
                if (!mx && !test_bit(B_Claimed, &db->b.flags))
                        /* OK not to have a mutex */;
-               else if (!mx || !mutex_trylock(mx))
+               else if (!mx || !mutex_trylock(mx)) {
+                       /* we cannot get a wakeup when mutex
+                        * is unlocked, so we need timeout
+                        * FIXME this is unfortunate
+                        */
+                       timeout = msecs_to_jiffies(500);
                        continue;
+               }
                getdref(db, MKREF(run_orphans));
                spin_unlock(&fs->lock);
 
@@ -517,7 +525,7 @@ long lafs_run_orphans(struct fs *fs)
        if (list_empty_careful(&fs->pending_orphans))
                /* unmount might be waiting... */
                wake_up(&fs->async_complete);
-       return MAX_SCHEDULE_TIMEOUT;
+       return timeout;
 }
 
 int lafs_drop_orphan(struct fs *fs, struct datablock *db)