From patchwork Mon Oct 17 17:18:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kani, Toshi" X-Patchwork-Id: 9380057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 34084607D4 for ; Mon, 17 Oct 2016 17:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D79028B4D for ; Mon, 17 Oct 2016 17:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 11DD528B56; Mon, 17 Oct 2016 17:20:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8FE0728B4D for ; Mon, 17 Oct 2016 17:20:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S937878AbcJQRUr (ORCPT ); Mon, 17 Oct 2016 13:20:47 -0400 Received: from g9t1613g.houston.hpe.com ([15.241.32.99]:59465 "EHLO g9t1613g.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S938589AbcJQRUp (ORCPT ); Mon, 17 Oct 2016 13:20:45 -0400 Received: from g2t2354.austin.hpe.com (g2t2354.austin.hpe.com [15.233.44.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g9t1613g.houston.hpe.com (Postfix) with ESMTPS id 4C49B6ABA9; Mon, 17 Oct 2016 17:20:43 +0000 (UTC) Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2354.austin.hpe.com (Postfix) with ESMTP id 2D3714D; Mon, 17 Oct 2016 17:20:41 +0000 (UTC) Received: from misato.fc.hp.com (misato.fc.hp.com [16.78.168.61]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 228EC36; Mon, 17 Oct 2016 17:20:39 +0000 (UTC) From: Toshi Kani To: akpm@linux-foundation.org, dan.j.williams@intel.com Cc: viro@zeniv.linux.org.uk, ross.zwisler@linux.intel.com, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Toshi Kani Subject: [PATCH v2] DAX: enable iostat for read/write Date: Mon, 17 Oct 2016 11:18:58 -0600 Message-Id: <1476724738-19133-1-git-send-email-toshi.kani@hpe.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP DAX IO path does not support iostat, but its metadata IO path does. Therefore, iostat shows metadata IO statistics only, which has been confusing to users. Add iostat support to the DAX read/write path. Note, iostat still does not support the DAX mmap path as it allows user applications to access directly. Signed-off-by: Toshi Kani Cc: Andrew Morton Cc: Alexander Viro Cc: Dan Williams Cc: Ross Zwisler --- v2: - Set a minimum of one sector (Dan Williams) --- fs/dax.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/dax.c b/fs/dax.c index 014defd..43e5e7a 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -144,6 +144,34 @@ static sector_t to_sector(const struct buffer_head *bh, return sector; } +static void dax_iostat_start(struct gendisk *disk, struct iov_iter *iter, + unsigned long *start) +{ + int rw = iov_iter_rw(iter); + int sec = iov_iter_count(iter) >> 9; + int cpu = part_stat_lock(); + + *start = jiffies; + part_round_stats(cpu, &disk->part0); + part_stat_inc(cpu, &disk->part0, ios[rw]); + part_stat_add(cpu, &disk->part0, sectors[rw], ((!sec) ? 1 : sec)); + part_inc_in_flight(&disk->part0, rw); + part_stat_unlock(); +} + +static void dax_iostat_end(struct gendisk *disk, struct iov_iter *iter, + unsigned long start) +{ + unsigned long duration = jiffies - start; + int rw = iov_iter_rw(iter); + int cpu = part_stat_lock(); + + part_stat_add(cpu, &disk->part0, ticks[rw], duration); + part_round_stats(cpu, &disk->part0); + part_dec_in_flight(&disk->part0, rw); + part_stat_unlock(); +} + static ssize_t dax_io(struct inode *inode, struct iov_iter *iter, loff_t start, loff_t end, get_block_t get_block, struct buffer_head *bh) @@ -265,9 +293,12 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, ssize_t retval = -EINVAL; loff_t pos = iocb->ki_pos; loff_t end = pos + iov_iter_count(iter); + struct gendisk *disk; + unsigned long start = 0; memset(&bh, 0, sizeof(bh)); bh.b_bdev = inode->i_sb->s_bdev; + disk = bh.b_bdev->bd_disk; if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) inode_lock(inode); @@ -276,8 +307,14 @@ ssize_t dax_do_io(struct kiocb *iocb, struct inode *inode, if (!(flags & DIO_SKIP_DIO_COUNT)) inode_dio_begin(inode); + if (blk_queue_io_stat(disk->queue)) + dax_iostat_start(disk, iter, &start); + retval = dax_io(inode, iter, pos, end, get_block, &bh); + if (start) + dax_iostat_end(disk, iter, start); + if ((flags & DIO_LOCKING) && iov_iter_rw(iter) == READ) inode_unlock(inode);