mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Namjae Jeon <namjae.jeon@samsung.com>,
	Amit Sahrawat <a.sahrawat@samsung.com>
Subject: Re: [PATCH v4 2/6] fat: add fat_fallocate operation
Date: Tue, 18 Mar 2014 23:55:39 +0900	[thread overview]
Message-ID: <87eh1z4kus.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <1393769338-3506-1-git-send-email-linkinjeon@gmail.com> (Namjae Jeon's message of "Sun, 2 Mar 2014 23:08:57 +0900")

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>

      reply	other threads:[~2014-03-18 14:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-02 14:08 Namjae Jeon
2014-03-18 14:55 ` OGAWA Hirofumi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh1z4kus.fsf@devron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=a.sahrawat@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=linkinjeon@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namjae.jeon@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®