Skip to content

Commit 048c397

Browse files
fllindenTrond Myklebust
authored andcommitted
NFSv4.2: xattr cache: get rid of cache discard work queue
Caches should be small enough to discard them inline, so do that instead of using a work queue. Signed-off-by: Frank van der Linden <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 9a74a2b commit 048c397

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

fs/nfs/nfs42xattr.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ struct nfs4_xattr_cache {
7575
spinlock_t listxattr_lock;
7676
struct inode *inode;
7777
struct nfs4_xattr_entry *listxattr;
78-
struct work_struct work;
7978
};
8079

8180
struct nfs4_xattr_entry {
@@ -101,8 +100,6 @@ static struct list_lru nfs4_xattr_large_entry_lru;
101100

102101
static struct kmem_cache *nfs4_xattr_cache_cachep;
103102

104-
static struct workqueue_struct *nfs4_xattr_cache_wq;
105-
106103
/*
107104
* Hashing helper functions.
108105
*/
@@ -365,9 +362,8 @@ nfs4_xattr_cache_unlink(struct inode *inode)
365362
}
366363

367364
/*
368-
* Discard a cache. Usually called by a worker, since walking all
369-
* the entries can take up some cycles that we don't want to waste
370-
* in the I/O path. Can also be called from the shrinker callback.
365+
* Discard a cache. Called by get_cache() if there was an old,
366+
* invalid cache. Can also be called from a shrinker callback.
371367
*
372368
* The cache is dead, it has already been unlinked from its inode,
373369
* and no longer appears on the cache LRU list.
@@ -414,21 +410,6 @@ nfs4_xattr_discard_cache(struct nfs4_xattr_cache *cache)
414410
kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
415411
}
416412

417-
static void
418-
nfs4_xattr_discard_cache_worker(struct work_struct *work)
419-
{
420-
struct nfs4_xattr_cache *cache = container_of(work,
421-
struct nfs4_xattr_cache, work);
422-
423-
nfs4_xattr_discard_cache(cache);
424-
}
425-
426-
static void
427-
nfs4_xattr_reap_cache(struct nfs4_xattr_cache *cache)
428-
{
429-
queue_work(nfs4_xattr_cache_wq, &cache->work);
430-
}
431-
432413
/*
433414
* Get a referenced copy of the cache structure. Avoid doing allocs
434415
* while holding i_lock. Which means that we do some optimistic allocation,
@@ -513,10 +494,10 @@ nfs4_xattr_get_cache(struct inode *inode, int add)
513494

514495
out:
515496
/*
516-
* Discarding an old cache is done via a workqueue.
497+
* Discard the now orphaned old cache.
517498
*/
518499
if (oldcache != NULL)
519-
nfs4_xattr_reap_cache(oldcache);
500+
nfs4_xattr_discard_cache(oldcache);
520501

521502
return cache;
522503
}
@@ -1008,7 +989,6 @@ static void nfs4_xattr_cache_init_once(void *p)
1008989
atomic_long_set(&cache->nent, 0);
1009990
nfs4_xattr_hash_init(cache);
1010991
cache->listxattr = NULL;
1011-
INIT_WORK(&cache->work, nfs4_xattr_discard_cache_worker);
1012992
INIT_LIST_HEAD(&cache->lru);
1013993
INIT_LIST_HEAD(&cache->dispose);
1014994
}
@@ -1039,13 +1019,9 @@ int __init nfs4_xattr_cache_init(void)
10391019
if (ret)
10401020
goto out2;
10411021

1042-
nfs4_xattr_cache_wq = alloc_workqueue("nfs4_xattr", WQ_MEM_RECLAIM, 0);
1043-
if (nfs4_xattr_cache_wq == NULL)
1044-
goto out1;
1045-
10461022
ret = register_shrinker(&nfs4_xattr_cache_shrinker);
10471023
if (ret)
1048-
goto out0;
1024+
goto out1;
10491025

10501026
ret = register_shrinker(&nfs4_xattr_entry_shrinker);
10511027
if (ret)
@@ -1058,8 +1034,6 @@ int __init nfs4_xattr_cache_init(void)
10581034
unregister_shrinker(&nfs4_xattr_entry_shrinker);
10591035
out:
10601036
unregister_shrinker(&nfs4_xattr_cache_shrinker);
1061-
out0:
1062-
destroy_workqueue(nfs4_xattr_cache_wq);
10631037
out1:
10641038
list_lru_destroy(&nfs4_xattr_cache_lru);
10651039
out2:
@@ -1079,5 +1053,4 @@ void nfs4_xattr_cache_exit(void)
10791053
list_lru_destroy(&nfs4_xattr_entry_lru);
10801054
list_lru_destroy(&nfs4_xattr_cache_lru);
10811055
kmem_cache_destroy(nfs4_xattr_cache_cachep);
1082-
destroy_workqueue(nfs4_xattr_cache_wq);
10831056
}

0 commit comments

Comments
 (0)