* [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation.
@ 2008-03-21 6:18 Aneesh Kumar K.V
2008-03-21 6:18 ` [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space Aneesh Kumar K.V
2008-03-21 22:08 ` [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Mingming Cao
0 siblings, 2 replies; 6+ messages in thread
From: Aneesh Kumar K.V @ 2008-03-21 6:18 UTC (permalink / raw)
To: cmm, tytso, sandeen, Solofo.Ramangalahy, dmonakhov
Cc: linux-ext4, Aneesh Kumar K.V
We need to update i_disksize after allocating blocks. writepages
already does this. Update writepage to also update i_disksize.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
fs/ext4/inode.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 79930df..50d700f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1488,6 +1488,44 @@ out:
return ret;
}
+/* FIXME!! only support data=writeback mode */
+static int ext4_da_writepage(struct page *page,
+ struct writeback_control *wbc)
+{
+ struct inode *inode = page->mapping->host;
+ handle_t *handle = NULL;
+ int ret = 0;
+ int err;
+
+ if (ext4_journal_current_handle())
+ goto out_fail;
+
+ handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
+ if (IS_ERR(handle)) {
+ ret = PTR_ERR(handle);
+ goto out_fail;
+ }
+
+ if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
+ ret = nobh_writepage(page, ext4_get_block, wbc);
+ else
+ ret = block_write_full_page(page, ext4_get_block, wbc);
+
+ if (!ret && inode->i_size > EXT4_I(inode)->i_disksize) {
+ EXT4_I(inode)->i_disksize = inode->i_size;
+ ext4_mark_inode_dirty(handle, inode);
+ }
+
+ err = ext4_journal_stop(handle);
+ if (!ret)
+ ret = err;
+ return ret;
+
+out_fail:
+ redirty_page_for_writepage(wbc, page);
+ unlock_page(page);
+ return ret;
+}
static int ext4_da_writepages(struct address_space *mapping,
struct writeback_control *wbc)
@@ -2015,7 +2053,7 @@ static const struct address_space_operations ext4_journalled_aops = {
static const struct address_space_operations ext4_da_aops = {
.readpage = ext4_readpage,
.readpages = ext4_readpages,
- .writepage = ext4_writeback_writepage,
+ .writepage = ext4_da_writepage,
.writepages = ext4_da_writepages,
.sync_page = block_sync_page,
.write_begin = ext4_da_write_begin,
--
1.5.5.rc0.16.g02b00.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread* [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space.
2008-03-21 6:18 [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Aneesh Kumar K.V
@ 2008-03-21 6:18 ` Aneesh Kumar K.V
2008-03-21 22:13 ` Mingming Cao
2008-03-21 22:08 ` [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Mingming Cao
1 sibling, 1 reply; 6+ messages in thread
From: Aneesh Kumar K.V @ 2008-03-21 6:18 UTC (permalink / raw)
To: cmm, tytso, sandeen, Solofo.Ramangalahy, dmonakhov
Cc: linux-ext4, Aneesh Kumar K.V
ext4_ext_get_blocks returns number of blocks allocated with buffer head
unmapped for a read from prealloc space. This is needed so that delayed
allocation doesn't do block reservation for prealloc space since the blocks
are already resevred on disk. Fix ext4_ext_get_blocks to not return greater
than max_blocks and also mark the buffer head unwritten. Some code path tries
to read the block if buffer_head is not new and no uptodate. Marking the buffer
head unwritten avoid this reading.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
fs/ext4/extents.c | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index d6ae40a..edd1bf2 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2600,8 +2600,20 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
}
if (create == EXT4_CREATE_UNINITIALIZED_EXT)
goto out;
- if (!create)
+ if (!create) {
+ /*
+ * We have blocks reserved already. We
+ * return allocated blocks so that delalloc
+ * won't do block reservation for us. But
+ * the buffer head will be unmapped so that
+ * a read from the block return 0
+ */
+ if (allocated > max_blocks)
+ allocated = max_blocks;
+ /* mark the buffer unwritten */
+ __set_bit(BH_Unwritten, &bh_result->b_state);
goto out2;
+ }
ret = ext4_ext_convert_to_initialized(handle, inode,
path, iblock,
--
1.5.5.rc0.16.g02b00.dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space.
2008-03-21 6:18 ` [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space Aneesh Kumar K.V
@ 2008-03-21 22:13 ` Mingming Cao
2008-03-24 8:11 ` Aneesh Kumar K.V
0 siblings, 1 reply; 6+ messages in thread
From: Mingming Cao @ 2008-03-21 22:13 UTC (permalink / raw)
To: Aneesh Kumar K.V
Cc: tytso, sandeen, Solofo.Ramangalahy, dmonakhov, linux-ext4
On Fri, 2008-03-21 at 11:48 +0530, Aneesh Kumar K.V wrote:
> ext4_ext_get_blocks returns number of blocks allocated with buffer head
> unmapped for a read from prealloc space. This is needed so that delayed
> allocation doesn't do block reservation for prealloc space since the blocks
> are already resevred on disk. Fix ext4_ext_get_blocks to not return greater
> than max_blocks and also mark the buffer head unwritten. Some code path tries
> to read the block if buffer_head is not new and no uptodate. Marking the buffer
> head unwritten avoid this reading.
>
Seems this patch fixes two bugs together, it would be nice to split to
two as they cause two different problems.
To fix the bh->b_size warning solof founds for delayed allocation, I
would say we need to fix it in ext4_get_blocks_handle() (for indirect
files) and ext4_ext_get_blocks()(for extent files) both, not allowing
returning b_size greater than what the caller asking for. Also, the
patch below seems only address the preallocation map case, we need to
fix in in general block lookup case.
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> fs/ext4/extents.c | 14 +++++++++++++-
> 1 files changed, 13 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index d6ae40a..edd1bf2 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -2600,8 +2600,20 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
> }
> if (create == EXT4_CREATE_UNINITIALIZED_EXT)
> goto out;
> - if (!create)
> + if (!create) {
> + /*
> + * We have blocks reserved already. We
> + * return allocated blocks so that delalloc
> + * won't do block reservation for us. But
> + * the buffer head will be unmapped so that
> + * a read from the block return 0
> + */
> + if (allocated > max_blocks)
> + allocated = max_blocks;
> + /* mark the buffer unwritten */
> + __set_bit(BH_Unwritten, &bh_result->b_state);
> goto out2;
> + }
>
> ret = ext4_ext_convert_to_initialized(handle, inode,
> path, iblock,
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space.
2008-03-21 22:13 ` Mingming Cao
@ 2008-03-24 8:11 ` Aneesh Kumar K.V
2008-03-24 16:04 ` Mingming Cao
0 siblings, 1 reply; 6+ messages in thread
From: Aneesh Kumar K.V @ 2008-03-24 8:11 UTC (permalink / raw)
To: Mingming Cao; +Cc: tytso, sandeen, Solofo.Ramangalahy, dmonakhov, linux-ext4
On Fri, Mar 21, 2008 at 03:13:58PM -0700, Mingming Cao wrote:
> On Fri, 2008-03-21 at 11:48 +0530, Aneesh Kumar K.V wrote:
> > ext4_ext_get_blocks returns number of blocks allocated with buffer head
> > unmapped for a read from prealloc space. This is needed so that delayed
> > allocation doesn't do block reservation for prealloc space since the blocks
> > are already resevred on disk. Fix ext4_ext_get_blocks to not return greater
> > than max_blocks and also mark the buffer head unwritten. Some code path tries
> > to read the block if buffer_head is not new and no uptodate. Marking the buffer
> > head unwritten avoid this reading.
> >
>
> Seems this patch fixes two bugs together, it would be nice to split to
> two as they cause two different problems.
Split patches here.
http://www.radian.org/~kvaneesh/ext4/patches-to-patchqueue/
>
> To fix the bh->b_size warning solof founds for delayed allocation, I
> would say we need to fix it in ext4_get_blocks_handle() (for indirect
> files) and ext4_ext_get_blocks()(for extent files) both, not allowing
> returning b_size greater than what the caller asking for. Also, the
> patch below seems only address the preallocation map case, we need to
> fix in in general block lookup case.
>
ext4_ext_get_blocks already make sure we doesn't return > max_blocks.
for normal allocation.
2694 out:
2695 if (allocated > max_blocks)
2696 allocated = max_blocks;
-aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space.
2008-03-24 8:11 ` Aneesh Kumar K.V
@ 2008-03-24 16:04 ` Mingming Cao
0 siblings, 0 replies; 6+ messages in thread
From: Mingming Cao @ 2008-03-24 16:04 UTC (permalink / raw)
To: Aneesh Kumar K.V
Cc: tytso, sandeen, Solofo.Ramangalahy, dmonakhov, linux-ext4
On Mon, 2008-03-24 at 13:41 +0530, Aneesh Kumar K.V wrote:
> On Fri, Mar 21, 2008 at 03:13:58PM -0700, Mingming Cao wrote:
> > On Fri, 2008-03-21 at 11:48 +0530, Aneesh Kumar K.V wrote:
> > > ext4_ext_get_blocks returns number of blocks allocated with buffer head
> > > unmapped for a read from prealloc space. This is needed so that delayed
> > > allocation doesn't do block reservation for prealloc space since the blocks
> > > are already resevred on disk. Fix ext4_ext_get_blocks to not return greater
> > > than max_blocks and also mark the buffer head unwritten. Some code path tries
> > > to read the block if buffer_head is not new and no uptodate. Marking the buffer
> > > head unwritten avoid this reading.
> > >
> >
> > Seems this patch fixes two bugs together, it would be nice to split to
> > two as they cause two different problems.
>
> Split patches here.
>
> http://www.radian.org/~kvaneesh/ext4/patches-to-patchqueue/
>
I will pick them up in patch queue.
> >
> > To fix the bh->b_size warning solof founds for delayed allocation, I
> > would say we need to fix it in ext4_get_blocks_handle() (for indirect
> > files) and ext4_ext_get_blocks()(for extent files) both, not allowing
> > returning b_size greater than what the caller asking for. Also, the
> > patch below seems only address the preallocation map case, we need to
> > fix in in general block lookup case.
> >
>
> ext4_ext_get_blocks already make sure we doesn't return > max_blocks.
> for normal allocation.
>
> 2694 out:
> 2695 if (allocated > max_blocks)
> 2696 allocated = max_blocks;
>
Oh I see, I missed that.
Regards,
Mingming
>
> -aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation.
2008-03-21 6:18 [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Aneesh Kumar K.V
2008-03-21 6:18 ` [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space Aneesh Kumar K.V
@ 2008-03-21 22:08 ` Mingming Cao
1 sibling, 0 replies; 6+ messages in thread
From: Mingming Cao @ 2008-03-21 22:08 UTC (permalink / raw)
To: Aneesh Kumar K.V
Cc: tytso, sandeen, Solofo.Ramangalahy, dmonakhov, linux-ext4
On Fri, 2008-03-21 at 11:48 +0530, Aneesh Kumar K.V wrote:
> We need to update i_disksize after allocating blocks. writepages
> already does this. Update writepage to also update i_disksize.
>
I agree that we should update the i_disk size after the allocation, to
avoid possible exposing stale data in case of fs crash happened after
the metadata hit to disk but before data being written out.
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> fs/ext4/inode.c | 40 +++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 39 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 79930df..50d700f 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1488,6 +1488,44 @@ out:
>
> return ret;
> }
> +/* FIXME!! only support data=writeback mode */
> +static int ext4_da_writepage(struct page *page,
> + struct writeback_control *wbc)
> +{
> + struct inode *inode = page->mapping->host;
> + handle_t *handle = NULL;
> + int ret = 0;
> + int err;
> +
> + if (ext4_journal_current_handle())
> + goto out_fail;
> +
> + handle = ext4_journal_start(inode, ext4_writepage_trans_blocks(inode));
> + if (IS_ERR(handle)) {
> + ret = PTR_ERR(handle);
> + goto out_fail;
> + }
> +
> + if (test_opt(inode->i_sb, NOBH) && ext4_should_writeback_data(inode))
> + ret = nobh_writepage(page, ext4_get_block, wbc);
> + else
> + ret = block_write_full_page(page, ext4_get_block, wbc);
> +
> + if (!ret && inode->i_size > EXT4_I(inode)->i_disksize) {
> + EXT4_I(inode)->i_disksize = inode->i_size;
> + ext4_mark_inode_dirty(handle, inode);
> + }
> +
> + err = ext4_journal_stop(handle);
> + if (!ret)
> + ret = err;
> + return ret;
> +
> +out_fail:
> + redirty_page_for_writepage(wbc, page);
> + unlock_page(page);
> + return ret;
> +}
>
> static int ext4_da_writepages(struct address_space *mapping,
> struct writeback_control *wbc)
> @@ -2015,7 +2053,7 @@ static const struct address_space_operations ext4_journalled_aops = {
> static const struct address_space_operations ext4_da_aops = {
> .readpage = ext4_readpage,
> .readpages = ext4_readpages,
> - .writepage = ext4_writeback_writepage,
> + .writepage = ext4_da_writepage,
> .writepages = ext4_da_writepages,
> .sync_page = block_sync_page,
> .write_begin = ext4_da_write_begin,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-03-24 16:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21 6:18 [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Aneesh Kumar K.V
2008-03-21 6:18 ` [RFC PATCH] ext4: Return unwritten buffer head when trying to read from prealloc space Aneesh Kumar K.V
2008-03-21 22:13 ` Mingming Cao
2008-03-24 8:11 ` Aneesh Kumar K.V
2008-03-24 16:04 ` Mingming Cao
2008-03-21 22:08 ` [RFC PATCH] ext4: Update i_diskzie during writepage for delayed allocation Mingming Cao
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.