xfs: remove a superflous hash lookup when inserting new buffers
authorDave Chinner <dchinner@redhat.com>
Thu, 14 Jul 2022 02:04:43 +0000 (12:04 +1000)
committerDave Chinner <david@fromorbit.com>
Thu, 14 Jul 2022 02:04:43 +0000 (12:04 +1000)
commit32dd4f9c506b1bf147c24cf05423cd893bc06e38
tree3609c32414136ae8fd8df7d812283b0d784332c0
parentd8d9bbb0ee6c79191b704d88c8ae712b89e0d2bb
xfs: remove a superflous hash lookup when inserting new buffers

Currently on the slow path insert we repeat the initial hash table
lookup before we attempt the insert, resulting in a two traversals
of the hash table to ensure the insert is valid. The rhashtable API
provides a method for an atomic lookup and insert operation, so we
can avoid one of the hash table traversals by using this method.

Adapted from a large patch containing this optimisation by Christoph
Hellwig.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_buf.c