Deleted Added
sdiff udiff text old ( 274835 ) new ( 283735 )
full compact
1/*-
2 * Copyright (c) 2001, 2002 Ian Dowse. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 14 unchanged lines hidden (view full) ---

23 * SUCH DAMAGE.
24 */
25
26/*
27 * This implements a hash-based lookup scheme for UFS directories.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/sys/ufs/ufs/ufs_dirhash.c 283735 2015-05-29 13:24:17Z kib $");
32
33#include "opt_ufs.h"
34
35#ifdef UFS_DIRHASH
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>

--- 145 unchanged lines hidden (view full) ---

185 * simultaneous access while only a shared vnode lock is held.
186 */
187static struct dirhash *
188ufsdirhash_create(struct inode *ip)
189{
190 struct dirhash *ndh;
191 struct dirhash *dh;
192 struct vnode *vp;
193
194 ndh = dh = NULL;
195 vp = ip->i_vnode;
196 for (;;) {
197 /* Racy check for i_dirhash to prefetch a dirhash structure. */
198 if (ip->i_dirhash == NULL && ndh == NULL) {
199 ndh = malloc(sizeof *dh, M_DIRHASH,
200 M_NOWAIT | M_ZERO);
201 if (ndh == NULL)

--- 65 unchanged lines hidden (view full) ---

267 * Acquire an exclusive lock on an existing hash. Requires an exclusive
268 * vnode lock to protect the i_dirhash pointer. hashes that have been
269 * recycled are reclaimed here and NULL is returned.
270 */
271static struct dirhash *
272ufsdirhash_acquire(struct inode *ip)
273{
274 struct dirhash *dh;
275
276 ASSERT_VOP_ELOCKED(ip->i_vnode, __FUNCTION__);
277
278 dh = ip->i_dirhash;
279 if (dh == NULL)
280 return (NULL);
281 sx_xlock(&dh->dh_lock);
282 if (dh->dh_hash != NULL)
283 return (dh);
284 ufsdirhash_free_locked(ip);
285 return (NULL);

--- 1033 unchanged lines hidden ---