From patchwork Thu Aug 14 21:39:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 4725551 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4F2B9F402 for ; Thu, 14 Aug 2014 21:40:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FA812013A for ; Thu, 14 Aug 2014 21:40:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3C94E201DE for ; Thu, 14 Aug 2014 21:40:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932081AbaHNVjo (ORCPT ); Thu, 14 Aug 2014 17:39:44 -0400 Received: from mail-ig0-f180.google.com ([209.85.213.180]:39926 "EHLO mail-ig0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755037AbaHNVjl (ORCPT ); Thu, 14 Aug 2014 17:39:41 -0400 Received: by mail-ig0-f180.google.com with SMTP id l13so221038iga.1 for ; Thu, 14 Aug 2014 14:39:41 -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:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=xQ/WR7vGhyGdt3yxuViMcXUoM8aN/lxbLpnmd8qE6wM=; b=YJ1biE0xwn0Es6Z71iOmFtXYLY30ZUrCTULR8vvv4ugmGM9POhvWKN11vFlYyvG2tu bhhb0DmQKpaSMvViVefHrcj9gbxpjgdwE6HW7XsnyCtOhyDXN3Db7t1qq4IaosIQPueh 9Uuco2R6izkvQlX+Gre21aFZ3/SPV2XVBHpq8dQ02joU4rtVoSVs2inB/t/LEl2UUoIG FS55g/oGfSFdJIgnSFRmWS6sm2TQti76YKpdEus5H1fCE2RXaHaa0jwW2cmTiiwaudrF EIYSDJcz44rD9gRoTXMKogLYhmPAIypEtmGX10OaDM7fOfv4fiWlWgtD6DeHXiZYzHGo bYTg== X-Gm-Message-State: ALoCoQkzF6ZNkkZ5SbPfnq/Kx9itvwZAHKfJfLqUvgOkPHRGZb+i/UXL/5ZM6oUy0KjIZsD9/32i X-Received: by 10.50.39.8 with SMTP id l8mr21025706igk.13.1408052380907; Thu, 14 Aug 2014 14:39:40 -0700 (PDT) Received: from gavrio-wifi.robotsandstuff.fake (c-98-209-19-144.hsd1.mi.comcast.net. [98.209.19.144]) by mx.google.com with ESMTPSA id qd8sm254789igb.1.2014.08.14.14.39.40 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 14 Aug 2014 14:39:40 -0700 (PDT) From: Weston Andros Adamson To: linux-nfs@vger.kernel.org Cc: Weston Andros Adamson Subject: [PATCH 2/2] nfs: can_coalesce_requests must enforce contiguity Date: Thu, 14 Aug 2014 17:39:33 -0400 Message-Id: <1408052373-4306-3-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1408052373-4306-1-git-send-email-dros@primarydata.com> References: <1408052373-4306-1-git-send-email-dros@primarydata.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 Commit 6094f83864c1d1296566a282cba05ba613f151ee "nfs: allow coalescing of subpage requests" got rid of the requirement that requests cover whole pages, but it made some incorrect assumptions. It turns out that callers of this interface can map adjacent requests (by file position as seen by req_offset + req->wb_bytes) to different pages, even when they could share a page. An example is the direct I/O interface - iov_iter_get_pages_alloc may return one segment with a partial page filled and the next segment (which is adjacent in the file position) starts with a new page. Reported-by: Toralf Förster Signed-off-by: Weston Andros Adamson --- fs/nfs/pagelist.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 73476df..d512887 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -836,6 +836,14 @@ static bool nfs_can_coalesce_requests(struct nfs_page *prev, return false; if (req_offset(req) != req_offset(prev) + prev->wb_bytes) return false; + if (req->wb_page == prev->wb_page) { + if (req->wb_pgbase != prev->wb_pgbase + prev->wb_bytes) + return false; + } else { + if (req->wb_pgbase != 0 || + prev->wb_pgbase + prev->wb_bytes != PAGE_CACHE_SIZE) + return false; + } } size = pgio->pg_ops->pg_test(pgio, prev, req); WARN_ON_ONCE(size > req->wb_bytes);