]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/cifs/file.c
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik...
[linux-2.6-omap-h63xx.git] / fs / cifs / file.c
index 0f05cab5d24ad245ec6f42bf8efa7e44dad58bc2..a1265c9bfec0cb250196dd9acc60bb9a8de76a31 100644 (file)
@@ -1014,8 +1014,9 @@ static ssize_t cifs_write(struct file *file, const char *write_data,
        /* since the write may have blocked check these pointers again */
        if (file->f_path.dentry) {
                if (file->f_path.dentry->d_inode) {
-                       file->f_path.dentry->d_inode->i_ctime =
-                       file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;
+/*BB We could make this contingent on superblock ATIME flag too */
+/*                     file->f_path.dentry->d_inode->i_ctime =
+                       file->f_path.dentry->d_inode->i_mtime = CURRENT_TIME;*/
                        if (total_written > 0) {
                                if (*poffset > file->f_path.dentry->d_inode->i_size)
                                        i_size_write(file->f_path.dentry->d_inode,
@@ -1146,7 +1147,7 @@ static int cifs_writepages(struct address_space *mapping,
        pgoff_t end;
        pgoff_t index;
        int range_whole = 0;
-       struct kvec iov[32];
+       struct kvec * iov;
        int len;
        int n_iov = 0;
        pgoff_t next;
@@ -1171,15 +1172,21 @@ static int cifs_writepages(struct address_space *mapping,
        if((cifs_sb->tcon->ses) && (cifs_sb->tcon->ses->server))
                if(cifs_sb->tcon->ses->server->secMode &
                           (SECMODE_SIGN_REQUIRED | SECMODE_SIGN_ENABLED))
-                       if(!experimEnabled)
+                       if(!experimEnabled) 
                                return generic_writepages(mapping, wbc);
 
+       iov = kmalloc(32 * sizeof(struct kvec), GFP_KERNEL);
+       if(iov == NULL)
+               return generic_writepages(mapping, wbc);
+
+
        /*
         * BB: Is this meaningful for a non-block-device file system?
         * If it is, we should test it again after we do I/O
         */
        if (wbc->nonblocking && bdi_write_congested(bdi)) {
                wbc->encountered_congestion = 1;
+               kfree(iov);
                return 0;
        }
 
@@ -1245,14 +1252,21 @@ retry:
                                wait_on_page_writeback(page);
 
                        if (PageWriteback(page) ||
-                                       !test_clear_page_dirty(page)) {
+                                       !clear_page_dirty_for_io(page)) {
                                unlock_page(page);
                                break;
                        }
 
+                       /*
+                        * This actually clears the dirty bit in the radix tree.
+                        * See cifs_writepage() for more commentary.
+                        */
+                       set_page_writeback(page);
+
                        if (page_offset(page) >= mapping->host->i_size) {
                                done = 1;
                                unlock_page(page);
+                               end_page_writeback(page);
                                break;
                        }
 
@@ -1316,6 +1330,7 @@ retry:
                                        SetPageError(page);
                                kunmap(page);
                                unlock_page(page);
+                               end_page_writeback(page);
                                page_cache_release(page);
                        }
                        if ((wbc->nr_to_write -= n_iov) <= 0)
@@ -1337,7 +1352,7 @@ retry:
                mapping->writeback_index = index;
 
        FreeXid(xid);
-
+       kfree(iov);
        return rc;
 }
 
@@ -1352,11 +1367,23 @@ static int cifs_writepage(struct page* page, struct writeback_control *wbc)
         if (!PageUptodate(page)) {
                cFYI(1, ("ppw - page not up to date"));
        }
-       
+
+       /*
+        * Set the "writeback" flag, and clear "dirty" in the radix tree.
+        *
+        * A writepage() implementation always needs to do either this,
+        * or re-dirty the page with "redirty_page_for_writepage()" in
+        * the case of a failure.
+        *
+        * Just unlocking the page will cause the radix tree tag-bits
+        * to fail to update with the state of the page correctly.
+        */
+       set_page_writeback(page);               
        rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE);
        SetPageUptodate(page); /* BB add check for error and Clearuptodate? */
        unlock_page(page);
-       page_cache_release(page);       
+       end_page_writeback(page);
+       page_cache_release(page);
        FreeXid(xid);
        return rc;
 }
@@ -1928,7 +1955,7 @@ static int cifs_readpage(struct file *file, struct page *page)
    refreshing the inode only on increases in the file size 
    but this is tricky to do without racing with writebehind
    page caching in the current Linux kernel design */
-int is_size_safe_to_change(struct cifsInodeInfo *cifsInode)
+int is_size_safe_to_change(struct cifsInodeInfo *cifsInode, __u64 end_of_file)
 {
        struct cifsFileInfo *open_file = NULL;
 
@@ -1950,6 +1977,9 @@ int is_size_safe_to_change(struct cifsInodeInfo *cifsInode)
                        return 1;
                }
 
+               if(i_size_read(&cifsInode->vfs_inode) < end_of_file)
+                       return 1;
+
                return 0;
        } else
                return 1;