* [PATCH, RFC] support discard in non-journal ext4 @ 2010-05-13 5:00 Jiaying Zhang 2010-05-13 9:08 ` Coly Li 0 siblings, 1 reply; 5+ messages in thread From: Jiaying Zhang @ 2010-05-13 5:00 UTC (permalink / raw) To: linux-ext4; +Cc: jiayingz This patch issues discard request for freed blocks in ext4_free_blocks() if ext4 is mounted with discard option and without journal. Author: Jiaying Zhang <jiayingz@google.com> Date: Wed May 12 21:11:46 2010 -0700 Issue discard request in ext4_free_blocks() when ext4 has no journal and is mounted with discard option. Signed-off-by: Jiaying Zhang <jiayingz@google.com> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a291cc3..d51b79a 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) return 0; } +static void ext4_issue_discard(struct super_block *sb, ext4_group_t block_group, + ext4_grpblk_t block, int count) +{ + int ret; + ext4_fsblk_t discard_block; + + discard_block = block + ext4_group_first_block_no(sb, block_group); + trace_ext4_discard_blocks(sb, + (unsigned long long) discard_block, count); + ret = sb_issue_discard(sb, discard_block, count); + if (ret == EOPNOTSUPP) { + ext4_warning(sb, "discard not supported, disabling"); + clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); + } +} + /* * This function is called by the jbd2 layer once the commit has finished, * so we know we can free the blocks that were released with that commit. @@ -2532,22 +2548,9 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) mb_debug(1, "gonna free %u blocks in group %u (0x%p):", entry->count, entry->group, entry); - if (test_opt(sb, DISCARD)) { - int ret; - ext4_fsblk_t discard_block; - - discard_block = entry->start_blk + - ext4_group_first_block_no(sb, entry->group); - trace_ext4_discard_blocks(sb, - (unsigned long long)discard_block, - entry->count); - ret = sb_issue_discard(sb, discard_block, entry->count); - if (ret == EOPNOTSUPP) { - ext4_warning(sb, - "discard not supported, disabling"); - clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); - } - } + if (test_opt(sb, DISCARD)) + ext4_issue_discard(sb, entry->group, + entry->start_blk, entry->count); err = ext4_mb_load_buddy(sb, entry->group, &e4b); /* we expect to find existing buddy because it's pinned */ @@ -4600,6 +4603,8 @@ do_more: mb_clear_bits(bitmap_bh->b_data, bit, count); mb_free_blocks(inode, &e4b, bit, count); ext4_mb_return_to_preallocation(inode, &e4b, block, count); + if (test_opt(sb, DISCARD)) + ext4_issue_discard(sb, block_group, bit, count); } ret = ext4_free_blks_count(sb, gdp) + count; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH, RFC] support discard in non-journal ext4 2010-05-13 5:00 [PATCH, RFC] support discard in non-journal ext4 Jiaying Zhang @ 2010-05-13 9:08 ` Coly Li 2010-05-14 0:29 ` Jiaying Zhang 0 siblings, 1 reply; 5+ messages in thread From: Coly Li @ 2010-05-13 9:08 UTC (permalink / raw) To: Jiaying Zhang; +Cc: linux-ext4 On 05/13/2010 01:00 PM, Jiaying Zhang Wrote: > This patch issues discard request for freed blocks in ext4_free_blocks() > if ext4 is mounted with discard option and without journal. > > Author: Jiaying Zhang <jiayingz@google.com> > Date: Wed May 12 21:11:46 2010 -0700 > > Issue discard request in ext4_free_blocks() when ext4 has no journal and > is mounted with discard option. > > Signed-off-by: Jiaying Zhang <jiayingz@google.com> > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > index a291cc3..d51b79a 100644 > --- a/fs/ext4/mballoc.c > +++ b/fs/ext4/mballoc.c > @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) > return 0; > } > > +static void ext4_issue_discard(struct super_block *sb, ext4_group_t block_group, > + ext4_grpblk_t block, int count) > +{ > + int ret; > + ext4_fsblk_t discard_block; > + > + discard_block = block + ext4_group_first_block_no(sb, block_group); > + trace_ext4_discard_blocks(sb, > + (unsigned long long) discard_block, count); > + ret = sb_issue_discard(sb, discard_block, count); > + if (ret == EOPNOTSUPP) { > + ext4_warning(sb, "discard not supported, disabling"); > + clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); > + } > +} > + How about make it as an inline routine? Thanks. -- Coly Li SuSE Labs ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH, RFC] support discard in non-journal ext4 2010-05-13 9:08 ` Coly Li @ 2010-05-14 0:29 ` Jiaying Zhang 2010-05-14 4:03 ` Coly Li 2010-05-14 4:09 ` Coly Li 0 siblings, 2 replies; 5+ messages in thread From: Jiaying Zhang @ 2010-05-14 0:29 UTC (permalink / raw) To: coly.li; +Cc: linux-ext4 [-- Attachment #1: Type: text/plain, Size: 1655 bytes --] On Thu, May 13, 2010 at 2:08 AM, Coly Li <coly.li@suse.de> wrote: > > > On 05/13/2010 01:00 PM, Jiaying Zhang Wrote: > > This patch issues discard request for freed blocks in ext4_free_blocks() > > if ext4 is mounted with discard option and without journal. > > > > Author: Jiaying Zhang <jiayingz@google.com> > > Date: Wed May 12 21:11:46 2010 -0700 > > > > Issue discard request in ext4_free_blocks() when ext4 has no journal and > > is mounted with discard option. > > > > Signed-off-by: Jiaying Zhang <jiayingz@google.com> > > > > diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c > > index a291cc3..d51b79a 100644 > > --- a/fs/ext4/mballoc.c > > +++ b/fs/ext4/mballoc.c > > @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) > > return 0; > > } > > > > +static void ext4_issue_discard(struct super_block *sb, ext4_group_t block_group, > > + ext4_grpblk_t block, int count) > > +{ > > + int ret; > > + ext4_fsblk_t discard_block; > > + > > + discard_block = block + ext4_group_first_block_no(sb, block_group); > > + trace_ext4_discard_blocks(sb, > > + (unsigned long long) discard_block, count); > > + ret = sb_issue_discard(sb, discard_block, count); > > + if (ret == EOPNOTSUPP) { > > + ext4_warning(sb, "discard not supported, disabling"); > > + clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); > > + } > > +} > > + > > How about make it as an inline routine? Thanks. Ok. I changed it to inline. The modified patch is attached. Thanks! Jiaying > > -- > Coly Li > SuSE Labs [-- Attachment #2: ext4-discard-nojournal.v2.patch --] [-- Type: text/x-patch, Size: 2421 bytes --] commit 43e4186b502e13957544991c6a456447a6aa3aa9 Author: Jiaying Zhang <jiayingz@google.com> Date: Wed May 12 21:11:46 2010 -0700 Issue discard request in ext4_free_blocks() when ext4 has no journal and is mounted with discard option. Signed-off-by: Jiaying Zhang <jiayingz@google.com> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index a291cc3..ecaf7e7 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) return 0; } +static inline void ext4_issue_discard(struct super_block *sb, + ext4_group_t block_group, ext4_grpblk_t block, int count) +{ + int ret; + ext4_fsblk_t discard_block; + + discard_block = block + ext4_group_first_block_no(sb, block_group); + trace_ext4_discard_blocks(sb, + (unsigned long long) discard_block, count); + ret = sb_issue_discard(sb, discard_block, count); + if (ret == EOPNOTSUPP) { + ext4_warning(sb, "discard not supported, disabling"); + clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); + } +} + /* * This function is called by the jbd2 layer once the commit has finished, * so we know we can free the blocks that were released with that commit. @@ -2532,22 +2548,9 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn) mb_debug(1, "gonna free %u blocks in group %u (0x%p):", entry->count, entry->group, entry); - if (test_opt(sb, DISCARD)) { - int ret; - ext4_fsblk_t discard_block; - - discard_block = entry->start_blk + - ext4_group_first_block_no(sb, entry->group); - trace_ext4_discard_blocks(sb, - (unsigned long long)discard_block, - entry->count); - ret = sb_issue_discard(sb, discard_block, entry->count); - if (ret == EOPNOTSUPP) { - ext4_warning(sb, - "discard not supported, disabling"); - clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); - } - } + if (test_opt(sb, DISCARD)) + ext4_issue_discard(sb, entry->group, + entry->start_blk, entry->count); err = ext4_mb_load_buddy(sb, entry->group, &e4b); /* we expect to find existing buddy because it's pinned */ @@ -4600,6 +4603,8 @@ do_more: mb_clear_bits(bitmap_bh->b_data, bit, count); mb_free_blocks(inode, &e4b, bit, count); ext4_mb_return_to_preallocation(inode, &e4b, block, count); + if (test_opt(sb, DISCARD)) + ext4_issue_discard(sb, block_group, bit, count); } ret = ext4_free_blks_count(sb, gdp) + count; ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH, RFC] support discard in non-journal ext4 2010-05-14 0:29 ` Jiaying Zhang @ 2010-05-14 4:03 ` Coly Li 2010-05-14 4:09 ` Coly Li 1 sibling, 0 replies; 5+ messages in thread From: Coly Li @ 2010-05-14 4:03 UTC (permalink / raw) To: Jiaying Zhang; +Cc: linux-ext4 On 05/14/2010 08:29 AM, Jiaying Zhang Wrote: > On Thu, May 13, 2010 at 2:08 AM, Coly Li <coly.li@suse.de> wrote: >> >> >> On 05/13/2010 01:00 PM, Jiaying Zhang Wrote: >>> This patch issues discard request for freed blocks in ext4_free_blocks() >>> if ext4 is mounted with discard option and without journal. >>> >>> Author: Jiaying Zhang <jiayingz@google.com> >>> Date: � Wed May 12 21:11:46 2010 -0700 >>> >>> � � Issue discard request in ext4_free_blocks() when ext4 has no journal and >>> � � is mounted with discard option. >>> >>> � � Signed-off-by: Jiaying Zhang <jiayingz@google.com> >>> >>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >>> index a291cc3..d51b79a 100644 >>> --- a/fs/ext4/mballoc.c >>> +++ b/fs/ext4/mballoc.c >>> @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) >>> � � � return 0; >>> �} >>> >>> +static void ext4_issue_discard(struct super_block *sb, ext4_group_t block_group, [snip] >> >> How about make it as an inline routine? Thanks. > > Ok. I changed it to inline. The modified patch is attached. > Acked-by: Coly Li <coly.li@suse.de> Thanks. -- Coly Li SuSE Labs -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH, RFC] support discard in non-journal ext4 2010-05-14 0:29 ` Jiaying Zhang 2010-05-14 4:03 ` Coly Li @ 2010-05-14 4:09 ` Coly Li 1 sibling, 0 replies; 5+ messages in thread From: Coly Li @ 2010-05-14 4:09 UTC (permalink / raw) To: Jiaying Zhang; +Cc: linux-ext4 On 05/14/2010 08:29 AM, Jiaying Zhang Wrote: > On Thu, May 13, 2010 at 2:08 AM, Coly Li <coly.li@suse.de> wrote: >> >> >> On 05/13/2010 01:00 PM, Jiaying Zhang Wrote: >>> This patch issues discard request for freed blocks in ext4_free_blocks() >>> if ext4 is mounted with discard option and without journal. >>> >>> Author: Jiaying Zhang <jiayingz@google.com> >>> Date: � Wed May 12 21:11:46 2010 -0700 >>> >>> � � Issue discard request in ext4_free_blocks() when ext4 has no journal and >>> � � is mounted with discard option. >>> >>> � � Signed-off-by: Jiaying Zhang <jiayingz@google.com> >>> >>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c >>> index a291cc3..d51b79a 100644 >>> --- a/fs/ext4/mballoc.c >>> +++ b/fs/ext4/mballoc.c >>> @@ -2513,6 +2513,22 @@ int ext4_mb_release(struct super_block *sb) >>> � � � return 0; >>> �} >>> >>> +static void ext4_issue_discard(struct super_block *sb, ext4_group_t block_group, [snip] >> >> How about make it as an inline routine? Thanks. > > Ok. I changed it to inline. The modified patch is attached. > - Acked-by: Coly Li <coly.li@suse.de> + Reviewed-by: Coly Li <coly.li@suse.de> Thanks. -- Coly Li SuSE Labs -- 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 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-14 3:55 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-13 5:00 [PATCH, RFC] support discard in non-journal ext4 Jiaying Zhang 2010-05-13 9:08 ` Coly Li 2010-05-14 0:29 ` Jiaying Zhang 2010-05-14 4:03 ` Coly Li 2010-05-14 4:09 ` Coly Li
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).