From patchwork Wed Dec 3 19:54:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olga Kornievskaia X-Patchwork-Id: 5432931 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AFF29F1C5 for ; Wed, 3 Dec 2014 19:55:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5FE7420272 for ; Wed, 3 Dec 2014 19:55:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 58A1F201ED for ; Wed, 3 Dec 2014 19:55:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751046AbaLCTzA (ORCPT ); Wed, 3 Dec 2014 14:55:00 -0500 Received: from mail-ie0-f169.google.com ([209.85.223.169]:34258 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750798AbaLCTy7 (ORCPT ); Wed, 3 Dec 2014 14:54:59 -0500 Received: by mail-ie0-f169.google.com with SMTP id y20so14446909ier.14 for ; Wed, 03 Dec 2014 11:54:59 -0800 (PST) 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=GdppBbSivv04VYEtVreRla1gCS+aWNApnLw11yVItz0=; b=TRa/8PolLUlN1DppK/X7t55jH6o4HPVti2A2dZekg6eltfr12hFAOP8zaip20CtOM4 VAHoeyJ+GX7Hb9MzyVcP8nLqIWEsx8A2p5Q9Q+7OMsl+mzqxfqReHg6jHEc7n1sjpGo3 uYusAa/RB/oWH7QOvvrbfaeC24hYqMVLaN3PlE4YYxngfi+7aQ6I5F/z5Yv2S0OZxxHe 1kS4UXKrXAYUM5mK0eVeB1NyPXHxRKFQlv7Z/8QX32hOLdc6mgxoZ5CCGrXp/fX5vSez uTxbg2M9BkfXZvflO1qOtvpvK9wZuyTnDR4ANBGOLwgnXgsqUbE93nKOTwlgbCsPbGhs Xs/w== MIME-Version: 1.0 X-Received: by 10.50.66.234 with SMTP id i10mr25687390igt.25.1417636499283; Wed, 03 Dec 2014 11:54:59 -0800 (PST) Received: by 10.107.134.227 with HTTP; Wed, 3 Dec 2014 11:54:59 -0800 (PST) Date: Wed, 3 Dec 2014 14:54:59 -0500 X-Google-Sender-Auth: ZDvwsYkudeOPFBwKl4U77T5Sa0w Message-ID: Subject: not picking a delegation stateid for IO when delegation stateid is being returned 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 Hi folks, I would like an opinion about changing code in such as way that we don't select a delegation stateid for an IO operation when this particular delegation is being returned. The reason it's some what problematic is that we send out a DELEG_RETURN and then we don't remove the stateid until we receive a reply. In the mean while, an IO operation can be happening and in nfs4_select_rw_stateid() it sees a delegation stateid and uses it. Well, at the server, it finishes processing DELEG_RETURN before getting an IO op and by that time the server is finished with the stateid and can error an IO operation with BAD_STATEID. nfs_mark_delegation_referenced(delegation); --- 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/delegation.c b/fs/nfs/delegation.c index 7f3f606..4f6f6c9 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -854,7 +854,8 @@ bool nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *in flags &= FMODE_READ|FMODE_WRITE; rcu_read_lock(); delegation = rcu_dereference(nfsi->delegation); - ret = (delegation != NULL && (delegation->type & flags) == flags); + ret = (delegation != NULL && (delegation->type & flags) == flags && + !test_bit(NFS_DELEGATION_RETURNING, &delegation->flags)); if (ret) { nfs4_stateid_copy(dst, &delegation->stateid);