Re: [PATCH 03/39] ocfs2: throttle back local alloc when low on diskspace

From: Andrew Morton
Date: Thu Oct 02 2008 - 02:12:48 EST


> On Wed, 24 Sep 2008 15:00:44 -0700 Mark Fasheh <mfasheh@xxxxxxxx> wrote:
> +void ocfs2_local_alloc_seen_free_bits(struct ocfs2_super *osb,
> + unsigned int num_clusters)
> +{
> + spin_lock(&osb->osb_lock);
> + if (osb->local_alloc_state == OCFS2_LA_DISABLED ||
> + osb->local_alloc_state == OCFS2_LA_THROTTLED)
> + if (num_clusters >= osb->local_alloc_default_bits) {
> + cancel_delayed_work(&osb->la_enable_wq);
> + osb->local_alloc_state = OCFS2_LA_ENABLED;
> + }
> + spin_unlock(&osb->osb_lock);
> +}
> +
> +void ocfs2_la_enable_worker(struct work_struct *work)
> +{
> + struct ocfs2_super *osb =
> + container_of(work, struct ocfs2_super,
> + la_enable_wq.work);
> + spin_lock(&osb->osb_lock);
> + osb->local_alloc_state = OCFS2_LA_ENABLED;
> + spin_unlock(&osb->osb_lock);
> +}

cacnel_delayed_work() is a pretty risky function. The work handler
(ocfs2_la_enable_worker) can execute an arbitrarily long time after
cancel_delayed_work() has returned. Can all the code here cope with such a
surprise alteration of ->local_alloc_state()?

And you canot use cancel_delayed_work_sync() here due to a deadlock on
->osb_lock().

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/