All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: linux-kernel@vger.kernel.org
Cc: hch@infradead.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH 05/11] direct-io: only inc/dec inode->i_dio_count for file systems
Date: Thu, 24 Oct 2013 10:46:00 +0100	[thread overview]
Message-ID: <20131024094600.GS14598@kernel.dk> (raw)
In-Reply-To: <1382606764-8309-6-git-send-email-axboe@kernel.dk>

On Thu, Oct 24 2013, Jens Axboe wrote:
> We don't need truncate protection for block devices, so add a flag
> bypassing this cache line dirtying twice for every IO. This easily
> contributes to 5-10% of the CPU time on high IOPS O_DIRECT testing.

There's a merge error in this patch, please find the correct one below.

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 1e86823..e20b7c1 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -172,7 +172,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 0e04142..acc1471 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -265,7 +265,11 @@ static ssize_t dio_complete(struct dio *dio, loff_t offset, ssize_t ret,
 	if (dio->end_io && dio->result)
 		dio->end_io(dio->iocb, offset, transferred, dio->private);
 
-	inode_dio_done(dio->inode);
+	if (dio->flags & DIO_IGNORE_TRUNCATE)
+		__inode_dio_done(dio->inode);
+	else
+		inode_dio_done(dio->inode);
+
 	if (is_async) {
 		if (dio->rw & WRITE) {
 			int err;
@@ -1223,9 +1227,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);
 
 	retval = 0;
 	sdio.blkbits = blkbits;
diff --git a/fs/inode.c b/fs/inode.c
index b33ba8e..22319db 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -1854,6 +1854,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
@@ -1864,6 +1869,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 3f40547..d90a688 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2468,6 +2468,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);
@@ -2488,6 +2491,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;

-- 
Jens Axboe


  reply	other threads:[~2013-10-24  9:46 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-24  9:25 Jens Axboe
2013-10-24  9:25 ` [PATCH 01/11] Export __smp_call_function_single() Jens Axboe
2013-10-24  9:50   ` Christoph Hellwig
2013-10-24 10:16     ` Jens Axboe
2013-10-24 12:50       ` Christoph Hellwig
2013-10-25 10:21   ` Ingo Molnar
2013-10-25 10:44     ` Jens Axboe
2013-10-25 10:45       ` Ingo Molnar
2013-10-24  9:25 ` [PATCH 02/11] smp: don't warn about csd->flags having CSD_FLAG_LOCK cleared for !wait Jens Axboe
2013-10-24  9:39   ` Christoph Hellwig
2013-10-24  9:25 ` [PATCH 03/11] block: make rq->cmd_flags be 64-bit Jens Axboe
2013-10-24  9:40   ` Christoph Hellwig
2013-10-24  9:25 ` [PATCH 04/11] block: remove request ref_count Jens Axboe
2013-10-24  9:25 ` [PATCH 05/11] direct-io: only inc/dec inode->i_dio_count for file systems Jens Axboe
2013-10-24  9:46   ` Jens Axboe [this message]
2013-10-24  9:47     ` Christoph Hellwig
2013-10-24  9:49       ` Jens Axboe
2015-02-05 16:54         ` Mike Snitzer
2013-10-24  9:25 ` [PATCH 06/11] percpu_counter: make APIs irq safe Jens Axboe
2013-10-24  9:26 ` [PATCH 07/11] percpu_ida: make percpu_ida percpu size/batch configurable Jens Axboe
2013-10-24  9:26 ` [PATCH 08/11] percpu_ida: add percpu_ida_for_each_free Jens Axboe
2013-10-24  9:26 ` [PATCH 09/11] percpu_ida: add an API to return free tags Jens Axboe
2013-10-24  9:26 ` [PATCH 10/11] blk-mq: new multi-queue block IO queueing mechanism Jens Axboe
2013-10-24  9:39   ` Dave Jones
2013-10-24  9:50     ` Jens Axboe
2013-10-24  9:51   ` Christoph Hellwig
2013-10-24  9:26 ` [PATCH 11/11] null_blk: multi queue aware block test driver Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131024094600.GS14598@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.