From patchwork Thu Aug 3 13:45:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9879135 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 417C460360 for ; Thu, 3 Aug 2017 13:45:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 370DE28830 for ; Thu, 3 Aug 2017 13:45:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C15A288FC; Thu, 3 Aug 2017 13:45:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8C4928830 for ; Thu, 3 Aug 2017 13:45:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751884AbdHCNps (ORCPT ); Thu, 3 Aug 2017 09:45:48 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:33191 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbdHCNpq (ORCPT ); Thu, 3 Aug 2017 09:45:46 -0400 Received: by mail-io0-f193.google.com with SMTP id q64so1310629ioi.0 for ; Thu, 03 Aug 2017 06:45:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=lyRc6RrgFTFKSJ3anQX7I+CPgJ3qxgZV1A3e6dQxb+0=; b=Z/F6uN2Cb38NSUQXDW5arUsXKKj2nluvzBj72gwucO9ikH3jrxPgd4uJbDwyF+5fUP nOd7a+Ird3YovkOK1DpQsB0ENyCTwxpC3nPjtxR+eUnkOPExCa4AS73GiJwtVoUpwF1p J0eCq+OmS238cyTM0cEuPJ0adV6ibGXFOZzQQOtC8YdUo4cij279aoTnMUzeXzo/ojuj t7x23zqHucPJikjuCPB60d6lrF5NIb5BD2Vpjxg6L7Q6pf8Cm6cANWMPlD+VTZb27HYn pU89zxX8cZHC1hnUnUIqtObqJZiM7zkiX+z7nldcRnCz/O11VHx9KsS6jWtpDN7W3YUi 10EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=lyRc6RrgFTFKSJ3anQX7I+CPgJ3qxgZV1A3e6dQxb+0=; b=QfI4Qxon6DG8X7C62TRydaLbG2fdxHl9fyZfxtI93QUrSJN9yVAtM7myi4mvucpmvm eeBxXqVNXRMo9GCMj6KAnom2Tr6tW9/Typ28ov+k7x/Kxk16spfIee30TtwhFqRFeLPm mK0BSvUOXma8aiwDKxVU6A3vXd+qsInWXbX3FPzE8onp/c2ZdDyRMaMJ1cIeR9KMV6t+ Gx3O9jD+rMY89EazJWhHy2ZEKawC8jypnt/K4/7vqh2HXoMsbAu21y4YwPVn2cR4svum L1mHisFsH/9poZr1ZaD4M9Zr+YNh9qbNImiYbuUU9iDNaw0xfKo2igHTS2OYTjSHMiLB +2kQ== X-Gm-Message-State: AIVw112CFZ4R765c8dfgOZiLBeI5TkY+jP0w0SxMX/aWqJ5KoOYI1tah pCrW56d64nScNw== X-Received: by 10.107.55.66 with SMTP id e63mr1754443ioa.118.1501767945540; Thu, 03 Aug 2017 06:45:45 -0700 (PDT) Received: from localhost.localdomain (50-108-95-251.adr01.mskg.mi.frontiernet.net. [50.108.95.251]) by smtp.gmail.com with ESMTPSA id q90sm5759547ioi.41.2017.08.03.06.45.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 06:45:44 -0700 (PDT) From: Trond Myklebust To: Chuck Lever , linux-nfs@vger.kernel.org Subject: [PATCH v2 09/28] NFS: Fix the inode request accounting when pages have subrequests Date: Thu, 3 Aug 2017 09:45:04 -0400 Message-Id: <20170803134523.4922-10-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170803134523.4922-9-trond.myklebust@primarydata.com> References: <20170803134523.4922-1-trond.myklebust@primarydata.com> <20170803134523.4922-2-trond.myklebust@primarydata.com> <20170803134523.4922-3-trond.myklebust@primarydata.com> <20170803134523.4922-4-trond.myklebust@primarydata.com> <20170803134523.4922-5-trond.myklebust@primarydata.com> <20170803134523.4922-6-trond.myklebust@primarydata.com> <20170803134523.4922-7-trond.myklebust@primarydata.com> <20170803134523.4922-8-trond.myklebust@primarydata.com> <20170803134523.4922-9-trond.myklebust@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Both nfs_destroy_unlinked_subrequests() and nfs_lock_and_join_requests() manipulate the inode flags adjusting the NFS_I(inode)->nrequests. Signed-off-by: Trond Myklebust --- fs/nfs/write.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index bb38c881fc48..ee981353d4aa 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -418,7 +418,8 @@ nfs_unroll_locks_and_wait(struct inode *inode, struct nfs_page *head, */ static void nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, - struct nfs_page *old_head) + struct nfs_page *old_head, + struct inode *inode) { while (destroy_list) { struct nfs_page *subreq = destroy_list; @@ -443,9 +444,12 @@ nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, nfs_page_group_clear_bits(subreq); /* release the PG_INODE_REF reference */ - if (test_and_clear_bit(PG_INODE_REF, &subreq->wb_flags)) + if (test_and_clear_bit(PG_INODE_REF, &subreq->wb_flags)) { nfs_release_request(subreq); - else + spin_lock(&inode->i_lock); + NFS_I(inode)->nrequests--; + spin_unlock(&inode->i_lock); + } else WARN_ON_ONCE(1); } else { WARN_ON_ONCE(test_bit(PG_CLEAN, &subreq->wb_flags)); @@ -572,25 +576,24 @@ nfs_lock_and_join_requests(struct page *page) head->wb_bytes = total_bytes; } + /* Postpone destruction of this request */ + if (test_and_clear_bit(PG_REMOVE, &head->wb_flags)) { + set_bit(PG_INODE_REF, &head->wb_flags); + kref_get(&head->wb_kref); + NFS_I(inode)->nrequests++; + } + /* * prepare head request to be added to new pgio descriptor */ nfs_page_group_clear_bits(head); - /* - * some part of the group was still on the inode list - otherwise - * the group wouldn't be involved in async write. - * grab a reference for the head request, iff it needs one. - */ - if (!test_and_set_bit(PG_INODE_REF, &head->wb_flags)) - kref_get(&head->wb_kref); - nfs_page_group_unlock(head); /* drop lock to clean uprequests on destroy list */ spin_unlock(&inode->i_lock); - nfs_destroy_unlinked_subrequests(destroy_list, head); + nfs_destroy_unlinked_subrequests(destroy_list, head, inode); /* still holds ref on head from nfs_page_find_head_request_locked * and still has lock on head from lock loop */