]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFS: Clean up - simplify nfs_lock_request()
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 9 May 2012 17:19:15 +0000 (13:19 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 9 May 2012 19:17:34 +0000 (15:17 -0400)
We only have two places where we need to grab a reference when trying
to lock the nfs_page. We're better off making that explicit.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: Fred Isaman <iisaman@netapp.com>
fs/nfs/direct.c
fs/nfs/write.c
include/linux/nfs_page.h

index 257d0091148b6b079ddc2204aa2138ace774a078..465ea84a2874f0cfc17736dbd4a1a4293e61ecb1 100644 (file)
@@ -657,6 +657,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_pageio_descriptor *d
                                break;
                        }
                        nfs_lock_request(req);
+                       kref_get(&req->wb_kref);
                        req->wb_index = pos >> PAGE_SHIFT;
                        req->wb_offset = pos & ~PAGE_MASK;
                        if (!nfs_pageio_add_request(desc, req)) {
index 83823294ffd25e8a1afefcc08594e4624bf24665..553f7ef1079bf16dcc6103cc7c2959d9e10ca8b1 100644 (file)
@@ -260,10 +260,10 @@ static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblo
                req = nfs_page_find_request_locked(page);
                if (req == NULL)
                        break;
-               if (nfs_lock_request_dontget(req))
+               if (nfs_lock_request(req))
                        break;
                /* Note: If we hold the page lock, as is the case in nfs_writepage,
-                *       then the call to nfs_lock_request_dontget() will always
+                *       then the call to nfs_lock_request() will always
                 *       succeed provided that someone hasn't already marked the
                 *       request as dirty (in which case we don't care).
                 */
@@ -406,7 +406,7 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req)
        struct nfs_inode *nfsi = NFS_I(inode);
 
        /* Lock the request! */
-       nfs_lock_request_dontget(req);
+       nfs_lock_request(req);
 
        spin_lock(&inode->i_lock);
        if (!nfsi->npages && nfs_have_delegation(inode, FMODE_WRITE))
@@ -651,6 +651,7 @@ nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
        list_for_each_entry_safe(req, tmp, src, wb_list) {
                if (!nfs_lock_request(req))
                        continue;
+               kref_get(&req->wb_kref);
                if (cond_resched_lock(cinfo->lock))
                        list_safe_reset_next(req, tmp, wb_list);
                nfs_request_remove_commit_list(req, cinfo);
@@ -741,7 +742,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,
                    || end < req->wb_offset)
                        goto out_flushme;
 
-               if (nfs_lock_request_dontget(req))
+               if (nfs_lock_request(req))
                        break;
 
                /* The request is locked, so wait and then retry */
@@ -1717,7 +1718,7 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page)
                req = nfs_page_find_request(page);
                if (req == NULL)
                        break;
-               if (nfs_lock_request_dontget(req)) {
+               if (nfs_lock_request(req)) {
                        nfs_clear_request_commit(req);
                        nfs_inode_remove_request(req);
                        /*
index ef7504215446e89bb69ebdc09847c22fc3d55b78..263f30a5e10de7d8698def328887be1696251d64 100644 (file)
@@ -99,24 +99,14 @@ extern      void nfs_unlock_request(struct nfs_page *req);
 extern void nfs_unlock_request_dont_release(struct nfs_page *req);
 
 /*
- * Lock the page of an asynchronous request without getting a new reference
+ * Lock the page of an asynchronous request
  */
-static inline int
-nfs_lock_request_dontget(struct nfs_page *req)
-{
-       return !test_and_set_bit(PG_BUSY, &req->wb_flags);
-}
-
 static inline int
 nfs_lock_request(struct nfs_page *req)
 {
-       if (test_and_set_bit(PG_BUSY, &req->wb_flags))
-               return 0;
-       kref_get(&req->wb_kref);
-       return 1;
+       return !test_and_set_bit(PG_BUSY, &req->wb_flags);
 }
 
-
 /**
  * nfs_list_add_request - Insert a request into a list
  * @req: request