public inbox for linux-kernel@vger.kernel.org
 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 RESEND v5] fat: editions to support fat_fallocate
Date: Wed, 01 May 2013 15:42:06 +0900	[thread overview]
Message-ID: <87bo8v42wx.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <CAKYAXd8v-eF0E2FzLfm1KaZaRu-adQcDVQQeWAiH6-8Pr+BxmA@mail.gmail.com> (Namjae Jeon's message of "Wed, 1 May 2013 13:14:10 +0900")

Namjae Jeon <linkinjeon@gmail.com> writes:

> Hi OGAWA.

Hi,

>> I couldn't review fully though.
>>
>>> +	if (mmu_private_ideal < MSDOS_I(inode)->mmu_private &&
>>> +	    filp->f_dentry->d_count == 1)
>>> +		fat_truncate_blocks(inode, inode->i_size);
>>
>> Hm, why d_count == 1 check is needed? Feel strange and racy.
> Since, fat_file_release() is called on every close for the file.

What is wrong? IIRC, it is what you choose (i.e. for each last close for
the file descriptor).

> But we want to free up the reserved blocks only at the last reference
> for the file exits.
> So, we have used “d_count ==1” i.e., when there is only one reference
> left for the file and it is being closed.
> Then call the truncate blocks to free up the space.

It probably doesn't work. E.g. if unlink(2) is grabbing refcount, then
close(2) may not be last referencer, right?

So, then, nobody truncates anymore.

>>> +		/* Start the allocation.We are not zeroing out the clusters */
>>> +		while (nr_cluster-- > 0) {
>>> +			err = fat_alloc_clusters(inode, &cluster, 1);
>>
>> Why doesn't allocate clusters at once by fat_alloc_clusters()?
> It is because of default design, where we cannot allocate all the
> clusters at once. For reference if we try to allocate all clusters at
> once, it will trigger a BUG_ON in
> fat_alloc_clusters()->
> BUG_ON(nr_cluster > (MAX_BUF_PER_PAGE / 2)); /* fixed limit */
> And we needed to update the fat chain after each allocation and take
> care of the failure cases as well. So, we have done that sequential.
> That optimization of allocating all clusters at once can be considered
> as a separate changeline.

OK.

>>> +	size = i_size_read(inode);
>>> +	mmu_private_actual = MSDOS_I(inode)->mmu_private;
>>> +	mmu_private_ideal = round_up(size, sb->s_blocksize);
>>> +	if ((mmu_private_actual > mmu_private_ideal) && (pos > size)) {
>>> +		err = fat_zero_falloc_area(file, mapping, pos);
>>> +		if (err) {
>>> +			fat_msg(sb, KERN_ERR,
>>> +				"Error (%d) zeroing fallocated area", err);
>>> +			return err;
>>> +		}
>>> +	}
>>
>> This way probably inefficient. This would write data twice times (one is
>> zeroed, one is actual data). So, cpu time would be twice higher if
>> user uses fallocated, right?
> We introduced the “zeroing out” after there was a comment regarding
> the security loophole of accessing invalid data.
> So, while doing fallocate we reserved the space. But, if there is a
> request to access the pre-allocated space we zeroout the complete area
> to avoid any security issue.

I know. Question is, why do we need to initialize twice.

1) zeroed for uninitialized area, 2) then copy user data area. We need
only either, right? This seems to be doing both for all fallocated area.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2013-05-01  6:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-28  0:08 [PATCH RESEND v5] fat: editions to support fat_fallocate Namjae Jeon
2013-04-29 14:31 ` OGAWA Hirofumi
2013-05-01  4:14   ` Namjae Jeon
2013-05-01  6:42     ` OGAWA Hirofumi [this message]
2013-05-02  4:46       ` Namjae Jeon
2013-05-02  5:12         ` OGAWA Hirofumi
2013-05-02  6:12           ` Namjae Jeon
2013-05-02  7:36             ` OGAWA Hirofumi
2013-05-02  7:43               ` OGAWA Hirofumi
2013-05-02  9:15                 ` Namjae Jeon
2013-05-02  9:34                   ` OGAWA Hirofumi
2013-05-02  9:56                     ` Namjae Jeon
2013-06-18  5:47                       ` Namjae Jeon
2013-06-18 17:33                         ` OGAWA Hirofumi
2013-06-20  6:28                           ` Namjae Jeon

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=87bo8v42wx.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