Function CIFSSMBQPathInfo() returns NT_STATUS_DELETE_PENDING status code
when the path is in the delete pending state. So use this information when
filling the fi.DeletePending member in cifs_query_path_info() function.
Depends on "cifs: Change translation of STATUS_DELETE_PENDING to -EBUSY".
Signed-off-by: Pali Rohár <pali@kernel.org>
---
fs/smb/client/cifssmb.c | 6 ++++++
fs/smb/client/smb1ops.c | 6 +++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c
index 6dabff82f6ae..2427752bc224 100644
--- a/fs/smb/client/cifssmb.c
+++ b/fs/smb/client/cifssmb.c
@@ -35,6 +35,7 @@
#include "cifs_debug.h"
#include "fscache.h"
#include "smbdirect.h"
+#include "nterr.h"
#ifdef CONFIG_CIFS_DFS_UPCALL
#include "dfs_cache.h"
#endif
@@ -3902,6 +3903,11 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
(struct smb_hdr *) pSMBr, &bytes_returned, 0);
if (rc) {
cifs_dbg(FYI, "Send error in QPathInfo = %d\n", rc);
+ /* Fill at least the DeletePending for -EBUSY error code */
+ if (rc == -EBUSY && data)
+ data->DeletePending =
+ (pSMBr->hdr.Flags2 & SMBFLG2_ERR_STATUS) &&
+ pSMBr->hdr.Status.CifsError == cpu_to_le32(NT_STATUS_DELETE_PENDING);
} else { /* decode response */
rc = validate_t2((struct smb_t2_rsp *)pSMBr);
diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c
index 176bc2a211bf..618470db6444 100644
--- a/fs/smb/client/smb1ops.c
+++ b/fs/smb/client/smb1ops.c
@@ -628,7 +628,11 @@ static int cifs_query_path_info(const unsigned int xid,
fi.EASize = di->EaSize;
}
fi.NumberOfLinks = cpu_to_le32(1);
- fi.DeletePending = 0;
+ /*
+ * Do not change fi.DeletePending as it is set by the above
+ * CIFSSMBQPathInfo() call even on error. By default it is
+ * initialized to zero (false).
+ */
fi.Directory = !!(le32_to_cpu(fi.Attributes) & ATTR_DIRECTORY);
cifs_buf_release(search_info.ntwrk_buf_start);
} else if (!full_path[0]) {
--
2.20.1