NFSv4.1/pNFS: Don't queue up a new commit if the layout segment is invalid
[linux-2.6-block.git] / fs / nfs / pnfs_nfs.c
index 24655b807d442596e14c360b29c81d4cedca9ef0..81ac6480f9e77d66d45ba966b31cb440f17f246a 100644 (file)
@@ -266,17 +266,14 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
                } else {
                        nfs_retry_commit(mds_pages, NULL, cinfo, 0);
                        pnfs_generic_retry_commit(cinfo, 0);
-                       cinfo->completion_ops->error_cleanup(NFS_I(inode));
                        return -ENOMEM;
                }
        }
 
        nreq += pnfs_generic_alloc_ds_commits(cinfo, &list);
 
-       if (nreq == 0) {
-               cinfo->completion_ops->error_cleanup(NFS_I(inode));
+       if (nreq == 0)
                goto out;
-       }
 
        atomic_add(nreq, &cinfo->mds->rpcs_out);
 
@@ -871,6 +868,11 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
        buckets = cinfo->ds->buckets;
        list = &buckets[ds_commit_idx].written;
        if (list_empty(list)) {
+               if (!pnfs_is_valid_lseg(lseg)) {
+                       spin_unlock(cinfo->lock);
+                       cinfo->completion_ops->resched_write(cinfo, req);
+                       return;
+               }
                /* Non-empty buckets hold a reference on the lseg.  That ref
                 * is normally transferred to the COMMIT call and released
                 * there.  It could also be released if the last req is pulled