David Howells 0dfcc215b4 cifs: Fix rmdir failure due to ongoing I/O on deleted file
[ Upstream commit bb57c81e97e0082abfb0406ed6f67c615c3d206c ]

The cifs_io_request struct (a wrapper around netfs_io_request) holds open
the file on the server, even beyond the local Linux file being closed.
This can cause problems with Windows-based filesystems as the file's name
still exists after deletion until the file is closed, preventing the parent
directory from being removed and causing spurious test failures in xfstests
due to inability to remove a directory.  The symptom looks something like
this in the test output:

   rm: cannot remove '/mnt/scratch/test/p0/d3': Directory not empty
   rm: cannot remove '/mnt/scratch/test/p1/dc/dae': Directory not empty

Fix this by waiting in unlink and rename for any outstanding I/O requests
to be completed on the target file before removing that file.

Note that this doesn't prevent Linux from trying to start new requests
after deletion if it still has the file open locally - something that's
perfectly acceptable on a UNIX system.

Note also that whilst I've marked this as fixing the commit to make cifs
use netfslib, I don't know that it won't occur before that.

Fixes: 3ee1a1fc3981 ("cifs: Cut over to using netfslib")
Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
cc: Jeff Layton <jlayton@kernel.org>
cc: linux-cifs@vger.kernel.org
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-12-19 18:13:16 +01:00
..
2024-09-16 13:07:59 +02:00
2024-11-01 07:37:10 -10:00
2024-07-15 11:14:59 -07:00
2024-09-16 09:14:02 +02:00
2024-10-17 00:28:06 -07:00
2024-11-01 07:45:00 -10:00
2024-12-14 20:04:14 +01:00
2024-09-19 10:18:15 +02:00
2024-05-28 11:52:53 +02:00
2024-08-21 22:32:58 +02:00
2024-04-23 13:27:43 +02:00
2024-10-02 12:02:15 -07:00
2024-08-29 06:20:44 +12:00
2024-09-16 08:54:30 +02:00
2024-09-16 08:35:09 +02:00
2024-12-14 20:03:35 +01:00
2024-12-05 14:02:47 +01:00
2024-09-18 08:53:53 +02:00
2024-08-28 13:05:39 +02:00
2024-09-16 08:54:30 +02:00
2024-09-24 15:29:42 -07:00
2024-09-16 11:15:26 +02:00
2024-09-27 08:18:43 -07:00
2024-09-27 18:29:19 +02:00
2024-09-27 08:18:43 -07:00
2024-05-02 16:28:20 +02:00