Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
[sfrench/cifs-2.6.git] / fs / nfs / nfs4proc.c
index 47c7e6e3910d738a9bdf4313e390b7349427f9d3..f52cf5c33c6c83adcde94ed37202adaf3a0d969f 100644 (file)
@@ -138,10 +138,10 @@ const u32 nfs4_fs_locations_bitmap[2] = {
        | FATTR4_WORD1_MOUNTED_ON_FILEID
 };
 
-static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry,
+static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
                struct nfs4_readdir_arg *readdir)
 {
-       u32 *start, *p;
+       __be32 *start, *p;
 
        BUG_ON(readdir->count < 80);
        if (cookie > 2) {
@@ -162,7 +162,7 @@ static void nfs4_setup_readdir(u64 cookie, u32 *verifier, struct dentry *dentry,
         * when talking to the server, we always send cookie 0
         * instead of 1 or 2.
         */
-       start = p = (u32 *)kmap_atomic(*readdir->pages, KM_USER0);
+       start = p = kmap_atomic(*readdir->pages, KM_USER0);
        
        if (cookie == 0) {
                *p++ = xdr_one;                                  /* next */
@@ -636,7 +636,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
                smp_wmb();
        } else
                status = data->rpc_status;
-       rpc_release_task(task);
+       rpc_put_task(task);
        return status;
 }
 
@@ -742,7 +742,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
                smp_wmb();
        } else
                status = data->rpc_status;
-       rpc_release_task(task);
+       rpc_put_task(task);
        if (status != 0)
                return status;
 
@@ -1140,7 +1140,6 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
                        break;
                case -NFS4ERR_STALE_STATEID:
                case -NFS4ERR_EXPIRED:
-                       nfs4_schedule_state_recovery(server->nfs_client);
                        break;
                default:
                        if (nfs4_async_handle_error(task, server) == -EAGAIN) {
@@ -1314,11 +1313,9 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st
                        case -EROFS:
                                lookup_instantiate_filp(nd, (struct dentry *)state, NULL);
                                return 1;
-                       case -ENOENT:
-                               if (dentry->d_inode == NULL)
-                                       return 1;
+                       default:
+                               goto out_drop;
                }
-               goto out_drop;
        }
        if (state->inode == dentry->d_inode) {
                nfs4_intent_set_file(nd, dentry, state);
@@ -1426,7 +1423,6 @@ static int nfs4_get_referral(struct inode *dir, struct qstr *name, struct nfs_fa
        int status = -ENOMEM;
        struct page *page = NULL;
        struct nfs4_fs_locations *locations = NULL;
-       struct dentry dentry = {};
 
        page = alloc_page(GFP_KERNEL);
        if (page == NULL)
@@ -1435,9 +1431,7 @@ static int nfs4_get_referral(struct inode *dir, struct qstr *name, struct nfs_fa
        if (locations == NULL)
                goto out;
 
-       dentry.d_name.name = name->name;
-       dentry.d_name.len = name->len;
-       status = nfs4_proc_fs_locations(dir, &dentry, locations, page);
+       status = nfs4_proc_fs_locations(dir, name, locations, page);
        if (status != 0)
                goto out;
        /* Make sure server returned a different fsid for the referral */
@@ -1739,127 +1733,6 @@ static int nfs4_proc_readlink(struct inode *inode, struct page *page,
        return err;
 }
 
-static int _nfs4_proc_read(struct nfs_read_data *rdata)
-{
-       int flags = rdata->flags;
-       struct inode *inode = rdata->inode;
-       struct nfs_fattr *fattr = rdata->res.fattr;
-       struct nfs_server *server = NFS_SERVER(inode);
-       struct rpc_message msg = {
-               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_READ],
-               .rpc_argp       = &rdata->args,
-               .rpc_resp       = &rdata->res,
-               .rpc_cred       = rdata->cred,
-       };
-       unsigned long timestamp = jiffies;
-       int status;
-
-       dprintk("NFS call  read %d @ %Ld\n", rdata->args.count,
-                       (long long) rdata->args.offset);
-
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(server->client, &msg, flags);
-       if (!status)
-               renew_lease(server, timestamp);
-       dprintk("NFS reply read: %d\n", status);
-       return status;
-}
-
-static int nfs4_proc_read(struct nfs_read_data *rdata)
-{
-       struct nfs4_exception exception = { };
-       int err;
-       do {
-               err = nfs4_handle_exception(NFS_SERVER(rdata->inode),
-                               _nfs4_proc_read(rdata),
-                               &exception);
-       } while (exception.retry);
-       return err;
-}
-
-static int _nfs4_proc_write(struct nfs_write_data *wdata)
-{
-       int rpcflags = wdata->flags;
-       struct inode *inode = wdata->inode;
-       struct nfs_fattr *fattr = wdata->res.fattr;
-       struct nfs_server *server = NFS_SERVER(inode);
-       struct rpc_message msg = {
-               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_WRITE],
-               .rpc_argp       = &wdata->args,
-               .rpc_resp       = &wdata->res,
-               .rpc_cred       = wdata->cred,
-       };
-       int status;
-
-       dprintk("NFS call  write %d @ %Ld\n", wdata->args.count,
-                       (long long) wdata->args.offset);
-
-       wdata->args.bitmask = server->attr_bitmask;
-       wdata->res.server = server;
-       wdata->timestamp = jiffies;
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(server->client, &msg, rpcflags);
-       dprintk("NFS reply write: %d\n", status);
-       if (status < 0)
-               return status;
-       renew_lease(server, wdata->timestamp);
-       nfs_post_op_update_inode(inode, fattr);
-       return wdata->res.count;
-}
-
-static int nfs4_proc_write(struct nfs_write_data *wdata)
-{
-       struct nfs4_exception exception = { };
-       int err;
-       do {
-               err = nfs4_handle_exception(NFS_SERVER(wdata->inode),
-                               _nfs4_proc_write(wdata),
-                               &exception);
-       } while (exception.retry);
-       return err;
-}
-
-static int _nfs4_proc_commit(struct nfs_write_data *cdata)
-{
-       struct inode *inode = cdata->inode;
-       struct nfs_fattr *fattr = cdata->res.fattr;
-       struct nfs_server *server = NFS_SERVER(inode);
-       struct rpc_message msg = {
-               .rpc_proc       = &nfs4_procedures[NFSPROC4_CLNT_COMMIT],
-               .rpc_argp       = &cdata->args,
-               .rpc_resp       = &cdata->res,
-               .rpc_cred       = cdata->cred,
-       };
-       int status;
-
-       dprintk("NFS call  commit %d @ %Ld\n", cdata->args.count,
-                       (long long) cdata->args.offset);
-
-       cdata->args.bitmask = server->attr_bitmask;
-       cdata->res.server = server;
-       cdata->timestamp = jiffies;
-       nfs_fattr_init(fattr);
-       status = rpc_call_sync(server->client, &msg, 0);
-       if (status >= 0)
-               renew_lease(server, cdata->timestamp);
-       dprintk("NFS reply commit: %d\n", status);
-       if (status >= 0)
-               nfs_post_op_update_inode(inode, fattr);
-       return status;
-}
-
-static int nfs4_proc_commit(struct nfs_write_data *cdata)
-{
-       struct nfs4_exception exception = { };
-       int err;
-       do {
-               err = nfs4_handle_exception(NFS_SERVER(cdata->inode),
-                               _nfs4_proc_commit(cdata),
-                               &exception);
-       } while (exception.retry);
-       return err;
-}
-
 /*
  * Got race?
  * We will need to arrange for the VFS layer to provide an atomic open.
@@ -1962,7 +1835,7 @@ static int nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dir,
        struct nfs_server *server = NFS_SERVER(dir->d_inode);
        struct unlink_desc *up;
 
-       up = (struct unlink_desc *) kmalloc(sizeof(*up), GFP_KERNEL);
+       up = kmalloc(sizeof(*up), GFP_KERNEL);
        if (!up)
                return -ENOMEM;
        
@@ -2225,13 +2098,11 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred,
                        dentry->d_parent->d_name.name,
                        dentry->d_name.name,
                        (unsigned long long)cookie);
-       lock_kernel();
        nfs4_setup_readdir(cookie, NFS_COOKIEVERF(dir), dentry, &args);
        res.pgbase = args.pgbase;
        status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
        if (status == 0)
                memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE);
-       unlock_kernel();
        dprintk("%s: returns %d\n", __FUNCTION__, status);
        return status;
 }
@@ -2840,11 +2711,15 @@ static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs_client *clp)
 
        might_sleep();
 
+       rwsem_acquire(&clp->cl_sem.dep_map, 0, 0, _RET_IP_);
+
        rpc_clnt_sigmask(clnt, &oldset);
        res = wait_on_bit(&clp->cl_state, NFS4CLNT_STATE_RECOVER,
                        nfs4_wait_bit_interruptible,
                        TASK_INTERRUPTIBLE);
        rpc_clnt_sigunmask(clnt, &oldset);
+
+       rwsem_release(&clp->cl_sem.dep_map, 1, _RET_IP_);
        return res;
 }
 
@@ -2917,11 +2792,11 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, unsigned short po
                .rpc_resp = clp,
                .rpc_cred = cred,
        };
-       u32 *p;
+       __be32 *p;
        int loop = 0;
        int status;
 
-       p = (u32*)sc_verifier.data;
+       p = (__be32*)sc_verifier.data;
        *p++ = htonl((u32)clp->cl_boot_time.tv_sec);
        *p = htonl((u32)clp->cl_boot_time.tv_nsec);
 
@@ -3069,7 +2944,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
                if (status == 0)
                        nfs_post_op_update_inode(inode, &data->fattr);
        }
-       rpc_release_task(task);
+       rpc_put_task(task);
        return status;
 }
 
@@ -3083,7 +2958,6 @@ int nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, const nfs4
                switch (err) {
                        case -NFS4ERR_STALE_STATEID:
                        case -NFS4ERR_EXPIRED:
-                               nfs4_schedule_state_recovery(server->nfs_client);
                        case 0:
                                return 0;
                }
@@ -3237,12 +3111,10 @@ static void nfs4_locku_done(struct rpc_task *task, void *data)
                        break;
                case -NFS4ERR_STALE_STATEID:
                case -NFS4ERR_EXPIRED:
-                       nfs4_schedule_state_recovery(calldata->server->nfs_client);
                        break;
                default:
-                       if (nfs4_async_handle_error(task, calldata->server) == -EAGAIN) {
+                       if (nfs4_async_handle_error(task, calldata->server) == -EAGAIN)
                                rpc_restart_call(task);
-                       }
        }
 }
 
@@ -3316,7 +3188,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *
        if (IS_ERR(task))
                goto out;
        status = nfs4_wait_for_completion_rpc_task(task);
-       rpc_release_task(task);
+       rpc_put_task(task);
 out:
        return status;
 }
@@ -3432,7 +3304,7 @@ static void nfs4_lock_release(void *calldata)
                task = nfs4_do_unlck(&data->fl, data->ctx, data->lsp,
                                data->arg.lock_seqid);
                if (!IS_ERR(task))
-                       rpc_release_task(task);
+                       rpc_put_task(task);
                dprintk("%s: cancelling lock!\n", __FUNCTION__);
        } else
                nfs_free_seqid(data->arg.lock_seqid);
@@ -3474,7 +3346,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
                        ret = -EAGAIN;
        } else
                data->cancelled = 1;
-       rpc_release_task(task);
+       rpc_put_task(task);
        dprintk("%s: done, ret = %d!\n", __FUNCTION__, ret);
        return ret;
 }
@@ -3672,7 +3544,7 @@ ssize_t nfs4_listxattr(struct dentry *dentry, char *buf, size_t buflen)
        return len;
 }
 
-int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
+int nfs4_proc_fs_locations(struct inode *dir, struct qstr *name,
                struct nfs4_fs_locations *fs_locations, struct page *page)
 {
        struct nfs_server *server = NFS_SERVER(dir);
@@ -3682,7 +3554,7 @@ int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
        };
        struct nfs4_fs_locations_arg args = {
                .dir_fh = NFS_FH(dir),
-               .name = &dentry->d_name,
+               .name = name,
                .page = page,
                .bitmask = bitmask,
        };
@@ -3694,7 +3566,7 @@ int nfs4_proc_fs_locations(struct inode *dir, struct dentry *dentry,
        int status;
 
        dprintk("%s: start\n", __FUNCTION__);
-       fs_locations->fattr.valid = 0;
+       nfs_fattr_init(&fs_locations->fattr);
        fs_locations->server = server;
        fs_locations->nlocations = 0;
        status = rpc_call_sync(server->client, &msg, 0);
@@ -3712,7 +3584,7 @@ struct nfs4_state_recovery_ops nfs4_network_partition_recovery_ops = {
        .recover_lock   = nfs4_lock_expired,
 };
 
-static struct inode_operations nfs4_file_inode_operations = {
+static const struct inode_operations nfs4_file_inode_operations = {
        .permission     = nfs_permission,
        .getattr        = nfs_getattr,
        .setattr        = nfs_setattr,
@@ -3733,9 +3605,6 @@ const struct nfs_rpc_ops nfs_v4_clientops = {
        .lookup         = nfs4_proc_lookup,
        .access         = nfs4_proc_access,
        .readlink       = nfs4_proc_readlink,
-       .read           = nfs4_proc_read,
-       .write          = nfs4_proc_write,
-       .commit         = nfs4_proc_commit,
        .create         = nfs4_proc_create,
        .remove         = nfs4_proc_remove,
        .unlink_setup   = nfs4_proc_unlink_setup,