From patchwork Thu Jun 9 15:45:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Weston Andros Adamson X-Patchwork-Id: 9167353 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 6B92E6048F for ; Thu, 9 Jun 2016 15:45:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D99C2834F for ; Thu, 9 Jun 2016 15:45:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 524D628356; Thu, 9 Jun 2016 15:45:34 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 2FE882834F for ; Thu, 9 Jun 2016 15:45:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbcFIPpb (ORCPT ); Thu, 9 Jun 2016 11:45:31 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:36055 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752154AbcFIPpb (ORCPT ); Thu, 9 Jun 2016 11:45:31 -0400 Received: by mail-io0-f193.google.com with SMTP id o127so2839885iod.3; Thu, 09 Jun 2016 08:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=k0s5SsWLo7igcVQafCmbJdpwj7LYewHXAa+J1wZk/Wk=; b=Y4LiduIV21sWOK2bSklbW2Eb+dnyUpdubjeLpplkGoXaUnHX7EMHhFRN0M1AbjRHEC lBD5rhLD5cao+9hDhuoAnqZv0Q1qsY3YsjlBDuMfe3HhfEXlUsTRDS2pe01e5rOpkv6X zBMHP7dF/ZOn5+uViW8ecquUHMR6I57k70kR2JErFuSn7zDIGSWVeSHX4ZbvZR5UBBYx DvXnvC1WtMHHZJijTtJTT3+lCDwExXxO7zIW8l594ynxxiqSjy/If+FS9J34TLNdPCxX WZz0DPBa1MTc1izfu+XLA9JyyNf/gizWBjXDJTVwXS/Y315ePrcz0SOEN+Y/LeUtw6iW eUSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=k0s5SsWLo7igcVQafCmbJdpwj7LYewHXAa+J1wZk/Wk=; b=FtBMhFu4LkY8Z76cJQ0jrzgyw/jSI3iNa+HvGyZyzlZwEOSrIvnJ+D1aBwTPUnm1XY t978EtOm1WIEVQX/U1vkKECsrG9cD8/58b7QRzeeQWVSMq8F/dacBlewNGsiOvnQwdLG cHHZtiAnOyN9dUpt96v9IWQQD211Oi2qbL3nFwIaHGSyplWW2qieCYizLtYgDKHY6t0+ B63OupH3o6BAR8sYzQrj6ssormybb2M+E+xHDEpr+XewAaAsR73V/3mTg37sY34zaCpB NI1mW8sLeuX0w0tHx7u79LDkkUpsaC/+G3O967qyGSoibZNPxpWIcGkke3Rol9n8FeFz UTcg== X-Gm-Message-State: ALyK8tIOEpCuTPY58dSK2ptr8v9nlgWkKIpnnOfZSWQCqTtQqwNXfzB5Pal3WlcGMnx3gQ== X-Received: by 10.107.59.66 with SMTP id i63mr12560526ioa.90.1465487130066; Thu, 09 Jun 2016 08:45:30 -0700 (PDT) Received: from dhcp-56.robotsandstuff.fake (c-68-49-175-159.hsd1.mi.comcast.net. [68.49.175.159]) by smtp.gmail.com with ESMTPSA id f69sm749859ioj.39.2016.06.09.08.45.28 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 Jun 2016 08:45:29 -0700 (PDT) From: Weston Andros Adamson X-Google-Original-From: Weston Andros Adamson To: trond.myklebust@primarydata.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson , stable@vger.kernel.org Subject: [PATCH] pnfs_nfs: fix _cancel_empty_pagelist Date: Thu, 9 Jun 2016 11:45:26 -0400 Message-Id: <1465487126-1899-1-git-send-email-dros@primarydata.com> X-Mailer: git-send-email 2.6.4 (Apple Git-63) 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 pnfs_generic_commit_cancel_empty_pagelist calls nfs_commitdata_release, but that is wrong: nfs_commitdata_release puts the open context, something that isn't valid until nfs_init_commit is called, which is never the case when pnfs_generic_commit_cancel_empty_pagelist is called. This was introduced in "nfs: avoid race that crashes nfs_init_commit". Signed-off-by: Weston Andros Adamson Cc: stable@vger.kernel.org --- This is fix to the issue I brought up on the list last week. It fixes a bug I introduced in the last "fix": "nfs: avoid race that crashes nfs_init_commit" So it should be included in the stable releases that patch was sent to. -dros fs/nfs/pnfs_nfs.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c index 0dfc476da3e1..b38e3c0dc790 100644 --- a/fs/nfs/pnfs_nfs.c +++ b/fs/nfs/pnfs_nfs.c @@ -247,7 +247,11 @@ void pnfs_fetch_commit_bucket_list(struct list_head *pages, } /* Helper function for pnfs_generic_commit_pagelist to catch an empty - * page list. This can happen when two commits race. */ + * page list. This can happen when two commits race. + * + * This must be called instead of nfs_init_commit - call one or the other, but + * not both! + */ static bool pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages, struct nfs_commit_data *data, @@ -256,7 +260,11 @@ pnfs_generic_commit_cancel_empty_pagelist(struct list_head *pages, if (list_empty(pages)) { if (atomic_dec_and_test(&cinfo->mds->rpcs_out)) wake_up_atomic_t(&cinfo->mds->rpcs_out); - nfs_commitdata_release(data); + /* don't call nfs_commitdata_release - it tries to put + * the open_context which is not acquired until nfs_init_commit + * which has not been called on @data */ + WARN_ON_ONCE(data->context); + nfs_commit_free(data); return true; }