* [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region
@ 2013-11-17 11:38 Namjae Jeon
2013-12-01 12:52 ` OGAWA Hirofumi
0 siblings, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2013-11-17 11:38 UTC (permalink / raw)
To: hirofumi, akpm
Cc: linux-fsdevel, linux-kernel, Namjae Jeon, Namjae Jeon, Amit Sahrawat
From: Namjae Jeon <namjae.jeon@samsung.com>
Make the fibmap call the return the proper physical block number for any
offset request in the fallocated range.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
---
fs/fat/cache.c | 16 ++++++++++++++--
fs/fat/inode.c | 4 ++--
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/fs/fat/cache.c b/fs/fat/cache.c
index c56bd7e..7777822 100644
--- a/fs/fat/cache.c
+++ b/fs/fat/cache.c
@@ -312,6 +312,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
const unsigned char blocksize_bits = sb->s_blocksize_bits;
sector_t last_block;
int cluster, offset;
+ loff_t i_size = i_size_read(inode);
*phys = 0;
*mapped_blocks = 0;
@@ -323,10 +324,20 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
return 0;
}
- last_block = (i_size_read(inode) + (blocksize - 1)) >> blocksize_bits;
+ last_block = (i_size + (blocksize - 1)) >> blocksize_bits;
if (sector >= last_block) {
- if (!create)
+ if (!create) {
+ /*
+ * to map cluster in case of read request
+ * for a block in fallocated region
+ */
+ if (MSDOS_I(inode)->i_disksize >
+ round_up(i_size, sb->s_blocksize)) {
+ goto out_map_cluster;
+ }
+
return 0;
+ }
/*
* Both ->mmu_private and ->i_disksize can access
@@ -339,6 +350,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
return 0;
}
+out_map_cluster:
cluster = sector >> (sbi->cluster_bits - sb->s_blocksize_bits);
offset = sector & (sbi->sec_per_clus - 1);
cluster = fat_bmap_cluster(inode, cluster);
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index c9fb9b6..bdd1efd 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -243,9 +243,9 @@ static sector_t _fat_bmap(struct address_space *mapping, sector_t block)
sector_t blocknr;
/* fat_get_cluster() assumes the requested blocknr isn't truncated. */
- down_read(&MSDOS_I(mapping->host)->truncate_lock);
+ mutex_lock(&mapping->host->i_mutex);
blocknr = generic_block_bmap(mapping, block, fat_get_block);
- up_read(&MSDOS_I(mapping->host)->truncate_lock);
+ mutex_unlock(&mapping->host->i_mutex);
return blocknr;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region
2013-11-17 11:38 [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region Namjae Jeon
@ 2013-12-01 12:52 ` OGAWA Hirofumi
2013-12-05 14:20 ` Namjae Jeon
0 siblings, 1 reply; 5+ messages in thread
From: OGAWA Hirofumi @ 2013-12-01 12:52 UTC (permalink / raw)
To: Namjae Jeon; +Cc: akpm, linux-fsdevel, linux-kernel, Namjae Jeon, Amit Sahrawat
Namjae Jeon <linkinjeon@gmail.com> writes:
> diff --git a/fs/fat/cache.c b/fs/fat/cache.c
> index c56bd7e..7777822 100644
> --- a/fs/fat/cache.c
> +++ b/fs/fat/cache.c
> @@ -312,6 +312,7 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
> const unsigned char blocksize_bits = sb->s_blocksize_bits;
> sector_t last_block;
> int cluster, offset;
> + loff_t i_size = i_size_read(inode);
>
> *phys = 0;
> *mapped_blocks = 0;
> @@ -323,10 +324,20 @@ int fat_bmap(struct inode *inode, sector_t sector, sector_t *phys,
> return 0;
> }
>
> - last_block = (i_size_read(inode) + (blocksize - 1)) >> blocksize_bits;
> + last_block = (i_size + (blocksize - 1)) >> blocksize_bits;
> if (sector >= last_block) {
> - if (!create)
> + if (!create) {
> + /*
> + * to map cluster in case of read request
> + * for a block in fallocated region
> + */
> + if (MSDOS_I(inode)->i_disksize >
> + round_up(i_size, sb->s_blocksize)) {
> + goto out_map_cluster;
> + }
Said on another reply though, we will have to add new flag for
this. Because normal read get_block() operation should not return
mapping beyond ->i_size.
> /* fat_get_cluster() assumes the requested blocknr isn't truncated. */
> - down_read(&MSDOS_I(mapping->host)->truncate_lock);
> + mutex_lock(&mapping->host->i_mutex);
> blocknr = generic_block_bmap(mapping, block, fat_get_block);
> - up_read(&MSDOS_I(mapping->host)->truncate_lock);
> + mutex_unlock(&mapping->host->i_mutex);
>
> return blocknr;
> }
->i_mutex doesn't work for swapfile.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region
2013-12-01 12:52 ` OGAWA Hirofumi
@ 2013-12-05 14:20 ` Namjae Jeon
2013-12-05 15:48 ` OGAWA Hirofumi
0 siblings, 1 reply; 5+ messages in thread
From: Namjae Jeon @ 2013-12-05 14:20 UTC (permalink / raw)
To: OGAWA Hirofumi
Cc: akpm, linux-fsdevel, linux-kernel, Namjae Jeon, Amit Sahrawat
2013/12/1, OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>:
> Namjae Jeon <linkinjeon@gmail.com> writes:
>
>> diff --git a/fs/fat/cache.c b/fs/fat/cache.c
>> index c56bd7e..7777822 100644
>> --- a/fs/fat/cache.c
>> +++ b/fs/fat/cache.c
>> @@ -312,6 +312,7 @@ int fat_bmap(struct inode *inode, sector_t sector,
>> sector_t *phys,
>> const unsigned char blocksize_bits = sb->s_blocksize_bits;
>> sector_t last_block;
>> int cluster, offset;
>> + loff_t i_size = i_size_read(inode);
>>
>> *phys = 0;
>> *mapped_blocks = 0;
>> @@ -323,10 +324,20 @@ int fat_bmap(struct inode *inode, sector_t sector,
>> sector_t *phys,
>> return 0;
>> }
>>
>> - last_block = (i_size_read(inode) + (blocksize - 1)) >> blocksize_bits;
>> + last_block = (i_size + (blocksize - 1)) >> blocksize_bits;
>> if (sector >= last_block) {
>> - if (!create)
>> + if (!create) {
>> + /*
>> + * to map cluster in case of read request
>> + * for a block in fallocated region
>> + */
>> + if (MSDOS_I(inode)->i_disksize >
>> + round_up(i_size, sb->s_blocksize)) {
>> + goto out_map_cluster;
>> + }
>
> Said on another reply though, we will have to add new flag for
> this. Because normal read get_block() operation should not return
> mapping beyond ->i_size.
Okay.
>
>> /* fat_get_cluster() assumes the requested blocknr isn't truncated. */
>> - down_read(&MSDOS_I(mapping->host)->truncate_lock);
>> + mutex_lock(&mapping->host->i_mutex);
>> blocknr = generic_block_bmap(mapping, block, fat_get_block);
>> - up_read(&MSDOS_I(mapping->host)->truncate_lock);
>> + mutex_unlock(&mapping->host->i_mutex);
>>
>> return blocknr;
>> }
>
> ->i_mutex doesn't work for swapfile.
Sorry, Actually, I don't understand why it is related with swapfile.
Could you elaborate more ?
Thanks.
> --
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region
2013-12-05 14:20 ` Namjae Jeon
@ 2013-12-05 15:48 ` OGAWA Hirofumi
2013-12-06 14:39 ` Namjae Jeon
0 siblings, 1 reply; 5+ messages in thread
From: OGAWA Hirofumi @ 2013-12-05 15:48 UTC (permalink / raw)
To: Namjae Jeon; +Cc: akpm, linux-fsdevel, linux-kernel, Namjae Jeon, Amit Sahrawat
Namjae Jeon <linkinjeon@gmail.com> writes:
>> ->i_mutex doesn't work for swapfile.
> Sorry, Actually, I don't understand why it is related with swapfile.
> Could you elaborate more ?
swapfile.c calls ->bmap to know physical address in swapfile. However,
swapfile.c calls ->bmap under inode->i_mutex.
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region
2013-12-05 15:48 ` OGAWA Hirofumi
@ 2013-12-06 14:39 ` Namjae Jeon
0 siblings, 0 replies; 5+ messages in thread
From: Namjae Jeon @ 2013-12-06 14:39 UTC (permalink / raw)
To: OGAWA Hirofumi
Cc: akpm, linux-fsdevel, linux-kernel, Namjae Jeon, Amit Sahrawat
2013/12/6, OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>:
> Namjae Jeon <linkinjeon@gmail.com> writes:
>
>>> ->i_mutex doesn't work for swapfile.
>> Sorry, Actually, I don't understand why it is related with swapfile.
>> Could you elaborate more ?
>
> swapfile.c calls ->bmap to know physical address in swapfile. However,
> swapfile.c calls ->bmap under inode->i_mutex.
Okay, Thanks for explanation.
>
> Thanks.
> --
> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-06 14:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-17 11:38 [PATCH v2 5/5] fat: permit to return phy block number by fibmap in fallocated region Namjae Jeon
2013-12-01 12:52 ` OGAWA Hirofumi
2013-12-05 14:20 ` Namjae Jeon
2013-12-05 15:48 ` OGAWA Hirofumi
2013-12-06 14:39 ` Namjae Jeon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.