Skip to content

Commit 3d4ff43

Browse files
author
Al Viro
committed
nfs_open_context doesn't need struct path either
just dentry, please... Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 82a2c1b commit 3d4ff43

8 files changed

Lines changed: 42 additions & 44 deletions

File tree

‎fs/nfs/dir.c‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,18 +1345,14 @@ static int is_atomic_open(struct nameidata *nd)
13451345

13461346
static struct nfs_open_context *nameidata_to_nfs_open_context(struct dentry *dentry, struct nameidata *nd)
13471347
{
1348-
struct path path = {
1349-
.mnt = nd->path.mnt,
1350-
.dentry = dentry,
1351-
};
13521348
struct nfs_open_context *ctx;
13531349
struct rpc_cred *cred;
13541350
fmode_t fmode = nd->intent.open.flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC);
13551351

13561352
cred = rpc_lookup_cred();
13571353
if (IS_ERR(cred))
13581354
return ERR_CAST(cred);
1359-
ctx = alloc_nfs_open_context(&path, cred, fmode);
1355+
ctx = alloc_nfs_open_context(dentry, cred, fmode);
13601356
put_rpccred(cred);
13611357
if (ctx == NULL)
13621358
return ERR_PTR(-ENOMEM);
@@ -1376,13 +1372,13 @@ static int nfs_intent_set_file(struct nameidata *nd, struct nfs_open_context *ct
13761372

13771373
/* If the open_intent is for execute, we have an extra check to make */
13781374
if (ctx->mode & FMODE_EXEC) {
1379-
ret = nfs_may_open(ctx->path.dentry->d_inode,
1375+
ret = nfs_may_open(ctx->dentry->d_inode,
13801376
ctx->cred,
13811377
nd->intent.open.flags);
13821378
if (ret < 0)
13831379
goto out;
13841380
}
1385-
filp = lookup_instantiate_filp(nd, ctx->path.dentry, do_open);
1381+
filp = lookup_instantiate_filp(nd, ctx->dentry, do_open);
13861382
if (IS_ERR(filp))
13871383
ret = PTR_ERR(filp);
13881384
else
@@ -1463,8 +1459,8 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
14631459
res = d_add_unique(dentry, inode);
14641460
nfs_unblock_sillyrename(dentry->d_parent);
14651461
if (res != NULL) {
1466-
dput(ctx->path.dentry);
1467-
ctx->path.dentry = dget(res);
1462+
dput(ctx->dentry);
1463+
ctx->dentry = dget(res);
14681464
dentry = res;
14691465
}
14701466
err = nfs_intent_set_file(nd, ctx);

‎fs/nfs/direct.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
284284
loff_t pos)
285285
{
286286
struct nfs_open_context *ctx = dreq->ctx;
287-
struct inode *inode = ctx->path.dentry->d_inode;
287+
struct inode *inode = ctx->dentry->d_inode;
288288
unsigned long user_addr = (unsigned long)iov->iov_base;
289289
size_t count = iov->iov_len;
290290
size_t rsize = NFS_SERVER(inode)->rsize;
@@ -715,7 +715,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
715715
loff_t pos, int sync)
716716
{
717717
struct nfs_open_context *ctx = dreq->ctx;
718-
struct inode *inode = ctx->path.dentry->d_inode;
718+
struct inode *inode = ctx->dentry->d_inode;
719719
unsigned long user_addr = (unsigned long)iov->iov_base;
720720
size_t count = iov->iov_len;
721721
struct rpc_task *task;

‎fs/nfs/inode.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context
567567
struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
568568
{
569569
struct nfs_lock_context *res, *new = NULL;
570-
struct inode *inode = ctx->path.dentry->d_inode;
570+
struct inode *inode = ctx->dentry->d_inode;
571571

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

599599
if (!atomic_dec_and_lock(&l_ctx->count, &inode->i_lock))
600600
return;
@@ -620,7 +620,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
620620
return;
621621
if (!is_sync)
622622
return;
623-
inode = ctx->path.dentry->d_inode;
623+
inode = ctx->dentry->d_inode;
624624
if (!list_empty(&NFS_I(inode)->open_files))
625625
return;
626626
server = NFS_SERVER(inode);
@@ -629,14 +629,14 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
629629
nfs_revalidate_inode(server, inode);
630630
}
631631

632-
struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred, fmode_t f_mode)
632+
struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode)
633633
{
634634
struct nfs_open_context *ctx;
635635

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

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

663664
if (!list_empty(&ctx->list)) {
664665
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)
671672
NFS_PROTO(inode)->close_context(ctx, is_sync);
672673
if (ctx->cred != NULL)
673674
put_rpccred(ctx->cred);
674-
path_put(&ctx->path);
675+
dput(ctx->dentry);
676+
nfs_sb_deactive(sb);
675677
kfree(ctx);
676678
}
677679

