From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752117AbdJ3FAX (ORCPT ); Mon, 30 Oct 2017 01:00:23 -0400 Received: from mx2.suse.de ([195.135.220.15]:49279 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752013AbdJ3FAT (ORCPT ); Mon, 30 Oct 2017 01:00:19 -0400 From: NeilBrown To: Oleg Drokin , Andreas Dilger , James Simmons , Greg Kroah-Hartman Date: Mon, 30 Oct 2017 15:59:27 +1100 Subject: [PATCH 01/10] staging: lustre: use list_last_entry to simplify fld_cache_shrink Cc: linux-kernel@vger.kernel.org, lustre-devel@lists.lustre.org Message-ID: <150933956703.22133.5329157273101330596.stgit@noble> In-Reply-To: <150933945578.22133.8029060522107378499.stgit@noble> References: <150933945578.22133.8029060522107378499.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: NeilBrown --- drivers/staging/lustre/lustre/fld/fld_cache.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c index b723ece02eff..c01709cd22a1 100644 --- a/drivers/staging/lustre/lustre/fld/fld_cache.c +++ b/drivers/staging/lustre/lustre/fld/fld_cache.c @@ -212,19 +212,18 @@ static inline void fld_cache_entry_add(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; if (cache->fci_cache_count < cache->fci_cache_size) return 0; - curr = cache->fci_lru.prev; - while (cache->fci_cache_count + cache->fci_threshold > - cache->fci_cache_size && curr != &cache->fci_lru) { - flde = list_entry(curr, struct fld_cache_entry, fce_lru); - curr = curr->prev; + cache->fci_cache_size && + !list_empty(&cache->fci_lru)) { + struct fld_cache_entry *flde = + list_last_entry(&cache->fci_lru, + struct fld_cache_entry, fce_lru); + fld_cache_entry_delete(cache, flde); num++; }