[CIFS] Fix cifs update of page cache. Write at correct offset when out of memory
[pandora-kernel.git] / fs / cifs / file.c
index 1df26dd..30ab70c 100644 (file)
@@ -512,7 +512,8 @@ int cifs_closedir(struct inode *inode, struct file *file)
                pTcon = cifs_sb->tcon;
 
                cFYI(1, ("Freeing private data in close dir"));
-               if (pCFileStruct->srch_inf.endOfSearch == FALSE) {
+               if ((pCFileStruct->srch_inf.endOfSearch == FALSE) &&
+                  (pCFileStruct->invalidHandle == FALSE)) {
                        pCFileStruct->invalidHandle = TRUE;
                        rc = CIFSFindClose(xid, pTcon, pCFileStruct->netfid);
                        cFYI(1, ("Closing uncompleted readdir with rc %d",
@@ -1351,6 +1352,8 @@ static void cifs_copy_cache_pages(struct address_space *mapping,
                                      GFP_KERNEL)) {
                        page_cache_release(page);
                        cFYI(1, ("Add page cache failed"));
+                       data += PAGE_CACHE_SIZE;
+                       bytes_read -= PAGE_CACHE_SIZE;
                        continue;
                }