From patchwork Mon Sep 14 23:54:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 7179341 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B72099F314 for ; Mon, 14 Sep 2015 23:54:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C75DB20690 for ; Mon, 14 Sep 2015 23:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFAE320647 for ; Mon, 14 Sep 2015 23:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751198AbbINXym (ORCPT ); Mon, 14 Sep 2015 19:54:42 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:35477 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107AbbINXyh convert rfc822-to-8bit (ORCPT ); Mon, 14 Sep 2015 19:54:37 -0400 Received: by ioiz6 with SMTP id z6so183868229ioi.2 for ; Mon, 14 Sep 2015 16:54:37 -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 :content-transfer-encoding; bh=ZRxuBQRkL+ps6CZi3/1Z6aqVSchGX4se9vzET3IKrb8=; b=rwgt/EFXRp8j1D3HJYvbQUgl1FzAPp4tbmodOmE2Hbd8dayDW2YhS0ks8y7rkTgVjk wgiAM/VHEDs0iXHzD09l28OwOzegrMKBWK7zQfgQkYORginvEqtqgx0cTYm5C0j2JBLC JyhNwAvtBquNcoF7PoaiEO/84bmKthvhyjssD3j32X6TWsvnHtKf6muxTPppiwjUnyM7 irvDSpqYDd2j29wG8aDKVu2Q/fE2OUQwcUM0Yt5aGbCvRnTwKvAdPW3+w2FST+1sikRb naoHkbZnl7ykeuVVUMQ3/EZQAdZ3aWW2ENkWit2wbu127h06JfS8ohKjHiFUA9rJEhme MZyw== MIME-Version: 1.0 X-Received: by 10.107.155.146 with SMTP id d140mr32881143ioe.43.1442274876966; Mon, 14 Sep 2015 16:54:36 -0700 (PDT) Received: by 10.107.4.6 with HTTP; Mon, 14 Sep 2015 16:54:36 -0700 (PDT) Date: Mon, 14 Sep 2015 19:54:36 -0400 X-Google-Sender-Auth: Xw1MS9uUl-0Rs1AraylWVg59DnY Message-ID: Subject: Failing to send a CLOSE if file is opened WRONLY and server reboots on a 4.x mount 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 A test case is as the description says: open(foobar, O_WRONLY); sleep() --> reboot the server close(foobar) The bug is because in nfs4state.c in nfs4_reclaim_open_state() a few line before going to restart, there is clear_bit(NFS4CLNT_RECLAIM_NOGRACE, &state->flags). NFS4CLNT_RECLAIM_NOGRACE is a flag for the client states not open owner states. Value of NFS4CLNT_RECLAIM_NOGRACE is 4 which is the value of NFS_O_WRONLY_STATE in nfs4_state->flags. So clearing it wipes out state and when we go to close it, “call_close” doesn’t get set as state flag is not set and CLOSE doesn’t go on the wire. That line was introduced to fix an infinite loop for OPEN recovery upon receiving a BAD_STATEID error: commit e8d975e73. I have tested injecting BAD_STATEID error using the patch below and the code recovers without problems. However, I'm not sure the clearing of the bit is needed any more. I have tested for infinite loop by reverting the patch and didn't hit the infinite loop. --- 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/nfs4state.c b/fs/nfs/nfs4state.c index da73bc4..5db3246 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1481,7 +1481,7 @@ restart: spin_unlock(&state->state_lock); } nfs4_put_open_state(state); - clear_bit(NFS4CLNT_RECLAIM_NOGRACE, + clear_bit(NFS_STATE_RECLAIM_NOGRACE, &state->flags); spin_lock(&sp->so_lock); goto restart;