From patchwork Thu Aug 23 16:27:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 1368141 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id D974D3FCAE for ; Thu, 23 Aug 2012 16:28:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752435Ab2HWQ2d (ORCPT ); Thu, 23 Aug 2012 12:28:33 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:45127 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751767Ab2HWQ2c (ORCPT ); Thu, 23 Aug 2012 12:28:32 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so1767813pbb.19 for ; Thu, 23 Aug 2012 09:28:32 -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:in-reply-to:references; bh=wfA93AtisJlmCiARzZFlZbRbX55tkrPSsLtiQ7e/mMI=; b=C1JjLn0QOsDg+OQK/gPukT8XvOOMaxLm/1uxncFF32Opy4L1LKYtvKOVo/PibCtBIk hXu2DPvDaq7AfuudZZ/d9SNx8McCS109sWijiNpffPNqOT1CABgpdyGK6TxYOOF28bpu tUg6TkKYKreCI35mtqihIjq4+7zZlNF/AFIXxCjRVW/h6uzk5HCuaegJRQjzDBD5SXbZ pMDqinQa0808WJZA7Hx5hf1cA2zjGh8nvVFxdePpabMV9KSwIqANDsa41TOIQJUkR/bt r3nUvE23G1SEgk+FWx1bJBkXP6gjbYE6fo188BD+qAgkIuvvrw4Ynk+JxG9WqdXca9q8 mxiA== Received: by 10.68.234.73 with SMTP id uc9mr5778444pbc.158.1345739312727; Thu, 23 Aug 2012 09:28:32 -0700 (PDT) Received: from debian-sid.localdomain ([123.118.157.62]) by mx.google.com with ESMTPS id kc7sm6325160pbb.5.2012.08.23.09.28.29 (version=SSLv3 cipher=OTHER); Thu, 23 Aug 2012 09:28:31 -0700 (PDT) From: Peng Tao To: Trond.Myklebust@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH-resend 1/6] NFSv41: fix DIO write_io calculation Date: Fri, 24 Aug 2012 00:27:48 +0800 Message-Id: <1345739273-2241-2-git-send-email-bergwolf@gmail.com> X-Mailer: git-send-email 1.7.1.262.g5ef3d In-Reply-To: <1345739273-2241-1-git-send-email-bergwolf@gmail.com> References: <1345739273-2241-1-git-send-email-bergwolf@gmail.com> 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 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