commit 43c70d84f283a98c683a05d397afbea3ce9d04fa
Author: Erez Zadok <[EMAIL PROTECTED]>
Date:   Tue Apr 15 20:04:08 2008 -0400

    Unionfs: implement sendfile directly
    
    Must implement sendfile, because we can no longer rely on
    generic_file_sendfile: it needs the ->readpage address_space_operation
    implemented, which we no longer have.
    
    Signed-off-by: Erez Zadok <[EMAIL PROTECTED]>

diff --git a/fs/unionfs/file.c b/fs/unionfs/file.c
index df3756e..f476c04 100644
--- a/fs/unionfs/file.c
+++ b/fs/unionfs/file.c
@@ -173,6 +173,41 @@ out:
        return err;
 }
 
+static ssize_t unionfs_sendfile(struct file *file, loff_t *ppos, size_t count,
+                               read_actor_t actor, void *target)
+{
+       ssize_t err;
+       struct file *lower_file;
+       struct dentry *dentry = file->f_dentry;
+
+       unionfs_read_lock(dentry->d_sb, UNIONFS_SMUTEX_PARENT);
+       unionfs_lock_dentry(dentry, UNIONFS_DMUTEX_CHILD);
+       err = unionfs_file_revalidate(file, false);
+       if (unlikely(err))
+               goto out;
+
+       lower_file = unionfs_lower_file(file);
+
+       if (!lower_file->f_op || !lower_file->f_op->sendfile) {
+               err = -EINVAL;
+               goto out;
+       }
+
+       err = lower_file->f_op->sendfile(lower_file, ppos, count,
+                                        actor, target);
+       /* update our inode atime upon a successful lower sendfile */
+       if (err >= 0) {
+               fsstack_copy_attr_atime(dentry->d_inode,
+                                       lower_file->f_dentry->d_inode);
+               unionfs_check_file(file);
+       }
+
+out:
+       unionfs_unlock_dentry(dentry);
+       unionfs_read_unlock(dentry->d_sb);
+       return err;
+}
+
 struct file_operations unionfs_main_fops = {
        .llseek         = generic_file_llseek,
        .read           = do_sync_read,
@@ -187,5 +222,5 @@ struct file_operations unionfs_main_fops = {
        .release        = unionfs_file_release,
        .fsync          = unionfs_fsync,
        .fasync         = unionfs_fasync,
-       .sendfile       = generic_file_sendfile,
+       .sendfile       = unionfs_sendfile,
 };
_______________________________________________
unionfs-cvs mailing list: http://unionfs.filesystems.org/
[email protected]
http://www.fsl.cs.sunysb.edu/mailman/listinfo/unionfs-cvs

Reply via email to