cifs: Fix inability to write files >2GB to SMB2/3 shares (THIS TIME I GOT IT RIGHT, PROMISE!)
Subsystems (2)
When connecting to SMB2/3 shares, maximum file size is set to non-LFS maximum in superblock. This is due to cap_large_files bit being different for SMB1 and SMB2/3 (where it is just an internal flag that is not negotiated and the SMB1 one corresponds to multichannel capability, so maybe LFS works correctly if server sends 0x08 flag) while capabilities are checked always for the SMB1 bit in cifs_read_super().
The patch fixes this by checking for the correct bit according to the protocol version.
Sorry for the TWO reposts, Gmail messed up the first mail, Thunderbird added spaces to the patch part in the second. I am really sorry! I think I fixed a quite significant bug, so have mercy on me...
---
fs/cifs/cifsfs.c +4 -2
@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) {struct inode *inode;struct cifs_sb_info *cifs_sb; +struct cifs_tcon *tcon;int rc =0 ; cifs_sb =CIFS_SB (sb); + tcon =cifs_sb_master_tcon (cifs_sb);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIXACL ) sb->s_flags |=MS_POSIXACL ; -if (cifs_sb_master_tcon (cifs_sb)->ses->capabilities &CAP_LARGE_FILES ) +if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) sb->s_maxbytes =MAX_LFS_FILESIZE ;else sb->s_maxbytes =MAX_NON_LFS ;
@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) goto out_no_root; } -if (cifs_sb_master_tcon (cifs_sb)->nocase) +if (tcon->nocase) sb->s_d_op = &cifs_ci_dentry_ops;else sb->s_d_op = &cifs_dentry_ops;
Looks good.
Will plan to merge into cifs-2..6.git soon.
Probably should also go to stable kernels
Quoted 41 lines · Jan Klos
When connecting to SMB2/3 shares, maximum file size is set to non-LFS maximum in superblock. This is due to
cap_large_filesbit being different for SMB1 and SMB2/3 (where it is just an internal flag that is not negotiated and the SMB1 one corresponds to multichannel capability, so maybe LFS works correctly if server sends0x08flag) while capabilities are checked always for the SMB1 bit incifs_read_super().The patch fixes this by checking for the correct bit according to the protocol version.
Sorry for the TWO reposts, Gmail messed up the first mail, Thunderbird added spaces to the patch part in the second. I am really sorry! I think I fixed a quite significant bug, so have mercy on me...
Signed-off-by Jan Klos <[email protected]>---
diff -uprN
a/fs/cifs/cifsfs.cb/fs/cifs/cifsfs.cfs/cifs/cifsfs.c 2013-10-06 16:18:13.488378000 +0200 renamed from fs/cifs/cifsfs.c 2013-10-05 16:18:07.000000000 +0200 +4
-2@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) { struct inode *inode; struct cifs_sb_info *cifs_sb; + struct cifs_tcon *tcon; int rc = 0; cifs_sb = CIFS_SB(sb); + tcon = cifs_sb_master_tcon(cifs_sb); if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) sb->s_flags |= MS_POSIXACL; - if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) + if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) sb->s_maxbytes = MAX_LFS_FILESIZE; else sb->s_maxbytes = MAX_NON_LFS;@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) goto out_no_root; } - if (cifs_sb_master_tcon(cifs_sb)->nocase) + if (tcon->nocase) sb->s_d_op = &cifs_ci_dentry_ops; else sb->s_d_op = &cifs_dentry_ops;
Signature · 3 lines
Thanks, Steve
Jeff Layton
Reviewed-byQuoted 33 lines · On Sun, 06 Oct 2013 21:08:20 +0200 Jan Klos…
When connecting to SMB2/3 shares, maximum file size is set to non-LFS maximum in superblock. This is due to
cap_large_filesbit being different for SMB1 and SMB2/3 (where it is just an internal flag that is not negotiated and the SMB1 one corresponds to multichannel capability, so maybe LFS works correctly if server sends0x08flag) while capabilities are checked always for the SMB1 bit incifs_read_super().The patch fixes this by checking for the correct bit according to the protocol version.
Sorry for the TWO reposts, Gmail messed up the first mail, Thunderbird added spaces to the patch part in the second. I am really sorry! I think I fixed a quite significant bug, so have mercy on me...
Signed-off-by Jan Klos <[email protected]>---
diff -uprN
a/fs/cifs/cifsfs.cb/fs/cifs/cifsfs.cfs/cifs/cifsfs.c +3
-1@@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) {struct inode *inode;struct cifs_sb_info *cifs_sb; +struct cifs_tcon *tcon;int rc =0 ; cifs_sb =CIFS_SB (sb); + tcon =cifs_sb_master_tcon (cifs_sb);if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIXACL ) sb->s_flags |=MS_POSIXACL ; -if (cifs_sb_master_tcon (cifs_sb)->ses->capabilities &CAP_LARGE_FILES ) +if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) sb->s_maxbytes =MAX_LFS_FILESIZE ;else sb->s_maxbytes =MAX_NON_LFS ;
fs/cifs/cifsfs.c cifs_read_super(struct super_block *sb) · line 155
Quoted 8 lines
fs/cifs/cifsfs.c +1
-1@@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) goto out_no_root; } -if (cifs_sb_master_tcon (cifs_sb)->nocase) +if (tcon->nocase) sb->s_d_op = &cifs_ci_dentry_ops;else sb->s_d_op = &cifs_dentry_ops;
Nice catch.