From patchwork Wed Apr 8 12:24:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 6179111 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D8CD5BF4A6 for ; Wed, 8 Apr 2015 12:24:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 132B420376 for ; Wed, 8 Apr 2015 12:24:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6B10E202A1 for ; Wed, 8 Apr 2015 12:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753474AbbDHMY3 (ORCPT ); Wed, 8 Apr 2015 08:24:29 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:36073 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752835AbbDHMY2 (ORCPT ); Wed, 8 Apr 2015 08:24:28 -0400 Received: by pabsx10 with SMTP id sx10so113283564pab.3 for ; Wed, 08 Apr 2015 05:24:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IKmrYOWsJduixhn8HjCChDqrY3l7GdWaCKOQEA4SkhM=; b=IkLajA1+DYz+FyvuCLzuK4+MoRm9IKIFHB+gWF92AarGaYhMKqJVBi1u1kT0wehHhv NAeBnyoaJ3gvmApRAEvWekCEcmNWQHIZbdzGhG+gZo2DlIlDCGxrRM9Tz8home0QUrnE GJWaPPXhAwVXlZHswclkcbrIuQrCAXzSblvN4ZOAR0ksfwQzUsrhhekJ5ZhGsR2HyaKe kEjgotzvUhdK0VVRBh1bWkEVl1aH+l/yoWmShlW3ubkF7opnw6oPNJAVa6ZTIq/bw4BD oYJj9STL4xueFHld+E7bDGoUZmh15v4JYhRZ6ot0fIxI1RXx1jfIgW87IHmLkT4n8OVh FujA== X-Gm-Message-State: ALoCoQl1ufiUv57K7lwqqnoBVXz6djn4Nr1RnKOTFRznr/UjzXtFAjCaw0iJGhxfJtV/mmBUEYYD X-Received: by 10.70.45.16 with SMTP id i16mr15178470pdm.51.1428495868185; Wed, 08 Apr 2015 05:24:28 -0700 (PDT) Received: from localhost.localdomain (ec2-54-65-164-9.ap-northeast-1.compute.amazonaws.com. [54.65.164.9]) by mx.google.com with ESMTPSA id kq3sm10936815pbc.74.2015.04.08.05.24.24 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Apr 2015 05:24:27 -0700 (PDT) From: Peng Tao To: linux-nfs@vger.kernel.org Cc: Trond Myklebust , Peng Tao , Subject: [PATCH] nfs: fix DIO good bytes calculation Date: Wed, 8 Apr 2015 20:24:10 +0800 Message-Id: <1428495850-7136-1-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.9.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When adding completed bytes, we should just use hdr->good_bytes. Otherwise if we send multiple requests for one direct IO (due to rsize/wsize limitation), we'll count completed bytes incorrectly. This fixes 5fadeb47("nfs: count DIO good bytes correctly with mirroring"). Reported-by: Jean Spector Cc: # v3.19+ Signed-off-by: Peng Tao --- fs/nfs/direct.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index e907c8c..645109e 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -132,10 +132,8 @@ nfs_direct_good_bytes(struct nfs_direct_req *dreq, struct nfs_pgio_header *hdr) WARN_ON_ONCE(hdr->pgio_mirror_idx >= dreq->mirror_count); count = dreq->mirrors[hdr->pgio_mirror_idx].count; - if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) { - count = hdr->io_start + hdr->good_bytes - dreq->io_start; - dreq->mirrors[hdr->pgio_mirror_idx].count = count; - } + if (count + dreq->io_start < hdr->io_start + hdr->good_bytes) + dreq->mirrors[hdr->pgio_mirror_idx].count += hdr->good_bytes; /* update the dreq->count by finding the minimum agreed count from all * mirrors */