Re: [PATCH v4 2/6] fat: add fat_fallocate operation

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

 



Namjae Jeon <linkinjeon@xxxxxxxxx> writes:

> +	if (mode & FALLOC_FL_KEEP_SIZE) {
> +		/* First compute the number of clusters to be allocated */
> +		mm_bytes = offset + len - round_up(MSDOS_I(inode)->i_disksize,
> +			sbi->cluster_size);
> +		nr_cluster = (mm_bytes + (sbi->cluster_size - 1)) >>
> +			sbi->cluster_bits;
> +
> +		/* Start the allocation.We are not zeroing out the clusters */
> +		while (nr_cluster-- > 0) {
> +			err = fat_alloc_clusters(inode, &cluster, 1);
> +			if (err) {
> +				fat_msg(sb, KERN_ERR,
> +					"fat_fallocate(): fat_alloc_clusters() error");
> +				goto error;
> +			}
> +			err = fat_chain_add(inode, cluster, 1);
> +			if (err) {
> +				fat_free_clusters(inode, cluster);
> +				goto error;
> +			}
> +			MSDOS_I(inode)->i_disksize += sbi->cluster_size;
> +		}

Hm. This ->i_disksize calculation is right? Why do we use cluster align
here? My concern is, say blocksize == 512 and clustersize == 4096,

        0      512               5120
        |       |                  |
        +-------+-----------+------+
                           4096

Before fallocate(), ->i_disksize == 512. Then user called fallocate()
with offset == 512 and len == 4608.

After that, this sets ->i_disksize += 4096, == 4608?  I think, we should
set ->i_disksize == 5120, finally. I can be missing something though.
-- 
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




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