From patchwork Fri Jul 11 14:20:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 4534951 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 35D72BEEAA for ; Fri, 11 Jul 2014 14:21:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B56452017A for ; Fri, 11 Jul 2014 14:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D53E920176 for ; Fri, 11 Jul 2014 14:21:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754832AbaGKOU6 (ORCPT ); Fri, 11 Jul 2014 10:20:58 -0400 Received: from mail-ig0-f174.google.com ([209.85.213.174]:63770 "EHLO mail-ig0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754113AbaGKOU5 (ORCPT ); Fri, 11 Jul 2014 10:20:57 -0400 Received: by mail-ig0-f174.google.com with SMTP id c1so4305107igq.13 for ; Fri, 11 Jul 2014 07:20:56 -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; bh=jrHHq+qIGd4gs/b7xpMKkDNoyecpXQo/Jp2s2mP/4LI=; b=YOQXooJeSNOD13fgiH1bNDR4it59J7eK9t8Zm/5RZ8eCICwCq06tli+Oky9MAFF+j4 5QMOOy8con48f9TbTXXCAmfR/2viCynpVrag6oi+oUvTUKq0UBaM17MJ7t22vDZPg7qF MO/lqMlU2V+1+XRljbc72Ob7F7MQZ4qzYwLtzjyulbr/Steft1WCtgz/1Q8aaps1lDqr Tzc4BhulawOy8QoImLRxYNtmE4xHh9aIQyKh4zQvhDP9AYPdeJXpoiqP8m7DtOsCojLf dS3Ix7M927mqDnkZF40TFdJfRen8MAEH0J/bRr+6V6aTCMTab0mtSfWI/42w9UAMaaU9 p3gw== X-Gm-Message-State: ALoCoQl3/BRwIK+JXez5wM558Lx0ToQGsfbpZi/IOPaekegzjl3/27zt0cP8Re14BFYv4IPyqean X-Received: by 10.50.114.226 with SMTP id jj2mr4854371igb.27.1405088456620; Fri, 11 Jul 2014 07:20:56 -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 v6sm6334244igz.21.2014.07.11.07.20.55 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 11 Jul 2014 07:20:56 -0700 (PDT) From: Weston Andros Adamson To: trond.myklebust@primarydata.com Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson Subject: [PATCH 5/5] nfs: handle multiple reqs in nfs_wb_page_cancel Date: Fri, 11 Jul 2014 10:20:49 -0400 Message-Id: <1405088449-11268-6-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 1.8.5.2 (Apple Git-48) In-Reply-To: <1405088449-11268-1-git-send-email-dros@primarydata.com> References: <1405088449-11268-1-git-send-email-dros@primarydata.com> 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.5 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 Use nfs_lock_and_join_requests to merge all subrequests into the head request - this cancels and dereferences all subrequests. Signed-off-by: Weston Andros Adamson --- fs/nfs/write.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 4dab432..dac9b31c 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1784,27 +1784,28 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) struct nfs_page *req; int ret = 0; - for (;;) { - wait_on_page_writeback(page); - req = nfs_page_find_head_request(page); - if (req == NULL) - break; - if (nfs_lock_request(req)) { - nfs_clear_request_commit(req); - nfs_inode_remove_request(req); - /* - * In case nfs_inode_remove_request has marked the - * page as being dirty - */ - cancel_dirty_page(page, PAGE_CACHE_SIZE); - nfs_unlock_and_release_request(req); - break; - } - ret = nfs_wait_on_request(req); - nfs_release_request(req); - if (ret < 0) - break; + wait_on_page_writeback(page); + + /* blocking call to cancel all requests and join to a single (head) + * request */ + req = nfs_lock_and_join_requests(page, false); + + if (IS_ERR(req)) { + ret = PTR_ERR(req); + } else if (req) { + /* all requests from this page have been cancelled by + * nfs_lock_and_join_requests, so just remove the head + * request from the inode / page_private pointer and + * release it */ + nfs_inode_remove_request(req); + /* + * In case nfs_inode_remove_request has marked the + * page as being dirty + */ + cancel_dirty_page(page, PAGE_CACHE_SIZE); + nfs_unlock_and_release_request(req); } + return ret; }