diff options
-rw-r--r-- | fs/gfs2/rgrp.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 70d1cd0b5f3b..5a51265a4341 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1181,12 +1181,9 @@ int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset, | |||
1181 | const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed) | 1181 | const struct gfs2_bitmap *bi, unsigned minlen, u64 *ptrimmed) |
1182 | { | 1182 | { |
1183 | struct super_block *sb = sdp->sd_vfs; | 1183 | struct super_block *sb = sdp->sd_vfs; |
1184 | struct block_device *bdev = sb->s_bdev; | ||
1185 | const unsigned int sects_per_blk = sdp->sd_sb.sb_bsize / | ||
1186 | bdev_logical_block_size(sb->s_bdev); | ||
1187 | u64 blk; | 1184 | u64 blk; |
1188 | sector_t start = 0; | 1185 | sector_t start = 0; |
1189 | sector_t nr_sects = 0; | 1186 | sector_t nr_blks = 0; |
1190 | int rv; | 1187 | int rv; |
1191 | unsigned int x; | 1188 | unsigned int x; |
1192 | u32 trimmed = 0; | 1189 | u32 trimmed = 0; |
@@ -1206,35 +1203,34 @@ int gfs2_rgrp_send_discards(struct gfs2_sbd *sdp, u64 offset, | |||
1206 | if (diff == 0) | 1203 | if (diff == 0) |
1207 | continue; | 1204 | continue; |
1208 | blk = offset + ((bi->bi_start + x) * GFS2_NBBY); | 1205 | blk = offset + ((bi->bi_start + x) * GFS2_NBBY); |
1209 | blk *= sects_per_blk; /* convert to sectors */ | ||
1210 | while(diff) { | 1206 | while(diff) { |
1211 | if (diff & 1) { | 1207 | if (diff & 1) { |
1212 | if (nr_sects == 0) | 1208 | if (nr_blks == 0) |
1213 | goto start_new_extent; | 1209 | goto start_new_extent; |
1214 | if ((start + nr_sects) != blk) { | 1210 | if ((start + nr_blks) != blk) { |
1215 | if (nr_sects >= minlen) { | 1211 | if (nr_blks >= minlen) { |
1216 | rv = blkdev_issue_discard(bdev, | 1212 | rv = sb_issue_discard(sb, |
1217 | start, nr_sects, | 1213 | start, nr_blks, |
1218 | GFP_NOFS, 0); | 1214 | GFP_NOFS, 0); |
1219 | if (rv) | 1215 | if (rv) |
1220 | goto fail; | 1216 | goto fail; |
1221 | trimmed += nr_sects; | 1217 | trimmed += nr_blks; |
1222 | } | 1218 | } |
1223 | nr_sects = 0; | 1219 | nr_blks = 0; |
1224 | start_new_extent: | 1220 | start_new_extent: |
1225 | start = blk; | 1221 | start = blk; |
1226 | } | 1222 | } |
1227 | nr_sects += sects_per_blk; | 1223 | nr_blks++; |
1228 | } | 1224 | } |
1229 | diff >>= 2; | 1225 | diff >>= 2; |
1230 | blk += sects_per_blk; | 1226 | blk++; |
1231 | } | 1227 | } |
1232 | } | 1228 | } |
1233 | if (nr_sects >= minlen) { | 1229 | if (nr_blks >= minlen) { |
1234 | rv = blkdev_issue_discard(bdev, start, nr_sects, GFP_NOFS, 0); | 1230 | rv = sb_issue_discard(sb, start, nr_blks, GFP_NOFS, 0); |
1235 | if (rv) | 1231 | if (rv) |
1236 | goto fail; | 1232 | goto fail; |
1237 | trimmed += nr_sects; | 1233 | trimmed += nr_blks; |
1238 | } | 1234 | } |
1239 | if (ptrimmed) | 1235 | if (ptrimmed) |
1240 | *ptrimmed = trimmed; | 1236 | *ptrimmed = trimmed; |