Deleted Added
full compact
ufs_dirhash.c (274835) ufs_dirhash.c (283735)
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>
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 274835 2014-11-22 00:42:30Z davide $");
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;
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 int error;
194
193
195 error = 0;
196 ndh = dh = NULL;
197 vp = ip->i_vnode;
198 for (;;) {
199 /* Racy check for i_dirhash to prefetch a dirhash structure. */
200 if (ip->i_dirhash == NULL && ndh == NULL) {
201 ndh = malloc(sizeof *dh, M_DIRHASH,
202 M_NOWAIT | M_ZERO);
203 if (ndh == NULL)

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

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

--- 1033 unchanged lines hidden ---
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 ---