dir.c (ef75c7974b383769ae5741cf930b8aa4dcaef395) dir.c (c79ba787c11e767ffaf8d723923afda99ba6c63c)
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

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

632 return 0;
633}
634
635/*
636 * A check for whether or not the parent directory has changed.
637 * In the case it has, we assume that the dentries are untrustworthy
638 * and may need to be looked up again.
639 */
1/*
2 * linux/fs/nfs/dir.c
3 *
4 * Copyright (C) 1992 Rick Sladkey
5 *
6 * nfs directory handling functions
7 *
8 * 10 Apr 1996 Added silly rename for unlink --okir

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

632 return 0;
633}
634
635/*
636 * A check for whether or not the parent directory has changed.
637 * In the case it has, we assume that the dentries are untrustworthy
638 * and may need to be looked up again.
639 */
640static inline int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
640static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
641{
642 if (IS_ROOT(dentry))
643 return 1;
644 if ((NFS_I(dir)->cache_validity & NFS_INO_INVALID_ATTR) != 0
645 || nfs_attribute_timeout(dir))
646 return 0;
647 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata);
648}
649
650static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
651{
652 dentry->d_fsdata = (void *)verf;
653}
654
641{
642 if (IS_ROOT(dentry))
643 return 1;
644 if ((NFS_I(dir)->cache_validity & NFS_INO_INVALID_ATTR) != 0
645 || nfs_attribute_timeout(dir))
646 return 0;
647 return nfs_verify_change_attribute(dir, (unsigned long)dentry->d_fsdata);
648}
649
650static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf)
651{
652 dentry->d_fsdata = (void *)verf;
653}
654
655static void nfs_refresh_verifier(struct dentry * dentry, unsigned long verf)
656{
657 if (time_after(verf, (unsigned long)dentry->d_fsdata))
658 nfs_set_verifier(dentry, verf);
659}
660
655/*
656 * Whenever an NFS operation succeeds, we know that the dentry
657 * is valid, so we update the revalidation timestamp.
658 */
659static inline void nfs_renew_times(struct dentry * dentry)
660{
661 dentry->d_time = jiffies;
662}

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

780 if (error)
781 goto out_bad;
782 if (nfs_compare_fh(NFS_FH(inode), &fhandle))
783 goto out_bad;
784 if ((error = nfs_refresh_inode(inode, &fattr)) != 0)
785 goto out_bad;
786
787 nfs_renew_times(dentry);
661/*
662 * Whenever an NFS operation succeeds, we know that the dentry
663 * is valid, so we update the revalidation timestamp.
664 */
665static inline void nfs_renew_times(struct dentry * dentry)
666{
667 dentry->d_time = jiffies;
668}

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

786 if (error)
787 goto out_bad;
788 if (nfs_compare_fh(NFS_FH(inode), &fhandle))
789 goto out_bad;
790 if ((error = nfs_refresh_inode(inode, &fattr)) != 0)
791 goto out_bad;
792
793 nfs_renew_times(dentry);
788 nfs_set_verifier(dentry, verifier);
794 nfs_refresh_verifier(dentry, verifier);
789 out_valid:
790 unlock_kernel();
791 dput(parent);
792 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n",
793 __FUNCTION__, dentry->d_parent->d_name.name,
794 dentry->d_name.name);
795 return 1;
796out_zap_parent:

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

1080 * Note: we're not holding inode->i_mutex and so may be racing with
1081 * operations that change the directory. We therefore save the
1082 * change attribute *before* we do the RPC call.
1083 */
1084 lock_kernel();
1085 verifier = nfs_save_change_attribute(dir);
1086 ret = nfs4_open_revalidate(dir, dentry, openflags, nd);
1087 if (!ret)
795 out_valid:
796 unlock_kernel();
797 dput(parent);
798 dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is valid\n",
799 __FUNCTION__, dentry->d_parent->d_name.name,
800 dentry->d_name.name);
801 return 1;
802out_zap_parent:

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

1086 * Note: we're not holding inode->i_mutex and so may be racing with
1087 * operations that change the directory. We therefore save the
1088 * change attribute *before* we do the RPC call.
1089 */
1090 lock_kernel();
1091 verifier = nfs_save_change_attribute(dir);
1092 ret = nfs4_open_revalidate(dir, dentry, openflags, nd);
1093 if (!ret)
1088 nfs_set_verifier(dentry, verifier);
1094 nfs_refresh_verifier(dentry, verifier);
1089 unlock_kernel();
1090out:
1091 dput(parent);
1092 if (!ret)
1093 d_drop(dentry);
1094 return ret;
1095no_open:
1096 dput(parent);

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

1154 alias = d_materialise_unique(dentry, inode);
1155 if (alias != NULL) {
1156 dput(dentry);
1157 if (IS_ERR(alias))
1158 return NULL;
1159 dentry = alias;
1160 }
1161
1095 unlock_kernel();
1096out:
1097 dput(parent);
1098 if (!ret)
1099 d_drop(dentry);
1100 return ret;
1101no_open:
1102 dput(parent);

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

1160 alias = d_materialise_unique(dentry, inode);
1161 if (alias != NULL) {
1162 dput(dentry);
1163 if (IS_ERR(alias))
1164 return NULL;
1165 dentry = alias;
1166 }
1167
1162out_renew:
1163 nfs_renew_times(dentry);
1164 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1165 return dentry;
1168 nfs_renew_times(dentry);
1169 nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
1170 return dentry;
1171out_renew:
1172 nfs_renew_times(dentry);
1173 nfs_refresh_verifier(dentry, nfs_save_change_attribute(dir));
1174 return dentry;
1166}
1167
1168/*
1169 * Code common to create, mkdir, and mknod.
1170 */
1171int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1172 struct nfs_fattr *fattr)
1173{

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

1695 nfs_end_data_update(new_dir);
1696 nfs_end_data_update(old_dir);
1697out:
1698 if (rehash)
1699 d_rehash(rehash);
1700 if (!error) {
1701 d_move(old_dentry, new_dentry);
1702 nfs_renew_times(new_dentry);
1175}
1176
1177/*
1178 * Code common to create, mkdir, and mknod.
1179 */
1180int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
1181 struct nfs_fattr *fattr)
1182{

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

1704 nfs_end_data_update(new_dir);
1705 nfs_end_data_update(old_dir);
1706out:
1707 if (rehash)
1708 d_rehash(rehash);
1709 if (!error) {
1710 d_move(old_dentry, new_dentry);
1711 nfs_renew_times(new_dentry);
1703 nfs_set_verifier(new_dentry, nfs_save_change_attribute(new_dir));
1712 nfs_refresh_verifier(new_dentry, nfs_save_change_attribute(new_dir));
1704 }
1705
1706 /* new dentry created? */
1707 if (dentry)
1708 dput(dentry);
1709 unlock_kernel();
1710 return error;
1711}

--- 294 unchanged lines hidden ---
1713 }
1714
1715 /* new dentry created? */
1716 if (dentry)
1717 dput(dentry);
1718 unlock_kernel();
1719 return error;
1720}

--- 294 unchanged lines hidden ---