dir.c (2c2c336506e9bd4056fca25301b8a06fb7aefd32) | dir.c (0b3cc71b5ab31ef90eb9b8b2d8ca580fbf88c590) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/nfs/dir.c 4 * 5 * Copyright (C) 1992 Rick Sladkey 6 * 7 * nfs directory handling functions 8 * --- 680 unchanged lines hidden (view full) --- 689 S_ISDIR(dir->i_mode)) { 690 rcu_read_lock(); 691 list_for_each_entry_rcu (ctx, &nfsi->open_files, list) 692 atomic_inc(&ctx->cache_misses); 693 rcu_read_unlock(); 694 } 695} 696 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * linux/fs/nfs/dir.c 4 * 5 * Copyright (C) 1992 Rick Sladkey 6 * 7 * nfs directory handling functions 8 * --- 680 unchanged lines hidden (view full) --- 689 S_ISDIR(dir->i_mode)) { 690 rcu_read_lock(); 691 list_for_each_entry_rcu (ctx, &nfsi->open_files, list) 692 atomic_inc(&ctx->cache_misses); 693 rcu_read_unlock(); 694 } 695} 696 |
697static void nfs_lookup_advise_force_readdirplus(struct inode *dir) | 697static void nfs_lookup_advise_force_readdirplus(struct inode *dir, 698 unsigned int flags) |
698{ 699 if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) 700 return; | 699{ 700 if (nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE)) 701 return; |
702 if (flags & (LOOKUP_EXCL | LOOKUP_PARENT | LOOKUP_REVAL)) 703 return; |
|
701 nfs_readdir_record_entry_cache_miss(dir); 702} 703 704static 705void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry, 706 unsigned long dir_verifier) 707{ 708 struct qstr filename = QSTR_INIT(entry->name, entry->len); --- 882 unchanged lines hidden (view full) --- 1591static int 1592nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry, 1593 struct inode *inode) 1594{ 1595 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1596 return nfs_lookup_revalidate_done(dir, dentry, inode, 1); 1597} 1598 | 704 nfs_readdir_record_entry_cache_miss(dir); 705} 706 707static 708void nfs_prime_dcache(struct dentry *parent, struct nfs_entry *entry, 709 unsigned long dir_verifier) 710{ 711 struct qstr filename = QSTR_INIT(entry->name, entry->len); --- 882 unchanged lines hidden (view full) --- 1594static int 1595nfs_lookup_revalidate_delegated(struct inode *dir, struct dentry *dentry, 1596 struct inode *inode) 1597{ 1598 nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); 1599 return nfs_lookup_revalidate_done(dir, dentry, inode, 1); 1600} 1601 |
1599static int 1600nfs_lookup_revalidate_dentry(struct inode *dir, struct dentry *dentry, 1601 struct inode *inode) | 1602static int nfs_lookup_revalidate_dentry(struct inode *dir, 1603 struct dentry *dentry, 1604 struct inode *inode, unsigned int flags) |
1602{ 1603 struct nfs_fh *fhandle; 1604 struct nfs_fattr *fattr; 1605 unsigned long dir_verifier; 1606 int ret; 1607 | 1605{ 1606 struct nfs_fh *fhandle; 1607 struct nfs_fattr *fattr; 1608 unsigned long dir_verifier; 1609 int ret; 1610 |
1611 trace_nfs_lookup_revalidate_enter(dir, dentry, flags); 1612 |
|
1608 ret = -ENOMEM; 1609 fhandle = nfs_alloc_fhandle(); 1610 fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); 1611 if (fhandle == NULL || fattr == NULL) 1612 goto out; 1613 1614 dir_verifier = nfs_save_change_attribute(dir); 1615 ret = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr); --- 4 unchanged lines hidden (view full) --- 1620 ret = 0; 1621 break; 1622 case -ETIMEDOUT: 1623 if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL) 1624 ret = 1; 1625 } 1626 goto out; 1627 } | 1613 ret = -ENOMEM; 1614 fhandle = nfs_alloc_fhandle(); 1615 fattr = nfs_alloc_fattr_with_label(NFS_SERVER(inode)); 1616 if (fhandle == NULL || fattr == NULL) 1617 goto out; 1618 1619 dir_verifier = nfs_save_change_attribute(dir); 1620 ret = NFS_PROTO(dir)->lookup(dir, dentry, fhandle, fattr); --- 4 unchanged lines hidden (view full) --- 1625 ret = 0; 1626 break; 1627 case -ETIMEDOUT: 1628 if (NFS_SERVER(inode)->flags & NFS_MOUNT_SOFTREVAL) 1629 ret = 1; 1630 } 1631 goto out; 1632 } |
1633 1634 /* Request help from readdirplus */ 1635 nfs_lookup_advise_force_readdirplus(dir, flags); 1636 |
|
1628 ret = 0; 1629 if (nfs_compare_fh(NFS_FH(inode), fhandle)) 1630 goto out; 1631 if (nfs_refresh_inode(inode, fattr) < 0) 1632 goto out; 1633 1634 nfs_setsecurity(inode, fattr); 1635 nfs_set_verifier(dentry, dir_verifier); 1636 | 1637 ret = 0; 1638 if (nfs_compare_fh(NFS_FH(inode), fhandle)) 1639 goto out; 1640 if (nfs_refresh_inode(inode, fattr) < 0) 1641 goto out; 1642 1643 nfs_setsecurity(inode, fattr); 1644 nfs_set_verifier(dentry, dir_verifier); 1645 |
1637 /* set a readdirplus hint that we had a cache miss */ 1638 nfs_lookup_advise_force_readdirplus(dir); | |
1639 ret = 1; 1640out: 1641 nfs_free_fattr(fattr); 1642 nfs_free_fhandle(fhandle); 1643 1644 /* 1645 * If the lookup failed despite the dentry change attribute being 1646 * a match, then we should revalidate the directory cache. --- 49 unchanged lines hidden (view full) --- 1696 } 1697 1698 if (flags & LOOKUP_RCU) 1699 return -ECHILD; 1700 1701 if (NFS_STALE(inode)) 1702 goto out_bad; 1703 | 1646 ret = 1; 1647out: 1648 nfs_free_fattr(fattr); 1649 nfs_free_fhandle(fhandle); 1650 1651 /* 1652 * If the lookup failed despite the dentry change attribute being 1653 * a match, then we should revalidate the directory cache. --- 49 unchanged lines hidden (view full) --- 1703 } 1704 1705 if (flags & LOOKUP_RCU) 1706 return -ECHILD; 1707 1708 if (NFS_STALE(inode)) 1709 goto out_bad; 1710 |
1704 trace_nfs_lookup_revalidate_enter(dir, dentry, flags); 1705 return nfs_lookup_revalidate_dentry(dir, dentry, inode); | 1711 return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags); |
1706out_valid: 1707 return nfs_lookup_revalidate_done(dir, dentry, inode, 1); 1708out_bad: 1709 if (flags & LOOKUP_RCU) 1710 return -ECHILD; 1711 return nfs_lookup_revalidate_done(dir, dentry, inode, 0); 1712} 1713 --- 177 unchanged lines hidden (view full) --- 1891 goto out; 1892 } 1893 inode = nfs_fhget(dentry->d_sb, fhandle, fattr); 1894 res = ERR_CAST(inode); 1895 if (IS_ERR(res)) 1896 goto out; 1897 1898 /* Notify readdir to use READDIRPLUS */ | 1712out_valid: 1713 return nfs_lookup_revalidate_done(dir, dentry, inode, 1); 1714out_bad: 1715 if (flags & LOOKUP_RCU) 1716 return -ECHILD; 1717 return nfs_lookup_revalidate_done(dir, dentry, inode, 0); 1718} 1719 --- 177 unchanged lines hidden (view full) --- 1897 goto out; 1898 } 1899 inode = nfs_fhget(dentry->d_sb, fhandle, fattr); 1900 res = ERR_CAST(inode); 1901 if (IS_ERR(res)) 1902 goto out; 1903 1904 /* Notify readdir to use READDIRPLUS */ |
1899 nfs_lookup_advise_force_readdirplus(dir); | 1905 nfs_lookup_advise_force_readdirplus(dir, flags); |
1900 1901no_entry: 1902 res = d_splice_alias(inode, dentry); 1903 if (res != NULL) { 1904 if (IS_ERR(res)) 1905 goto out; 1906 dentry = res; 1907 } --- 246 unchanged lines hidden (view full) --- 2154 if (!nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) 2155 goto reval_dentry; 2156 2157 /* Let f_op->open() actually open (and revalidate) the file */ 2158 return 1; 2159reval_dentry: 2160 if (flags & LOOKUP_RCU) 2161 return -ECHILD; | 1906 1907no_entry: 1908 res = d_splice_alias(inode, dentry); 1909 if (res != NULL) { 1910 if (IS_ERR(res)) 1911 goto out; 1912 dentry = res; 1913 } --- 246 unchanged lines hidden (view full) --- 2160 if (!nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) 2161 goto reval_dentry; 2162 2163 /* Let f_op->open() actually open (and revalidate) the file */ 2164 return 1; 2165reval_dentry: 2166 if (flags & LOOKUP_RCU) 2167 return -ECHILD; |
2162 return nfs_lookup_revalidate_dentry(dir, dentry, inode); | 2168 return nfs_lookup_revalidate_dentry(dir, dentry, inode, flags); |
2163 2164full_reval: 2165 return nfs_do_lookup_revalidate(dir, dentry, flags); 2166} 2167 2168static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags) 2169{ 2170 return __nfs_lookup_revalidate(dentry, flags, --- 1025 unchanged lines hidden --- | 2169 2170full_reval: 2171 return nfs_do_lookup_revalidate(dir, dentry, flags); 2172} 2173 2174static int nfs4_lookup_revalidate(struct dentry *dentry, unsigned int flags) 2175{ 2176 return __nfs_lookup_revalidate(dentry, flags, --- 1025 unchanged lines hidden --- |