aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iget.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_iget.c')
-rw-r--r--fs/xfs/xfs_iget.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 0724df7fabb7..b73d216ecaf9 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -50,7 +50,7 @@ void
50xfs_ihash_init(xfs_mount_t *mp) 50xfs_ihash_init(xfs_mount_t *mp)
51{ 51{
52 __uint64_t icount; 52 __uint64_t icount;
53 uint i, flags = KM_SLEEP | KM_MAYFAIL; 53 uint i;
54 54
55 if (!mp->m_ihsize) { 55 if (!mp->m_ihsize) {
56 icount = mp->m_maxicount ? mp->m_maxicount : 56 icount = mp->m_maxicount ? mp->m_maxicount :
@@ -61,14 +61,13 @@ xfs_ihash_init(xfs_mount_t *mp)
61 (64 * NBPP) / sizeof(xfs_ihash_t)); 61 (64 * NBPP) / sizeof(xfs_ihash_t));
62 } 62 }
63 63
64 while (!(mp->m_ihash = (xfs_ihash_t *)kmem_zalloc(mp->m_ihsize * 64 mp->m_ihash = kmem_zalloc_greedy(&mp->m_ihsize,
65 sizeof(xfs_ihash_t), flags))) { 65 NBPC * sizeof(xfs_ihash_t),
66 if ((mp->m_ihsize >>= 1) <= NBPP) 66 mp->m_ihsize * sizeof(xfs_ihash_t),
67 flags = KM_SLEEP; 67 KM_SLEEP | KM_MAYFAIL | KM_LARGE);
68 } 68 mp->m_ihsize /= sizeof(xfs_ihash_t);
69 for (i = 0; i < mp->m_ihsize; i++) { 69 for (i = 0; i < mp->m_ihsize; i++)
70 rwlock_init(&(mp->m_ihash[i].ih_lock)); 70 rwlock_init(&(mp->m_ihash[i].ih_lock));
71 }
72} 71}
73 72
74/* 73/*
@@ -77,7 +76,7 @@ xfs_ihash_init(xfs_mount_t *mp)
77void 76void
78xfs_ihash_free(xfs_mount_t *mp) 77xfs_ihash_free(xfs_mount_t *mp)
79{ 78{
80 kmem_free(mp->m_ihash, mp->m_ihsize*sizeof(xfs_ihash_t)); 79 kmem_free(mp->m_ihash, mp->m_ihsize * sizeof(xfs_ihash_t));
81 mp->m_ihash = NULL; 80 mp->m_ihash = NULL;
82} 81}
83 82
@@ -95,7 +94,7 @@ xfs_chash_init(xfs_mount_t *mp)
95 mp->m_chsize = min_t(uint, mp->m_chsize, mp->m_ihsize); 94 mp->m_chsize = min_t(uint, mp->m_chsize, mp->m_ihsize);
96 mp->m_chash = (xfs_chash_t *)kmem_zalloc(mp->m_chsize 95 mp->m_chash = (xfs_chash_t *)kmem_zalloc(mp->m_chsize
97 * sizeof(xfs_chash_t), 96 * sizeof(xfs_chash_t),
98 KM_SLEEP); 97 KM_SLEEP | KM_LARGE);
99 for (i = 0; i < mp->m_chsize; i++) { 98 for (i = 0; i < mp->m_chsize; i++) {
100 spinlock_init(&mp->m_chash[i].ch_lock,"xfshash"); 99 spinlock_init(&mp->m_chash[i].ch_lock,"xfshash");
101 } 100 }
@@ -244,7 +243,9 @@ again:
244 243
245 XFS_STATS_INC(xs_ig_found); 244 XFS_STATS_INC(xs_ig_found);
246 245
246 spin_lock(&ip->i_flags_lock);
247 ip->i_flags &= ~XFS_IRECLAIMABLE; 247 ip->i_flags &= ~XFS_IRECLAIMABLE;
248 spin_unlock(&ip->i_flags_lock);
248 version = ih->ih_version; 249 version = ih->ih_version;
249 read_unlock(&ih->ih_lock); 250 read_unlock(&ih->ih_lock);
250 xfs_ihash_promote(ih, ip, version); 251 xfs_ihash_promote(ih, ip, version);
@@ -290,15 +291,17 @@ again:
290 291
291finish_inode: 292finish_inode:
292 if (ip->i_d.di_mode == 0) { 293 if (ip->i_d.di_mode == 0) {
293 if (!(flags & IGET_CREATE)) 294 if (!(flags & XFS_IGET_CREATE))
294 return ENOENT; 295 return ENOENT;
295 xfs_iocore_inode_reinit(ip); 296 xfs_iocore_inode_reinit(ip);
296 } 297 }
297 298
298 if (lock_flags != 0) 299 if (lock_flags != 0)
299 xfs_ilock(ip, lock_flags); 300 xfs_ilock(ip, lock_flags);
300 301
302 spin_lock(&ip->i_flags_lock);
301 ip->i_flags &= ~XFS_ISTALE; 303 ip->i_flags &= ~XFS_ISTALE;
304 spin_unlock(&ip->i_flags_lock);
302 305
303 vn_trace_exit(vp, "xfs_iget.found", 306 vn_trace_exit(vp, "xfs_iget.found",
304 (inst_t *)__return_address); 307 (inst_t *)__return_address);
@@ -320,21 +323,20 @@ finish_inode:
320 * Read the disk inode attributes into a new inode structure and get 323 * Read the disk inode attributes into a new inode structure and get
321 * a new vnode for it. This should also initialize i_ino and i_mount. 324 * a new vnode for it. This should also initialize i_ino and i_mount.
322 */ 325 */
323 error = xfs_iread(mp, tp, ino, &ip, bno); 326 error = xfs_iread(mp, tp, ino, &ip, bno,
324 if (error) { 327 (flags & XFS_IGET_BULKSTAT) ? XFS_IMAP_BULKSTAT : 0);
328 if (error)
325 return error; 329 return error;
326 }
327 330
328 vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address); 331 vn_trace_exit(vp, "xfs_iget.alloc", (inst_t *)__return_address);
329 332
330 xfs_inode_lock_init(ip, vp); 333 xfs_inode_lock_init(ip, vp);
331 xfs_iocore_inode_init(ip); 334 xfs_iocore_inode_init(ip);
332 335
333 if (lock_flags != 0) { 336 if (lock_flags)
334 xfs_ilock(ip, lock_flags); 337 xfs_ilock(ip, lock_flags);
335 } 338
336 339 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
337 if ((ip->i_d.di_mode == 0) && !(flags & IGET_CREATE)) {
338 xfs_idestroy(ip); 340 xfs_idestroy(ip);
339 return ENOENT; 341 return ENOENT;
340 } 342 }
@@ -369,7 +371,9 @@ finish_inode:
369 ih->ih_next = ip; 371 ih->ih_next = ip;
370 ip->i_udquot = ip->i_gdquot = NULL; 372 ip->i_udquot = ip->i_gdquot = NULL;
371 ih->ih_version++; 373 ih->ih_version++;
374 spin_lock(&ip->i_flags_lock);
372 ip->i_flags |= XFS_INEW; 375 ip->i_flags |= XFS_INEW;
376 spin_unlock(&ip->i_flags_lock);
373 377
374 write_unlock(&ih->ih_lock); 378 write_unlock(&ih->ih_lock);
375 379
@@ -548,7 +552,7 @@ xfs_inode_lock_init(
548 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number); 552 mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number);
549 init_waitqueue_head(&ip->i_ipin_wait); 553 init_waitqueue_head(&ip->i_ipin_wait);
550 atomic_set(&ip->i_pincount, 0); 554 atomic_set(&ip->i_pincount, 0);
551 init_sema(&ip->i_flock, 1, "xfsfino", vp->v_number); 555 initnsema(&ip->i_flock, 1, "xfsfino");
552} 556}
553 557
554/* 558/*