@@ -741,7 +743,7 @@ int nfs_open(struct inode *inode, struct file *filp)
741743
cred = rpc_lookup_cred();
742744
if (IS_ERR(cred))
743745
return PTR_ERR(cred);
744-
ctx = alloc_nfs_open_context(&filp->f_path, cred, filp->f_mode);
746+
ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode);
745747
put_rpccred(cred);
746748
if (ctx == NULL)
747749
return -ENOMEM;

‎fs/nfs/nfs4proc.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
11321132
{
11331133
struct nfs4_opendata *opendata;
11341134

1135-
opendata = nfs4_opendata_alloc(ctx->path.dentry, state->owner, 0, 0, NULL, GFP_NOFS);
1135+
opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, NULL, GFP_NOFS);
11361136
if (opendata == NULL)
11371137
return ERR_PTR(-ENOMEM);
11381138
opendata->state = state;
@@ -1650,7 +1650,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
16501650
return PTR_ERR(opendata);
16511651
ret = nfs4_open_recover(opendata, state);
16521652
if (ret == -ESTALE)
1653-
d_drop(ctx->path.dentry);
1653+
d_drop(ctx->dentry);
16541654
nfs4_opendata_put(opendata);
16551655
return ret;
16561656
}
@@ -2081,7 +2081,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
20812081
struct nfs4_state *state;
20822082

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

26262626
if (ctx != NULL) {
26272627
cred = ctx->cred;
2628-
de = ctx->path.dentry;
2628+
de = ctx->dentry;
26292629
fmode = ctx->mode;
26302630
}
26312631
sattr->ia_mode &= ~current_umask();
@@ -4292,7 +4292,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
42924292
memcpy(data->lsp->ls_stateid.data, data->res.stateid.data,
42934293
sizeof(data->lsp->ls_stateid.data));
42944294
data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
4295-
renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp);
4295+
renew_lease(NFS_SERVER(data->ctx->dentry->d_inode), data->timestamp);
42964296
}
42974297
out:
42984298
dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);

