From patchwork Wed Aug 8 15:41:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 1301171 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id F0A5CDFF7B for ; Thu, 9 Aug 2012 14:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030517Ab2HIOnJ (ORCPT ); Thu, 9 Aug 2012 10:43:09 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:54248 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030385Ab2HIOnI (ORCPT ); Thu, 9 Aug 2012 10:43:08 -0400 Received: by pbbrr13 with SMTP id rr13so1006120pbb.19 for ; Thu, 09 Aug 2012 07:43:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=DzSJSEoxnDE35dC7HBHA3QWLj93sIyWa1TK4pq+7M50=; b=bUgJfjvAHMpV+yC3pCnfv1oO6E9+RnwWmoc8k728lEWgfD81lhRF9DsWzaq5awPZ9H BDwrq1ybg9VWKC/cRNh6mZJ1uG5Qf9P/UDl1Ruzqjvg8piWmA6LlE/F/mmeUfVtTEZLi J8fxAtO2OcT4CI/OVjKwJZifgQH3GxCTpIZguGWLgVcEy14HcpzRylyZ0+q71SdFXfnG RGcMqpRmu7kCMtMAXX1IY2rLLfbmAPRGUkbda+3yMttZlBXHPZ0uZpsWz9X5yeg0kw0g 1GcN4mmEu9bW+/F9HQecXKvhXxz3Kk54m94XxkokslBJ1qa912VwRv5XkwYkM5lUUbHw c24w== Received: by 10.68.235.236 with SMTP id up12mr4683910pbc.79.1344523388077; Thu, 09 Aug 2012 07:43:08 -0700 (PDT) Received: from debian-sid.localdomain ([123.115.212.137]) by mx.google.com with ESMTPS id ph1sm1264967pbb.45.2012.08.09.07.43.03 (version=SSLv3 cipher=OTHER); Thu, 09 Aug 2012 07:43:07 -0700 (PDT) From: Peng Tao To: Trond.Myklebust@netapp.com Cc: linux-nfs@vger.kernel.org, Andy Adamson , Peng Tao Subject: [PATCH-v2] NFSv41: fix DIO write_io calculation Date: Wed, 8 Aug 2012 23:41:25 +0800 Message-Id: <1344440485-2046-1-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.7.1.262.g5ef3d Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org pnfs_within_mdsthreshold() is called inside pg_init. We need to set read_io/write_io before that. Otherwise we fail pnfs_within_mdsthreshold() and IO goes to MDS. A simple test case: dd if=foo of=/mnt/pnfs/bar bs=10M count=1 oflag=direct Cc: Andy Adamson Signed-off-by: Peng Tao --- fs/nfs/direct.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 1ba385b..34a6282 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -463,10 +463,10 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, const struct iovec *iov, if (!is_sync_kiocb(iocb)) dreq->iocb = iocb; + NFS_I(inode)->read_io += iov_length(iov, nr_segs); result = nfs_direct_read_schedule_iovec(dreq, iov, nr_segs, pos, uio); if (!result) result = nfs_direct_wait(dreq); - NFS_I(inode)->read_io += result; out_release: nfs_direct_req_release(dreq); out: @@ -814,6 +814,7 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, get_dreq(dreq); atomic_inc(&inode->i_dio_count); + NFS_I(dreq->inode)->write_io += iov_length(iov, nr_segs); for (seg = 0; seg < nr_segs; seg++) { const struct iovec *vec = &iov[seg]; result = nfs_direct_write_schedule_segment(&desc, vec, pos, uio); @@ -825,7 +826,6 @@ static ssize_t nfs_direct_write_schedule_iovec(struct nfs_direct_req *dreq, pos += vec->iov_len; } nfs_pageio_complete(&desc); - NFS_I(dreq->inode)->write_io += desc.pg_bytes_written; /* * If no bytes were started, return the error, and let the