]> www.infradead.org Git - users/jedix/linux-maple.git/commit
cifs: Fix rmdir failure due to ongoing I/O on deleted file
authorDavid Howells <dhowells@redhat.com>
Fri, 6 Dec 2024 11:06:32 +0000 (11:06 +0000)
committerSteve French <stfrench@microsoft.com>
Wed, 11 Dec 2024 02:47:34 +0000 (20:47 -0600)
commitbb57c81e97e0082abfb0406ed6f67c615c3d206c
tree52ef775f4a215ff89029aa41f11d6604a77b7e80
parent6d44a780635b9b3fb6e20f366ee7750a9adfa884
cifs: Fix rmdir failure due to ongoing I/O on deleted file

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>
fs/smb/client/inode.c