From patchwork Wed Sep 11 05:13:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 11140315 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 9C04214DB for ; Wed, 11 Sep 2019 05:13:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 703EA21A4C for ; Wed, 11 Sep 2019 05:13:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="U1J323ZD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727055AbfIKFNh (ORCPT ); Wed, 11 Sep 2019 01:13:37 -0400 Received: from mail-io1-f47.google.com ([209.85.166.47]:34522 "EHLO mail-io1-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726818AbfIKFNg (ORCPT ); Wed, 11 Sep 2019 01:13:36 -0400 Received: by mail-io1-f47.google.com with SMTP id k13so27758445ioj.1 for ; Tue, 10 Sep 2019 22:13:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=FRmIM+b4/ZgTTvQ1jHgYdMIfmSKHuW3c2p/QmLaG3M0=; b=U1J323ZDsdHeaG2nQLFfNrg9MNxcH5fbxSe999fcTHG6mXqk+M21S187TZJBIBD3eN Z9iaApYRXoAzgtRdoi66vrGXxqCVS4Pt+lmXUTRHaDy8msaMTDKzSLgy+jVWtwUeX7Rl bfZ5EyvINsFfhDDExj4YYGzwf0BK+oKrCCx4EfqsiIAqUyQuI7wA/fZlGKRSyYaLflfb qDM9GAvOekuTVQ1rh9x5oPZ50lwUxNPI1GwtbTe2Pj8eOtLdkmiJlK4Ca9r72S17aDHg 9A36X0hq0t2gelbCyaLIleRoGRU/3pOKjzzdtntSZDm9ONc/mlrBNMUyarab8pbIJVoD bovQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=FRmIM+b4/ZgTTvQ1jHgYdMIfmSKHuW3c2p/QmLaG3M0=; b=mNXOrUAxZGBg1extU8SKPH1kHXGYszGFL7ddKTn2XxdWVBRWQqMFamuaoE/pZaI6vM rmmdtQvjP7jypmvRdzQmGTSFczw+STEXAevJM6TZGY2FeqnGFjBYUU0aYQAPmru/cAiW nBtyS/3gmRxHdWn1Iq3s7cv2C68Vnof1YbVO6HsZxtUwu0781j+WqZ+iDnu4P17A6hvQ 4yfIRMAtpqY/xBRgo06yjDm1ZFsJBqzdXa1itHez7hQhzIXw7SVd9ycVZcZ2kRhyI8W4 wTgldbXKh8QZwPH0YqC974zWQicMQo0lMcHZTWjUaZXbK92ueLJak2U1VjIovYUk36gW 9amw== X-Gm-Message-State: APjAAAVoIbFpMA2X7EHdXn1Nn/9h6GN3VtJq/TdH24TkM1clH0icPSRY YZw9HLQ8YrD+MVFKJwEfDmQPd5gYCQVU2AvNOiNBIf14WRk= X-Google-Smtp-Source: APXvYqzAs9QqBaRuj6o7AJr9zX3rltcnl5nlZ2AJnHTdAefREJEXOUYG7U1qHWlDSt0eQd0vyqWH4k7IBu4d76iyPQE= X-Received: by 2002:a6b:9203:: with SMTP id u3mr7834366iod.3.1568178814209; Tue, 10 Sep 2019 22:13:34 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Wed, 11 Sep 2019 00:13:22 -0500 Message-ID: Subject: [SMB3][PATCH] Fix share deleted and share recreated cases To: CIFS Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org When a share is deleted, returning EIO is confusing and no useful information is logged. Improve the handling of this case by at least logging a better error for this (and also mapping the error differently to EREMCHG). See e.g. the new messages that would be logged: [55243.639530] server share \\192.168.1.219\scratch deleted [55243.642568] CIFS VFS: \\192.168.1.219\scratch BAD_NETWORK_NAME: \\192.168.1.219\scratch In addition for the case where a share is deleted and then recreated with the same name, have now fixed that so it works. This is sometimes done for example, because the admin had to move a share to a different, bigger local drive when a share is running low on space. From 5bcb0717d45d41be27741d00708341c6e81e680e Mon Sep 17 00:00:00 2001 From: Steve French Date: Wed, 11 Sep 2019 00:07:36 -0500 Subject: [PATCH] smb3: improve handling of share deleted (and share recreated) When a share is deleted, returning EIO is confusing and no useful information is logged. Improve the handling of this case by at least logging a better error for this (and also mapping the error differently to EREMCHG). See e.g. the new messages that would be logged: [55243.639530] server share \\192.168.1.219\scratch deleted [55243.642568] CIFS VFS: \\192.168.1.219\scratch BAD_NETWORK_NAME: \\192.168.1.219\scratch In addition for the case where a share is deleted and then recreated with the same name, have now fixed that so it works. This is sometimes done for example, because the admin had to move a share to a different, bigger local drive when a share is running low on space. Signed-off-by: Steve French --- fs/cifs/smb2inode.c | 6 ++++++ fs/cifs/smb2maperror.c | 2 +- fs/cifs/smb2ops.c | 13 ++++++++++++- fs/cifs/smb2pdu.c | 5 +++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index c866555b6278..d2a3fb7e5c8d 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -335,6 +335,12 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, cifsFileInfo_put(cfile); SMB2_open_free(&rqst[0]); + if (rc == -EREMCHG) { + printk_once(KERN_WARNING "server share %s deleted\n", + tcon->treeName); + tcon->need_reconnect = true; + } + switch (command) { case SMB2_OP_QUERY_INFO: if (rc == 0) { diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c index 82ade16c9501..7fde3775cb57 100644 --- a/fs/cifs/smb2maperror.c +++ b/fs/cifs/smb2maperror.c @@ -511,7 +511,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = { {STATUS_PRINT_QUEUE_FULL, -EIO, "STATUS_PRINT_QUEUE_FULL"}, {STATUS_NO_SPOOL_SPACE, -EIO, "STATUS_NO_SPOOL_SPACE"}, {STATUS_PRINT_CANCELLED, -EIO, "STATUS_PRINT_CANCELLED"}, - {STATUS_NETWORK_NAME_DELETED, -EIO, "STATUS_NETWORK_NAME_DELETED"}, + {STATUS_NETWORK_NAME_DELETED, -EREMCHG, "STATUS_NETWORK_NAME_DELETED"}, {STATUS_NETWORK_ACCESS_DENIED, -EACCES, "STATUS_NETWORK_ACCESS_DENIED"}, {STATUS_BAD_DEVICE_TYPE, -EIO, "STATUS_BAD_DEVICE_TYPE"}, {STATUS_BAD_NETWORK_NAME, -ENOENT, "STATUS_BAD_NETWORK_NAME"}, diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 9b74149b471f..3672ce0bfbaf 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -741,8 +741,14 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) /* Cached root is still invalid, continue normaly */ - if (rc) + if (rc) { + if (rc == -EREMCHG) { + tcon->need_reconnect = true; + printk_once(KERN_WARNING "server share %s deleted\n", + tcon->treeName); + } goto oshr_exit; + } o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; oparms.fid->persistent_fid = o_rsp->PersistentFileId; @@ -2237,6 +2243,11 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, resp_buftype, rsp_iov); if (rc) { free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); + if (rc == -EREMCHG) { + tcon->need_reconnect = true; + printk_once(KERN_WARNING "server share %s deleted\n", + tcon->treeName); + } goto qic_exit; } *rsp = rsp_iov[1]; diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index cab696ac68ab..01d5c4af2458 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2595,6 +2595,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, } trace_smb3_open_err(xid, tcon->tid, ses->Suid, oparms->create_options, oparms->desired_access, rc); + if (rc == -EREMCHG) { + printk_once(KERN_WARNING "server share %s deleted\n", + tcon->treeName); + tcon->need_reconnect = true; + } goto creat_exit; } else trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid, -- 2.20.1