Merge branch 'sendmsg.cifs' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux-2.6-block.git] / fs / cifs / file.c
index 0f718679186e17577800404ba4bb2212b5d84c00..9793ae0bcaa2bc678f9a688c167ef2b091cc858f 100644 (file)
@@ -271,7 +271,7 @@ struct cifsFileInfo *
 cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
                  struct tcon_link *tlink, __u32 oplock)
 {
-       struct dentry *dentry = file->f_path.dentry;
+       struct dentry *dentry = file_dentry(file);
        struct inode *inode = d_inode(dentry);
        struct cifsInodeInfo *cinode = CIFS_I(inode);
        struct cifsFileInfo *cfile;
@@ -461,7 +461,7 @@ int cifs_open(struct inode *inode, struct file *file)
        tcon = tlink_tcon(tlink);
        server = tcon->ses->server;
 
-       full_path = build_path_from_dentry(file->f_path.dentry);
+       full_path = build_path_from_dentry(file_dentry(file));
        if (full_path == NULL) {
                rc = -ENOMEM;
                goto out;
@@ -1833,7 +1833,7 @@ refind_writable:
 static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
 {
        struct address_space *mapping = page->mapping;
-       loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
+       loff_t offset = (loff_t)page->index << PAGE_SHIFT;
        char *write_data;
        int rc = -EFAULT;
        int bytes_written = 0;
@@ -1849,7 +1849,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
        write_data = kmap(page);
        write_data += from;
 
-       if ((to > PAGE_CACHE_SIZE) || (from > to)) {
+       if ((to > PAGE_SIZE) || (from > to)) {
                kunmap(page);
                return -EIO;
        }
@@ -1902,7 +1902,7 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping,
         * find_get_pages_tag seems to return a max of 256 on each
         * iteration, so we must call it several times in order to
         * fill the array or the wsize is effectively limited to
-        * 256 * PAGE_CACHE_SIZE.
+        * 256 * PAGE_SIZE.
         */
        *found_pages = 0;
        pages = wdata->pages;
@@ -1991,7 +1991,7 @@ wdata_prepare_pages(struct cifs_writedata *wdata, unsigned int found_pages,
 
        /* put any pages we aren't going to use */
        for (i = nr_pages; i < found_pages; i++) {
-               page_cache_release(wdata->pages[i]);
+               put_page(wdata->pages[i]);
                wdata->pages[i] = NULL;
        }
 
@@ -2009,11 +2009,11 @@ wdata_send_pages(struct cifs_writedata *wdata, unsigned int nr_pages,
        wdata->sync_mode = wbc->sync_mode;
        wdata->nr_pages = nr_pages;
        wdata->offset = page_offset(wdata->pages[0]);
-       wdata->pagesz = PAGE_CACHE_SIZE;
+       wdata->pagesz = PAGE_SIZE;
        wdata->tailsz = min(i_size_read(mapping->host) -
                        page_offset(wdata->pages[nr_pages - 1]),
-                       (loff_t)PAGE_CACHE_SIZE);
-       wdata->bytes = ((nr_pages - 1) * PAGE_CACHE_SIZE) + wdata->tailsz;
+                       (loff_t)PAGE_SIZE);
+       wdata->bytes = ((nr_pages - 1) * PAGE_SIZE) + wdata->tailsz;
 
        if (wdata->cfile != NULL)
                cifsFileInfo_put(wdata->cfile);
@@ -2047,15 +2047,15 @@ static int cifs_writepages(struct address_space *mapping,
         * If wsize is smaller than the page cache size, default to writing
         * one page at a time via cifs_writepage
         */
-       if (cifs_sb->wsize < PAGE_CACHE_SIZE)
+       if (cifs_sb->wsize < PAGE_SIZE)
                return generic_writepages(mapping, wbc);
 
        if (wbc->range_cyclic) {
                index = mapping->writeback_index; /* Start from prev offset */
                end = -1;
        } else {
-               index = wbc->range_start >> PAGE_CACHE_SHIFT;
-               end = wbc->range_end >> PAGE_CACHE_SHIFT;
+               index = wbc->range_start >> PAGE_SHIFT;
+               end = wbc->range_end >> PAGE_SHIFT;
                if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
                        range_whole = true;
                scanned = true;
@@ -2071,7 +2071,7 @@ retry:
                if (rc)
                        break;
 
-               tofind = min((wsize / PAGE_CACHE_SIZE) - 1, end - index) + 1;
+               tofind = min((wsize / PAGE_SIZE) - 1, end - index) + 1;
 
                wdata = wdata_alloc_and_fillpages(tofind, mapping, end, &index,
                                                  &found_pages);
@@ -2111,7 +2111,7 @@ retry:
                                else
                                        SetPageError(wdata->pages[i]);
                                end_page_writeback(wdata->pages[i]);
-                               page_cache_release(wdata->pages[i]);
+                               put_page(wdata->pages[i]);
                        }
                        if (rc != -EAGAIN)
                                mapping_set_error(mapping, rc);
@@ -2154,7 +2154,7 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
 
        xid = get_xid();
 /* BB add check for wbc flags */
-       page_cache_get(page);
+       get_page(page);
        if (!PageUptodate(page))
                cifs_dbg(FYI, "ppw - page not up to date\n");
 
@@ -2170,7 +2170,7 @@ cifs_writepage_locked(struct page *page, struct writeback_control *wbc)
         */
        set_page_writeback(page);
 retry_write:
-       rc = cifs_partialpagewrite(page, 0, PAGE_CACHE_SIZE);
+       rc = cifs_partialpagewrite(page, 0, PAGE_SIZE);
        if (rc == -EAGAIN && wbc->sync_mode == WB_SYNC_ALL)
                goto retry_write;
        else if (rc == -EAGAIN)
@@ -2180,7 +2180,7 @@ retry_write:
        else
                SetPageUptodate(page);
        end_page_writeback(page);
-       page_cache_release(page);
+       put_page(page);
        free_xid(xid);
        return rc;
 }
@@ -2214,12 +2214,12 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
                if (copied == len)
                        SetPageUptodate(page);
                ClearPageChecked(page);
-       } else if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
+       } else if (!PageUptodate(page) && copied == PAGE_SIZE)
                SetPageUptodate(page);
 
        if (!PageUptodate(page)) {
                char *page_data;
-               unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
+               unsigned offset = pos & (PAGE_SIZE - 1);
                unsigned int xid;
 
                xid = get_xid();
@@ -2248,7 +2248,7 @@ static int cifs_write_end(struct file *file, struct address_space *mapping,
        }
 
        unlock_page(page);
-       page_cache_release(page);
+       put_page(page);
 
        return rc;
 }
@@ -2687,11 +2687,8 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from)
 out:
        inode_unlock(inode);
 
-       if (rc > 0) {
-               ssize_t err = generic_write_sync(file, iocb->ki_pos - rc, rc);
-               if (err < 0)
-                       rc = err;
-       }
+       if (rc > 0)
+               rc = generic_write_sync(iocb, rc);
        up_read(&cinode->lock_sem);
        return rc;
 }
@@ -3278,9 +3275,9 @@ cifs_readv_complete(struct work_struct *work)
                    (rdata->result == -EAGAIN && got_bytes))
                        cifs_readpage_to_fscache(rdata->mapping->host, page);
 
