lkml.org 
[lkml]   [2014]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH v4 2/6] fat: add fat_fallocate operation
    Date
    Namjae Jeon <linkinjeon@gmail.com> 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@mail.parknet.co.jp>


    \
     
     \ /
      Last update: 2014-03-18 16:41    [W:4.718 / U:0.000 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site