Skip to content

Commit

Permalink
Merge tag 'jfs-3.7-2' of git://github.com/kleikamp/linux-shaggy
Browse files Browse the repository at this point in the history
Pull jfs fix from Dave Kleikamp:
 "Bug fix: Fix FITRIM argument handling"

* tag 'jfs-3.7-2' of git://github.com/kleikamp/linux-shaggy:
  jfs: Fix FITRIM argument handling
  • Loading branch information
torvalds committed Oct 23, 2012
2 parents e589db7 + 4e7a4b0 commit d888af9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions fs/jfs/jfs_discard.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
struct super_block *sb = ipbmap->i_sb;
int agno, agno_end;
s64 start, end, minlen;
u64 start, end, minlen;
u64 trimmed = 0;

/**
Expand All @@ -93,15 +93,19 @@ int jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
* minlen: minimum extent length in Bytes
*/
start = range->start >> sb->s_blocksize_bits;
if (start < 0)
start = 0;
end = start + (range->len >> sb->s_blocksize_bits) - 1;
if (end >= bmp->db_mapsize)
end = bmp->db_mapsize - 1;
minlen = range->minlen >> sb->s_blocksize_bits;
if (minlen <= 0)
if (minlen == 0)
minlen = 1;

if (minlen > bmp->db_agsize ||
start >= bmp->db_mapsize ||
range->len < sb->s_blocksize)
return -EINVAL;

if (end >= bmp->db_mapsize)
end = bmp->db_mapsize - 1;

/**
* we trim all ag's within the range
*/
Expand Down

0 comments on commit d888af9

Please sign in to comment.