cache: don't use cache_purge_negative when renaming

It avoidably scans (and evicts) unrelated entries. Instead take
advantage of passed componentname and perform a hash lookup
for the exact one.

Sample data from buildworld probed on cache_purge_negative extended
to count both scanned and evicted entries on each call are below.
At most it has to evict 1.

  evicted
           value  ------------- Distribution ------------- count
              -1 |                                         0
               0 |@@@@@@@@@@@@@@@                          19506
               1 |@@@@@                                    5820
               2 |@@@@@@                                   7751
               4 |@@@@@                                    6506
               8 |@@@@@                                    5996
              16 |@@@                                      4029
              32 |@                                        1489
              64 |                                         193
             128 |                                         109
             256 |                                         56
             512 |                                         16
            1024 |                                         7
            2048 |                                         3
            4096 |                                         1
            8192 |                                         1
           16384 |                                         0

  scanned
           value  ------------- Distribution ------------- count
              -1 |                                         0
               0 |@@                                       2456
               1 |@                                        1496
               2 |@@                                       2728
               4 |@@@                                      4171
               8 |@@@@                                     5122
              16 |@@@@                                     5335
              32 |@@@@@                                    6279
              64 |@@@@                                     5671
             128 |@@@@                                     4558
             256 |@@                                       3123
             512 |@@                                       2790
            1024 |@@                                       2449
            2048 |@@                                       3021
            4096 |@                                        1398
            8192 |@                                        886
           16384 |                                         0
This commit is contained in:
Mateusz Guzik 2020-08-20 10:06:50 +00:00
parent 39f8815070
commit 17838b5869

View File

@ -2351,9 +2351,13 @@ cache_rename(struct vnode *fdvp, struct vnode *fvp, struct vnode *tdvp,
ASSERT_VOP_IN_SEQC(tvp);
cache_purge(fvp);
if (tvp != NULL)
if (tvp != NULL) {
cache_purge(tvp);
cache_purge_negative(tdvp);
KASSERT(!cache_remove_cnp(tdvp, tcnp),
("%s: lingering negative entry", __func__));
} else {
cache_remove_cnp(tdvp, tcnp);
}
}
/*