From ac7911292c4286d8a44cc9d6bb4ae7502c0ba3d3 Mon Sep 17 00:00:00 2001 From: Dmitri Monakhov Date: Tue, 6 Jan 2009 14:40:04 -0800 Subject: [PATCH] --- yaml --- r: 126235 b: refs/heads/master c: 0f64415d42760379753e6088787ce3fd3e069509 h: refs/heads/master i: 126233: 448bb75bd45cf54417749c0a512859537c02b233 126231: 70927c4a5657138164a4856e18f7620ba0380624 v: v3 --- [refs] | 2 +- trunk/fs/direct-io.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index 2b6c598ca82f..1bcb8840fb61 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 09f445e7f5107c91be12ed386350de6cd055e0a4 +refs/heads/master: 0f64415d42760379753e6088787ce3fd3e069509 diff --git a/trunk/fs/direct-io.c b/trunk/fs/direct-io.c index af0558dbe8b7..b6d43908ff7a 100644 --- a/trunk/fs/direct-io.c +++ b/trunk/fs/direct-io.c @@ -1209,6 +1209,19 @@ __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, retval = direct_io_worker(rw, iocb, inode, iov, offset, nr_segs, blkbits, get_block, end_io, dio); + /* + * In case of error extending write may have instantiated a few + * blocks outside i_size. Trim these off again for DIO_LOCKING. + * NOTE: DIO_NO_LOCK/DIO_OWN_LOCK callers have to handle this by + * it's own meaner. + */ + if (unlikely(retval < 0 && (rw & WRITE))) { + loff_t isize = i_size_read(inode); + + if (end > isize && dio_lock_type == DIO_LOCKING) + vmtruncate(inode, isize); + } + if (rw == READ && dio_lock_type == DIO_LOCKING) release_i_mutex = 0;