From patchwork Fri Sep 9 18:04:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 9324075 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 BEF27607D3 for ; Fri, 9 Sep 2016 18:04:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B38A729F98 for ; Fri, 9 Sep 2016 18:04:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A860229FA1; Fri, 9 Sep 2016 18:04: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=-4.4 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 1F17929F98 for ; Fri, 9 Sep 2016 18:04:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbcIISEo (ORCPT ); Fri, 9 Sep 2016 14:04:44 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34833 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbcIISEm (ORCPT ); Fri, 9 Sep 2016 14:04:42 -0400 Received: by mail-oi0-f67.google.com with SMTP id 2so11307441oif.2 for ; Fri, 09 Sep 2016 11:04:42 -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:in-reply-to:references; bh=bcO35ajWVFU0m774ougWAKvgXDwr7cS2dczUGhUAaaw=; b=i7LTnzXQp0RwCZoONH8SHR0y/IixjgGaw0yIfs0vCaRZJjjaIXAvM9+qJLAmYVqVxP JtSq8KCClKqBMk1MIzbqiBWeO1k7DbOa1D0UYtU0fvFRToxZfp0i3eP8+NUlTJIyEAKI 6ljV1dIkBIejEQJc4S1s25eOsqpFQsHxjrrcZ2cLg3JwnyZ1k25boiZFHYxMSG05Oed+ qhhtWMXAoBU981Me77O+QIt2LOvPEhxLzrkuIDrXx3YIGlz184B9pzR8ONcmKEns30P5 /SpMZaEsILJnPMtILVeIYy/RQzdCewEvccIpVjGuV5Ce566GgupA5RzWUMNbCwI3hY8C ZhHA== 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 :in-reply-to:references; bh=bcO35ajWVFU0m774ougWAKvgXDwr7cS2dczUGhUAaaw=; b=abr5jYFM+bPehxzZim4mtKx0Wu3JnveROiHN2L4+teTICbVDQk4Z8AOQ87qXjbK+cc vkKHnQ+O0UuZbteue8zIZukL+kPFHLvvAxIrilRIiaFUuorLbv38gwhAT8lmigN/KdUO iWLqueSgWKRcq1PkhefHnWpvOpcZmfJBL9qHoGYrlCUe8h4knt/Ht9xQrwIWBT5/2oVb pnbhd4I4wC2RtijiI2ubrO3Q7yoovsDCtbHknB7OzLt2vFWN7z1BG+5hiHA8z1KZKahu XdER7rtTCvZWidqr8s4JdmbJkJPBYlJXGYzazgeM1gANjG/r1oHV88SsXfn6HHOlBd+r I15Q== X-Gm-Message-State: AE9vXwMuu4c/dQfO55vEYVUpwzT8+xh2ZOPggPMASuu+rQeOl1QBbVrdVwufEpe+NNcgrA== X-Received: by 10.202.83.79 with SMTP id h76mr6243519oib.133.1473444281826; Fri, 09 Sep 2016 11:04:41 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-49-162-121.hsd1.mi.comcast.net. [68.49.162.121]) by smtp.gmail.com with ESMTPSA id r200sm1925797itc.13.2016.09.09.11.04.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Sep 2016 11:04:41 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Oleg Drokin Subject: [PATCH v3 01/12] NFSv4.1: Don't deadlock the state manager on the SEQUENCE status flags Date: Fri, 9 Sep 2016 14:04:02 -0400 Message-Id: <1473444253-12433-2-git-send-email-trond.myklebust@primarydata.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473444253-12433-1-git-send-email-trond.myklebust@primarydata.com> References: <1473444253-12433-1-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-Virus-Scanned: ClamAV using ClamSMTP As described in RFC5661, section 18.46, some of the status flags exist in order to tell the client when it needs to acknowledge the existence of revoked state on the server and/or to recover state. Those flags will then remain set until the recovery procedure is done. In order to avoid looping, the client therefore needs to ignore those particular flags while recovering. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4proc.c | 5 ++++- fs/nfs/nfs4session.h | 1 + fs/nfs/nfs4state.c | 12 +++++++++++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index f230aa62ca59..4390d73a92e5 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -439,7 +439,7 @@ extern void nfs4_schedule_path_down_recovery(struct nfs_client *clp); extern int nfs4_schedule_stateid_recovery(const struct nfs_server *, struct nfs4_state *); extern int nfs4_schedule_migration_recovery(const struct nfs_server *); extern void nfs4_schedule_lease_moved_recovery(struct nfs_client *); -extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags); +extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, bool); extern void nfs41_handle_server_scope(struct nfs_client *, struct nfs41_server_scope **); extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 25a2af707233..bd33777f03c4 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -616,6 +616,7 @@ int nfs40_setup_sequence(struct nfs4_slot_table *tbl, } spin_unlock(&tbl->slot_tbl_lock); + slot->privileged = args->sa_privileged ? 1 : 0; args->sa_slot = slot; res->sr_slot = slot; @@ -728,7 +729,8 @@ static int nfs41_sequence_process(struct rpc_task *task, clp = session->clp; do_renew_lease(clp, res->sr_timestamp); /* Check sequence flags */ - nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags); + nfs41_handle_sequence_flag_errors(clp, res->sr_status_flags, + !!slot->privileged); nfs41_update_target_slotid(slot->table, slot, res); break; case 1: @@ -875,6 +877,7 @@ int nfs41_setup_sequence(struct nfs4_session *session, } spin_unlock(&tbl->slot_tbl_lock); + slot->privileged = args->sa_privileged ? 1 : 0; args->sa_slot = slot; dprintk("<-- %s slotid=%u seqid=%u\n", __func__, diff --git a/fs/nfs/nfs4session.h b/fs/nfs/nfs4session.h index 3bb6af70973c..dae385500005 100644 --- a/fs/nfs/nfs4session.h +++ b/fs/nfs/nfs4session.h @@ -23,6 +23,7 @@ struct nfs4_slot { u32 slot_nr; u32 seq_nr; unsigned int interrupted : 1, + privileged : 1, seq_done : 1; }; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index cada00aa5096..9801b5bb5fac 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2227,13 +2227,22 @@ static void nfs41_handle_cb_path_down(struct nfs_client *clp) nfs4_schedule_state_manager(clp); } -void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) +void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags, + bool recovery) { if (!flags) return; dprintk("%s: \"%s\" (client ID %llx) flags=0x%08x\n", __func__, clp->cl_hostname, clp->cl_clientid, flags); + /* + * If we're called from the state manager thread, then assume we're + * already handling the RECLAIM_NEEDED and/or STATE_REVOKED. + * Those flags are expected to remain set until we're done + * recovering (see RFC5661, section 18.46.3). + */ + if (recovery) + goto out_recovery; if (flags & SEQ4_STATUS_RESTART_RECLAIM_NEEDED) nfs41_handle_server_reboot(clp); @@ -2246,6 +2255,7 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) nfs4_schedule_lease_moved_recovery(clp); if (flags & SEQ4_STATUS_RECALLABLE_STATE_REVOKED) nfs41_handle_recallable_state_revoked(clp); +out_recovery: if (flags & SEQ4_STATUS_BACKCHANNEL_FAULT) nfs41_handle_backchannel_fault(clp); else if (flags & (SEQ4_STATUS_CB_PATH_DOWN |