Re: [PATCH 06/24] dm cache policy mq: return NULL if mq->free list is empty in alloc_entry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 24, 2013 at 02:30:19PM -0400, Mike Snitzer wrote:
> From: Heinz Mauelshagen <heinzm@xxxxxxxxxx>
> Addresses callers' (insert_in*cache()) requirement that alloc_entry()
> return NULL when an entry isn't able to be allocated.
 
What is the code path that leads to the requirement for this patch?

> +++ b/drivers/md/dm-cache-policy-mq.c
>  static struct entry *alloc_entry(struct mq_policy *mq)

> +	struct entry *e = NULL;
>  
>  	if (mq->nr_entries_allocated >= mq->nr_entries) {
>  		BUG_ON(!list_empty(&mq->free));
>  		return NULL;
>  	}
>  
> -	e = list_entry(list_pop(&mq->free), struct entry, list);
> -	INIT_LIST_HEAD(&e->list);
> -	INIT_HLIST_NODE(&e->hlist);
> +	if (!list_empty(&mq->free)) {
> +		e = list_entry(list_pop(&mq->free), struct entry, list);
> +		INIT_LIST_HEAD(&e->list);
> +		INIT_HLIST_NODE(&e->hlist);
> +		mq->nr_entries_allocated++;
> +	}

In other words, under what circumstances is mq->nr_entries_allocated
less then mq->nr_entries, yet the mq->free list is empty?

Is it better to apply a patch like this, or rather to fix whatever situation
leads to those circumstances?  Has the bug/race always been there or is it a
regression?

Alasdair

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux