fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / smbfs / file.c
index f1b17ac..e50533a 100644 (file)
@@ -78,7 +78,8 @@ smb_readpage_sync(struct dentry *dentry, struct page *page)
                count -= result;
                offset += result;
                buffer += result;
-               dentry->d_inode->i_atime = CURRENT_TIME;
+               dentry->d_inode->i_atime =
+                       current_fs_time(dentry->d_inode->i_sb);
                if (result < rsize)
                        break;
        } while (count);
@@ -101,7 +102,7 @@ static int
 smb_readpage(struct file *file, struct page *page)
 {
        int             error;
-       struct dentry  *dentry = file->f_dentry;
+       struct dentry  *dentry = file->f_path.dentry;
 
        page_cache_get(page);
        error = smb_readpage_sync(dentry, page);
@@ -152,7 +153,7 @@ smb_writepage_sync(struct inode *inode, struct page *page,
                /*
                 * Update the inode now rather than waiting for a refresh.
                 */
-               inode->i_mtime = inode->i_atime = CURRENT_TIME;
+               inode->i_mtime = inode->i_atime = current_fs_time(inode->i_sb);
                SMB_I(inode)->flags |= SMB_F_LOCALWRITE;
                if (offset > inode->i_size)
                        inode->i_size = offset;
@@ -177,11 +178,9 @@ smb_writepage(struct page *page, struct writeback_control *wbc)
        unsigned offset = PAGE_CACHE_SIZE;
        int err;
 
-       if (!mapping)
-               BUG();
+       BUG_ON(!mapping);
        inode = mapping->host;
-       if (!inode)
-               BUG();
+       BUG_ON(!inode);
 
        end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 
@@ -206,22 +205,24 @@ static int
 smb_updatepage(struct file *file, struct page *page, unsigned long offset,
               unsigned int count)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
 
-       DEBUG1("(%s/%s %d@%ld)\n", DENTRY_PATH(dentry), 
-              count, (page->index << PAGE_CACHE_SHIFT)+offset);
+       DEBUG1("(%s/%s %d@%lld)\n", DENTRY_PATH(dentry), count,
+               ((unsigned long long)page->index << PAGE_CACHE_SHIFT) + offset);
 
        return smb_writepage_sync(dentry->d_inode, page, offset, count);
 }
 
 static ssize_t
-smb_file_read(struct file * file, char * buf, size_t count, loff_t *ppos)
+smb_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
+                       unsigned long nr_segs, loff_t pos)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct file * file = iocb->ki_filp;
+       struct dentry * dentry = file->f_path.dentry;
        ssize_t status;
 
        VERBOSE("file %s/%s, count=%lu@%lu\n", DENTRY_PATH(dentry),
-               (unsigned long) count, (unsigned long) *ppos);
+               (unsigned long) iocb->ki_left, (unsigned long) pos);
 
        status = smb_revalidate_inode(dentry);
        if (status) {
@@ -234,7 +235,7 @@ smb_file_read(struct file * file, char * buf, size_t count, loff_t *ppos)
                (long)dentry->d_inode->i_size,
                dentry->d_inode->i_flags, dentry->d_inode->i_atime);
 
-       status = generic_file_read(file, buf, count, ppos);
+       status = generic_file_aio_read(iocb, iov, nr_segs, pos);
 out:
        return status;
 }
@@ -242,7 +243,7 @@ out:
 static int
 smb_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct dentry * dentry = file->f_path.dentry;
        int     status;
 
        VERBOSE("file %s/%s, address %lu - %lu\n",
@@ -261,9 +262,9 @@ out:
 
 static ssize_t
 smb_file_sendfile(struct file *file, loff_t *ppos,
-                 size_t count, read_actor_t actor, void __user *target)
+                 size_t count, read_actor_t actor, void *target)
 {
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        ssize_t status;
 
        VERBOSE("file %s/%s, pos=%Ld, count=%d\n",
@@ -271,7 +272,7 @@ smb_file_sendfile(struct file *file, loff_t *ppos,
 
        status = smb_revalidate_inode(dentry);
        if (status) {
-               PARANOIA("%s/%s validation failed, error=%zd\n",
+               PARANOIA("%s/%s validation failed, error=%Zd\n",
                         DENTRY_PATH(dentry), status);
                goto out;
        }
@@ -307,7 +308,7 @@ static int smb_commit_write(struct file *file, struct page *page,
        return status;
 }
 
-struct address_space_operations smb_file_aops = {
+const struct address_space_operations smb_file_aops = {
        .readpage = smb_readpage,
        .writepage = smb_writepage,
        .prepare_write = smb_prepare_write,
@@ -318,14 +319,16 @@ struct address_space_operations smb_file_aops = {
  * Write to a file (through the page cache).
  */
 static ssize_t
-smb_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
+smb_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
+                              unsigned long nr_segs, loff_t pos)
 {
-       struct dentry * dentry = file->f_dentry;
+       struct file * file = iocb->ki_filp;
+       struct dentry * dentry = file->f_path.dentry;
        ssize_t result;
 
        VERBOSE("file %s/%s, count=%lu@%lu\n",
                DENTRY_PATH(dentry),
-               (unsigned long) count, (unsigned long) *ppos);
+               (unsigned long) iocb->ki_left, (unsigned long) pos);
 
        result = smb_revalidate_inode(dentry);
        if (result) {
@@ -338,8 +341,8 @@ smb_file_write(struct file *file, const char *buf, size_t count, loff_t *ppos)
        if (result)
                goto out;
 
-       if (count > 0) {
-               result = generic_file_write(file, buf, count, ppos);
+       if (iocb->ki_left > 0) {
+               result = generic_file_aio_write(iocb, iov, nr_segs, pos);
                VERBOSE("pos=%ld, size=%ld, mtime=%ld, atime=%ld\n",
                        (long) file->f_pos, (long) dentry->d_inode->i_size,
                        dentry->d_inode->i_mtime, dentry->d_inode->i_atime);
@@ -352,7 +355,7 @@ static int
 smb_file_open(struct inode *inode, struct file * file)
 {
        int result;
-       struct dentry *dentry = file->f_dentry;
+       struct dentry *dentry = file->f_path.dentry;
        int smb_mode = (file->f_mode & O_ACCMODE) - 1;
 
        lock_kernel();
@@ -362,7 +365,7 @@ smb_file_open(struct inode *inode, struct file * file)
        SMB_I(inode)->openers++;
 out:
        unlock_kernel();
-       return 0;
+       return result;
 }
 
 static int
@@ -373,8 +376,7 @@ smb_file_release(struct inode *inode, struct file * file)
                /* We must flush any dirty pages now as we won't be able to
                   write anything after close. mmap can trigger this.
                   "openers" should perhaps include mmap'ers ... */
-               filemap_fdatawrite(inode->i_mapping);
-               filemap_fdatawait(inode->i_mapping);
+               filemap_write_and_wait(inode->i_mapping);
                smb_close(inode);
        }
        unlock_kernel();
@@ -401,11 +403,13 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
        return error;
 }
 
-struct file_operations smb_file_operations =
+const struct file_operations smb_file_operations =
 {
        .llseek         = remote_llseek,
-       .read           = smb_file_read,
-       .write          = smb_file_write,
+       .read           = do_sync_read,
+       .aio_read       = smb_file_aio_read,
+       .write          = do_sync_write,
+       .aio_write      = smb_file_aio_write,
        .ioctl          = smb_ioctl,
        .mmap           = smb_file_mmap,
        .open           = smb_file_open,