From: Jiaying Zhang Subject: Re: [PATCH, RFC] support discard in non-journal ext4 Date: Thu, 13 May 2010 17:29:45 -0700 Message-ID: References: <20100513050014.879651BC316@ruihe.smo.corp.google.com> <4BEBC191.7060305@suse.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=0016e646060add0385048682f80e Cc: linux-ext4@vger.kernel.org To: coly.li@suse.de Return-path: 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 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) In-Reply-To: <4BEBC191.7060305@suse.de> Sender: linux-ext4-owner@vger.kernel.org List-ID: --0016e646060add0385048682f80e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: =A0 Wed May 12 21:11:46 2010 -0700 > > > > =A0 =A0 Issue discard request in ext4_free_blocks() when ext4 has no jo= urnal and > > =A0 =A0 is mounted with discard option. > > > > =A0 =A0 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) > > =A0 =A0 =A0 return 0; > > =A0} > > > > +static void ext4_issue_discard(struct super_block *sb, ext4_group_t bl= ock_group, > > + =A0 =A0 =A0 =A0 =A0 =A0 ext4_grpblk_t block, int count) > > +{ > > + =A0 =A0 int ret; > > + =A0 =A0 ext4_fsblk_t discard_block; > > + > > + =A0 =A0 discard_block =3D block + ext4_group_first_block_no(sb, block= _group); > > + =A0 =A0 trace_ext4_discard_blocks(sb, > > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (unsigned long long) discard_= block, count); > > + =A0 =A0 ret =3D sb_issue_discard(sb, discard_block, count); > > + =A0 =A0 if (ret =3D=3D EOPNOTSUPP) { > > + =A0 =A0 =A0 =A0 =A0 =A0 ext4_warning(sb, "discard not supported, disa= bling"); > > + =A0 =A0 =A0 =A0 =A0 =A0 clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD); > > + =A0 =A0 } > > +} > > + > > 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 --0016e646060add0385048682f80e Content-Type: text/x-patch; charset=US-ASCII; name="ext4-discard-nojournal.v2.patch" Content-Disposition: attachment; filename="ext4-discard-nojournal.v2.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_g969tfh10 Y29tbWl0IDQzZTQxODZiNTAyZTEzOTU3NTQ0OTkxYzZhNDU2NDQ3YTZhYTNhYTkKQXV0aG9yOiBK aWF5aW5nIFpoYW5nIDxqaWF5aW5nekBnb29nbGUuY29tPgpEYXRlOiAgIFdlZCBNYXkgMTIgMjE6 MTE6NDYgMjAxMCAtMDcwMAoKICAgIElzc3VlIGRpc2NhcmQgcmVxdWVzdCBpbiBleHQ0X2ZyZWVf YmxvY2tzKCkgd2hlbiBleHQ0IGhhcyBubyBqb3VybmFsIGFuZAogICAgaXMgbW91bnRlZCB3aXRo IGRpc2NhcmQgb3B0aW9uLgogICA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