From patchwork Wed Dec 18 22:47:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 11302401 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D4EC8109A for ; Wed, 18 Dec 2019 22:47:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B33652176D for ; Wed, 18 Dec 2019 22:47:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726518AbfLRWrd (ORCPT ); Wed, 18 Dec 2019 17:47:33 -0500 Received: from mx2.suse.de ([195.135.220.15]:53908 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbfLRWrd (ORCPT ); Wed, 18 Dec 2019 17:47:33 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 2041CAC45; Wed, 18 Dec 2019 22:47:30 +0000 (UTC) From: NeilBrown To: Trond Myklebust , Anna Schumaker Date: Thu, 19 Dec 2019 09:47:23 +1100 Subject: [PATCH/RFC] NFS: handle NFSv4.1 server that doesn't support NFS4_OPEN_CLAIM_DELEG_CUR_FH cc: linux-nfs@vger.kernel.org Message-ID: <87y2v9fdz8.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If an NFSv4.1 server doesn't support NFS4_OPEN_CLAIM_DELEG_CUR_FH (e.g. Linux 3.0), and a newer NFS client tries to use it to claim an open before returning a delegation, the server might return NFS4ERR_BADXDR. That is what Linux 3.0 does, though the RFC doesn't seem to be explicit on which flags must be supported, and what error can be returned for unsupported flags. When NFS_CAP_ATOMIC_OPEN_V1 support was added in Commit 49f9a0fafd84 ("NFSv4.1: Enable open-by-filehandle"), fall-back for non-supporting servers was added for various open types, but not for delegation recall. The code pattern for delegation recall is a little different to the other open types, so I cannot simply copy the same approach. I think the below patch should do the right thing, but I haven't tested yet. Does this look reasonable? Is there a cleaner way to do it? Should we check other errors? Thanks, NeilBrown diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index caacf5e7f5e1..14f958d16648 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2174,6 +2174,13 @@ static int nfs4_open_reclaim(struct nfs4_state_owner *sp, struct nfs4_state *sta static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct nfs4_state *state, const nfs4_stateid *stateid, struct file_lock *fl, int err) { switch (err) { + case -NFS4ERR_BADXDR: { + struct nfs4_exception exception; + if (nfs4_clear_cap_atomic_open_v1(server, -EINVAL, + &exception)) + return -EAGAIN; + } + /* fallthrough */ default: printk(KERN_ERR "NFS: %s: unhandled error " "%d.\n", __func__, err);