Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

exfat: fix s_maxbytes

With fallocate support, xfstest unit generic/213 fails with

QA output created by 213
We should get: fallocate: No space left on device
Strangely, xfs_io sometimes says "Success" when something went wrong
-fallocate: No space left on device
+fallocate: File too large

because sb->s_maxbytes is set to the volume size.

To be in line with other non-extent-based filesystems, set to max volume
size possible with the cluster size of the volume.

Signed-off-by: David Timber <dxdt@dev.snart.me>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

authored by

David Timber and committed by
Namjae Jeon
4129a3a2 73f01258

+10 -3
+1
fs/exfat/exfat_raw.h
··· 25 25 #define EXFAT_FIRST_CLUSTER 2 26 26 #define EXFAT_DATA_CLUSTER_COUNT(sbi) \ 27 27 ((sbi)->num_clusters - EXFAT_RESERVED_CLUSTERS) 28 + #define EXFAT_MAX_NUM_CLUSTER (0xFFFFFFF5) 28 29 29 30 /* AllocationPossible and NoFatChain field in GeneralSecondaryFlags Field */ 30 31 #define ALLOC_POSSIBLE 0x01
+1
fs/exfat/file.c
··· 34 34 return ret; 35 35 36 36 num_clusters = EXFAT_B_TO_CLU(exfat_ondisk_size(inode), sbi); 37 + /* integer overflow is already checked in inode_newsize_ok(). */ 37 38 new_num_clusters = EXFAT_B_TO_CLU_ROUND_UP(size, sbi); 38 39 39 40 if (new_num_clusters == num_clusters)
+8 -3
fs/exfat/super.c
··· 531 531 if (sbi->vol_flags & MEDIA_FAILURE) 532 532 exfat_warn(sb, "Medium has reported failures. Some data may be lost."); 533 533 534 - /* exFAT file size is limited by a disk volume size */ 535 - sb->s_maxbytes = (u64)(sbi->num_clusters - EXFAT_RESERVED_CLUSTERS) << 536 - sbi->cluster_size_bits; 534 + /* 535 + * Set to the max possible volume size for this volume's cluster size so 536 + * that any integer overflow from bytes to cluster size conversion is 537 + * checked in inode_newsize_ok(). Clamped to MAX_LFS_FILESIZE for 32-bit 538 + * machines. 539 + */ 540 + sb->s_maxbytes = min(MAX_LFS_FILESIZE, 541 + EXFAT_CLU_TO_B((loff_t)EXFAT_MAX_NUM_CLUSTER, sbi)); 537 542 538 543 /* check logical sector size */ 539 544 if (exfat_calibrate_blocksize(sb, 1 << p_boot->sect_size_bits))