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

ntfs: ->d_compare() must not block

... so don't use __getname() there. Switch it (and ntfs_d_hash(), while
we are at it) to kmalloc(PATH_MAX, GFP_NOWAIT). Yes, ntfs_d_hash()
almost certainly can do with smaller allocations, but let ntfs folks
deal with that - keep the allocation size as-is for now.

Stop abusing names_cachep in ntfs, period - various uses of that thing
in there have nothing to do with pathnames; just use k[mz]alloc() and
be done with that. For now let's keep sizes as-in, but AFAICS none of
the users actually want PATH_MAX.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro ca2a04e8 41670a59

+20 -24
+2 -3
fs/ntfs3/dir.c
··· 423 423 if (!dir_emit_dots(file, ctx)) 424 424 return 0; 425 425 426 - /* Allocate PATH_MAX bytes. */ 427 - name = __getname(); 426 + name = kmalloc(PATH_MAX, GFP_KERNEL); 428 427 if (!name) 429 428 return -ENOMEM; 430 429 ··· 501 502 502 503 out: 503 504 504 - __putname(name); 505 + kfree(name); 505 506 put_indx_node(node); 506 507 507 508 if (err == 1) {
+2 -2
fs/ntfs3/fsntfs.c
··· 2627 2627 u32 uni_bytes; 2628 2628 struct ntfs_inode *ni = sbi->volume.ni; 2629 2629 /* Allocate PATH_MAX bytes. */ 2630 - struct cpu_str *uni = __getname(); 2630 + struct cpu_str *uni = kmalloc(PATH_MAX, GFP_KERNEL); 2631 2631 2632 2632 if (!uni) 2633 2633 return -ENOMEM; ··· 2671 2671 err = _ni_write_inode(&ni->vfs_inode, 0); 2672 2672 2673 2673 out: 2674 - __putname(uni); 2674 + kfree(uni); 2675 2675 return err; 2676 2676 }
+6 -7
fs/ntfs3/inode.c
··· 1281 1281 fa |= FILE_ATTRIBUTE_READONLY; 1282 1282 1283 1283 /* Allocate PATH_MAX bytes. */ 1284 - new_de = kmem_cache_zalloc(names_cachep, GFP_KERNEL); 1284 + new_de = kzalloc(PATH_MAX, GFP_KERNEL); 1285 1285 if (!new_de) { 1286 1286 err = -ENOMEM; 1287 1287 goto out1; ··· 1702 1702 ntfs_mark_rec_free(sbi, ino, false); 1703 1703 1704 1704 out2: 1705 - __putname(new_de); 1705 + kfree(new_de); 1706 1706 kfree(rp); 1707 1707 1708 1708 out1: ··· 1723 1723 struct NTFS_DE *de; 1724 1724 1725 1725 /* Allocate PATH_MAX bytes. */ 1726 - de = kmem_cache_zalloc(names_cachep, GFP_KERNEL); 1726 + de = kzalloc(PATH_MAX, GFP_KERNEL); 1727 1727 if (!de) 1728 1728 return -ENOMEM; 1729 1729 ··· 1737 1737 1738 1738 err = ni_add_name(ntfs_i(d_inode(dentry->d_parent)), ni, de); 1739 1739 out: 1740 - __putname(de); 1740 + kfree(de); 1741 1741 return err; 1742 1742 } 1743 1743 ··· 1760 1760 if (ntfs_is_meta_file(sbi, ni->mi.rno)) 1761 1761 return -EINVAL; 1762 1762 1763 - /* Allocate PATH_MAX bytes. */ 1764 - de = kmem_cache_zalloc(names_cachep, GFP_KERNEL); 1763 + de = kzalloc(PATH_MAX, GFP_KERNEL); 1765 1764 if (!de) 1766 1765 return -ENOMEM; 1767 1766 ··· 1796 1797 1797 1798 out: 1798 1799 ni_unlock(ni); 1799 - __putname(de); 1800 + kfree(de); 1800 1801 return err; 1801 1802 } 1802 1803
+8 -9
fs/ntfs3/namei.c
··· 68 68 u32 flags) 69 69 { 70 70 struct ntfs_inode *ni = ntfs_i(dir); 71 - struct cpu_str *uni = __getname(); 71 + struct cpu_str *uni = kmalloc(PATH_MAX, GFP_KERNEL); 72 72 struct inode *inode; 73 73 int err; 74 74 ··· 85 85 inode = dir_search_u(dir, uni, NULL); 86 86 ni_unlock(ni); 87 87 } 88 - __putname(uni); 88 + kfree(uni); 89 89 } 90 90 91 91 /* ··· 303 303 return err; 304 304 } 305 305 306 - /* Allocate PATH_MAX bytes. */ 307 - de = __getname(); 306 + de = kmalloc(PATH_MAX, GFP_KERNEL); 308 307 if (!de) 309 308 return -ENOMEM; 310 309 ··· 348 349 ni_unlock(ni); 349 350 ni_unlock(dir_ni); 350 351 out: 351 - __putname(de); 352 + kfree(de); 352 353 return err; 353 354 } 354 355 ··· 406 407 /* 407 408 * Try slow way with current upcase table 408 409 */ 409 - uni = kmem_cache_alloc(names_cachep, GFP_NOWAIT); 410 + uni = kmalloc(PATH_MAX, GFP_NOWAIT); 410 411 if (!uni) 411 412 return -ENOMEM; 412 413 ··· 428 429 err = 0; 429 430 430 431 out: 431 - kmem_cache_free(names_cachep, uni); 432 + kfree(uni); 432 433 return err; 433 434 } 434 435 ··· 467 468 * Try slow way with current upcase table 468 469 */ 469 470 sbi = dentry->d_sb->s_fs_info; 470 - uni1 = __getname(); 471 + uni1 = kmalloc(PATH_MAX, GFP_NOWAIT); 471 472 if (!uni1) 472 473 return -ENOMEM; 473 474 ··· 497 498 ret = !ntfs_cmp_names_cpu(uni1, uni2, sbi->upcase, false) ? 0 : 1; 498 499 499 500 out: 500 - __putname(uni1); 501 + kfree(uni1); 501 502 return ret; 502 503 } 503 504
+2 -3
fs/ntfs3/xattr.c
··· 556 556 if (unlikely(is_bad_ni(ni))) 557 557 return ERR_PTR(-EINVAL); 558 558 559 - /* Allocate PATH_MAX bytes. */ 560 - buf = __getname(); 559 + buf = kmalloc(PATH_MAX, GFP_KERNEL); 561 560 if (!buf) 562 561 return ERR_PTR(-ENOMEM); 563 562 ··· 587 588 if (!IS_ERR(acl)) 588 589 set_cached_acl(inode, type, acl); 589 590 590 - __putname(buf); 591 + kfree(buf); 591 592 592 593 return acl; 593 594 }