diff options
author | Jens Axboe <axboe@suse.de> | 2006-05-03 10:35:10 +0200 |
---|---|---|
committer | Jens Axboe <axboe@nelson.home.kernel.dk> | 2006-05-04 06:55:12 +0200 |
commit | bfc4ee39fdbb2deb8864785d5e5bc5cdd3b31a69 (patch) | |
tree | 6f5f678cd07a4c65c1e7ea78f911fdd0932b0c7e /fs/splice.c | |
parent | [PATCH] ext3: multile block allocate little endian fixes (diff) | |
download | linux-bfc4ee39fdbb2deb8864785d5e5bc5cdd3b31a69.tar.xz linux-bfc4ee39fdbb2deb8864785d5e5bc5cdd3b31a69.zip |
[PATCH] splice: fix unlocking of page on error ->prepare_write()
Looking at generic_file_buffered_write(), we need to unlock_page() if
prepare write fails and it isn't due to racing with truncate().
Also trim the size if ->prepare_write() fails, if we have to.
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'fs/splice.c')
-rw-r--r-- | fs/splice.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/fs/splice.c b/fs/splice.c index 7fb04970c72d..27f5e3738a7b 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -647,11 +647,24 @@ find_page: } ret = mapping->a_ops->prepare_write(file, page, offset, offset+this_len); - if (ret == AOP_TRUNCATED_PAGE) { + if (unlikely(ret)) { + loff_t isize = i_size_read(mapping->host); + + if (ret != AOP_TRUNCATED_PAGE) + unlock_page(page); page_cache_release(page); - goto find_page; - } else if (ret) + if (ret == AOP_TRUNCATED_PAGE) + goto find_page; + + /* + * prepare_write() may have instantiated a few blocks + * outside i_size. Trim these off again. + */ + if (sd->pos + this_len > isize) + vmtruncate(mapping->host, isize); + goto out; + } if (buf->page != page) { /* |