patch-2.2.19 linux/fs/nfsd/nfsfh.c
Next file: linux/fs/nfsd/nfsproc.c
Previous file: linux/fs/nfsd/nfsctl.c
Back to the patch index
Back to the overall index
- Lines: 131
- Date:
Sun Mar 25 11:37:38 2001
- Orig file:
v2.2.18/fs/nfsd/nfsfh.c
- Orig date:
Sun Mar 25 11:28:34 2001
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/fs/nfsd/nfsfh.c linux/fs/nfsd/nfsfh.c
@@ -183,7 +183,6 @@
if (!(target->d_flags & DCACHE_NFSD_DISCONNECTED))
printk("nfsd: d_splice with non-DISCONNECTED target: %s/%s\n", parent->d_name.name, name->name);
#endif
- name->hash = full_name_hash(name->name, name->len);
tdentry = d_alloc(parent, name);
if (tdentry == NULL)
return -ENOMEM;
@@ -275,7 +274,6 @@
struct qstr qs;
char namebuf[256];
struct list_head *lp;
- struct dentry *tmp;
/* child is an IS_ROOT (anonymous) dentry, but it is hypothesised that
* it should be a child of parent.
* We see if we can find a name and, if we can - splice it in.
@@ -295,8 +293,8 @@
* parent by a lookup. In this case return that dentry.
* caller must notice and act accordingly
*/
- for (lp = child->d_inode->i_dentry.next; lp != &child->d_inode->i_dentry ; lp=lp->next) {
- tmp = list_entry(lp,struct dentry, d_alias);
+ list_for_each(lp, &child->d_inode->i_dentry) {
+ struct dentry *tmp = list_entry(lp,struct dentry, d_alias);
if (tmp->d_parent == parent) {
child = dget(tmp);
goto out;
@@ -308,12 +306,12 @@
err = get_ino_name(parent, &qs, child->d_inode->i_ino);
if (err)
goto out;
- tmp = d_lookup(parent, &qs);
- if (tmp) {
+
+ /* find_inode_number calculates the name hash as a side effect */
+ if (find_inode_number(parent, &qs) != 0) {
/* Now that IS odd. I wonder what it means... */
err = -EEXIST;
printk("nfsd-fh: found a name that I didn't expect: %s/%s\n", parent->d_name.name, qs.name);
- dput(tmp);
goto out;
}
err = d_splice(child, parent, &qs);
@@ -339,7 +337,7 @@
struct dentry *dentry, *result = NULL;
struct dentry *tmp;
int found =0;
- int err;
+ int err = -ESTALE;
/* the sb->s_nfsd_free_path_sem semaphore is needed to make sure that only one unconnected (free)
* dcache path ever exists, as otherwise two partial paths might get
* joined together, which would be very confusing.
@@ -353,23 +351,21 @@
* Attempt to find the inode.
*/
retry:
+ down(&sb->s_nfsd_free_path_sem);
result = nfsd_iget(sb, fh->fh_ino, fh->fh_generation);
- err = PTR_ERR(result);
- if (IS_ERR(result))
- goto err_out;
- err = -ESTALE;
- if (!result) {
- dprintk("find_fh_dentry: No inode found.\n");
- goto err_out;
- }
- if (! (result->d_flags & DCACHE_NFSD_DISCONNECTED))
- return result;
-
- /* result is now an anonymous dentry, which may be adequate as it
- * stands, or else will get spliced into the dcache tree */
-
- if (!S_ISDIR(result->d_inode->i_mode) && ! needpath) {
- nfsdstats.fh_anon++;
+ if (!result || IS_ERR(result)
+ || !(result->d_flags & DCACHE_NFSD_DISCONNECTED)
+ || (!S_ISDIR(result->d_inode->i_mode) && !needpath)) {
+ up(&sb->s_nfsd_free_path_sem);
+ if (!result) {
+ dprintk("find_fh_dentry: No inode found.\n");
+ goto err_out;
+ }
+ err = PTR_ERR(result);
+ if (IS_ERR(result))
+ goto err_out;
+ if ( (result->d_flags & DCACHE_NFSD_DISCONNECTED))
+ nfsdstats.fh_anon++;
return result;
}
@@ -377,14 +373,6 @@
* location in the tree.
*/
dprintk("nfs_fh: need to look harder for %d/%d\n",sb->s_dev,fh->fh_ino);
- down(&sb->s_nfsd_free_path_sem);
-
- /* claiming the semaphore might have allow things to get fixed up */
- if (! (result->d_flags & DCACHE_NFSD_DISCONNECTED)) {
- up(&sb->s_nfsd_free_path_sem);
- return result;
- }
-
found = 0;
if (!S_ISDIR(result->d_inode->i_mode)) {
@@ -466,6 +454,7 @@
if (tmp != dentry) {
/* we lost a race, try again
*/
+ dput(pdentry);
dput(tmp);
dput(dentry);
dput(result); /* this will discard the whole free path, so we can up the semaphore */
@@ -563,7 +552,7 @@
!(exp->ex_flags & NFSEXP_NOSUBTREECHECK));
if (IS_ERR(dentry)) {
- error = nfserrno(-PTR_ERR(dentry));
+ error = nfserrno(PTR_ERR(dentry));
goto out;
}
#ifdef NFSD_PARANOIA
@@ -690,7 +679,7 @@
fhp->fh_handle.fh_dev = kdev_t_to_u32(parent->d_inode->i_dev);
fhp->fh_handle.fh_xdev = kdev_t_to_u32(exp->ex_dev);
fhp->fh_handle.fh_xino = ino_t_to_u32(exp->ex_ino);
- fhp->fh_handle.fh_dcookie = (struct dentry *)0xfeebbaca;
+ fhp->fh_handle.fh_dcookie = 0xfeebbaca;
if (inode) {
fhp->fh_handle.fh_ino = ino_t_to_u32(inode->i_ino);
fhp->fh_handle.fh_generation = inode->i_generation;
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)