Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 898f635c authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFSv4: Don't ignore the error return codes from nfs_intent_set_file



If nfs_intent_set_file() returns an error, we usually want to pass that
back up the stack.

Also ensure that nfs_open_revalidate() returns '1' on success.

Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 6eaa6149
Loading
Loading
Loading
Loading
+23 −12
Original line number Original line Diff line number Diff line
@@ -1086,6 +1086,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
	struct dentry *res = NULL;
	struct dentry *res = NULL;
	struct inode *inode;
	struct inode *inode;
	int open_flags;
	int open_flags;
	int err;


	dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
	dfprintk(VFS, "NFS: atomic_lookup(%s/%ld), %s\n",
			dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
			dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
@@ -1119,9 +1120,8 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
		if (!IS_POSIXACL(dir))
		if (!IS_POSIXACL(dir))
			attr.ia_mode &= ~current_umask();
			attr.ia_mode &= ~current_umask();
	} else {
	} else {
		open_flags &= ~O_EXCL;
		open_flags &= ~(O_EXCL | O_CREAT);
		attr.ia_valid = 0;
		attr.ia_valid = 0;
		BUG_ON(open_flags & O_CREAT);
	}
	}


	/* Open the file on the server */
	/* Open the file on the server */
@@ -1150,13 +1150,18 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
		}
		}
	}
	}
	res = d_add_unique(dentry, inode);
	res = d_add_unique(dentry, inode);
	nfs_unblock_sillyrename(dentry->d_parent);
	if (res != NULL) {
	if (res != NULL) {
		dput(ctx->path.dentry);
		dput(ctx->path.dentry);
		ctx->path.dentry = dget(res);
		ctx->path.dentry = dget(res);
		dentry = res;
		dentry = res;
	}
	}
	nfs_intent_set_file(nd, ctx);
	err = nfs_intent_set_file(nd, ctx);
	nfs_unblock_sillyrename(dentry->d_parent);
	if (err < 0) {
		if (res != NULL)
			dput(res);
		return ERR_PTR(err);
	}
out:
out:
	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
	return res;
	return res;
@@ -1221,11 +1226,13 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
		}
		}
	}
	}
	iput(inode);
	iput(inode);
	if (inode == dentry->d_inode) {
	if (inode != dentry->d_inode)
		nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
		nfs_intent_set_file(nd, ctx);
	} else
		goto out_drop;
		goto out_drop;

	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
	ret = nfs_intent_set_file(nd, ctx);
	if (ret >= 0)
		ret = 1;
out:
out:
	dput(parent);
	dput(parent);
	return ret;
	return ret;
@@ -1262,20 +1269,24 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
		ctx = nameidata_to_nfs_open_context(dentry, nd);
		ctx = nameidata_to_nfs_open_context(dentry, nd);
		error = PTR_ERR(ctx);
		error = PTR_ERR(ctx);
		if (IS_ERR(ctx))
		if (IS_ERR(ctx))
			goto out_err;
			goto out_err_drop;
	}
	}


	error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, ctx);
	error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, ctx);
	if (error != 0)
	if (error != 0)
		goto out_put_ctx;
		goto out_put_ctx;
	if (ctx != NULL)
	if (ctx != NULL) {
		nfs_intent_set_file(nd, ctx);
		error = nfs_intent_set_file(nd, ctx);
		if (error < 0)
			goto out_err;
	}
	return 0;
	return 0;
out_put_ctx:
out_put_ctx:
	if (ctx != NULL)
	if (ctx != NULL)
		put_nfs_open_context(ctx);
		put_nfs_open_context(ctx);
out_err:
out_err_drop:
	d_drop(dentry);
	d_drop(dentry);
out_err:
	return error;
	return error;
}
}