RE: [PATCH v2 2/2] exfat: do not zeroed the extended part

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Namjae Jeon <linkinjeon@xxxxxxxxxx>
> Sent: Monday, August 14, 2023 12:39 PM
> To: Mo, Yuezhang <Yuezhang.Mo@xxxxxxxx>
> Cc: sj1557.seo@xxxxxxxxxxx; linux-fsdevel@xxxxxxxxxxxxxxx; Wu, Andy
> <Andy.Wu@xxxxxxxx>; Aoyama, Wataru (SGC) <Wataru.Aoyama@xxxxxxxx>
> Subject: Re: [PATCH v2 2/2] exfat: do not zeroed the extended part
> 
> [snip]
> > +static int exfat_cont_expand(struct inode *inode, loff_t size) {
> > +	if (mapping_writably_mapped(inode->i_mapping))
> Could you elaborate why mapping_writably_mapped is used here instead of
> comparing new size and old size ?
> 
> Thanks.
> > +		return exfat_expand_and_zero(inode, size);
> > +
> > +	return exfat_expand(inode, size);
> > +}
> > +
> >  static bool exfat_allow_set_time(struct exfat_sb_info *sbi, struct
> > inode
> > *inode)
> >  {
> >  	mode_t allow_utime = sbi->options.allow_utime;
> > --
> > 2.25.1
> >
> >

In the following case, since exfat_file_write_iter() is not called. If without
mapping_writably_mapped() and remove exfat_expand_and_zero(),
->valid_size is not fixup to the written size.

+ rm -fr /mnt/test/testfile
+ xfs_io -t -f -c 'truncate 5121' -c 'mmap -rw 0 5121' -c 'truncate 2047' -c 'truncate 5121' -c 'mwrite -S 0x59 2047 3071' -c close /mnt/test/testfile
+ umount /mnt/test
+ fsck.exfat /dev/sdc1
exfatprogs version : 1.2.1
ERROR: /testfile: valid size 5632 greater than size 5121 at 0x528ba0. Fix (y/N)? n
/dev/sdc1: corrupted. directories 58, files 4261
/dev/sdc1: files corrupted 1, files fixed 0

If moving fixup ->valid_size into __exfat_write_inode(), maybe we can remove exfat_expand_and_zero().

--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -72,6 +72,9 @@ int __exfat_write_inode(struct inode *inode, int sync)
        if (ei->start_clu == EXFAT_EOF_CLUSTER)
                on_disk_size = 0;

+       if (on_disk_size < ei->valid_size)
+               ei->valid_size = i_size_read(inode);
+
        ep2->dentry.stream.valid_size = cpu_to_le64(ei->valid_size);
        ep2->dentry.stream.size = cpu_to_le64(on_disk_size);
        if (on_disk_size) {

If fixup ->valid_size in __exfat_write_inode(), it is not only for above case.
Do you think fixup ->valid_size in __exfat_write_inode() is acceptable?




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux