Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7d5ea743 authored by NeilBrown's avatar NeilBrown Committed by Greg Kroah-Hartman
Browse files

staging: lustre: use list_last_entry to simplify fld_cache_shrink



Using list_empty() and list_last_entry() makes the code clearer,
and allows a local variable to be discarded.

Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 93d3ad90
Loading
Loading
Loading
Loading
+6 −7
Original line number Original line Diff line number Diff line
@@ -213,19 +213,18 @@ static inline void fld_cache_entry_add(struct fld_cache *cache,
 */
 */
static int fld_cache_shrink(struct fld_cache *cache)
static int fld_cache_shrink(struct fld_cache *cache)
{
{
	struct fld_cache_entry *flde;
	struct list_head *curr;
	int num = 0;
	int num = 0;


	if (cache->fci_cache_count < cache->fci_cache_size)
	if (cache->fci_cache_count < cache->fci_cache_size)
		return 0;
		return 0;


	curr = cache->fci_lru.prev;

	while (cache->fci_cache_count + cache->fci_threshold >
	while (cache->fci_cache_count + cache->fci_threshold >
	       cache->fci_cache_size && curr != &cache->fci_lru) {
	       cache->fci_cache_size &&
		flde = list_entry(curr, struct fld_cache_entry, fce_lru);
	       !list_empty(&cache->fci_lru)) {
		curr = curr->prev;
		struct fld_cache_entry *flde =
			list_last_entry(&cache->fci_lru,
					struct fld_cache_entry, fce_lru);

		fld_cache_entry_delete(cache, flde);
		fld_cache_entry_delete(cache, flde);
		num++;
		num++;
	}
	}