From patchwork Thu Jul 14 22:58:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9230863 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 0A5866075D for ; Thu, 14 Jul 2016 22:59:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 014C02818B for ; Thu, 14 Jul 2016 22:59:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9F28281A7; Thu, 14 Jul 2016 22:59:09 +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 3C404281A7 for ; Thu, 14 Jul 2016 22:59:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752049AbcGNW7G (ORCPT ); Thu, 14 Jul 2016 18:59:06 -0400 Received: from mail-io0-f194.google.com ([209.85.223.194]:36545 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751279AbcGNW7F (ORCPT ); Thu, 14 Jul 2016 18:59:05 -0400 Received: by mail-io0-f194.google.com with SMTP id y34so5351007ioi.3 for ; Thu, 14 Jul 2016 15:59:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id; bh=li1FQfad5MNvvnGuJ5XYww8InJ784z2RkkQmZ15UpHg=; b=cak+J2oJmCiSG05qLhjnLsyosTXkyaQc5ubcq28EKuEyHfDlaAUoXGpZInpo/Ys66D /9HDQLZE0WBDE2llIbvp8fWMi/Dfyw1RfZXZtjKGW7fi/5w8yYFC8gRKt9xOx15d8u5Y JA96Cea0vmdtNneEwzt2cte7IwvxNFS1vCow9bZOE3OD0+xG8K0iZrX2Hlp9tfUCMltE EdHGBZ6mHtyjswCwXsTtxmDh9BaTwbIK/+4nTqqPEseIBXOiTIoJ4Qc7iRXWbzYq0uT0 kzABaYHgxRHCfY7TDp6WawZuURlVmFEOPFtvxw73OQqRfy7LOyrTf2SdVxZfB6kDYwT1 eI9g== 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:subject:date:message-id; bh=li1FQfad5MNvvnGuJ5XYww8InJ784z2RkkQmZ15UpHg=; b=G1s7kR3uZwoFDyoMgDbRFj2b+D8uoSwELjJ+shKfMum5trQ5OcKCpLbAbVb82kAiXB aqt8f5Jdp32lCtJudo8cBxBhId4dmD+GMMAsUK+mcLfpMAdfmJx4/oRccpUX1CMgJbBo xaTpgAuqOwPrllWnugqtW1IdQHCUhl4yvpN37pVtwA1OYxNSx/XXZEVRoS7KpzAm9scq S0MZYQGaAYxD/bT+ADXC0p+QiUjbOxvYnIQD4MggUc8qqvw25DzN12Mdfj8CAME/cK9I OhXqXfZbHHi2FmTUqCUWlUwO4JpbnC5bm347Hko27iw+Ei2IIMY65K2Tss+Gu+hLuc9c 5rtw== X-Gm-Message-State: ALyK8tKJ1gJVYrHMpAOBF/jw1u5OqWzB0qJbbM9bqMqVX+zNjtzFEDHpB/jPMwqUvWQ12w== X-Received: by 10.107.170.149 with SMTP id g21mr19345733ioj.44.1468537143393; Thu, 14 Jul 2016 15:59:03 -0700 (PDT) Received: from leira.trondhjem.org.localdomain ([50.108.12.87]) by smtp.gmail.com with ESMTPSA id m203sm2183353iom.21.2016.07.14.15.59.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Jul 2016 15:59:02 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 1/4] pNFS: Fix post-layoutget error handling in pnfs_update_layout() Date: Thu, 14 Jul 2016 18:58:32 -0400 Message-Id: <1468537115-65826-1-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 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 The non-retry error path is currently broken and ends up releasing the reference to the layout twice. It also can end up clearing the NFS_LAYOUT_FIRST_LAYOUTGET flag twice, causing a race. In addition, the retry path will fail to decrement the plh_outstanding counter. Fixes: 183d9e7b112aa ("pnfs: rework LAYOUTGET retry handling") Cc: stable@vger.kernel.org # 4.7 Signed-off-by: Trond Myklebust Reviewed-by: Jeff Layton --- fs/nfs/pnfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 0fbe734cc38c..73b0dc90265a 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1645,6 +1645,7 @@ lookup_again: lseg = send_layoutget(lo, ctx, &stateid, &arg, &timeout, gfp_flags); trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg, PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET); + atomic_dec(&lo->plh_outstanding); if (IS_ERR(lseg)) { switch(PTR_ERR(lseg)) { case -ERECALLCONFLICT: @@ -1652,26 +1653,25 @@ lookup_again: lseg = NULL; /* Fallthrough */ case -EAGAIN: - pnfs_put_layout_hdr(lo); - if (first) - pnfs_clear_first_layoutget(lo); - if (lseg) { - trace_pnfs_update_layout(ino, pos, count, - iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY); - goto lookup_again; - } - /* Fallthrough */ + break; default: if (!nfs_error_is_fatal(PTR_ERR(lseg))) { pnfs_layout_clear_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode)); lseg = NULL; } } + if (lseg) { + pnfs_put_layout_hdr(lo); + if (first) + pnfs_clear_first_layoutget(lo); + trace_pnfs_update_layout(ino, pos, count, + iomode, lo, lseg, PNFS_UPDATE_LAYOUT_RETRY); + goto lookup_again; + } } else { pnfs_layout_clear_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode)); } - atomic_dec(&lo->plh_outstanding); out_put_layout_hdr: if (first) pnfs_clear_first_layoutget(lo);