ALSA: hda - iMac9,1 sound fixes
[safe/jmp/linux-2.6] / fs / nfs / pagelist.c
index 68f6bf1..a3654e5 100644 (file)
@@ -58,19 +58,12 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
                   struct page *page,
                   unsigned int offset, unsigned int count)
 {
-       struct nfs_server *server = NFS_SERVER(inode);
        struct nfs_page         *req;
 
-       for (;;) {
-               /* try to allocate the request struct */
-               req = nfs_page_alloc();
-               if (req != NULL)
-                       break;
-
-               if (signalled() && (server->flags & NFS_MOUNT_INTR))
-                       return ERR_PTR(-ERESTARTSYS);
-               yield();
-       }
+       /* try to allocate the request struct */
+       req = nfs_page_alloc();
+       if (req == NULL)
+               return ERR_PTR(-ENOMEM);
 
        /* Initialize the request struct. Initially, we assume a
         * long write-back delay. This will be adjusted in
@@ -111,13 +104,12 @@ void nfs_unlock_request(struct nfs_page *req)
  * nfs_set_page_tag_locked - Tag a request as locked
  * @req:
  */
-static int nfs_set_page_tag_locked(struct nfs_page *req)
+int nfs_set_page_tag_locked(struct nfs_page *req)
 {
-       struct nfs_inode *nfsi = NFS_I(req->wb_context->path.dentry->d_inode);
-
-       if (!nfs_lock_request(req))
+       if (!nfs_lock_request_dontget(req))
                return 0;
-       radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
+       if (req->wb_page != NULL)
+               radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
        return 1;
 }
 
@@ -126,30 +118,38 @@ static int nfs_set_page_tag_locked(struct nfs_page *req)
  */
 void nfs_clear_page_tag_locked(struct nfs_page *req)
 {
-       struct nfs_inode *nfsi = NFS_I(req->wb_context->path.dentry->d_inode);
-
        if (req->wb_page != NULL) {
-               spin_lock(&nfsi->req_lock);
+               struct inode *inode = req->wb_context->path.dentry->d_inode;
+               struct nfs_inode *nfsi = NFS_I(inode);
+
+               spin_lock(&inode->i_lock);
                radix_tree_tag_clear(&nfsi->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
-               spin_unlock(&nfsi->req_lock);
-       }
-       nfs_unlock_request(req);
+               nfs_unlock_request(req);
+               spin_unlock(&inode->i_lock);
+       } else
+               nfs_unlock_request(req);
 }
 
 /**
  * nfs_clear_request - Free up all resources allocated to the request
  * @req:
  *
- * Release page resources associated with a write request after it
- * has completed.
+ * Release page and open context resources associated with a read/write
+ * request after it has completed.
  */
 void nfs_clear_request(struct nfs_page *req)
 {
        struct page *page = req->wb_page;
+       struct nfs_open_context *ctx = req->wb_context;
+
        if (page != NULL) {
                page_cache_release(page);
                req->wb_page = NULL;
        }
+       if (ctx != NULL) {
+               put_nfs_open_context(ctx);
+               req->wb_context = NULL;
+       }
 }
 
 
@@ -163,9 +163,8 @@ static void nfs_free_request(struct kref *kref)
 {
        struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref);
 
-       /* Release struct file or cached credential */
+       /* Release struct file and open context */
        nfs_clear_request(req);
-       put_nfs_open_context(req->wb_context);
        nfs_page_free(req);
 }
 
@@ -174,43 +173,25 @@ void nfs_release_request(struct nfs_page *req)
        kref_put(&req->wb_kref, nfs_free_request);
 }
 
-static int nfs_wait_bit_interruptible(void *word)
+static int nfs_wait_bit_uninterruptible(void *word)
 {
-       int ret = 0;
-
-       if (signal_pending(current))
-               ret = -ERESTARTSYS;
-       else
-               schedule();
-       return ret;
+       io_schedule();
+       return 0;
 }
 
 /**
  * nfs_wait_on_request - Wait for a request to complete.
  * @req: request to wait upon.
  *
- * Interruptible by signals only if mounted with intr flag.
+ * Interruptible by fatal signals only.
  * The user is responsible for holding a count on the request.
  */
 int
 nfs_wait_on_request(struct nfs_page *req)
 {
-       struct rpc_clnt *clnt = NFS_CLIENT(req->wb_context->path.dentry->d_inode);
-       sigset_t oldmask;
-       int ret = 0;
-
-       if (!test_bit(PG_BUSY, &req->wb_flags))
-               goto out;
-       /*
-        * Note: the call to rpc_clnt_sigmask() suffices to ensure that we
-        *       are not interrupted if intr flag is not set
-        */
-       rpc_clnt_sigmask(clnt, &oldmask);
-       ret = out_of_line_wait_on_bit(&req->wb_flags, PG_BUSY,
-                       nfs_wait_bit_interruptible, TASK_INTERRUPTIBLE);
-       rpc_clnt_sigunmask(clnt, &oldmask);
-out:
-       return ret;
+       return wait_on_bit(&req->wb_flags, PG_BUSY,
+                       nfs_wait_bit_uninterruptible,
+                       TASK_UNINTERRUPTIBLE);
 }
 
 /**
@@ -390,7 +371,7 @@ void nfs_pageio_cond_complete(struct nfs_pageio_descriptor *desc, pgoff_t index)
  * If the number of requests is set to 0, the entire address_space
  * starting at index idx_start, is scanned.
  * The requests are *not* checked to ensure that they form a contiguous set.
- * You must be holding the inode's req_lock when calling this function
+ * You must be holding the inode's i_lock when calling this function
  */
 int nfs_scan_list(struct nfs_inode *nfsi,
                struct list_head *dst, pgoff_t idx_start,
@@ -420,6 +401,7 @@ int nfs_scan_list(struct nfs_inode *nfsi,
                                goto out;
                        idx_start = req->wb_index + 1;
                        if (nfs_set_page_tag_locked(req)) {
+                               kref_get(&req->wb_kref);
                                nfs_list_remove_request(req);
                                radix_tree_tag_clear(&nfsi->nfs_page_tree,
                                                req->wb_index, tag);
@@ -429,7 +411,8 @@ int nfs_scan_list(struct nfs_inode *nfsi,
                                        goto out;
                        }
                }
-
+               /* for latency reduction */
+               cond_resched_lock(&nfsi->vfs_inode.i_lock);
        }
 out:
        return res;
@@ -440,7 +423,7 @@ int __init nfs_init_nfspagecache(void)
        nfs_page_cachep = kmem_cache_create("nfs_page",
                                            sizeof(struct nfs_page),
                                            0, SLAB_HWCACHE_ALIGN,
-                                           NULL, NULL);
+                                           NULL);
        if (nfs_page_cachep == NULL)
                return -ENOMEM;