Commit:     bcd4f3acbaec102e2b8000c977ecc38dcd0fe367
Parent:     56a68a500fcab9e3a9a49ca7fbef14230ab7d144
Author:     Jens Axboe <[EMAIL PROTECTED]>
AuthorDate: Mon Jul 16 14:41:49 2007 +0200
Committer:  Jens Axboe <[EMAIL PROTECTED]>
CommitDate: Mon Jul 16 15:02:48 2007 +0200

    splice: direct splicing updates ppos twice
    OGAWA Hirofumi <[EMAIL PROTECTED]> reported that he's noticed
    nfsd read corruption in recent kernels, and did the hard work of
    discovering that it's due to splice updating the file position twice.
    This means that the next operation would start further ahead than it
            while(len) {
                do_splice_to()                     [update sd->pos]
                    -> generic_file_splice_read()  [read from sd->pos]
                    -> __splice_from_pipe()        [update sd->pos]
    There's nothing wrong with the core splice code, but the direct
    splicing is an addon that calls both input and output paths.
    So it has to take care in locally caching offset so it remains correct.
    Signed-off-by: Jens Axboe <[EMAIL PROTECTED]>
 fs/splice.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/fs/splice.c b/fs/splice.c
index 6c98286..53fc208 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -1061,8 +1061,9 @@ ssize_t splice_direct_to_actor(struct file *in, struct 
splice_desc *sd,
        while (len) {
                size_t read_len;
+               loff_t pos = sd->pos;
-               ret = do_splice_to(in, &sd->pos, pipe, len, flags);
+               ret = do_splice_to(in, &pos, pipe, len, flags);
                if (unlikely(ret <= 0))
                        goto out_release;
@@ -1080,6 +1081,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct 
splice_desc *sd,
                bytes += ret;
                len -= ret;
+               sd->pos = pos;
                if (ret < read_len)
                        goto out_release;
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to