Commit 3d4ff43d authored by Al Viro's avatar Al Viro
Browse files

nfs_open_context doesn't need struct path either



just dentry, please...

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 82a2c1b7
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -1345,10 +1345,6 @@ static int is_atomic_open(struct nameidata *nd)

static struct nfs_open_context *nameidata_to_nfs_open_context(struct dentry *dentry, struct nameidata *nd)
{
	struct path path = {
		.mnt = nd->path.mnt,
		.dentry = dentry,
	};
	struct nfs_open_context *ctx;
	struct rpc_cred *cred;
	fmode_t fmode = nd->intent.open.flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
@@ -1356,7 +1352,7 @@ static struct nfs_open_context *nameidata_to_nfs_open_context(struct dentry *den
	cred = rpc_lookup_cred();
	if (IS_ERR(cred))
		return ERR_CAST(cred);
	ctx = alloc_nfs_open_context(&path, cred, fmode);
	ctx = alloc_nfs_open_context(dentry, cred, fmode);
	put_rpccred(cred);
	if (ctx == NULL)
		return ERR_PTR(-ENOMEM);
@@ -1376,13 +1372,13 @@ static int nfs_intent_set_file(struct nameidata *nd, struct nfs_open_context *ct

	/* If the open_intent is for execute, we have an extra check to make */
	if (ctx->mode & FMODE_EXEC) {
		ret = nfs_may_open(ctx->path.dentry->d_inode,
		ret = nfs_may_open(ctx->dentry->d_inode,
				ctx->cred,
				nd->intent.open.flags);
		if (ret < 0)
			goto out;
	}
	filp = lookup_instantiate_filp(nd, ctx->path.dentry, do_open);
	filp = lookup_instantiate_filp(nd, ctx->dentry, do_open);
	if (IS_ERR(filp))
		ret = PTR_ERR(filp);
	else
@@ -1463,8 +1459,8 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
	res = d_add_unique(dentry, inode);
	nfs_unblock_sillyrename(dentry->d_parent);
	if (res != NULL) {
		dput(ctx->path.dentry);
		ctx->path.dentry = dget(res);
		dput(ctx->dentry);
		ctx->dentry = dget(res);
		dentry = res;
	}
	err = nfs_intent_set_file(nd, ctx);
+2 −2
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
						loff_t pos)
{
	struct nfs_open_context *ctx = dreq->ctx;
	struct inode *inode = ctx->path.dentry->d_inode;
	struct inode *inode = ctx->dentry->d_inode;
	unsigned long user_addr = (unsigned long)iov->iov_base;
	size_t count = iov->iov_len;
	size_t rsize = NFS_SERVER(inode)->rsize;
@@ -715,7 +715,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
						 loff_t pos, int sync)
{
	struct nfs_open_context *ctx = dreq->ctx;
	struct inode *inode = ctx->path.dentry->d_inode;
	struct inode *inode = ctx->dentry->d_inode;
	unsigned long user_addr = (unsigned long)iov->iov_base;
	size_t count = iov->iov_len;
	struct rpc_task *task;
+11 −9
Original line number Diff line number Diff line
@@ -567,7 +567,7 @@ static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context
struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
{
	struct nfs_lock_context *res, *new = NULL;
	struct inode *inode = ctx->path.dentry->d_inode;
	struct inode *inode = ctx->dentry->d_inode;

	spin_lock(&inode->i_lock);
	res = __nfs_find_lock_context(ctx);
@@ -594,7 +594,7 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
void nfs_put_lock_context(struct nfs_lock_context *l_ctx)
{
	struct nfs_open_context *ctx = l_ctx->open_context;
	struct inode *inode = ctx->path.dentry->d_inode;
	struct inode *inode = ctx->dentry->d_inode;

	if (!atomic_dec_and_lock(&l_ctx->count, &inode->i_lock))
		return;
@@ -620,7 +620,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
		return;
	if (!is_sync)
		return;
	inode = ctx->path.dentry->d_inode;
	inode = ctx->dentry->d_inode;
	if (!list_empty(&NFS_I(inode)->open_files))
		return;
	server = NFS_SERVER(inode);
@@ -629,14 +629,14 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
	nfs_revalidate_inode(server, inode);
}

struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred, fmode_t f_mode)
struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode)
{
	struct nfs_open_context *ctx;

	ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
	if (ctx != NULL) {
		ctx->path = *path;
		path_get(&ctx->path);
		nfs_sb_active(dentry->d_sb);
		ctx->dentry = dget(dentry);
		ctx->cred = get_rpccred(cred);
		ctx->state = NULL;
		ctx->mode = f_mode;
@@ -658,7 +658,8 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)

static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
{
	struct inode *inode = ctx->path.dentry->d_inode;
	struct inode *inode = ctx->dentry->d_inode;
	struct super_block *sb = ctx->dentry->d_sb;

	if (!list_empty(&ctx->list)) {
		if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
@@ -671,7 +672,8 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
		NFS_PROTO(inode)->close_context(ctx, is_sync);
	if (ctx->cred != NULL)
		put_rpccred(ctx->cred);
	path_put(&ctx->path);
	dput(ctx->dentry);
	nfs_sb_deactive(sb);
	kfree(ctx);
}

@@ -741,7 +743,7 @@ int nfs_open(struct inode *inode, struct file *filp)
	cred = rpc_lookup_cred();
	if (IS_ERR(cred))
		return PTR_ERR(cred);
	ctx = alloc_nfs_open_context(&filp->f_path, cred, filp->f_mode);
	ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode);
	put_rpccred(cred);
	if (ctx == NULL)
		return -ENOMEM;
+5 −5
Original line number Diff line number Diff line
@@ -1132,7 +1132,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
{
	struct nfs4_opendata *opendata;

	opendata = nfs4_opendata_alloc(ctx->path.dentry, state->owner, 0, 0, NULL, GFP_NOFS);
	opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, NULL, GFP_NOFS);
	if (opendata == NULL)
		return ERR_PTR(-ENOMEM);
	opendata->state = state;
@@ -1650,7 +1650,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
		return PTR_ERR(opendata);
	ret = nfs4_open_recover(opendata, state);
	if (ret == -ESTALE)
		d_drop(ctx->path.dentry);
		d_drop(ctx->dentry);
	nfs4_opendata_put(opendata);
	return ret;
}
@@ -2081,7 +2081,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
	struct nfs4_state *state;

	/* Protect against concurrent sillydeletes */
	state = nfs4_do_open(dir, ctx->path.dentry, ctx->mode, open_flags, attr, ctx->cred);
	state = nfs4_do_open(dir, ctx->dentry, ctx->mode, open_flags, attr, ctx->cred);
	if (IS_ERR(state))
		return ERR_CAST(state);
	ctx->state = state;
@@ -2625,7 +2625,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,

	if (ctx != NULL) {
		cred = ctx->cred;
		de = ctx->path.dentry;
		de = ctx->dentry;
		fmode = ctx->mode;
	}
	sattr->ia_mode &= ~current_umask();
@@ -4292,7 +4292,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
		memcpy(data->lsp->ls_stateid.data, data->res.stateid.data,
					sizeof(data->lsp->ls_stateid.data));
		data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
		renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp);
		renew_lease(NFS_SERVER(data->ctx->dentry->d_inode), data->timestamp);
	}
out:
	dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
+2 −2
Original line number Diff line number Diff line
@@ -114,7 +114,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
	if (!nfs_lock_request_dontget(req))
		return 0;
	if (test_bit(PG_MAPPED, &req->wb_flags))
		radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
		radix_tree_tag_set(&NFS_I(req->wb_context->dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
	return 1;
}

@@ -124,7 +124,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
void nfs_clear_page_tag_locked(struct nfs_page *req)
{
	if (test_bit(PG_MAPPED, &req->wb_flags)) {
		struct inode *inode = req->wb_context->path.dentry->d_inode;
		struct inode *inode = req->wb_context->dentry->d_inode;
		struct nfs_inode *nfsi = NFS_I(inode);

		spin_lock(&inode->i_lock);
Loading