From patchwork Fri May 14 00:29:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jiaying Zhang X-Patchwork-Id: 52529 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E2307B7E39 for ; Fri, 14 May 2010 10:31:18 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753627Ab0ENA3u (ORCPT ); Thu, 13 May 2010 20:29:50 -0400 Received: from smtp-out.google.com ([216.239.44.51]:9077 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755087Ab0ENA3s (ORCPT ); Thu, 13 May 2010 20:29:48 -0400 Received: from wpaz33.hot.corp.google.com (wpaz33.hot.corp.google.com [172.24.198.97]) by smtp-out.google.com with ESMTP id o4E0Tlko027269 for ; Thu, 13 May 2010 17:29:47 -0700 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=google.com; s=beta; t=1273796987; bh=QbLTO2Bu96WWP8uMpe8pMzQJFW8=; h=MIME-Version:In-Reply-To:References:Date:Message-ID:Subject:From: To:Cc:Content-Type; b=TppvpYWhgnZFjF7s3qsxuO5tgZqEINpD5fZ+qb0y3ELcQ/zeAKpQE/sbBauYHZ4/H Obt4EcRaxwp4LhhiK1xJA== DomainKey-Signature: a=rsa-sha1; s=beta; d=google.com; c=nofws; q=dns; h=mime-version:in-reply-to:references:date:message-id:subject:from:to: cc:content-type:x-system-of-record; b=STrc1xPB+l3LbKJdOP3wUejkW7jJ9eN/SFJDYu/AhAEiMs0x3f+I/p2+puXe7o0CQ 6bEWr0vpwh4nRE1dtJnfw== Received: from gyh4 (gyh4.prod.google.com [10.243.50.196]) by wpaz33.hot.corp.google.com with ESMTP id o4E0Tk1u005879 for ; Thu, 13 May 2010 17:29:46 -0700 Received: by gyh4 with SMTP id 4so1002894gyh.31 for ; Thu, 13 May 2010 17:29:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.91.168.7 with SMTP id v7mr719791ago.87.1273796985946; Thu, 13 May 2010 17:29:45 -0700 (PDT) Received: by 10.91.214.9 with HTTP; Thu, 13 May 2010 17:29:45 -0700 (PDT) In-Reply-To: <4BEBC191.7060305@suse.de> References: <20100513050014.879651BC316@ruihe.smo.corp.google.com> <4BEBC191.7060305@suse.de> Date: Thu, 13 May 2010 17:29:45 -0700 Message-ID: Subject: Re: [PATCH, RFC] support discard in non-journal ext4 From: Jiaying Zhang To: coly.li@suse.de Cc: linux-ext4@vger.kernel.org X-System-Of-Record: true Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, May 13, 2010 at 2:08 AM, Coly Li 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 > > 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 > > > > 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 Acked-by: Coly Li commit 43e4186b502e13957544991c6a456447a6aa3aa9 Author: Jiaying Zhang 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 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;