Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: icache RCU free inodes

RCU free the struct inode. This will allow:

- Subsequent store-free path walking patch. The inode must be consulted for
permissions when walking, so an RCU inode reference is a must.
- sb_inode_list_lock to be moved inside i_lock because sb list walkers who want
to take i_lock no longer need to take sb_inode_list_lock to walk the list in
the first place. This will simplify and optimize locking.
- Could remove some nested trylock loops in dcache code
- Could potentially simplify things a bit in VM land. Do not need to take the
page lock to follow page->mapping.

The downsides of this is the performance cost of using RCU. In a simple
creat/unlink microbenchmark, performance drops by about 10% due to inability to
reuse cache-hot slab objects. As iterations increase and RCU freeing starts
kicking over, this increases to about 20%.

In cases where inode lifetimes are longer (ie. many inodes may be allocated
during the average life span of a single inode), a lot of this cache reuse is
not applicable, so the regression caused by this patch is smaller.

The cache-hot regression could largely be avoided by using SLAB_DESTROY_BY_RCU,
however this adds some complexity to list walking and store-free path walking,
so I prefer to implement this at a later date, if it is shown to be a win in
real situations. I haven't found a regression in any non-micro benchmark so I
doubt it will be a problem.

Signed-off-by: Nick Piggin <npiggin@kernel.dk>

