]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/smbfs/file.c
[Bluetooth] Add generic driver for Bluetooth USB devices
[linux-2.6-omap-h63xx.git] / fs / smbfs / file.c
index f161797160c41a591e4de16913b2efe4cea36072..f5d14cebc75a5141a3eaf8f85a918fae9f82e913 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/pagemap.h>
 #include <linux/smp_lock.h>
 #include <linux/net.h>
+#include <linux/aio.h>
 
 #include <asm/uaccess.h>
 #include <asm/system.h>
@@ -261,8 +262,9 @@ 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;
@@ -276,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;
 }
@@ -290,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(mapping, index);
+       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,
 };
 
 /* 
@@ -415,7 +433,7 @@ const struct file_operations smb_file_operations =
        .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 =