[Ocfs2-devel] [PATCH 03/39] ocfs2: throttle back local alloc when low on disk space

Andrew Morton akpm at linux-foundation.org
Wed Oct 1 23:11:50 PDT 2008


> On Wed, 24 Sep 2008 15:00:44 -0700 Mark Fasheh <mfasheh at suse.com> 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().




More information about the Ocfs2-devel mailing list