From: NeilBrown Date: Fri, 9 Jul 2010 12:02:50 +0000 (+1000) Subject: Make sure we retry orphan handling if mutex unavailable. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=f3774db5d6d9edfbf464c76be69d2b1711d11c2a;p=LaFS.git Make sure we retry orphan handling if mutex unavailable. 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 --- diff --git a/orphan.c b/orphan.c index 69464d0..1abe643 100644 --- 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)