]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/nfs/nfs4proc.c
NFS: Replace file->private_data with calls to nfs_file_open_context()
[mirror_ubuntu-artful-kernel.git] / fs / nfs / nfs4proc.c
index 6ca2795ccd9c7164f77c2a601841d1637af28550..2919271a983a9915ed74538a9eb2d6f3cc3b6c0d 100644 (file)
@@ -177,7 +177,7 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent
                *p++ = xdr_one;                         /* bitmap length */
                *p++ = htonl(FATTR4_WORD0_FILEID);             /* bitmap */
                *p++ = htonl(8);              /* attribute buffer length */
-               p = xdr_encode_hyper(p, dentry->d_inode->i_ino);
+               p = xdr_encode_hyper(p, NFS_FILEID(dentry->d_inode));
        }
        
        *p++ = xdr_one;                                  /* next */
@@ -189,7 +189,7 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent
        *p++ = xdr_one;                         /* bitmap length */
        *p++ = htonl(FATTR4_WORD0_FILEID);             /* bitmap */
        *p++ = htonl(8);              /* attribute buffer length */
-       p = xdr_encode_hyper(p, dentry->d_parent->d_inode->i_ino);
+       p = xdr_encode_hyper(p, NFS_FILEID(dentry->d_parent->d_inode));
 
        readdir->pgbase = (char *)p - (char *)start;
        readdir->count -= readdir->pgbase;
@@ -332,11 +332,9 @@ static int can_open_cached(struct nfs4_state *state, int mode)
        switch (mode & (FMODE_READ|FMODE_WRITE|O_EXCL)) {
                case FMODE_READ:
                        ret |= test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0;
-                       ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0;
                        break;
                case FMODE_WRITE:
                        ret |= test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0;
-                       ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0;
                        break;
                case FMODE_READ|FMODE_WRITE:
                        ret |= test_bit(NFS_O_RDWR_STATE, &state->flags) != 0;
@@ -648,7 +646,7 @@ static int _nfs4_do_open_reclaim(struct nfs_open_context *ctx, struct nfs4_state
        rcu_read_lock();
        delegation = rcu_dereference(NFS_I(state->inode)->delegation);
        if (delegation != NULL && (delegation->flags & NFS_DELEGATION_NEED_RECLAIM) != 0)
-               delegation_type = delegation->flags;
+               delegation_type = delegation->type;
        rcu_read_unlock();
        opendata->o_arg.u.delegation_type = delegation_type;
        status = nfs4_open_recover(opendata, state);
@@ -1260,7 +1258,7 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
        nfs_increment_open_seqid(task->tk_status, calldata->arg.seqid);
        switch (task->tk_status) {
                case 0:
-                       nfs_set_open_stateid(state, &calldata->res.stateid, calldata->arg.open_flags);
+                       nfs_set_open_stateid(state, &calldata->res.stateid, 0);
                        renew_lease(server, calldata->timestamp);
                        break;
                case -NFS4ERR_STALE_STATEID:
@@ -1286,23 +1284,19 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
                .rpc_cred = state->owner->so_cred,
        };
        int clear_rd, clear_wr, clear_rdwr;
-       int mode;
 
        if (nfs_wait_on_sequence(calldata->arg.seqid, task) != 0)
                return;
 
-       mode = FMODE_READ|FMODE_WRITE;
        clear_rd = clear_wr = clear_rdwr = 0;
        spin_lock(&state->owner->so_lock);
        /* Calculate the change in open mode */
        if (state->n_rdwr == 0) {
                if (state->n_rdonly == 0) {
-                       mode &= ~FMODE_READ;
                        clear_rd |= test_and_clear_bit(NFS_O_RDONLY_STATE, &state->flags);
                        clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags);
                }
                if (state->n_wronly == 0) {
-                       mode &= ~FMODE_WRITE;
                        clear_wr |= test_and_clear_bit(NFS_O_WRONLY_STATE, &state->flags);
                        clear_rdwr |= test_and_clear_bit(NFS_O_RDWR_STATE, &state->flags);
                }
@@ -1314,9 +1308,13 @@ static void nfs4_close_prepare(struct rpc_task *task, void *data)
                return;
        }
        nfs_fattr_init(calldata->res.fattr);
-       if (mode != 0)
+       if (test_bit(NFS_O_RDONLY_STATE, &state->flags) != 0) {
                msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
-       calldata->arg.open_flags = mode;
+               calldata->arg.open_flags = FMODE_READ;
+       } else if (test_bit(NFS_O_WRONLY_STATE, &state->flags) != 0) {
+               msg.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_OPEN_DOWNGRADE];
+               calldata->arg.open_flags = FMODE_WRITE;
+       }
        calldata->timestamp = jiffies;
        rpc_call_setup(task, &msg, 0);
 }
@@ -1392,7 +1390,7 @@ static int nfs4_intent_set_file(struct nameidata *nd, struct path *path, struct
        filp = lookup_instantiate_filp(nd, path->dentry, NULL);
        if (!IS_ERR(filp)) {
                struct nfs_open_context *ctx;
-               ctx = (struct nfs_open_context *)filp->private_data;
+               ctx = nfs_file_open_context(filp);
                ctx->state = state;
                return 0;
        }
@@ -1436,7 +1434,7 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
        }
        res = d_add_unique(dentry, igrab(state->inode));
        if (res != NULL)
-               dentry = res;
+               path.dentry = res;
        nfs4_intent_set_file(nd, &path, state);
        return res;
 }
@@ -3305,7 +3303,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
        status = -ENOMEM;
        if (seqid == NULL)
                goto out;
-       task = nfs4_do_unlck(request, request->fl_file->private_data, lsp, seqid);
+       task = nfs4_do_unlck(request, nfs_file_open_context(request->fl_file), lsp, seqid);
        status = PTR_ERR(task);
        if (IS_ERR(task))
                goto out;
@@ -3449,7 +3447,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
        int ret;
 
        dprintk("%s: begin!\n", __FUNCTION__);
-       data = nfs4_alloc_lockdata(fl, fl->fl_file->private_data,
+       data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file),
                        fl->fl_u.nfs4_fl.owner);
        if (data == NULL)
                return -ENOMEM;
@@ -3575,7 +3573,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
        int status;
 
        /* verify open state */
-       ctx = (struct nfs_open_context *)filp->private_data;
+       ctx = nfs_file_open_context(filp);
        state = ctx->state;
 
        if (request->fl_start < 0 || request->fl_end < 0)