‎fs/nfs/pagelist.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
114114
if (!nfs_lock_request_dontget(req))
115115
return 0;
116116
if (test_bit(PG_MAPPED, &req->wb_flags))
117-
radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
117+
radix_tree_tag_set(&NFS_I(req->wb_context->dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
118118
return 1;
119119
}
120120

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

130130
spin_lock(&inode->i_lock);

‎fs/nfs/read.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
144144

145145
static void nfs_readpage_release(struct nfs_page *req)
146146
{
147-
struct inode *d_inode = req->wb_context->path.dentry->d_inode;
147+
struct inode *d_inode = req->wb_context->dentry->d_inode;
148148

149149
if (PageUptodate(req->wb_page))
150150
nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
151151

152152
unlock_page(req->wb_page);
153153

154154
dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
155-
req->wb_context->path.dentry->d_inode->i_sb->s_id,
156-
(long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
155+
req->wb_context->dentry->d_inode->i_sb->s_id,
156+
(long long)NFS_FILEID(req->wb_context->dentry->d_inode),
157157
req->wb_bytes,
158158
(long long)req_offset(req));
159159
nfs_release_request(req);
@@ -207,7 +207,7 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
207207
unsigned int count, unsigned int offset,
208208
struct pnfs_layout_segment *lseg)
209209
{
210-
struct inode *inode = req->wb_context->path.dentry->d_inode;
210+
struct inode *inode = req->wb_context->dentry->d_inode;
211211

212212
data->req = req;
213213
data->inode = inode;

‎fs/nfs/write.c‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
409409
*/
410410
static void nfs_inode_remove_request(struct nfs_page *req)
411411
{
412-
struct inode *inode = req->wb_context->path.dentry->d_inode;
412+
struct inode *inode = req->wb_context->dentry->d_inode;
413413
struct nfs_inode *nfsi = NFS_I(inode);
414414

415415
BUG_ON (!NFS_WBACK_BUSY(req));
@@ -438,7 +438,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
438438
static void
439439
nfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg)
440440
{
441-
struct inode *inode = req->wb_context->path.dentry->d_inode;
441+
struct inode *inode = req->wb_context->dentry->d_inode;
442442
struct nfs_inode *nfsi = NFS_I(inode);
443443

444444
spin_lock(&inode->i_lock);
@@ -852,13 +852,13 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
852852
struct pnfs_layout_segment *lseg,
853853
int how)
854854
{
855-
struct inode *inode = req->wb_context->path.dentry->d_inode;
855+
struct inode *inode = req->wb_context->dentry->d_inode;
856856

857857
/* Set up the RPC argument and reply structs
858858
* NB: take care not to mess about with data->commit et al. */
859859

860860
data->req = req;
861-
data->inode = inode = req->wb_context->path.dentry->d_inode;
861+
data->inode = inode = req->wb_context->dentry->d_inode;
862862
data->cred = req->wb_context->cred;
863863
data->lseg = get_lseg(lseg);
864864

@@ -1053,9 +1053,9 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
10531053

10541054
dprintk("NFS: %5u write(%s/%lld %d@%lld)",
10551055
task->tk_pid,
1056-
data->req->wb_context->path.dentry->d_inode->i_sb->s_id,
1056+
data->req->wb_context->dentry->d_inode->i_sb->s_id,
10571057
(long long)
1058-
NFS_FILEID(data->req->wb_context->path.dentry->d_inode),
1058+
NFS_FILEID(data->req->wb_context->dentry->d_inode),
10591059
data->req->wb_bytes, (long long)req_offset(data->req));
10601060

10611061
nfs_writeback_done(task, data);
@@ -1148,8 +1148,8 @@ static void nfs_writeback_release_full(void *calldata)
11481148

11491149
dprintk("NFS: %5u write (%s/%lld %d@%lld)",
11501150
data->task.tk_pid,
1151-
req->wb_context->path.dentry->d_inode->i_sb->s_id,
1152-
(long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
1151+
req->wb_context->dentry->d_inode->i_sb->s_id,
1152+
(long long)NFS_FILEID(req->wb_context->dentry->d_inode),
11531153
req->wb_bytes,
11541154
(long long)req_offset(req));
11551155

@@ -1347,7 +1347,7 @@ void nfs_init_commit(struct nfs_write_data *data,
13471347
struct pnfs_layout_segment *lseg)
13481348
{
13491349
struct nfs_page *first = nfs_list_entry(head->next);
1350-
struct inode *inode = first->wb_context->path.dentry->d_inode;
1350+
struct inode *inode = first->wb_context->dentry->d_inode;
13511351

13521352
/* Set up the RPC argument and reply structs
13531353
* NB: take care not to mess about with data->commit et al. */
@@ -1435,8 +1435,8 @@ void nfs_commit_release_pages(struct nfs_write_data *data)
14351435
nfs_clear_request_commit(req);
14361436

14371437
dprintk("NFS: commit (%s/%lld %d@%lld)",
1438-
req->wb_context->path.dentry->d_inode->i_sb->s_id,
1439-
(long long)NFS_FILEID(req->wb_context->path.dentry->d_inode),
1438+
req->wb_context->dentry->d_sb->s_id,
1439+
(long long)NFS_FILEID(req->wb_context->dentry->d_inode),
14401440
req->wb_bytes,
14411441
(long long)req_offset(req));
14421442
if (status < 0) {

‎include/linux/nfs_fs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct nfs_lock_context {
8585
struct nfs4_state;
8686
struct nfs_open_context {
8787
struct nfs_lock_context lock_context;
88-
struct path path;
88+
struct dentry *dentry;
8989
struct rpc_cred *cred;
9090
struct nfs4_state *state;
9191
fmode_t mode;
@@ -372,7 +372,7 @@ extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr);
372372
extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
373373
extern void put_nfs_open_context(struct nfs_open_context *ctx);
374374
extern struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_cred *cred, fmode_t mode);
375-
extern struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred, fmode_t f_mode);
375+
extern struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode);
376376
extern void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx);
377377
extern struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx);
378378
extern void nfs_put_lock_context(struct nfs_lock_context *l_ctx);

0 commit comments

Comments
 (0)