* [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc @ 2008-06-18 17:52 Aneesh Kumar K.V 2008-06-18 18:03 ` Eric Sandeen 2008-06-18 22:26 ` Mingming 0 siblings, 2 replies; 5+ messages in thread From: Aneesh Kumar K.V @ 2008-06-18 17:52 UTC (permalink / raw) To: cmm, tytso, sandeen, adilger; +Cc: linux-ext4, Aneesh Kumar K.V With delalloc we don't do block allocation in the write_begin/write_end. So when using bmap we first need to flush data to the disk so that blocks get allocated and then call generic_block_bmap. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext4/inode.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 7035621..cfeb869 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1833,6 +1833,17 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) journal_t *journal; int err; + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && + test_opt(inode->i_sb, DELALLOC)) { + /* + * With delalloc we want to sync the file + * so that we can make sure we allocate + * blocks for file + */ + filemap_fdatawrite(mapping); + filemap_fdatawait(mapping); + } + if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) { /* * This is a REALLY heavyweight approach, but the use of -- 1.5.6.rc2.15.g457bb.dirty ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc 2008-06-18 17:52 [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc Aneesh Kumar K.V @ 2008-06-18 18:03 ` Eric Sandeen 2008-06-18 18:30 ` Aneesh Kumar K.V 2008-06-18 22:26 ` Mingming 1 sibling, 1 reply; 5+ messages in thread From: Eric Sandeen @ 2008-06-18 18:03 UTC (permalink / raw) To: Aneesh Kumar K.V; +Cc: cmm, tytso, adilger, linux-ext4 Aneesh Kumar K.V wrote: > With delalloc we don't do block allocation in the write_begin/write_end. > So when using bmap we first need to flush data to the disk so that blocks > get allocated and then call generic_block_bmap. > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> > --- > fs/ext4/inode.c | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 7035621..cfeb869 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1833,6 +1833,17 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) > journal_t *journal; > int err; > > + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && > + test_opt(inode->i_sb, DELALLOC)) { > + /* > + * With delalloc we want to sync the file > + * so that we can make sure we allocate > + * blocks for file > + */ > + filemap_fdatawrite(mapping); > + filemap_fdatawait(mapping); > + } This seems fine. I wonder, does it make any sense at all to only do the flushing if the block we wish to map is actually in a delalloc state at the moment? -Eric > + > if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) { > /* > * This is a REALLY heavyweight approach, but the use of ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc 2008-06-18 18:03 ` Eric Sandeen @ 2008-06-18 18:30 ` Aneesh Kumar K.V 0 siblings, 0 replies; 5+ messages in thread From: Aneesh Kumar K.V @ 2008-06-18 18:30 UTC (permalink / raw) To: Eric Sandeen; +Cc: cmm, tytso, adilger, linux-ext4 On Wed, Jun 18, 2008 at 01:03:32PM -0500, Eric Sandeen wrote: > Aneesh Kumar K.V wrote: > > With delalloc we don't do block allocation in the write_begin/write_end. > > So when using bmap we first need to flush data to the disk so that blocks > > get allocated and then call generic_block_bmap. > > > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> > > --- > > fs/ext4/inode.c | 11 +++++++++++ > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index 7035621..cfeb869 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -1833,6 +1833,17 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) > > journal_t *journal; > > int err; > > > > + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && > > + test_opt(inode->i_sb, DELALLOC)) { > > + /* > > + * With delalloc we want to sync the file > > + * so that we can make sure we allocate > > + * blocks for file > > + */ > > + filemap_fdatawrite(mapping); > > + filemap_fdatawait(mapping); > > + } > > This seems fine. > > I wonder, does it make any sense at all to only do the flushing if the > block we wish to map is actually in a delalloc state at the moment? > I am not sure it is worth the complexity considering bmap is not a frequently used API. Initially I was even thinking should i be doing it only for delalloc. That test seems to be a simple one to put. -aneesh ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc 2008-06-18 17:52 [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc Aneesh Kumar K.V 2008-06-18 18:03 ` Eric Sandeen @ 2008-06-18 22:26 ` Mingming 2008-06-19 3:29 ` Aneesh Kumar K.V 1 sibling, 1 reply; 5+ messages in thread From: Mingming @ 2008-06-18 22:26 UTC (permalink / raw) To: Aneesh Kumar K.V; +Cc: tytso, sandeen, adilger, linux-ext4 On Wed, 2008-06-18 at 23:22 +0530, Aneesh Kumar K.V wrote: > With delalloc we don't do block allocation in the write_begin/write_end. > So when using bmap we first need to flush data to the disk so that blocks > get allocated and then call generic_block_bmap. > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> > --- > fs/ext4/inode.c | 11 +++++++++++ > 1 files changed, 11 insertions(+), 0 deletions(-) > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > index 7035621..cfeb869 100644 > --- a/fs/ext4/inode.c > +++ b/fs/ext4/inode.c > @@ -1833,6 +1833,17 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) > journal_t *journal; > int err; > > + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && > + test_opt(inode->i_sb, DELALLOC)) { > + /* > + * With delalloc we want to sync the file > + * so that we can make sure we allocate > + * blocks for file > + */ > + filemap_fdatawrite(mapping); > + filemap_fdatawait(mapping); > + } > + I would use filemap_write_and_wait(), it is essentially the same as above two functions, but with a little extra checking. Mingming > if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) { > /* > * This is a REALLY heavyweight approach, but the use of ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc 2008-06-18 22:26 ` Mingming @ 2008-06-19 3:29 ` Aneesh Kumar K.V 0 siblings, 0 replies; 5+ messages in thread From: Aneesh Kumar K.V @ 2008-06-19 3:29 UTC (permalink / raw) To: Mingming; +Cc: tytso, sandeen, adilger, linux-ext4 On Wed, Jun 18, 2008 at 03:26:25PM -0700, Mingming wrote: > > On Wed, 2008-06-18 at 23:22 +0530, Aneesh Kumar K.V wrote: > > With delalloc we don't do block allocation in the write_begin/write_end. > > So when using bmap we first need to flush data to the disk so that blocks > > get allocated and then call generic_block_bmap. > > > > Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> > > --- > > fs/ext4/inode.c | 11 +++++++++++ > > 1 files changed, 11 insertions(+), 0 deletions(-) > > > > diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c > > index 7035621..cfeb869 100644 > > --- a/fs/ext4/inode.c > > +++ b/fs/ext4/inode.c > > @@ -1833,6 +1833,17 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) > > journal_t *journal; > > int err; > > > > + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && > > + test_opt(inode->i_sb, DELALLOC)) { > > + /* > > + * With delalloc we want to sync the file > > + * so that we can make sure we allocate > > + * blocks for file > > + */ > > + filemap_fdatawrite(mapping); > > + filemap_fdatawait(mapping); > > + } > > + > > I would use filemap_write_and_wait(), it is essentially the same as > above two functions, but with a little extra checking. > Updated patch below ext4: Fix ext4_bmap to flush the data to the disk with delalloc From: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> With delalloc we don't do block allocation in the write_begin/write_end. So when using bmap we first need to flush data to the disk so that blocks get allocated and then call generic_block_bmap. Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> --- fs/ext4/inode.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 7035621..f1bd194 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1833,6 +1833,16 @@ sector_t ext4_bmap(struct address_space *mapping, sector_t block) journal_t *journal; int err; + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && + test_opt(inode->i_sb, DELALLOC)) { + /* + * With delalloc we want to sync the file + * so that we can make sure we allocate + * blocks for file + */ + filemap_write_and_wait(mapping); + } + if (EXT4_I(inode)->i_state & EXT4_STATE_JDATA) { /* * This is a REALLY heavyweight approach, but the use of ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-19 3:29 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-06-18 17:52 [PATCH] ext4: Fix ext4_bmap to flush the data to the disk with delalloc Aneesh Kumar K.V 2008-06-18 18:03 ` Eric Sandeen 2008-06-18 18:30 ` Aneesh Kumar K.V 2008-06-18 22:26 ` Mingming 2008-06-19 3:29 ` Aneesh Kumar K.V
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox