diff mbox series

incorrect lock checks in cifs_writev()

Message ID CAH2r5msXPLo5KDNTK6N5WUcytqf93BO4PKiFMQ0RYS3BLt0aBg@mail.gmail.com (mailing list archive)
State New, archived
Headers show
Series incorrect lock checks in cifs_writev() | expand

Commit Message

Steve French Aug. 15, 2024, 3:46 a.m. UTC
In file.c we are checking for Windows style lock conflicts (even
though this is Linux) for cached i/o which seems wrong (unless user
mouns with "forcemandatorylock" which today is ignored for non-POSIX
mounts)

One obvious way to fix this would be to do something like this change:

        netfs_end_io_write(inode);


Any opinions about which approach looks better?
diff mbox series

Patch

diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c
index 45459af5044d..57f9d934eb4e 100644
--- a/fs/smb/client/file.c
+++ b/fs/smb/client/file.c
@@ -2753,6 +2753,7 @@  cifs_writev(struct kiocb *iocb, struct iov_iter *from)
 	struct inode *inode = file->f_mapping->host;
 	struct cifsInodeInfo *cinode = CIFS_I(inode);
 	struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
+	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
 	ssize_t rc;
 
 	rc = netfs_start_io_write(inode);
@@ -2769,12 +2770,16 @@  cifs_writev(struct kiocb *iocb, struct iov_iter *from)
 	if (rc <= 0)
 		goto out;
 
-	if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from),
+	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL))
+		if (cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from),
 				     server->vals->exclusive_lock_type, 0,
-				     NULL, CIFS_WRITE_OP))
-		rc = netfs_buffered_write_iter_locked(iocb, from, NULL);
-	else
-		rc = -EACCES;
+				     NULL, CIFS_WRITE_OP)) {
+			rc = -EACCES;
+			goto out;
+		}
+
+	rc = netfs_buffered_write_iter_locked(iocb, from, NULL);
+
 out:
 	up_read(&cinode->lock_sem);
 	netfs_end_io_write(inode);