From patchwork Mon Oct 13 18:51:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 5077071 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 E9BCDC11AC for ; Mon, 13 Oct 2014 18:52:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA40420204 for ; Mon, 13 Oct 2014 18:51:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1450201F7 for ; Mon, 13 Oct 2014 18:51:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754168AbaJMSv5 (ORCPT ); Mon, 13 Oct 2014 14:51:57 -0400 Received: from mail-ig0-f175.google.com ([209.85.213.175]:37752 "EHLO mail-ig0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753797AbaJMSv5 (ORCPT ); Mon, 13 Oct 2014 14:51:57 -0400 Received: by mail-ig0-f175.google.com with SMTP id uq10so11604883igb.8 for ; Mon, 13 Oct 2014 11:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=QnjeTcggl5jZs8e2Ebh2MoDsPs1j3wbB1hQbcZl6zWg=; b=KxIMiDK3YKMZJEb9coPkRIJ3aLoDoERSlUU/Bdu3/6aYOUUrJFkGS60ED+tbuKVGhU HNqa2wyqV0JaLitubI4olE6LEx+OoYJ/t2Olej4GYk2r+DeEenaSjkiiY8oH+L4OOJMe XGnJYdWvSdwRL/aRJhIHByzJptJOns3eKdB1rVl93qxd1wuTEqsbMBchcTwAtJyuriz5 qMxL5Jb+ly2lzic7HqYYEr8+RJopZ1ryEKXCAx7TfbMlc2b/HxctVNb7JOC/F583Sep0 zuzQvVnsi7veh0yWet0n23DtiuSL7DS1lbx2dem/QHd1SiAR9Bnx1jRn3R3MYlS7VEf3 qYoQ== MIME-Version: 1.0 X-Received: by 10.107.16.85 with SMTP id y82mr96850ioi.87.1413226316606; Mon, 13 Oct 2014 11:51:56 -0700 (PDT) Received: by 10.107.134.80 with HTTP; Mon, 13 Oct 2014 11:51:56 -0700 (PDT) Date: Mon, 13 Oct 2014 14:51:56 -0400 X-Google-Sender-Auth: 1rjffDn5v10XAnZUZEl7XTO06CU Message-ID: Subject: how to properly handle failures during delegation recall process From: Olga Kornievskaia To: linux-nfs Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 I'd like to hear community's thought about how to properly handle failures during delegation recall process and/or thoughts about a proposed fixed listed at the end. There are two problems seen during the following situation: A client get a cb_call for a delegation it currently holds. Consider the case where the client has a delegated lock for this open. Callback thread will send an open with delegation_cur, followed by a lock operation, and finally delegreturn. Problem#1: the client will send a lock operation regardless of whether or not the open succeeded. This is a new_owner lock and in nfs4xdr.c, the lock operation will choose to use the open_stateid. However, when the open failed, the stateid is 0. Thus, we send an erroneous stateid of 0. Problem#2: if the open fails with admin_revoked, bad_stateid errors, it leads to an infinite loop of sending an open with deleg_cur and getting a bad_stateid error back. It seems to me that we shouldn't even be trying to recover if we get a bad_stateid-type of errors on open with deleg_cur because they are unrecoverable. Furthermore, I propose that if we get an error in nfs4_open_delegation_recall() then we mark any delegation locks as lost and in nfs4_lock_delegation_recall() don't attempt to recover lost lock. I have tested to following code as a fix: return nfs4_handle_delegation_recall_error(server, state, stateid, err); } @@ -5957,6 +5973,10 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state, err = nfs4_set_lock_state(state, fl); if (err != 0) return err; + if (test_bit(NFS_LOCK_LOST, &fl->fl_u.nfs4_fl.owner->ls_flags)) { + pr_warn_ratelimited("NFS: %s: Lock reclaim failed!\n", __func__); + return -EIO; + } err = _nfs4_do_setlk(state, F_SETLK, fl, NFS_LOCK_NEW); return nfs4_handle_delegation_recall_error(server, state, stateid, err); } --- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 5aa55c1..523fae0 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -1682,6 +1682,22 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx, struct nfs4_state nfs4_stateid_copy(&opendata->o_arg.u.delegation, stateid); err = nfs4_open_recover(opendata, state); nfs4_opendata_put(opendata); + switch(err) { + case -NFS4ERR_DELEG_REVOKED: + case -NFS4ERR_ADMIN_REVOKED: + case -NFS4ERR_BAD_STATEID: + case -NFS4ERR_OPENMODE: { + struct nfs4_lock_state *lock; + /* go through open locks and mark them lost */ + spin_lock(&state->state_lock); + list_for_each_entry(lock, &state->lock_states, ls_locks) { + if (!test_bit(NFS_LOCK_INITIALIZED, &lock->ls_flags)) + set_bit(NFS_LOCK_LOST, &lock->ls_flags); + } + spin_unlock(&state->state_lock); + return 0; + } + }