From: Lukas Czerner <lczerner@redhat.com>
To: Jan Kara <jack@suse.cz>
Cc: Lukas Czerner <lczerner@redhat.com>,
linux-ext4@vger.kernel.org, dmonakhov@openvz.org,
jmoyer@redhat.com, rwheeler@redhat.com, eshishki@redhat.com,
sandeen@redhat.com, tytso@mit.edu
Subject: Re: [PATCH 3/3] Add batched discard support for ext4
Date: Tue, 10 Aug 2010 13:32:37 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1008101332060.2831@localhost> (raw)
In-Reply-To: <20100807222540.GA3573@quack.suse.cz>
On Sun, 8 Aug 2010, Jan Kara wrote:
> On Fri 06-08-10 13:31:16, Lukas Czerner wrote:
> ...
> > +/**
> > + * ext4_trim_fs() -- trim ioctl handle function
> > + * @sb: superblock for filesystem
> > + * @start: First Byte to trim
> > + * @len: number of Bytes to trim from start
> > + * @minlen: minimum extent length in Bytes
> > + *
> > + * ext4_trim_fs goes through all allocation groups containing Bytes from
> > + * start to start+len. For each such a group ext4_trim_all_free function
> > + * is invoked to trim all free space.
> > + */
> > +int ext4_trim_fs(struct super_block *sb, uint64_t start, uint64_t len,
> > + uint64_t minlen)
> > +{
> > + struct ext4_buddy e4b;
> > + ext4_fsblk_t first_group, last_group;
> > + ext4_group_t group, ngroups = ext4_get_groups_count(sb);
> > + ext4_grpblk_t cnt, first_block, last_block;
> > + struct ext4_super_block *es = EXT4_SB(sb)->s_es;
> > + int ret = 0;
> > +
> > + start >>= sb->s_blocksize_bits;
> > + len >>= sb->s_blocksize_bits;
> > + minlen >>= sb->s_blocksize_bits;
> > +
> > + if (unlikely(minlen > EXT4_BLOCKS_PER_GROUP(sb)))
> > + return -EINVAL;
> > +
> > + /* Determine first and last group to examine based on start and len */
> > + first_group = (start - le32_to_cpu(es->s_first_data_block)) /
> > + EXT4_BLOCKS_PER_GROUP(sb);
> > + last_group = (start + len - le32_to_cpu(es->s_first_data_block)) /
> > + EXT4_BLOCKS_PER_GROUP(sb);
> > + last_group = (last_group > ngroups - 1) ? ngroups - 1 : last_group;
> > +
> > + if (first_group > last_group)
> > + return -EINVAL;
> > +
> > + first_block = start % EXT4_BLOCKS_PER_GROUP(sb);
> I think you should substract "le32_to_cpu(es->s_first_data_block)" from
> the start before doing modulo.
>
> Honza
Oh, right thanks.
-Lukas
next prev parent reply other threads:[~2010-08-10 11:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-06 11:31 [PATCH 0/3] Batched discard support Lukas Czerner
2010-08-06 11:31 ` [PATCH 1/3] Add ioctl FITRIM Lukas Czerner
2010-08-06 11:31 ` [PATCH 2/3] Add batched discard support for ext3 Lukas Czerner
2010-08-06 11:31 ` [PATCH 3/3] Add batched discard support for ext4 Lukas Czerner
2010-08-06 13:03 ` Dmitry Monakhov
2010-08-06 13:23 ` Lukas Czerner
2010-08-07 22:25 ` Jan Kara
2010-08-10 11:32 ` Lukas Czerner [this message]
2010-08-06 13:05 ` [PATCH 0/3] Batched discard support Dmitry Monakhov
2010-08-06 13:49 ` Lukas Czerner
2010-08-06 14:24 ` Dmitry Monakhov
2010-08-06 14:32 ` Lukas Czerner
2010-08-06 15:02 ` Dmitry Monakhov
2010-08-10 11:31 ` Lukas Czerner
-- strict thread matches above, loose matches on Subject: below --
2010-08-10 14:19 [PATCH 0/3 ver. 7] Ext3/Ext4 " Lukas Czerner
2010-08-10 14:19 ` [PATCH 3/3] Add batched discard support for ext4 Lukas Czerner
2010-08-04 13:44 [PATCH 1/3] Add ioctl FITRIM Lukas Czerner
2010-08-04 13:44 ` [PATCH 3/3] Add batched discard support for ext4 Lukas Czerner
2010-08-04 14:17 ` Jan Kara
2010-07-27 12:41 [PATCH 0/3 v3] Batched discard support for Ext3/Ext4 Lukas Czerner
2010-07-27 12:41 ` [PATCH 3/3] Add batched discard support for ext4 Lukas Czerner
2010-07-27 16:28 ` Jan Kara
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=alpine.LFD.2.00.1008101332060.2831@localhost \
--to=lczerner@redhat.com \
--cc=dmonakhov@openvz.org \
--cc=eshishki@redhat.com \
--cc=jack@suse.cz \
--cc=jmoyer@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=rwheeler@redhat.com \
--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 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.