lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Thu, 14 Jul 2022 17:17:02 +0530 From: Ritesh Harjani <ritesh.list@...il.com> To: Jan Kara <jack@...e.cz> Cc: Ted Tso <tytso@....edu>, linux-ext4@...r.kernel.org, stable@...r.kernel.org Subject: Re: [PATCH 01/10] mbcache: Don't reclaim used entries On 22/07/12 12:54PM, Jan Kara wrote: > Do not reclaim entries that are currently used by somebody from a > shrinker. Firstly, these entries are likely useful. Secondly, we will > need to keep such entries to protect pending increment of xattr block > refcount. > > CC: stable@...r.kernel.org > Fixes: 82939d7999df ("ext4: convert to mbcache2") > Signed-off-by: Jan Kara <jack@...e.cz> > --- > fs/mbcache.c | 10 +++++++++- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/fs/mbcache.c b/fs/mbcache.c > index 97c54d3a2227..cfc28129fb6f 100644 > --- a/fs/mbcache.c > +++ b/fs/mbcache.c > @@ -288,7 +288,7 @@ static unsigned long mb_cache_shrink(struct mb_cache *cache, > while (nr_to_scan-- && !list_empty(&cache->c_list)) { > entry = list_first_entry(&cache->c_list, > struct mb_cache_entry, e_list); > - if (entry->e_referenced) { > + if (entry->e_referenced || atomic_read(&entry->e_refcnt) > 2) { > entry->e_referenced = 0; > list_move_tail(&entry->e_list, &cache->c_list); > continue; > @@ -302,6 +302,14 @@ static unsigned long mb_cache_shrink(struct mb_cache *cache, > spin_unlock(&cache->c_list_lock); > head = mb_cache_entry_head(cache, entry->e_key); > hlist_bl_lock(head); > + /* Now a reliable check if the entry didn't get used... */ > + if (atomic_read(&entry->e_refcnt) > 2) { On taking a look at this patchset again. I think if we move this "if" condition of checking refcnt to above i.e. before we delete the entry from c_list. Then we can avoid => removing of the entry -> checking it's refcnt under lock -> adding it back if the refcnt is elevated. Thoughts? -ritesh > + hlist_bl_unlock(head); > + spin_lock(&cache->c_list_lock); > + list_add_tail(&entry->e_list, &cache->c_list); > + cache->c_entry_count++; > + continue; > + } > if (!hlist_bl_unhashed(&entry->e_hash_list)) { > hlist_bl_del_init(&entry->e_hash_list); > atomic_dec(&entry->e_refcnt); > -- > 2.35.3 >
Powered by blists - more mailing lists