+490 -68
+14
Documentation/filesystems/porting
··· 346 346 for details of what locks to replace dcache_lock with in order to protect 347 347 particular things. Most of the time, a filesystem only needs ->d_lock, which 348 348 protects *all* the dcache state of a given dentry. 349 + 350 + -- 351 + [mandatory] 352 + 353 + Filesystems must RCU-free their inodes, if they can have been accessed 354 + via rcu-walk path walk (basically, if the file can have had a path name in the 355 + vfs namespace). 356 + 357 + i_dentry and i_rcu share storage in a union, and the vfs expects 358 + i_dentry to be reinitialized before it is freed, so an: 359 + 360 + INIT_LIST_HEAD(&inode->i_dentry); 361 + 362 + must be done in the RCU callback.
+8 -2
arch/powerpc/platforms/cell/spufs/inode.c
··· 71 71 return &ei->vfs_inode; 72 72 } 73 73 74 - static void 75 - spufs_destroy_inode(struct inode *inode) 74 + static void spufs_i_callback(struct rcu_head *head) 76 75 { 76 + struct inode *inode = container_of(head, struct inode, i_rcu); 77 + INIT_LIST_HEAD(&inode->i_dentry); 77 78 kmem_cache_free(spufs_inode_cache, SPUFS_I(inode)); 79 + } 80 + 81 + static void spufs_destroy_inode(struct inode *inode) 82 + { 83 + call_rcu(&inode->i_rcu, spufs_i_callback); 78 84 } 79 85 80 86 static void
+8 -1
drivers/staging/pohmelfs/inode.c
··· 826 826 .set_page_dirty = __set_page_dirty_nobuffers, 827 827 }; 828 828 829 + static void pohmelfs_i_callback(struct rcu_head *head) 830 + { 831 + struct inode *inode = container_of(head, struct inode, i_rcu); 832 + INIT_LIST_HEAD(&inode->i_dentry); 833 + kmem_cache_free(pohmelfs_inode_cache, POHMELFS_I(inode)); 834 + } 835 + 829 836 /* 830 837 * ->detroy_inode() callback. Deletes inode from the caches 831 838 * and frees private data. ··· 849 842 850 843 dprintk("%s: pi: %p, inode: %p, ino: %llu.\n", 851 844 __func__, pi, &pi->vfs_inode, pi->ino); 852 - kmem_cache_free(pohmelfs_inode_cache, pi); 853 845 atomic_long_dec(&psb->total_inodes); 846 + call_rcu(&inode->i_rcu, pohmelfs_i_callback); 854 847 } 855 848 856 849 /*
+8 -1
drivers/staging/smbfs/inode.c
··· 62 62 return &ei->vfs_inode; 63 63 } 64 64 65 + static void smb_i_callback(struct rcu_head *head) 66 + { 67 + struct inode *inode = container_of(head, struct inode, i_rcu); 68 + INIT_LIST_HEAD(&inode->i_dentry); 69 + kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 70 + } 71 + 65 72 static void smb_destroy_inode(struct inode *inode) 66 73 { 67 - kmem_cache_free(smb_inode_cachep, SMB_I(inode)); 74 + call_rcu(&inode->i_rcu, smb_i_callback); 68 75 } 69 76 70 77 static void init_once(void *foo)
+8 -1
fs/9p/vfs_inode.c
··· 237 237 * 238 238 */ 239 239 240 + static void v9fs_i_callback(struct rcu_head *head) 241 + { 242 + struct inode *inode = container_of(head, struct inode, i_rcu); 243 + INIT_LIST_HEAD(&inode->i_dentry); 244 + kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode)); 245 + } 246 + 240 247 void v9fs_destroy_inode(struct inode *inode) 241 248 { 242 - kmem_cache_free(vcookie_cache, v9fs_inode2cookie(inode)); 249 + call_rcu(&inode->i_rcu, v9fs_i_callback); 243 250 } 244 251 #endif 245 252
+8 -1
fs/adfs/super.c
··· 240 240 return &ei->vfs_inode; 241 241 } 242 242 243 + static void adfs_i_callback(struct rcu_head *head) 244 + { 245 + struct inode *inode = container_of(head, struct inode, i_rcu); 246 + INIT_LIST_HEAD(&inode->i_dentry); 247 + kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 248 + } 249 + 243 250 static void adfs_destroy_inode(struct inode *inode) 244 251 { 245 - kmem_cache_free(adfs_inode_cachep, ADFS_I(inode)); 252 + call_rcu(&inode->i_rcu, adfs_i_callback); 246 253 } 247 254 248 255 static void init_once(void *foo)
+8 -1
fs/affs/super.c
··· 95 95 return &i->vfs_inode; 96 96 } 97 97 98 + static void affs_i_callback(struct rcu_head *head) 99 + { 100 + struct inode *inode = container_of(head, struct inode, i_rcu); 101 + INIT_LIST_HEAD(&inode->i_dentry); 102 + kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 103 + } 104 + 98 105 static void affs_destroy_inode(struct inode *inode) 99 106 { 100 - kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 107 + call_rcu(&inode->i_rcu, affs_i_callback); 101 108 } 102 109 103 110 static void init_once(void *foo)
+9 -1
fs/afs/super.c
··· 498 498 return &vnode->vfs_inode; 499 499 } 500 500 501 + static void afs_i_callback(struct rcu_head *head) 502 + { 503 + struct inode *inode = container_of(head, struct inode, i_rcu); 504 + struct afs_vnode *vnode = AFS_FS_I(inode); 505 + INIT_LIST_HEAD(&inode->i_dentry); 506 + kmem_cache_free(afs_inode_cachep, vnode); 507 + } 508 + 501 509 /* 502 510 * destroy an AFS inode struct 503 511 */ ··· 519 511 520 512 ASSERTCMP(vnode->server, ==, NULL); 521 513 522 - kmem_cache_free(afs_inode_cachep, vnode); 514 + call_rcu(&inode->i_rcu, afs_i_callback); 523 515 atomic_dec(&afs_count_active_inodes); 524 516 } 525 517
+8 -2
fs/befs/linuxvfs.c
··· 284 284 return &bi->vfs_inode; 285 285 } 286 286 287 - static void 288 - befs_destroy_inode(struct inode *inode) 287 + static void befs_i_callback(struct rcu_head *head) 289 288 { 289 + struct inode *inode = container_of(head, struct inode, i_rcu); 290 + INIT_LIST_HEAD(&inode->i_dentry); 290 291 kmem_cache_free(befs_inode_cachep, BEFS_I(inode)); 292 + } 293 + 294 + static void befs_destroy_inode(struct inode *inode) 295 + { 296 + call_rcu(&inode->i_rcu, befs_i_callback); 291 297 } 292 298 293 299 static void init_once(void *foo)
+8 -1
fs/bfs/inode.c
··· 248 248 return &bi->vfs_inode; 249 249 } 250 250 251 + static void bfs_i_callback(struct rcu_head *head) 252 + { 253 + struct inode *inode = container_of(head, struct inode, i_rcu); 254 + INIT_LIST_HEAD(&inode->i_dentry); 255 + kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 256 + } 257 + 251 258 static void bfs_destroy_inode(struct inode *inode) 252 259 { 253 - kmem_cache_free(bfs_inode_cachep, BFS_I(inode)); 260 + call_rcu(&inode->i_rcu, bfs_i_callback); 254 261 } 255 262 256 263 static void init_once(void *foo)
+8 -1
fs/block_dev.c
··· 409 409 return &ei->vfs_inode; 410 410 } 411 411 412 - static void bdev_destroy_inode(struct inode *inode) 412 + static void bdev_i_callback(struct rcu_head *head) 413 413 { 414 + struct inode *inode = container_of(head, struct inode, i_rcu); 414 415 struct bdev_inode *bdi = BDEV_I(inode); 415 416 417 + INIT_LIST_HEAD(&inode->i_dentry); 416 418 kmem_cache_free(bdev_cachep, bdi); 419 + } 420 + 421 + static void bdev_destroy_inode(struct inode *inode) 422 + { 423 + call_rcu(&inode->i_rcu, bdev_i_callback); 417 424 } 418 425 419 426 static void init_once(void *foo)
+8 -1
fs/btrfs/inode.c
··· 6495 6495 return inode; 6496 6496 } 6497 6497 6498 + static void btrfs_i_callback(struct rcu_head *head) 6499 + { 6500 + struct inode *inode = container_of(head, struct inode, i_rcu); 6501 + INIT_LIST_HEAD(&inode->i_dentry); 6502 + kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); 6503 + } 6504 + 6498 6505 void btrfs_destroy_inode(struct inode *inode) 6499 6506 { 6500 6507 struct btrfs_ordered_extent *ordered; ··· 6571 6564 inode_tree_del(inode); 6572 6565 btrfs_drop_extent_cache(inode, 0, (u64)-1, 0); 6573 6566 free: 6574 - kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); 6567 + call_rcu(&inode->i_rcu, btrfs_i_callback); 6575 6568 } 6576 6569 6577 6570 int btrfs_drop_inode(struct inode *inode)
+10 -1
fs/ceph/inode.c
··· 368 368 return &ci->vfs_inode; 369 369 } 370 370 371 + static void ceph_i_callback(struct rcu_head *head) 372 + { 373 + struct inode *inode = container_of(head, struct inode, i_rcu); 374 + struct ceph_inode_info *ci = ceph_inode(inode); 375 + 376 + INIT_LIST_HEAD(&inode->i_dentry); 377 + kmem_cache_free(ceph_inode_cachep, ci); 378 + } 379 + 371 380 void ceph_destroy_inode(struct inode *inode) 372 381 { 373 382 struct ceph_inode_info *ci = ceph_inode(inode); ··· 416 407 if (ci->i_xattrs.prealloc_blob) 417 408 ceph_buffer_put(ci->i_xattrs.prealloc_blob); 418 409 419 - kmem_cache_free(ceph_inode_cachep, ci); 410 + call_rcu(&inode->i_rcu, ceph_i_callback); 420 411 } 421 412 422 413
+8 -1
fs/cifs/cifsfs.c
··· 334 334 return &cifs_inode->vfs_inode; 335 335 } 336 336 337 + static void cifs_i_callback(struct rcu_head *head) 338 + { 339 + struct inode *inode = container_of(head, struct inode, i_rcu); 340 + INIT_LIST_HEAD(&inode->i_dentry); 341 + kmem_cache_free(cifs_inode_cachep, CIFS_I(inode)); 342 + } 343 + 337 344 static void 338 345 cifs_destroy_inode(struct inode *inode) 339 346 { 340 - kmem_cache_free(cifs_inode_cachep, CIFS_I(inode)); 347 + call_rcu(&inode->i_rcu, cifs_i_callback); 341 348 } 342 349 343 350 static void
+8 -1
fs/coda/inode.c
··· 56 56 return &ei->vfs_inode; 57 57 } 58 58 59 + static void coda_i_callback(struct rcu_head *head) 60 + { 61 + struct inode *inode = container_of(head, struct inode, i_rcu); 62 + INIT_LIST_HEAD(&inode->i_dentry); 63 + kmem_cache_free(coda_inode_cachep, ITOC(inode)); 64 + } 65 + 59 66 static void coda_destroy_inode(struct inode *inode) 60 67 { 61 - kmem_cache_free(coda_inode_cachep, ITOC(inode)); 68 + call_rcu(&inode->i_rcu, coda_i_callback); 62 69 } 63 70 64 71 static void init_once(void *foo)
+11 -1
fs/ecryptfs/super.c
··· 62 62 return inode; 63 63 } 64 64 65 + static void ecryptfs_i_callback(struct rcu_head *head) 66 + { 67 + struct inode *inode = container_of(head, struct inode, i_rcu); 68 + struct ecryptfs_inode_info *inode_info; 69 + inode_info = ecryptfs_inode_to_private(inode); 70 + 71 + INIT_LIST_HEAD(&inode->i_dentry); 72 + kmem_cache_free(ecryptfs_inode_info_cache, inode_info); 73 + } 74 + 65 75 /** 66 76 * ecryptfs_destroy_inode 67 77 * @inode: The ecryptfs inode ··· 98 88 } 99 89 } 100 90 ecryptfs_destroy_crypt_stat(&inode_info->crypt_stat); 101 - kmem_cache_free(ecryptfs_inode_info_cache, inode_info); 91 + call_rcu(&inode->i_rcu, ecryptfs_i_callback); 102 92 } 103 93 104 94 /**
+8 -1
fs/efs/super.c
··· 65 65 return &ei->vfs_inode; 66 66 } 67 67 68 + static void efs_i_callback(struct rcu_head *head) 69 + { 70 + struct inode *inode = container_of(head, struct inode, i_rcu); 71 + INIT_LIST_HEAD(&inode->i_dentry); 72 + kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 73 + } 74 + 68 75 static void efs_destroy_inode(struct inode *inode) 69 76 { 70 - kmem_cache_free(efs_inode_cachep, INODE_INFO(inode)); 77 + call_rcu(&inode->i_rcu, efs_i_callback); 71 78 } 72 79 73 80 static void init_once(void *foo)
+8 -1
fs/exofs/super.c
··· 150 150 return &oi->vfs_inode; 151 151 } 152 152 153 + static void exofs_i_callback(struct rcu_head *head) 154 + { 155 + struct inode *inode = container_of(head, struct inode, i_rcu); 156 + INIT_LIST_HEAD(&inode->i_dentry); 157 + kmem_cache_free(exofs_inode_cachep, exofs_i(inode)); 158 + } 159 + 153 160 /* 154 161 * Remove an inode from the cache 155 162 */ 156 163 static void exofs_destroy_inode(struct inode *inode) 157 164 { 158 - kmem_cache_free(exofs_inode_cachep, exofs_i(inode)); 165 + call_rcu(&inode->i_rcu, exofs_i_callback); 159 166 } 160 167 161 168 /*
+8 -1
fs/ext2/super.c
··· 161 161 return &ei->vfs_inode; 162 162 } 163 163 164 + static void ext2_i_callback(struct rcu_head *head) 165 + { 166 + struct inode *inode = container_of(head, struct inode, i_rcu); 167 + INIT_LIST_HEAD(&inode->i_dentry); 168 + kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 169 + } 170 + 164 171 static void ext2_destroy_inode(struct inode *inode) 165 172 { 166 - kmem_cache_free(ext2_inode_cachep, EXT2_I(inode)); 173 + call_rcu(&inode->i_rcu, ext2_i_callback); 167 174 } 168 175 169 176 static void init_once(void *foo)
+8 -1
fs/ext3/super.c
··· 479 479 return &ei->vfs_inode; 480 480 } 481 481 482 + static void ext3_i_callback(struct rcu_head *head) 483 + { 484 + struct inode *inode = container_of(head, struct inode, i_rcu); 485 + INIT_LIST_HEAD(&inode->i_dentry); 486 + kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 487 + } 488 + 482 489 static void ext3_destroy_inode(struct inode *inode) 483 490 { 484 491 if (!list_empty(&(EXT3_I(inode)->i_orphan))) { ··· 496 489 false); 497 490 dump_stack(); 498 491 } 499 - kmem_cache_free(ext3_inode_cachep, EXT3_I(inode)); 492 + call_rcu(&inode->i_rcu, ext3_i_callback); 500 493 } 501 494 502 495 static void init_once(void *foo)
+8 -1
fs/ext4/super.c
··· 841 841 return drop; 842 842 } 843 843 844 + static void ext4_i_callback(struct rcu_head *head) 845 + { 846 + struct inode *inode = container_of(head, struct inode, i_rcu); 847 + INIT_LIST_HEAD(&inode->i_dentry); 848 + kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 849 + } 850 + 844 851 static void ext4_destroy_inode(struct inode *inode) 845 852 { 846 853 ext4_ioend_wait(inode); ··· 860 853 true); 861 854 dump_stack(); 862 855 } 863 - kmem_cache_free(ext4_inode_cachep, EXT4_I(inode)); 856 + call_rcu(&inode->i_rcu, ext4_i_callback); 864 857 } 865 858 866 859 static void init_once(void *foo)
+8 -1
fs/fat/inode.c
··· 514 514 return &ei->vfs_inode; 515 515 } 516 516 517 + static void fat_i_callback(struct rcu_head *head) 518 + { 519 + struct inode *inode = container_of(head, struct inode, i_rcu); 520 + INIT_LIST_HEAD(&inode->i_dentry); 521 + kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 522 + } 523 + 517 524 static void fat_destroy_inode(struct inode *inode) 518 525 { 519 - kmem_cache_free(fat_inode_cachep, MSDOS_I(inode)); 526 + call_rcu(&inode->i_rcu, fat_i_callback); 520 527 } 521 528 522 529 static void init_once(void *foo)
+8 -1
fs/freevxfs/vxfs_inode.c
··· 337 337 return ip; 338 338 } 339 339 340 + static void vxfs_i_callback(struct rcu_head *head) 341 + { 342 + struct inode *inode = container_of(head, struct inode, i_rcu); 343 + INIT_LIST_HEAD(&inode->i_dentry); 344 + kmem_cache_free(vxfs_inode_cachep, inode->i_private); 345 + } 346 + 340 347 /** 341 348 * vxfs_evict_inode - remove inode from main memory 342 349 * @ip: inode to discard. ··· 357 350 { 358 351 truncate_inode_pages(&ip->i_data, 0); 359 352 end_writeback(ip); 360 - kmem_cache_free(vxfs_inode_cachep, ip->i_private); 353 + call_rcu(&ip->i_rcu, vxfs_i_callback); 361 354 }
+8 -1
fs/fuse/inode.c
··· 99 99 return inode; 100 100 } 101 101 102 + static void fuse_i_callback(struct rcu_head *head) 103 + { 104 + struct inode *inode = container_of(head, struct inode, i_rcu); 105 + INIT_LIST_HEAD(&inode->i_dentry); 106 + kmem_cache_free(fuse_inode_cachep, inode); 107 + } 108 + 102 109 static void fuse_destroy_inode(struct inode *inode) 103 110 { 104 111 struct fuse_inode *fi = get_fuse_inode(inode); ··· 113 106 BUG_ON(!list_empty(&fi->queued_writes)); 114 107 if (fi->forget_req) 115 108 fuse_request_free(fi->forget_req); 116 - kmem_cache_free(fuse_inode_cachep, inode); 109 + call_rcu(&inode->i_rcu, fuse_i_callback); 117 110 } 118 111 119 112 void fuse_send_forget(struct fuse_conn *fc, struct fuse_req *req,
+8 -1
fs/gfs2/super.c
··· 1405 1405 return &ip->i_inode; 1406 1406 } 1407 1407 1408 + static void gfs2_i_callback(struct rcu_head *head) 1409 + { 1410 + struct inode *inode = container_of(head, struct inode, i_rcu); 1411 + INIT_LIST_HEAD(&inode->i_dentry); 1412 + kmem_cache_free(gfs2_inode_cachep, inode); 1413 + } 1414 + 1408 1415 static void gfs2_destroy_inode(struct inode *inode) 1409 1416 { 1410 - kmem_cache_free(gfs2_inode_cachep, inode); 1417 + call_rcu(&inode->i_rcu, gfs2_i_callback); 1411 1418 } 1412 1419 1413 1420 const struct super_operations gfs2_super_ops = {
+8 -1
fs/hfs/super.c
··· 167 167 return i ? &i->vfs_inode : NULL; 168 168 } 169 169 170 + static void hfs_i_callback(struct rcu_head *head) 171 + { 172 + struct inode *inode = container_of(head, struct inode, i_rcu); 173 + INIT_LIST_HEAD(&inode->i_dentry); 174 + kmem_cache_free(hfs_inode_cachep, HFS_I(inode)); 175 + } 176 + 170 177 static void hfs_destroy_inode(struct inode *inode) 171 178 { 172 - kmem_cache_free(hfs_inode_cachep, HFS_I(inode)); 179 + call_rcu(&inode->i_rcu, hfs_i_callback); 173 180 } 174 181 175 182 static const struct super_operations hfs_super_operations = {
+9 -1
fs/hfsplus/super.c
··· 488 488 return i ? &i->vfs_inode : NULL; 489 489 } 490 490 491 + static void hfsplus_i_callback(struct rcu_head *head) 492 + { 493 + struct inode *inode = container_of(head, struct inode, i_rcu); 494 + 495 + INIT_LIST_HEAD(&inode->i_dentry); 496 + kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode)); 497 + } 498 + 491 499 static void hfsplus_destroy_inode(struct inode *inode) 492 500 { 493 - kmem_cache_free(hfsplus_inode_cachep, HFSPLUS_I(inode)); 501 + call_rcu(&inode->i_rcu, hfsplus_i_callback); 494 502 } 495 503 496 504 #define HFSPLUS_INODE_SIZE sizeof(struct hfsplus_inode_info)
+8 -1
fs/hostfs/hostfs_kern.c
··· 247 247 } 248 248 } 249 249 250 + static void hostfs_i_callback(struct rcu_head *head) 251 + { 252 + struct inode *inode = container_of(head, struct inode, i_rcu); 253 + INIT_LIST_HEAD(&inode->i_dentry); 254 + kfree(HOSTFS_I(inode)); 255 + } 256 + 250 257 static void hostfs_destroy_inode(struct inode *inode) 251 258 { 252 - kfree(HOSTFS_I(inode)); 259 + call_rcu(&inode->i_rcu, hostfs_i_callback); 253 260 } 254 261 255 262 static int hostfs_show_options(struct seq_file *seq, struct vfsmount *vfs)
+8 -1
fs/hpfs/super.c
··· 177 177 return &ei->vfs_inode; 178 178 } 179 179 180 + static void hpfs_i_callback(struct rcu_head *head) 181 + { 182 + struct inode *inode = container_of(head, struct inode, i_rcu); 183 + INIT_LIST_HEAD(&inode->i_dentry); 184 + kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 185 + } 186 + 180 187 static void hpfs_destroy_inode(struct inode *inode) 181 188 { 182 - kmem_cache_free(hpfs_inode_cachep, hpfs_i(inode)); 189 + call_rcu(&inode->i_rcu, hpfs_i_callback); 183 190 } 184 191 185 192 static void init_once(void *foo)
+8 -1
fs/hppfs/hppfs.c
··· 632 632 mntput(ino->i_sb->s_fs_info); 633 633 } 634 634 635 + static void hppfs_i_callback(struct rcu_head *head) 636 + { 637 + struct inode *inode = container_of(head, struct inode, i_rcu); 638 + INIT_LIST_HEAD(&inode->i_dentry); 639 + kfree(HPPFS_I(inode)); 640 + } 641 + 635 642 static void hppfs_destroy_inode(struct inode *inode) 636 643 { 637 - kfree(HPPFS_I(inode)); 644 + call_rcu(&inode->i_rcu, hppfs_i_callback); 638 645 } 639 646 640 647 static const struct super_operations hppfs_sbops = {
+8 -1
fs/hugetlbfs/inode.c
··· 663 663 return &p->vfs_inode; 664 664 } 665 665 666 + static void hugetlbfs_i_callback(struct rcu_head *head) 667 + { 668 + struct inode *inode = container_of(head, struct inode, i_rcu); 669 + INIT_LIST_HEAD(&inode->i_dentry); 670 + kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); 671 + } 672 + 666 673 static void hugetlbfs_destroy_inode(struct inode *inode) 667 674 { 668 675 hugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode->i_sb)); 669 676 mpol_free_shared_policy(&HUGETLBFS_I(inode)->policy); 670 - kmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode)); 677 + call_rcu(&inode->i_rcu, hugetlbfs_i_callback); 671 678 } 672 679 673 680 static const struct address_space_operations hugetlbfs_aops = {
+9 -1
fs/inode.c
··· 272 272 } 273 273 EXPORT_SYMBOL(__destroy_inode); 274 274 275 + static void i_callback(struct rcu_head *head) 276 + { 277 + struct inode *inode = container_of(head, struct inode, i_rcu); 278 + INIT_LIST_HEAD(&inode->i_dentry); 279 + kmem_cache_free(inode_cachep, inode); 280 + } 281 + 275 282 static void destroy_inode(struct inode *inode) 276 283 { 277 284 BUG_ON(!list_empty(&inode->i_lru)); ··· 286 279 if (inode->i_sb->s_op->destroy_inode) 287 280 inode->i_sb->s_op->destroy_inode(inode); 288 281 else 289 - kmem_cache_free(inode_cachep, (inode)); 282 + call_rcu(&inode->i_rcu, i_callback); 290 283 } 291 284 292 285 /* ··· 439 432 BUG_ON(!(inode->i_state & I_FREEING)); 440 433 BUG_ON(inode->i_state & I_CLEAR); 441 434 inode_sync_wait(inode); 435 + /* don't need i_lock here, no concurrent mods to i_state */ 442 436 inode->i_state = I_FREEING | I_CLEAR; 443 437 } 444 438 EXPORT_SYMBOL(end_writeback);
+8 -1
fs/isofs/inode.c
··· 81 81 return &ei->vfs_inode; 82 82 } 83 83 84 + static void isofs_i_callback(struct rcu_head *head) 85 + { 86 + struct inode *inode = container_of(head, struct inode, i_rcu); 87 + INIT_LIST_HEAD(&inode->i_dentry); 88 + kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 89 + } 90 + 84 91 static void isofs_destroy_inode(struct inode *inode) 85 92 { 86 - kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode)); 93 + call_rcu(&inode->i_rcu, isofs_i_callback); 87 94 } 88 95 89 96 static void init_once(void *foo)
+8 -1
fs/jffs2/super.c
··· 40 40 return &f->vfs_inode; 41 41 } 42 42 43 + static void jffs2_i_callback(struct rcu_head *head) 44 + { 45 + struct inode *inode = container_of(head, struct inode, i_rcu); 46 + INIT_LIST_HEAD(&inode->i_dentry); 47 + kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 48 + } 49 + 43 50 static void jffs2_destroy_inode(struct inode *inode) 44 51 { 45 - kmem_cache_free(jffs2_inode_cachep, JFFS2_INODE_INFO(inode)); 52 + call_rcu(&inode->i_rcu, jffs2_i_callback); 46 53 } 47 54 48 55 static void jffs2_i_init_once(void *foo)
+9 -1
fs/jfs/super.c
··· 115 115 return &jfs_inode->vfs_inode; 116 116 } 117 117 118 + static void jfs_i_callback(struct rcu_head *head) 119 + { 120 + struct inode *inode = container_of(head, struct inode, i_rcu); 121 + struct jfs_inode_info *ji = JFS_IP(inode); 122 + INIT_LIST_HEAD(&inode->i_dentry); 123 + kmem_cache_free(jfs_inode_cachep, ji); 124 + } 125 + 118 126 static void jfs_destroy_inode(struct inode *inode) 119 127 { 120 128 struct jfs_inode_info *ji = JFS_IP(inode); ··· 136 128 ji->active_ag = -1; 137 129 } 138 130 spin_unlock_irq(&ji->ag_lock); 139 - kmem_cache_free(jfs_inode_cachep, ji); 131 + call_rcu(&inode->i_rcu, jfs_i_callback); 140 132 } 141 133 142 134 static int jfs_statfs(struct dentry *dentry, struct kstatfs *buf)
+8 -1
fs/logfs/inode.c
··· 141 141 return __logfs_iget(sb, ino); 142 142 } 143 143 144 + static void logfs_i_callback(struct rcu_head *head) 145 + { 146 + struct inode *inode = container_of(head, struct inode, i_rcu); 147 + INIT_LIST_HEAD(&inode->i_dentry); 148 + kmem_cache_free(logfs_inode_cache, logfs_inode(inode)); 149 + } 150 + 144 151 static void __logfs_destroy_inode(struct inode *inode) 145 152 { 146 153 struct logfs_inode *li = logfs_inode(inode); 147 154 148 155 BUG_ON(li->li_block); 149 156 list_del(&li->li_freeing_list); 150 - kmem_cache_free(logfs_inode_cache, li); 157 + call_rcu(&inode->i_rcu, logfs_i_callback); 151 158 } 152 159 153 160 static void logfs_destroy_inode(struct inode *inode)
+8 -1
fs/minix/inode.c
··· 68 68 return &ei->vfs_inode; 69 69 } 70 70 71 + static void minix_i_callback(struct rcu_head *head) 72 + { 73 + struct inode *inode = container_of(head, struct inode, i_rcu); 74 + INIT_LIST_HEAD(&inode->i_dentry); 75 + kmem_cache_free(minix_inode_cachep, minix_i(inode)); 76 + } 77 + 71 78 static void minix_destroy_inode(struct inode *inode) 72 79 { 73 - kmem_cache_free(minix_inode_cachep, minix_i(inode)); 80 + call_rcu(&inode->i_rcu, minix_i_callback); 74 81 } 75 82 76 83 static void init_once(void *foo)
+8 -1
fs/ncpfs/inode.c
··· 58 58 return &ei->vfs_inode; 59 59 } 60 60 61 + static void ncp_i_callback(struct rcu_head *head) 62 + { 63 + struct inode *inode = container_of(head, struct inode, i_rcu); 64 + INIT_LIST_HEAD(&inode->i_dentry); 65 + kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 66 + } 67 + 61 68 static void ncp_destroy_inode(struct inode *inode) 62 69 { 63 - kmem_cache_free(ncp_inode_cachep, NCP_FINFO(inode)); 70 + call_rcu(&inode->i_rcu, ncp_i_callback); 64 71 } 65 72 66 73 static void init_once(void *foo)
+8 -1
fs/nfs/inode.c
··· 1438 1438 return &nfsi->vfs_inode; 1439 1439 } 1440 1440 1441 + static void nfs_i_callback(struct rcu_head *head) 1442 + { 1443 + struct inode *inode = container_of(head, struct inode, i_rcu); 1444 + INIT_LIST_HEAD(&inode->i_dentry); 1445 + kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); 1446 + } 1447 + 1441 1448 void nfs_destroy_inode(struct inode *inode) 1442 1449 { 1443 - kmem_cache_free(nfs_inode_cachep, NFS_I(inode)); 1450 + call_rcu(&inode->i_rcu, nfs_i_callback); 1444 1451 } 1445 1452 1446 1453 static inline void nfs4_init_once(struct nfs_inode *nfsi)
+9 -1
fs/nilfs2/super.c
··· 162 162 return &ii->vfs_inode; 163 163 } 164 164 165 - void nilfs_destroy_inode(struct inode *inode) 165 + static void nilfs_i_callback(struct rcu_head *head) 166 166 { 167 + struct inode *inode = container_of(head, struct inode, i_rcu); 167 168 struct nilfs_mdt_info *mdi = NILFS_MDT(inode); 169 + 170 + INIT_LIST_HEAD(&inode->i_dentry); 168 171 169 172 if (mdi) { 170 173 kfree(mdi->mi_bgl); /* kfree(NULL) is safe */ 171 174 kfree(mdi); 172 175 } 173 176 kmem_cache_free(nilfs_inode_cachep, NILFS_I(inode)); 177 + } 178 + 179 + void nilfs_destroy_inode(struct inode *inode) 180 + { 181 + call_rcu(&inode->i_rcu, nilfs_i_callback); 174 182 } 175 183 176 184 static int nilfs_sync_super(struct nilfs_sb_info *sbi, int flag)
+8 -1
fs/ntfs/inode.c
··· 332 332 return NULL; 333 333 } 334 334 335 + static void ntfs_i_callback(struct rcu_head *head) 336 + { 337 + struct inode *inode = container_of(head, struct inode, i_rcu); 338 + INIT_LIST_HEAD(&inode->i_dentry); 339 + kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode)); 340 + } 341 + 335 342 void ntfs_destroy_big_inode(struct inode *inode) 336 343 { 337 344 ntfs_inode *ni = NTFS_I(inode); ··· 347 340 BUG_ON(ni->page); 348 341 if (!atomic_dec_and_test(&ni->count)) 349 342 BUG(); 350 - kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode)); 343 + call_rcu(&inode->i_rcu, ntfs_i_callback); 351 344 } 352 345 353 346 static inline ntfs_inode *ntfs_alloc_extent_inode(void)
+8 -1
fs/ocfs2/dlmfs/dlmfs.c
··· 351 351 return &ip->ip_vfs_inode; 352 352 } 353 353 354 + static void dlmfs_i_callback(struct rcu_head *head) 355 + { 356 + struct inode *inode = container_of(head, struct inode, i_rcu); 357 + INIT_LIST_HEAD(&inode->i_dentry); 358 + kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode)); 359 + } 360 + 354 361 static void dlmfs_destroy_inode(struct inode *inode) 355 362 { 356 - kmem_cache_free(dlmfs_inode_cache, DLMFS_I(inode)); 363 + call_rcu(&inode->i_rcu, dlmfs_i_callback); 357 364 } 358 365 359 366 static void dlmfs_evict_inode(struct inode *inode)
+8 -1
fs/ocfs2/super.c
··· 569 569 return &oi->vfs_inode; 570 570 } 571 571 572 + static void ocfs2_i_callback(struct rcu_head *head) 573 + { 574 + struct inode *inode = container_of(head, struct inode, i_rcu); 575 + INIT_LIST_HEAD(&inode->i_dentry); 576 + kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); 577 + } 578 + 572 579 static void ocfs2_destroy_inode(struct inode *inode) 573 580 { 574 - kmem_cache_free(ocfs2_inode_cachep, OCFS2_I(inode)); 581 + call_rcu(&inode->i_rcu, ocfs2_i_callback); 575 582 } 576 583 577 584 static unsigned long long ocfs2_max_file_offset(unsigned int bbits,
+8 -1
fs/openpromfs/inode.c
··· 343 343 return &oi->vfs_inode; 344 344 } 345 345 346 + static void openprom_i_callback(struct rcu_head *head) 347 + { 348 + struct inode *inode = container_of(head, struct inode, i_rcu); 349 + INIT_LIST_HEAD(&inode->i_dentry); 350 + kmem_cache_free(op_inode_cachep, OP_I(inode)); 351 + } 352 + 346 353 static void openprom_destroy_inode(struct inode *inode) 347 354 { 348 - kmem_cache_free(op_inode_cachep, OP_I(inode)); 355 + call_rcu(&inode->i_rcu, openprom_i_callback); 349 356 } 350 357 351 358 static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
+8 -1
fs/proc/inode.c
··· 65 65 return inode; 66 66 } 67 67 68 + static void proc_i_callback(struct rcu_head *head) 69 + { 70 + struct inode *inode = container_of(head, struct inode, i_rcu); 71 + INIT_LIST_HEAD(&inode->i_dentry); 72 + kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 73 + } 74 + 68 75 static void proc_destroy_inode(struct inode *inode) 69 76 { 70 - kmem_cache_free(proc_inode_cachep, PROC_I(inode)); 77 + call_rcu(&inode->i_rcu, proc_i_callback); 71 78 } 72 79 73 80 static void init_once(void *foo)
+8 -1
fs/qnx4/inode.c
··· 425 425 return &ei->vfs_inode; 426 426 } 427 427 428 + static void qnx4_i_callback(struct rcu_head *head) 429 + { 430 + struct inode *inode = container_of(head, struct inode, i_rcu); 431 + INIT_LIST_HEAD(&inode->i_dentry); 432 + kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 433 + } 434 + 428 435 static void qnx4_destroy_inode(struct inode *inode) 429 436 { 430 - kmem_cache_free(qnx4_inode_cachep, qnx4_i(inode)); 437 + call_rcu(&inode->i_rcu, qnx4_i_callback); 431 438 } 432 439 433 440 static void init_once(void *foo)
+8 -1
fs/reiserfs/super.c
··· 529 529 return &ei->vfs_inode; 530 530 } 531 531 532 + static void reiserfs_i_callback(struct rcu_head *head) 533 + { 534 + struct inode *inode = container_of(head, struct inode, i_rcu); 535 + INIT_LIST_HEAD(&inode->i_dentry); 536 + kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 537 + } 538 + 532 539 static void reiserfs_destroy_inode(struct inode *inode) 533 540 { 534 - kmem_cache_free(reiserfs_inode_cachep, REISERFS_I(inode)); 541 + call_rcu(&inode->i_rcu, reiserfs_i_callback); 535 542 } 536 543 537 544 static void init_once(void *foo)
+8 -1
fs/romfs/super.c
··· 400 400 /* 401 401 * return a spent inode to the slab cache 402 402 */ 403 + static void romfs_i_callback(struct rcu_head *head) 404 + { 405 + struct inode *inode = container_of(head, struct inode, i_rcu); 406 + INIT_LIST_HEAD(&inode->i_dentry); 407 + kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 408 + } 409 + 403 410 static void romfs_destroy_inode(struct inode *inode) 404 411 { 405 - kmem_cache_free(romfs_inode_cachep, ROMFS_I(inode)); 412 + call_rcu(&inode->i_rcu, romfs_i_callback); 406 413 } 407 414 408 415 /*
+8 -1
fs/squashfs/super.c
··· 440 440 } 441 441 442 442 443 + static void squashfs_i_callback(struct rcu_head *head) 444 + { 445 + struct inode *inode = container_of(head, struct inode, i_rcu); 446 + INIT_LIST_HEAD(&inode->i_dentry); 447 + kmem_cache_free(squashfs_inode_cachep, squashfs_i(inode)); 448 + } 449 + 443 450 static void squashfs_destroy_inode(struct inode *inode) 444 451 { 445 - kmem_cache_free(squashfs_inode_cachep, squashfs_i(inode)); 452 + call_rcu(&inode->i_rcu, squashfs_i_callback); 446 453 } 447 454 448 455
+8 -1
fs/sysv/inode.c
··· 333 333 return &si->vfs_inode; 334 334 } 335 335 336 + static void sysv_i_callback(struct rcu_head *head) 337 + { 338 + struct inode *inode = container_of(head, struct inode, i_rcu); 339 + INIT_LIST_HEAD(&inode->i_dentry); 340 + kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 341 + } 342 + 336 343 static void sysv_destroy_inode(struct inode *inode) 337 344 { 338 - kmem_cache_free(sysv_inode_cachep, SYSV_I(inode)); 345 + call_rcu(&inode->i_rcu, sysv_i_callback); 339 346 } 340 347 341 348 static void init_once(void *p)
+9 -1
fs/ubifs/super.c
··· 272 272 return &ui->vfs_inode; 273 273 }; 274 274 275 + static void ubifs_i_callback(struct rcu_head *head) 276 + { 277 + struct inode *inode = container_of(head, struct inode, i_rcu); 278 + struct ubifs_inode *ui = ubifs_inode(inode); 279 + INIT_LIST_HEAD(&inode->i_dentry); 280 + kmem_cache_free(ubifs_inode_slab, ui); 281 + } 282 + 275 283 static void ubifs_destroy_inode(struct inode *inode) 276 284 { 277 285 struct ubifs_inode *ui = ubifs_inode(inode); 278 286 279 287 kfree(ui->data); 280 - kmem_cache_free(ubifs_inode_slab, inode); 288 + call_rcu(&inode->i_rcu, ubifs_i_callback); 281 289 } 282 290 283 291 /*
+8 -1
fs/udf/super.c
··· 139 139 return &ei->vfs_inode; 140 140 } 141 141 142 + static void udf_i_callback(struct rcu_head *head) 143 + { 144 + struct inode *inode = container_of(head, struct inode, i_rcu); 145 + INIT_LIST_HEAD(&inode->i_dentry); 146 + kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 147 + } 148 + 142 149 static void udf_destroy_inode(struct inode *inode) 143 150 { 144 - kmem_cache_free(udf_inode_cachep, UDF_I(inode)); 151 + call_rcu(&inode->i_rcu, udf_i_callback); 145 152 } 146 153 147 154 static void init_once(void *foo)
+8 -1
fs/ufs/super.c
··· 1412 1412 return &ei->vfs_inode; 1413 1413 } 1414 1414 1415 + static void ufs_i_callback(struct rcu_head *head) 1416 + { 1417 + struct inode *inode = container_of(head, struct inode, i_rcu); 1418 + INIT_LIST_HEAD(&inode->i_dentry); 1419 + kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1420 + } 1421 + 1415 1422 static void ufs_destroy_inode(struct inode *inode) 1416 1423 { 1417 - kmem_cache_free(ufs_inode_cachep, UFS_I(inode)); 1424 + call_rcu(&inode->i_rcu, ufs_i_callback); 1418 1425 } 1419 1426 1420 1427 static void init_once(void *foo)
+12 -1
fs/xfs/xfs_iget.c
··· 91 91 return ip; 92 92 } 93 93 94 + STATIC void 95 + xfs_inode_free_callback( 96 + struct rcu_head *head) 97 + { 98 + struct inode *inode = container_of(head, struct inode, i_rcu); 99 + struct xfs_inode *ip = XFS_I(inode); 100 + 101 + INIT_LIST_HEAD(&inode->i_dentry); 102 + kmem_zone_free(xfs_inode_zone, ip); 103 + } 104 + 94 105 void 95 106 xfs_inode_free( 96 107 struct xfs_inode *ip) ··· 145 134 ASSERT(!spin_is_locked(&ip->i_flags_lock)); 146 135 ASSERT(completion_done(&ip->i_flush)); 147 136 148 - kmem_zone_free(xfs_inode_zone, ip); 137 + call_rcu(&ip->i_vnode.i_rcu, xfs_inode_free_callback); 149 138 } 150 139 151 140 /*
+4 -1
include/linux/fs.h
··· 737 737 struct list_head i_wb_list; /* backing dev IO list */ 738 738 struct list_head i_lru; /* inode LRU list */ 739 739 struct list_head i_sb_list; 740 - struct list_head i_dentry; 740 + union { 741 + struct list_head i_dentry; 742 + struct rcu_head i_rcu; 743 + }; 741 744 unsigned long i_ino; 742 745 atomic_t i_count; 743 746 unsigned int i_nlink;
-1
include/linux/net.h
··· 120 120 struct socket_wq { 121 121 wait_queue_head_t wait; 122 122 struct fasync_struct *fasync_list; 123 - struct rcu_head rcu; 124 123 } ____cacheline_aligned_in_smp; 125 124 126 125 /**
+8 -1
ipc/mqueue.c
··· 237 237 return &ei->vfs_inode; 238 238 } 239 239 240 + static void mqueue_i_callback(struct rcu_head *head) 241 + { 242 + struct inode *inode = container_of(head, struct inode, i_rcu); 243 + INIT_LIST_HEAD(&inode->i_dentry); 244 + kmem_cache_free(mqueue_inode_cachep, MQUEUE_I(inode)); 245 + } 246 + 240 247 static void mqueue_destroy_inode(struct inode *inode) 241 248 { 242 - kmem_cache_free(mqueue_inode_cachep, MQUEUE_I(inode)); 249 + call_rcu(&inode->i_rcu, mqueue_i_callback); 243 250 } 244 251 245 252 static void mqueue_evict_inode(struct inode *inode)
+8 -1
mm/shmem.c
··· 2415 2415 return &p->vfs_inode; 2416 2416 } 2417 2417 2418 + static void shmem_i_callback(struct rcu_head *head) 2419 + { 2420 + struct inode *inode = container_of(head, struct inode, i_rcu); 2421 + INIT_LIST_HEAD(&inode->i_dentry); 2422 + kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); 2423 + } 2424 + 2418 2425 static void shmem_destroy_inode(struct inode *inode) 2419 2426 { 2420 2427 if ((inode->i_mode & S_IFMT) == S_IFREG) { 2421 2428 /* only struct inode is valid if it's an inline symlink */ 2422 2429 mpol_free_shared_policy(&SHMEM_I(inode)->policy); 2423 2430 } 2424 - kmem_cache_free(shmem_inode_cachep, SHMEM_I(inode)); 2431 + call_rcu(&inode->i_rcu, shmem_i_callback); 2425 2432 } 2426 2433 2427 2434 static void init_once(void *foo)
+8 -8
net/socket.c
··· 262 262 } 263 263 264 264 265 - static void wq_free_rcu(struct rcu_head *head) 265 + static void sock_free_rcu(struct rcu_head *head) 266 266 { 267 - struct socket_wq *wq = container_of(head, struct socket_wq, rcu); 267 + struct inode *inode = container_of(head, struct inode, i_rcu); 268 + struct socket_alloc *ei = container_of(inode, struct socket_alloc, 269 + vfs_inode); 268 270 269 - kfree(wq); 271 + kfree(ei->socket.wq); 272 + INIT_LIST_HEAD(&inode->i_dentry); 273 + kmem_cache_free(sock_inode_cachep, ei); 270 274 } 271 275 272 276 static void sock_destroy_inode(struct inode *inode) 273 277 { 274 - struct socket_alloc *ei; 275 - 276 - ei = container_of(inode, struct socket_alloc, vfs_inode); 277 - call_rcu(&ei->socket.wq->rcu, wq_free_rcu); 278 - kmem_cache_free(sock_inode_cachep, ei); 278 + call_rcu(&inode->i_rcu, sock_free_rcu); 279 279 } 280 280 281 281 static void init_once(void *foo)
+9 -1
net/sunrpc/rpc_pipe.c
··· 162 162 } 163 163 164 164 static void 165 + rpc_i_callback(struct rcu_head *head) 166 + { 167 + struct inode *inode = container_of(head, struct inode, i_rcu); 168 + INIT_LIST_HEAD(&inode->i_dentry); 169 + kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); 170 + } 171 + 172 + static void 165 173 rpc_destroy_inode(struct inode *inode) 166 174 { 167 - kmem_cache_free(rpc_inode_cachep, RPC_I(inode)); 175 + call_rcu(&inode->i_rcu, rpc_i_callback); 168 176 } 169 177 170 178 static int