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, abartlet@samba.org,
Namjae Jeon <namjae.jeon@samsung.com>,
Ravishankar N <ravi.n1@samsung.com>
Subject: Re: [PATCH v3] fat: editions to support fat_fallocate
Date: Sat, 09 Mar 2013 23:18:05 +0900 [thread overview]
Message-ID: <87sj44ac82.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <1362664617-3825-1-git-send-email-linkinjeon@gmail.com> (Namjae Jeon's message of "Thu, 7 Mar 2013 22:56:57 +0900")
Namjae Jeon <linkinjeon@gmail.com> writes:
> static int fat_file_release(struct inode *inode, struct file *filp)
> {
> + struct super_block *sb = inode->i_sb;
> + loff_t mmu_private_ideal = (inode->i_size + (sb->s_blocksize-1)) &
> + ~(sb->s_blocksize-1);
> + if (mmu_private_ideal < MSDOS_I(inode)->mmu_private &&
> + filp->f_dentry->d_count == 1)
> + fat_truncate_blocks(inode, inode->i_size);
Without locking, truncate is racy.
This choose ->release(). BTW, we would also be able to do this only
->evict_inode(), although I'm not thinking yet which one is better.
If you had conclusion, it would be nice to explain it.
> +static long fat_fallocate(struct file *file, int mode,
> + loff_t offset, loff_t len)
> +{
>
> + if ((offset + len) <= MSDOS_I(inode)->mmu_private) {
> + fat_msg(sb, KERN_ERR,
> + "fat_fallocate():Blocks already allocated");
> + return -EINVAL;
> + }
Also this looks like totally racy.
> static int fat_write_begin(struct file *file, struct address_space *mapping,
> loff_t pos, unsigned len, unsigned flags,
> struct page **pagep, void **fsdata)
> {
> int err;
> + struct inode *inode = mapping->host;
> + struct super_block *sb = inode->i_sb;
> + loff_t mmu_private_actual = MSDOS_I(inode)->mmu_private;
> + loff_t mmu_private_ideal = (inode->i_size + (sb->s_blocksize-1)) &
> + ~(sb->s_blocksize-1);
> +
> + if ((mmu_private_actual > mmu_private_ideal) && (pos > inode->i_size)) {
> + err = fat_zero_falloc_area(file, mapping, pos);
> + if (err)
> + fat_msg(sb, KERN_ERR, "error zeroing fallocated area");
> + }
>
> *pagep = NULL;
> err = cont_write_begin(file, mapping, pos, len, flags,
Hm, only write_begin is enough to handle mmap, truncate, and etc.?
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2013-03-09 14:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-07 13:56 [PATCH v3] fat: editions to support fat_fallocate Namjae Jeon
2013-03-08 23:37 ` Andrew Morton
2013-03-11 9:43 ` Namjae Jeon
2013-03-09 14:18 ` OGAWA Hirofumi [this message]
2013-03-11 9:52 ` Namjae Jeon
2013-03-11 15:01 ` OGAWA Hirofumi
2013-03-12 8:29 ` Namjae Jeon
2013-03-12 9:07 ` OGAWA Hirofumi
2013-03-12 9:38 ` 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=87sj44ac82.fsf@devron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=abartlet@samba.org \
--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 \
--cc=ravi.n1@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