drop unused dentry argument to ->fsync
[safe/jmp/linux-2.6] / fs / smbfs / file.c
index aea3f8a..8e187a0 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/fcntl.h>
 #include <linux/stat.h>
 #include <linux/mm.h>
-#include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/net.h>
@@ -29,8 +28,9 @@
 #include "proto.h"
 
 static int
-smb_fsync(struct file *file, struct dentry * dentry, int datasync)
+smb_fsync(struct file *file, int datasync)
 {
+       struct dentry *dentry = file->f_path.dentry;
        struct smb_sb_info *server = server_from_dentry(dentry);
        int result;
 
@@ -234,7 +234,7 @@ smb_file_aio_read(struct kiocb *iocb, const struct iovec *iov,
 
        VERBOSE("before read, size=%ld, flags=%x, atime=%ld\n",
                (long)dentry->d_inode->i_size,
-               dentry->d_inode->i_flags, dentry->d_inode->i_atime);
+               dentry->d_inode->i_flags, dentry->d_inode->i_atime.tv_sec);
 
        status = generic_file_aio_read(iocb, iov, nr_segs, pos);
 out:
@@ -262,13 +262,14 @@ out:
 }
 
 static ssize_t
-smb_file_sendfile(struct file *file, loff_t *ppos,
-                 size_t count, read_actor_t actor, void *target)
+smb_file_splice_read(struct file *file, loff_t *ppos,
+                    struct pipe_inode_info *pipe, size_t count,
+                    unsigned int flags)
 {
        struct dentry *dentry = file->f_path.dentry;
        ssize_t status;
 
-       VERBOSE("file %s/%s, pos=%Ld, count=%d\n",
+       VERBOSE("file %s/%s, pos=%Ld, count=%lu\n",
                DENTRY_PATH(dentry), *ppos, count);
 
        status = smb_revalidate_inode(dentry);
@@ -277,7 +278,7 @@ smb_file_sendfile(struct file *file, loff_t *ppos,
                         DENTRY_PATH(dentry), status);
                goto out;
        }
-       status = generic_file_sendfile(file, ppos, count, actor, target);
+       status = generic_file_splice_read(file, ppos, pipe, count, flags);
 out:
        return status;
 }
@@ -291,29 +292,45 @@ out:
  * If the writer ends up delaying the write, the writer needs to
  * increment the page use counts until he is done with the page.
  */
-static int smb_prepare_write(struct file *file, struct page *page, 
-                            unsigned offset, unsigned to)
+static int smb_write_begin(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned flags,
+                       struct page **pagep, void **fsdata)
 {
+       pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+       *pagep = grab_cache_page_write_begin(mapping, index, flags);
+       if (!*pagep)
+               return -ENOMEM;
        return 0;
 }
 
-static int smb_commit_write(struct file *file, struct page *page,
-                           unsigned offset, unsigned to)
+static int smb_write_end(struct file *file, struct address_space *mapping,
+                       loff_t pos, unsigned len, unsigned copied,
+                       struct page *page, void *fsdata)
 {
        int status;
+       unsigned offset = pos & (PAGE_CACHE_SIZE - 1);
 
-       status = -EFAULT;
        lock_kernel();
-       status = smb_updatepage(file, page, offset, to-offset);
+       status = smb_updatepage(file, page, offset, copied);
        unlock_kernel();
+
+       if (!status) {
+               if (!PageUptodate(page) && copied == PAGE_CACHE_SIZE)
+                       SetPageUptodate(page);
+               status = copied;
+       }
+
+       unlock_page(page);
+       page_cache_release(page);
+
        return status;
 }
 
 const struct address_space_operations smb_file_aops = {
        .readpage = smb_readpage,
        .writepage = smb_writepage,
-       .prepare_write = smb_prepare_write,
-       .commit_write = smb_commit_write
+       .write_begin = smb_write_begin,
+       .write_end = smb_write_end,
 };
 
 /* 
@@ -346,7 +363,8 @@ smb_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
                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);
+                       dentry->d_inode->i_mtime.tv_sec,
+                       dentry->d_inode->i_atime.tv_sec);
        }
 out:
        return result;
@@ -390,7 +408,7 @@ smb_file_release(struct inode *inode, struct file * file)
  * privileges, so we need our own check for this.
  */
 static int
-smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
+smb_file_permission(struct inode *inode, int mask)
 {
        int mode = inode->i_mode;
        int error = 0;
@@ -399,24 +417,33 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd)
 
        /* Look at user permissions */
        mode >>= 6;
-       if ((mode & 7 & mask) != mask)
+       if (mask & ~mode & (MAY_READ | MAY_WRITE | MAY_EXEC))
                error = -EACCES;
        return error;
 }
 
+static loff_t smb_remote_llseek(struct file *file, loff_t offset, int origin)
+{
+       loff_t ret;
+       lock_kernel();
+       ret = generic_file_llseek_unlocked(file, offset, origin);
+       unlock_kernel();
+       return ret;
+}
+
 const struct file_operations smb_file_operations =
 {
-       .llseek         = remote_llseek,
+       .llseek         = smb_remote_llseek,
        .read           = do_sync_read,
        .aio_read       = smb_file_aio_read,
        .write          = do_sync_write,
        .aio_write      = smb_file_aio_write,
-       .ioctl          = smb_ioctl,
+       .unlocked_ioctl = smb_ioctl,
        .mmap           = smb_file_mmap,
        .open           = smb_file_open,
        .release        = smb_file_release,
        .fsync          = smb_fsync,
-       .sendfile       = smb_file_sendfile,
+       .splice_read    = smb_file_splice_read,
 };
 
 const struct inode_operations smb_file_inode_operations =