-               got_bytes -= min_t(unsigned int, PAGE_CACHE_SIZE, got_bytes);
+               got_bytes -= min_t(unsigned int, PAGE_SIZE, got_bytes);
 
-               page_cache_release(page);
+               put_page(page);
                rdata->pages[i] = NULL;
        }
        kref_put(&rdata->refcount, cifs_readdata_release);
@@ -3298,20 +3295,20 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
 
        /* determine the eof that the server (probably) has */
        eof = CIFS_I(rdata->mapping->host)->server_eof;
-       eof_index = eof ? (eof - 1) >> PAGE_CACHE_SHIFT : 0;
+       eof_index = eof ? (eof - 1) >> PAGE_SHIFT : 0;
        cifs_dbg(FYI, "eof=%llu eof_index=%lu\n", eof, eof_index);
 
        rdata->got_bytes = 0;
-       rdata->tailsz = PAGE_CACHE_SIZE;
+       rdata->tailsz = PAGE_SIZE;
        for (i = 0; i < nr_pages; i++) {
                struct page *page = rdata->pages[i];
-               size_t n = PAGE_CACHE_SIZE;
+               size_t n = PAGE_SIZE;
 
-               if (len >= PAGE_CACHE_SIZE) {
-                       len -= PAGE_CACHE_SIZE;
+               if (len >= PAGE_SIZE) {
+                       len -= PAGE_SIZE;
                } else if (len > 0) {
                        /* enough for partial page, fill and zero the rest */
-                       zero_user(page, len, PAGE_CACHE_SIZE - len);
+                       zero_user(page, len, PAGE_SIZE - len);
                        n = rdata->tailsz = len;
                        len = 0;
                } else if (page->index > eof_index) {
@@ -3323,12 +3320,12 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
                         * to prevent the VFS from repeatedly attempting to
                         * fill them until the writes are flushed.
                         */
-                       zero_user(page, 0, PAGE_CACHE_SIZE);
+                       zero_user(page, 0, PAGE_SIZE);
                        lru_cache_add_file(page);
                        flush_dcache_page(page);
                        SetPageUptodate(page);
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                        rdata->pages[i] = NULL;
                        rdata->nr_pages--;
                        continue;
@@ -3336,7 +3333,7 @@ cifs_readpages_read_into_pages(struct TCP_Server_Info *server,
                        /* no need to hold page hostage */
                        lru_cache_add_file(page);
                        unlock_page(page);
-                       page_cache_release(page);
+                       put_page(page);
                        rdata->pages[i] = NULL;
                        rdata->nr_pages--;
                        continue;
@@ -3383,8 +3380,8 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,
        }
 
        /* move first page to the tmplist */
-       *offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
-       *bytes = PAGE_CACHE_SIZE;
+       *offset = (loff_t)page->index << PAGE_SHIFT;
+       *bytes = PAGE_SIZE;
        *nr_pages = 1;
        list_move_tail(&page->lru, tmplist);
 
@@ -3396,7 +3393,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,
                        break;
 
                /* would this page push the read over the rsize? */
-               if (*bytes + PAGE_CACHE_SIZE > rsize)
+               if (*bytes + PAGE_SIZE > rsize)
                        break;
 
                __SetPageLocked(page);
@@ -3405,7 +3402,7 @@ readpages_get_pages(struct address_space *mapping, struct list_head *page_list,
                        break;
                }
                list_move_tail(&page->lru, tmplist);
-               (*bytes) += PAGE_CACHE_SIZE;
+               (*bytes) += PAGE_SIZE;
                expected_index++;
                (*nr_pages)++;
        }
@@ -3474,7 +3471,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                 * reach this point however since we set ra_pages to 0 when the
                 * rsize is smaller than a cache page.
                 */
-               if (unlikely(rsize < PAGE_CACHE_SIZE)) {
+               if (unlikely(rsize < PAGE_SIZE)) {
                        add_credits_and_wake_if(server, credits, 0);
                        return 0;
                }
@@ -3493,7 +3490,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                                list_del(&page->lru);
                                lru_cache_add_file(page);
                                unlock_page(page);
-                               page_cache_release(page);
+                               put_page(page);
                        }
                        rc = -ENOMEM;
                        add_credits_and_wake_if(server, credits, 0);
@@ -3505,7 +3502,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                rdata->offset = offset;
                rdata->bytes = bytes;
                rdata->pid = pid;
-               rdata->pagesz = PAGE_CACHE_SIZE;
+               rdata->pagesz = PAGE_SIZE;
                rdata->read_into_pages = cifs_readpages_read_into_pages;
                rdata->credits = credits;
 
@@ -3523,7 +3520,7 @@ static int cifs_readpages(struct file *file, struct address_space *mapping,
                                page = rdata->pages[i];
                                lru_cache_add_file(page);
                                unlock_page(page);
-                               page_cache_release(page);
+                               put_page(page);
                        }
                        /* Fallback to the readpage in error/reconnect cases */
                        kref_put(&rdata->refcount, cifs_readdata_release);
@@ -3558,7 +3555,7 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
        read_data = kmap(page);
        /* for reads over a certain size could initiate async read ahead */
 
-       rc = cifs_read(file, read_data, PAGE_CACHE_SIZE, poffset);
+       rc = cifs_read(file, read_data, PAGE_SIZE, poffset);
 
        if (rc < 0)
                goto io_error;
@@ -3568,8 +3565,8 @@ static int cifs_readpage_worker(struct file *file, struct page *page,
        file_inode(file)->i_atime =
                current_fs_time(file_inode(file)->i_sb);
 
-       if (PAGE_CACHE_SIZE > rc)
-               memset(read_data + rc, 0, PAGE_CACHE_SIZE - rc);
+       if (PAGE_SIZE > rc)
+               memset(read_data + rc, 0, PAGE_SIZE - rc);
 
        flush_dcache_page(page);
        SetPageUptodate(page);
@@ -3589,7 +3586,7 @@ read_complete:
 
 static int cifs_readpage(struct file *file, struct page *page)
 {
-       loff_t offset = (loff_t)page->index << PAGE_CACHE_SHIFT;
+       loff_t offset = (loff_t)page->index << PAGE_SHIFT;
        int rc = -EACCES;
        unsigned int xid;
 
@@ -3660,8 +3657,8 @@ static int cifs_write_begin(struct file *file, struct address_space *mapping,
                        struct page **pagep, void **fsdata)
 {
        int oncethru = 0;
-       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
-       loff_t offset = pos & (PAGE_CACHE_SIZE - 1);
+       pgoff_t index = pos >> PAGE_SHIFT;
+       loff_t offset = pos & (PAGE_SIZE - 1);
        loff_t page_start = pos & PAGE_MASK;
        loff_t i_size;
        struct page *page;
@@ -3684,7 +3681,7 @@ start:
         * the server. If the write is short, we'll end up doing a sync write
         * instead.
         */
-       if (len == PAGE_CACHE_SIZE)
+       if (len == PAGE_SIZE)
                goto out;
 
        /*
@@ -3699,7 +3696,7 @@ start:
                    (offset == 0 && (pos + len) >= i_size)) {
                        zero_user_segments(page, 0, offset,
                                           offset + len,
-                                          PAGE_CACHE_SIZE);
+                                          PAGE_SIZE);
                        /*
                         * PageChecked means that the parts of the page
                         * to which we're not writing are considered up
@@ -3718,7 +3715,7 @@ start:
                 * do a sync write instead since PG_uptodate isn't set.
                 */
                cifs_readpage_worker(file, page, &page_start);
-               page_cache_release(page);
+               put_page(page);
                oncethru = 1;
                goto start;
        } else {
@@ -3745,7 +3742,7 @@ static void cifs_invalidate_page(struct page *page, unsigned int offset,
 {
        struct cifsInodeInfo *cifsi = CIFS_I(page->mapping->host);
 
-       if (offset == 0 && length == PAGE_CACHE_SIZE)
+       if (offset == 0 && length == PAGE_SIZE)
                cifs_fscache_invalidate_page(page, &cifsi->vfs_inode);
 }
 
@@ -3753,7 +3750,7 @@ static int cifs_launder_page(struct page *page)
 {
        int rc = 0;
        loff_t range_start = page_offset(page);
-       loff_t range_end = range_start + (loff_t)(PAGE_CACHE_SIZE - 1);
+       loff_t range_end = range_start + (loff_t)(PAGE_SIZE - 1);
        struct writeback_control wbc = {
                .sync_mode = WB_SYNC_ALL,
                .nr_to_write = 0,
@@ -3835,7 +3832,7 @@ void cifs_oplock_break(struct work_struct *work)
  * Direct IO is not yet supported in the cached mode. 
  */
 static ssize_t
-cifs_direct_io(struct kiocb *iocb, struct iov_iter *iter, loff_t pos)
+cifs_direct_io(struct kiocb *iocb, struct iov_iter *iter)
 {
         /*
          * FIXME