Skip to contentSkip to conversation

cifs: Change translation of STATUS_DELETE_PENDING to -EBUSY

PATCH Superseded Pali Rohár 2 participants 4 messages Oct 5, 2024 – Oct 30, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cifs: Change translation of STATUS_DELETE_PENDING to -EBUSY

STATUS_DELETE_PENDING error is returned when trying to open a file which is in delete pending state. Linux SMB client currently translates this error to -ENOENT. So Linux application trying to open a file which still exists will receive -ENOENT error. This is confusing as -ENONET means that directory entry does not exist.

File on SMB server can be in delete pending state for an indefinite long period. Moreover it does not have to final state before the real deleting, as any SMB client who still have opened handle to such file can return file from delete pending state back to normal state. And therefore it can cancel any scheduled file removal.

So change translation of STATUS_DELETE_PENDING error to -EBUSY. -EBUSY is used also for STATUS_SHARING_VIOLATION error which is similar case, when opening a file was disallowed by server due to concurrent usage.

---
 fs/smb/client/smb2maperror.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/smb/client/smb2maperror.c +1 -1
index ac1895358908..fbc4ed038ff5 100644
@@ -368,7 +368,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
 	{STATUS_EA_CORRUPT_ERROR, -EIO, "STATUS_EA_CORRUPT_ERROR"},
 	{STATUS_FILE_LOCK_CONFLICT, -EACCES, "STATUS_FILE_LOCK_CONFLICT"},
 	{STATUS_LOCK_NOT_GRANTED, -EACCES, "STATUS_LOCK_NOT_GRANTED"},
-	{STATUS_DELETE_PENDING, -ENOENT, "STATUS_DELETE_PENDING"},
+	{STATUS_DELETE_PENDING, -EBUSY, "STATUS_DELETE_PENDING"},
 	{STATUS_CTL_FILE_NOT_SUPPORTED, -ENOSYS,
 	"STATUS_CTL_FILE_NOT_SUPPORTED"},
 	{STATUS_UNKNOWN_REVISION, -EIO, "STATUS_UNKNOWN_REVISION"},
Signature · 1 line
2.20.1
#1 lore raw

PATCH v2 1/1 cifs: Change translation of STATUS_DELETE_PENDING to -EBUSY

STATUS_DELETE_PENDING error is returned when trying to open a file which is in delete pending state. Linux SMB client currently translates this error to -ENOENT. So Linux application trying to open a file which still exists will receive -ENOENT error. This is confusing as -ENONET means that directory entry does not exist.

File on SMB server can be in delete pending state for an indefinite long period. Moreover it does not have to final state before the real deleting, as any SMB client who still have opened handle to such file can revert file from delete pending state back to normal state. And therefore client can cancel any scheduled file removal.

So change translation of STATUS_DELETE_PENDING error to -EBUSY. -EBUSY is used also for STATUS_SHARING_VIOLATION error which is similar case, when opening a file was disallowed by server due to concurrent usage.

For SMB1, STATUS_DELETE_PENDING is translated to ERRDOS+ERRbadshare which is then translated to -EBUSY. In the same way is STATUS_SHARING_VIOLATION translated to -EBUSY.

---
Changes in v2:
* Apply change also for SMB1 code

---
 fs/smb/client/netmisc.c      | 2 +-
 fs/smb/client/smb2maperror.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/netmisc.c +1 -1
index 2a8d71221e5e..a2fb1ae14d41 100644
@@ -302,7 +302,7 @@ static const struct {
 	ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
 	ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
 	ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
-	ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
+	ERRDOS, ERRbadshare, NT_STATUS_DELETE_PENDING}, {
 	ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
 	ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
 	ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
fs/smb/client/smb2maperror.c +1 -1
index b05313acf9b2..00c0bd79c074 100644
@@ -368,7 +368,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = {
 	{STATUS_EA_CORRUPT_ERROR, -EIO, "STATUS_EA_CORRUPT_ERROR"},
 	{STATUS_FILE_LOCK_CONFLICT, -EACCES, "STATUS_FILE_LOCK_CONFLICT"},
 	{STATUS_LOCK_NOT_GRANTED, -EACCES, "STATUS_LOCK_NOT_GRANTED"},
-	{STATUS_DELETE_PENDING, -ENOENT, "STATUS_DELETE_PENDING"},
+	{STATUS_DELETE_PENDING, -EBUSY, "STATUS_DELETE_PENDING"},
 	{STATUS_CTL_FILE_NOT_SUPPORTED, -ENOSYS,
 	"STATUS_CTL_FILE_NOT_SUPPORTED"},
 	{STATUS_UNKNOWN_REVISION, -EIO, "STATUS_UNKNOWN_REVISION"},
Signature · 1 line
2.20.1
#2 lore raw
Quoted 13 lines · Pali Rohár

STATUS_DELETE_PENDING error is returned when trying to open a file which is in delete pending state. Linux SMB client currently translates this error to -ENOENT. So Linux application trying to open a file which still exists will receive -ENOENT error. This is confusing as -ENONET means that directory entry does not exist.

File on SMB server can be in delete pending state for an indefinite long period. Moreover it does not have to final state before the real deleting, as any SMB client who still have opened handle to such file can revert file from delete pending state back to normal state. And therefore client can cancel any scheduled file removal.

Quoted 4 lines

So change translation of STATUS_DELETE_PENDING error to -EBUSY. -EBUSY is used also for STATUS_SHARING_VIOLATION error which is similar case, when opening a file was disallowed by server due to concurrent usage.

My worry is that, change in error code mapping might break some applications compatibility.

#3 lore raw
Quoted 14 lines · On Wednesday 30 October 2024 11:06:30 Bharath SM wrote:
Quoted 13 lines · Pali Rohár

STATUS_DELETE_PENDING error is returned when trying to open a file which is in delete pending state. Linux SMB client currently translates this error to -ENOENT. So Linux application trying to open a file which still exists will receive -ENOENT error. This is confusing as -ENONET means that directory entry does not exist.

File on SMB server can be in delete pending state for an indefinite long period. Moreover it does not have to final state before the real deleting, as any SMB client who still have opened handle to such file can revert file from delete pending state back to normal state. And therefore client can cancel any scheduled file removal.

Quoted 7 lines
Quoted 4 lines

So change translation of STATUS_DELETE_PENDING error to -EBUSY. -EBUSY is used also for STATUS_SHARING_VIOLATION error which is similar case, when opening a file was disallowed by server due to concurrent usage.

My worry is that, change in error code mapping might break some applications compatibility.

Do you have any specific example in mind where this can happen?

I was thinking about it and I cannot imagine how this change could break application compatibility. I do not know how can application think that -ENOENT error from open() or stat() syscall should be handled as file exists. This is direct contradiction of the -ENOENT meaning.