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 v2 3/5] fat: zero out seek range on _fat_get_block
Date: Sun, 01 Dec 2013 21:49:20 +0900 [thread overview]
Message-ID: <8761r8enxr.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <1384688291-2935-1-git-send-email-linkinjeon@gmail.com> (Namjae Jeon's message of "Sun, 17 Nov 2013 20:38:11 +0900")
Namjae Jeon <linkinjeon@gmail.com> writes:
> --- a/fs/fat/cache.c
> +++ b/fs/fat/cache.c
> @@ -334,7 +334,8 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
> */
> last_block = (MSDOS_I(inode)->i_disksize + (blocksize - 1))
> >> blocksize_bits;
> - if (sector >= last_block)
> + if (sector >= last_block &&
> + MSDOS_I(inode)->mmu_private == MSDOS_I(inode)->i_disksize)
> return 0;
This is strange check. Why do we want to map even if "sector > ->i_disksize"
(when ->mmu_private != ->i_disksize)?
Another point, for ->bmap(), maybe we will need new flag to read beyond
->i_size? Because ->bmap() returns physical address even if > ->i_size.
> diff --git a/fs/fat/inode.c b/fs/fat/inode.c
> index 655dcc7..12a37a9 100644
> --- a/fs/fat/inode.c
> +++ b/fs/fat/inode.c
> @@ -61,15 +61,26 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
> struct super_block *sb = inode->i_sb;
> struct msdos_sb_info *sbi = MSDOS_SB(sb);
> unsigned long mapped_blocks;
> - sector_t phys;
> + sector_t phys, last_block, disk_block;
> int err, offset;
> + const unsigned long blocksize = sb->s_blocksize;
> + const unsigned char blocksize_bits = sb->s_blocksize_bits;
>
> err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create);
> if (err)
> return err;
> if (phys) {
> - map_bh(bh_result, sb, phys);
> *max_blocks = min(mapped_blocks, *max_blocks);
> + last_block = (MSDOS_I(inode)->mmu_private + (blocksize - 1))
> + >> blocksize_bits;
> + disk_block = (MSDOS_I(inode)->i_disksize + (blocksize - 1))
> + >> blocksize_bits;
> + if (iblock >= last_block && iblock <= disk_block) {
> + MSDOS_I(inode)->mmu_private +=
> + *max_blocks << blocksize_bits;
> + set_buffer_new(bh_result);
> + }
> + map_bh(bh_result, sb, phys);
> return 0;
> }
> if (!create)
Let's give the name for this operation for readability, and make it
static function. With this, I think this one much readable.
static void check_fallocate_region()
{
/* code here */
}
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2013-12-01 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-17 11:38 Namjae Jeon
2013-12-01 12:49 ` OGAWA Hirofumi [this message]
2013-12-05 14:15 ` 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=8761r8enxr.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®