linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Lukas Czerner <lczerner@redhat.com>
Cc: Jan Kara <jack@suse.cz>,
	linux-ext4@vger.kernel.org, greg.freemyer@gmail.com,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 1/2] ext3: Add batched discard support for ext3
Date: Thu, 6 Jan 2011 15:26:37 +0100	[thread overview]
Message-ID: <20110106142637.GH4641@quack.suse.cz> (raw)
In-Reply-To: <alpine.LFD.2.00.1011251512020.2871@dhcp-lab-213.englab.brq.redhat.com>

  Hi,

On Thu 25-11-10 15:27:09, Lukas Czerner wrote:
> > +/**
> > + * ext3_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
> > + *
> > + * ext3_trim_fs goes through all allocation groups containing Bytes from
> > + * start to start+len. For each such a group ext3_trim_all_free function
> > + * is invoked to trim all free space.
> > + */
> > +int ext3_trim_fs(struct super_block *sb, struct fstrim_range *range)
> > +{
> > +	ext3_grpblk_t last_block, first_block, free_blocks;
> > +	unsigned long first_group, last_group;
> > +	unsigned long group, ngroups;
> > +	struct ext3_group_desc *gdp;
> > +	struct ext3_super_block *es;
> > +	uint64_t start, len, minlen, trimmed;
> > +	int ret = 0;
> We probably need to add this:
> 
> ext3_fsblk_t blocks_count = le32_to_cpu(EXT3_SB(sb)->s_es->s_blocks_count);
> 
> > +
> > +	start = range->start >> sb->s_blocksize_bits;
> > +	len = range->len >> sb->s_blocksize_bits;
> > +	minlen = range->minlen >> sb->s_blocksize_bits;
> > +	trimmed = 0;
> and this:
> 
> 	if (len > blocks_count)
> 		len = blocks_count - start;
  Thanks for letting me know. The above could go negative if start is too
big. So I've ended up with checks:

+       if (start >= max_blks)
+               goto out;
+       if (start + len > max_blks)
+               len = max_blks - start;

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

  parent reply	other threads:[~2011-01-06 14:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-24 13:06 [PATCH 0/2] Ext3 discard support Jan Kara
2010-11-24 13:06 ` [PATCH 1/2] ext3: Add batched discard support for ext3 Jan Kara
2010-11-24 14:56   ` Lukas Czerner
2010-11-24 16:35     ` Jan Kara
2010-11-25 14:27   ` Lukas Czerner
2010-11-25 18:29     ` Andreas Dilger
2010-11-26  8:01       ` Lukas Czerner
2010-11-26 10:33         ` Andreas Dilger
2011-01-06 14:26     ` Jan Kara [this message]
2010-11-24 13:06 ` [PATCH 2/2] ext3: Add FITRIM handling Jan Kara
  -- strict thread matches above, loose matches on Subject: below --
2010-11-22 11:29 [PATCH 1/2] ext3: Add batched discard support for ext3 Lukas Czerner

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=20110106142637.GH4641@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=greg.freemyer@gmail.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).