Re: [PATCH 1/2] ext3: Add batched discard support for ext3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  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@xxxxxxx>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux