From patchwork Mon Sep 15 18:14:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 4907191 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 EC892BEEA5 for ; Mon, 15 Sep 2014 18:15:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F3D4320149 for ; Mon, 15 Sep 2014 18:15:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C218120219 for ; Mon, 15 Sep 2014 18:15:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754421AbaIOSO7 (ORCPT ); Mon, 15 Sep 2014 14:14:59 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:59585 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754418AbaIOSO5 (ORCPT ); Mon, 15 Sep 2014 14:14:57 -0400 Received: by mail-ie0-f170.google.com with SMTP id tp5so5136709ieb.1 for ; Mon, 15 Sep 2014 11:14: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=+3jJA+W8Ta0OQQqx2nr0WOUNS5+dwhrePpOOwLZPwWc=; b=mPMVCcsxsyOAktqcEmKwyudO5OLxFQvCP1Dol/092Wm/UIK5+PnMeNqi44NYJmNMJi sQ5bvoSvSaijejWoa8oy9a4K8YrjF9vA/wE/PR9CFFTzRvUWbl4dhth8KJWU6fkrESNc XTsH9rXX7tPuJPNParyx2PT5EfItbw8mMgVbj0H8c6LtfofSEiUfT8Bq2OirE5/gZGmH 1p2iqM3G36gFIZCA8FpuyGeQJ0hxqno3u9M91w3cqbAcPkl/e9VhNmyaqWFZt8NejiOf EjeWcmf1QJjMhXb7M4kzR+R6kZXKDWTaAygwjTy4jdUqjyvc+29lCAXAijG8c8DfirW9 pu+w== X-Gm-Message-State: ALoCoQkF1zpTlIetLxi6KvXAlVh9MrB0/AQvdt6NDWORhODldjtORKmZ4//ngDvf/YQCqTJjtttg X-Received: by 10.50.41.8 with SMTP id b8mr24423402igl.11.1410804896471; Mon, 15 Sep 2014 11:14:56 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (50-108-114-100.adr01.mskg.mi.frontiernet.net. [50.108.114.100]) by mx.google.com with ESMTPSA id ro6sm10736835igb.3.2014.09.15.11.14.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Sep 2014 11:14:55 -0700 (PDT) From: Trond Myklebust To: stable@vger.kernel.org Cc: Weston Andros Adamson , linux-nfs@vger.kernel.org Subject: [PATCH 07/14] nfs: clear_request_commit while holding i_lock Date: Mon, 15 Sep 2014 14:14:38 -0400 Message-Id: <1410804885-17228-8-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1410804885-17228-7-git-send-email-trond.myklebust@primarydata.com> References: <1410804885-17228-1-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-2-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-3-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-4-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-5-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-6-git-send-email-trond.myklebust@primarydata.com> <1410804885-17228-7-git-send-email-trond.myklebust@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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Weston Andros Adamson commit 411a99adffb4f993eee29759f744de01487044ac upstream. Signed-off-by: Weston Andros Adamson Signed-off-by: Trond Myklebust --- fs/nfs/filelayout/filelayout.c | 5 ++--- fs/nfs/write.c | 15 ++++----------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index 537e7f7a0b48..a596a1938b52 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c @@ -1015,6 +1015,7 @@ static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j) /* The generic layer is about to remove the req from the commit list. * If this will make the bucket empty, it will need to put the lseg reference. + * Note this is must be called holding the inode (/cinfo) lock */ static void filelayout_clear_request_commit(struct nfs_page *req, @@ -1022,7 +1023,6 @@ filelayout_clear_request_commit(struct nfs_page *req, { struct pnfs_layout_segment *freeme = NULL; - spin_lock(cinfo->lock); if (!test_and_clear_bit(PG_COMMIT_TO_DS, &req->wb_flags)) goto out; cinfo->ds->nwritten--; @@ -1037,8 +1037,7 @@ filelayout_clear_request_commit(struct nfs_page *req, } out: nfs_request_remove_commit_list(req, cinfo); - spin_unlock(cinfo->lock); - pnfs_put_lseg(freeme); + pnfs_put_lseg_async(freeme); } static struct list_head * diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 2ed54b224bf2..e3054af396e9 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -379,8 +379,6 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, subreq->wb_head = subreq; subreq->wb_this_page = subreq; - nfs_clear_request_commit(subreq); - /* subreq is now totally disconnected from page group or any * write / commit lists. last chance to wake any waiters */ nfs_unlock_request(subreq); @@ -490,7 +488,7 @@ try_again: * Commit list removal accounting is done after locks are dropped */ subreq = head; do { - nfs_list_remove_request(subreq); + nfs_clear_request_commit(subreq); subreq = subreq->wb_this_page; } while (subreq != head); @@ -520,15 +518,11 @@ try_again: nfs_page_group_unlock(head); - /* drop lock to clear_request_commit the head req and clean up - * requests on destroy list */ + /* drop lock to clean uprequests on destroy list */ spin_unlock(&inode->i_lock); nfs_destroy_unlinked_subrequests(destroy_list, head); - /* clean up commit list state */ - nfs_clear_request_commit(head); - /* still holds ref on head from nfs_page_find_head_request_locked * and still has lock on head from lock loop */ return head; @@ -810,6 +804,7 @@ nfs_clear_page_commit(struct page *page) dec_bdi_stat(page_file_mapping(page)->backing_dev_info, BDI_RECLAIMABLE); } +/* Called holding inode (/cinfo) lock */ static void nfs_clear_request_commit(struct nfs_page *req) { @@ -819,9 +814,7 @@ nfs_clear_request_commit(struct nfs_page *req) nfs_init_cinfo_from_inode(&cinfo, inode); if (!pnfs_clear_request_commit(req, &cinfo)) { - spin_lock(cinfo.lock); nfs_request_remove_commit_list(req, &cinfo); - spin_unlock(cinfo.lock); } nfs_clear_page_commit(req->wb_page); } @@ -1040,9 +1033,9 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode, else req->wb_bytes = rqend - req->wb_offset; out_unlock: - spin_unlock(&inode->i_lock); if (req) nfs_clear_request_commit(req); + spin_unlock(&inode->i_lock); return req; out_flushme: spin_unlock(&inode->i_lock);