summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2012-12-14 09:16:19 +0100
committerJens Axboe <axboe@kernel.dk>2012-12-14 13:28:12 +0100
commit60fd4662d1fa4de6cf6ca28f2b69eeed6bf75f6a (patch)
tree599e004d2ecfbd02ba1077e99546776448687b56
parent8a2b425ef7a436674eba4baab9322f45b657a6b5 (diff)
fs: only inc/dec inode->i_dio_count for file systemsaio-dio-3.7
We don't need truncate protection for block devices, so add a flag bypassing this cache line dirtying for every IO. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--fs/block_dev.c3
-rw-r--r--fs/direct-io.c12
-rw-r--r--fs/inode.c7
-rw-r--r--include/linux/fs.h4
4 files changed, 21 insertions, 5 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index ab3a456f6650..c854484b23a8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -164,7 +164,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov,
struct inode *inode = file->f_mapping->host;
return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset,
- nr_segs, blkdev_get_block, NULL, NULL, 0);
+ nr_segs, blkdev_get_block, NULL, NULL,
+ DIO_IGNORE_TRUNCATE);
}
int __sync_blockdev(struct block_device *bdev, int wait)
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 556ad359a2ef..d5594da84e5d 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -268,7 +268,10 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret, bool is
} else {
if (is_async)
aio_complete(dio->iocb, ret, 0);
- inode_dio_done(dio->inode);
+ if (dio->flags & DIO_IGNORE_TRUNCATE)
+ __inode_dio_done(dio->inode);
+ else
+ inode_dio_done(dio->inode);
}
return ret;
@@ -1125,9 +1128,12 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
}
/*
- * Will be decremented at I/O completion time.
+ * Will be decremented at I/O completion time. For a block device
+ * we don't need to protect against truncate, so don't increment
+ * the inode direct IO count.
*/
- atomic_inc(&inode->i_dio_count);
+ if (!(dio->flags & DIO_IGNORE_TRUNCATE))
+ atomic_inc(&inode->i_dio_count);
/*
* For file extending writes updating i_size before data
diff --git a/fs/inode.c b/fs/inode.c
index 64999f144153..dd5fc965b11f 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1888,6 +1888,11 @@ void inode_dio_wait(struct inode *inode)
}
EXPORT_SYMBOL(inode_dio_wait);
+void __inode_dio_done(struct inode *inode)
+{
+ wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
+}
+
/*
* inode_dio_done - signal finish of a direct I/O requests
* @inode: inode the direct I/O happens on
@@ -1898,6 +1903,6 @@ EXPORT_SYMBOL(inode_dio_wait);
void inode_dio_done(struct inode *inode)
{
if (atomic_dec_and_test(&inode->i_dio_count))
- wake_up_bit(&inode->i_state, __I_DIO_WAKEUP);
+ __inode_dio_done(inode);
}
EXPORT_SYMBOL(inode_dio_done);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 75fe9a134803..4da47e5c0009 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2428,6 +2428,9 @@ enum {
/* filesystem does not support filling holes */
DIO_SKIP_HOLES = 0x02,
+
+ /* inode/fs/bdev does not need truncate protection */
+ DIO_IGNORE_TRUNCATE = 0x04,
};
void dio_end_io(struct bio *bio, int error);
@@ -2448,6 +2451,7 @@ static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
#endif
void inode_dio_wait(struct inode *inode);
+void __inode_dio_done(struct inode *inode);
void inode_dio_done(struct inode *inode);
extern const struct file_operations generic_ro_fops;