From: Mingming Cao <cmm@us.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: tytso@mit.edu, sandeen@redhat.com, linux-ext4@vger.kernel.org
Subject: Re: [PATCH -V3 05/11] ext4: Switch to non delalloc mode when we are low on free blocks count.
Date: Thu, 28 Aug 2008 13:57:59 -0700 [thread overview]
Message-ID: <1219957079.6384.18.camel@mingming-laptop> (raw)
In-Reply-To: <1219850916-8986-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
在 2008-08-27三的 20:58 +0530,Aneesh Kumar K.V写道:
> delayed allocation allocate blocks during writepages. That also
> means we cannot handle block allocation failures. Switch to
> non - delalloc when we are running low on free blocks.
> Delayed allocation need to do aggressive meta-data block reservation
> considering that the requested blocks can all be discontiguous.
> Switching to non-delalloc avoids that. Also we can satisfy
> partial write in non-delalloc mode.
>
Added to patch queue
Reviewed-by: Mingming Cao <cmm@us.ibm.com>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> fs/ext4/inode.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 50 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 14ec7d1..a45121f 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -2458,6 +2458,33 @@ static int ext4_da_writepages(struct address_space *mapping,
> return ret;
> }
>
> +#define FALL_BACK_TO_NONDELALLOC 1
> +static int ext4_nonda_switch(struct super_block *sb)
> +{
> + s64 free_blocks, dirty_blocks;
> + struct ext4_sb_info *sbi = EXT4_SB(sb);
> +
> + /*
> + * switch to non delalloc mode if we are running low
> + * on free block. The free block accounting via percpu
> + * counters can get slightly wrong with FBC_BATCH getting
> + * accumulated on each CPU without updating global counters
> + * Delalloc need an accurate free block accounting. So switch
> + * to non delalloc when we are near to error range.
> + */
> + free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
> + dirty_blocks = percpu_counter_read_positive(&sbi->s_dirtyblocks_counter);
> + if (2 * free_blocks < 3 * dirty_blocks ||
> + free_blocks < (dirty_blocks + EXT4_FREEBLOCKS_WATERMARK)) {
> + /*
> + * free block count is less that 150% of dirty blocks
> + * or free blocks is less that watermark
> + */
> + return 1;
> + }
> + return 0;
> +}
> +
> static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
> loff_t pos, unsigned len, unsigned flags,
> struct page **pagep, void **fsdata)
> @@ -2472,6 +2499,13 @@ static int ext4_da_write_begin(struct file *file, struct address_space *mapping,
> index = pos >> PAGE_CACHE_SHIFT;
> from = pos & (PAGE_CACHE_SIZE - 1);
> to = from + len;
> +
> + if (ext4_nonda_switch(inode->i_sb)) {
> + *fsdata = (void *)FALL_BACK_TO_NONDELALLOC;
> + return ext4_write_begin(file, mapping, pos,
> + len, flags, pagep, fsdata);
> + }
> + *fsdata = (void *)0;
> retry:
> /*
> * With delayed allocation, we don't log the i_disksize update
> @@ -2540,6 +2574,19 @@ static int ext4_da_write_end(struct file *file,
> handle_t *handle = ext4_journal_current_handle();
> loff_t new_i_size;
> unsigned long start, end;
> + int write_mode = (int)fsdata;
> +
> + if (write_mode == FALL_BACK_TO_NONDELALLOC) {
> + if (ext4_should_order_data(inode)) {
> + return ext4_ordered_write_end(file, mapping, pos,
> + len, copied, page, fsdata);
> + } else if (ext4_should_writeback_data(inode)) {
> + return ext4_writeback_write_end(file, mapping, pos,
> + len, copied, page, fsdata);
> + } else {
> + BUG();
> + }
> + }
>
> start = pos & (PAGE_CACHE_SIZE - 1);
> end = start + copied -1;
> @@ -4877,6 +4924,7 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page)
> loff_t size;
> unsigned long len;
> int ret = -EINVAL;
> + void *fsdata;
> struct file *file = vma->vm_file;
> struct inode *inode = file->f_path.dentry->d_inode;
> struct address_space *mapping = inode->i_mapping;
> @@ -4915,11 +4963,11 @@ int ext4_page_mkwrite(struct vm_area_struct *vma, struct page *page)
> * on the same page though
> */
> ret = mapping->a_ops->write_begin(file, mapping, page_offset(page),
> - len, AOP_FLAG_UNINTERRUPTIBLE, &page, NULL);
> + len, AOP_FLAG_UNINTERRUPTIBLE, &page, &fsdata);
> if (ret < 0)
> goto out_unlock;
> ret = mapping->a_ops->write_end(file, mapping, page_offset(page),
> - len, len, page, NULL);
> + len, len, page, fsdata);
> if (ret < 0)
> goto out_unlock;
> ret = 0;
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2008-08-28 20:58 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-27 15:28 [PATCH -V3 01/11] percpu_counters: make fbc->count read atomic on 32 bit architecture Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 02/11] ext4: Make sure all the block allocation paths reserve blocks Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 03/11] ext4: Retry block reservation Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 04/11] ext4: Add percpu dirty block accounting Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 05/11] ext4: Switch to non delalloc mode when we are low on free blocks count Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 06/11] ext4: Update meta-data reservation with delalloc Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 07/11] ext4: request for blocks with ar.excepted_group = -1 Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 08/11] ext4: Signed arithematic fix Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 09/11] ext4: Fix ext4 nomballoc allocator for ENOSPC Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 10/11] ext4: Add inode to journal handle after block allocation for ordered mode Aneesh Kumar K.V
2008-08-27 15:28 ` [PATCH -V3 11/11] ext4: Retry block allocation if we have free blocks left Aneesh Kumar K.V
2008-08-28 21:57 ` [PATCH -V3 09/11] ext4: Fix ext4 nomballoc allocator for ENOSPC Mingming Cao
2008-08-29 3:44 ` Aneesh Kumar K.V
2008-08-29 4:14 ` Aneesh Kumar K.V
2008-08-29 5:02 ` Mingming Cao
2008-08-29 5:06 ` Mingming Cao
2008-08-29 8:25 ` Aneesh Kumar K.V
2008-08-28 21:04 ` [PATCH -V3 08/11] ext4: Signed arithematic fix Mingming Cao
2008-08-28 21:03 ` [PATCH -V3 07/11] ext4: request for blocks with ar.excepted_group = -1 Mingming Cao
2008-08-28 21:03 ` [PATCH -V3 06/11] ext4: Update meta-data reservation with delalloc Mingming Cao
2008-08-28 20:57 ` Mingming Cao [this message]
2008-08-28 20:56 ` [PATCH -V3 04/11] ext4: Add percpu dirty block accounting Mingming Cao
2008-10-09 20:44 ` Eric Sandeen
2008-10-10 4:52 ` Aneesh Kumar K.V
2008-10-10 4:58 ` Eric Sandeen
2008-10-11 21:10 ` Andreas Dilger
2008-08-28 20:42 ` [PATCH -V3 03/11] ext4: Retry block reservation Mingming Cao
2008-08-28 20:41 ` [PATCH -V3 02/11] ext4: Make sure all the block allocation paths reserve blocks Mingming Cao
2008-08-27 19:05 ` [PATCH -V3 01/11] percpu_counters: make fbc->count read atomic on 32 bit architecture Andrew Morton
2008-08-27 21:01 ` Peter Zijlstra
2008-08-27 21:22 ` Andrew Morton
2008-08-28 3:52 ` Aneesh Kumar K.V
2008-08-28 4:09 ` Andrew Morton
2008-08-28 22:59 ` Mingming Cao
2008-08-28 7:57 ` Peter Zijlstra
2008-08-28 3:48 ` Aneesh Kumar K.V
2008-08-28 4:06 ` Andrew Morton
2008-08-28 14:19 ` Nick Piggin
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=1219957079.6384.18.camel@mingming-laptop \
--to=cmm@us.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-ext4@vger.kernel.org \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
/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