From d82376b374fc5594f7645a380e93f4cc485cbf96 Mon Sep 17 00:00:00 2001 From: Marco Stornelli Date: Sat, 15 Dec 2012 11:45:14 +0100 Subject: [PATCH] --- yaml --- r: 347792 b: refs/heads/master c: 83f6e3710a932d400100767ad445a4bd9476e083 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/ufs/inode.c | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 51543b688bd7..7d48949856f6 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 72651cac884b1e285fa8e8314b10e9f1b8458802 +refs/heads/master: 83f6e3710a932d400100767ad445a4bd9476e083 diff --git a/trunk/fs/ufs/inode.c b/trunk/fs/ufs/inode.c index eb6d0b7dc879..ff24e4449ece 100644 --- a/trunk/fs/ufs/inode.c +++ b/trunk/fs/ufs/inode.c @@ -526,6 +526,14 @@ int ufs_prepare_chunk(struct page *page, loff_t pos, unsigned len) return __block_write_begin(page, pos, len, ufs_getfrag_block); } +static void ufs_write_failed(struct address_space *mapping, loff_t to) +{ + struct inode *inode = mapping->host; + + if (to > inode->i_size) + truncate_pagecache(inode, to, inode->i_size); +} + static int ufs_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) @@ -534,11 +542,8 @@ static int ufs_write_begin(struct file *file, struct address_space *mapping, ret = block_write_begin(mapping, pos, len, flags, pagep, ufs_getfrag_block); - if (unlikely(ret)) { - loff_t isize = mapping->host->i_size; - if (pos + len > isize) - vmtruncate(mapping->host, isize); - } + if (unlikely(ret)) + ufs_write_failed(mapping, pos + len); return ret; }