Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 218866
b: refs/heads/master
c: 2407518
h: refs/heads/master
v: v3
  • Loading branch information
Lukas Czerner authored and Theodore Ts'o committed Oct 28, 2010
1 parent d604d27 commit d215a21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 63 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a31437b85aa2cbc4ea80f9ee5d603fdd5430980c
refs/heads/master: 2407518de63a2f80d9b850fb525f35df93bbbe53
69 changes: 7 additions & 62 deletions trunk/fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2535,77 +2535,22 @@ void ext4_ext_release(struct super_block *sb)
#endif
}

static void bi_complete(struct bio *bio, int error)
{
complete((struct completion *)bio->bi_private);
}

/* FIXME!! we need to try to merge to left or right after zero-out */
static int ext4_ext_zeroout(struct inode *inode, struct ext4_extent *ex)
{
ext4_fsblk_t ee_pblock;
unsigned int ee_len;
int ret;
struct bio *bio;
int blkbits, blocksize;
sector_t ee_pblock;
struct completion event;
unsigned int ee_len, len, done, offset;


blkbits = inode->i_blkbits;
blocksize = inode->i_sb->s_blocksize;
ee_len = ext4_ext_get_actual_len(ex);
ee_pblock = ext_pblock(ex);

/* convert ee_pblock to 512 byte sectors */
ee_pblock = ee_pblock << (blkbits - 9);

while (ee_len > 0) {

if (ee_len > BIO_MAX_PAGES)
len = BIO_MAX_PAGES;
else
len = ee_len;

bio = bio_alloc(GFP_NOIO, len);
if (!bio)
return -ENOMEM;

bio->bi_sector = ee_pblock;
bio->bi_bdev = inode->i_sb->s_bdev;

done = 0;
offset = 0;
while (done < len) {
ret = bio_add_page(bio, ZERO_PAGE(0),
blocksize, offset);
if (ret != blocksize) {
/*
* We can't add any more pages because of
* hardware limitations. Start a new bio.
*/
break;
}
done++;
offset += blocksize;
if (offset >= PAGE_CACHE_SIZE)
offset = 0;
}

init_completion(&event);
bio->bi_private = &event;
bio->bi_end_io = bi_complete;
submit_bio(WRITE, bio);
wait_for_completion(&event);
ret = sb_issue_zeroout(inode->i_sb, ee_pblock, ee_len,
GFP_NOFS, BLKDEV_IFL_WAIT);
if (ret > 0)
ret = 0;

if (!test_bit(BIO_UPTODATE, &bio->bi_flags)) {
bio_put(bio);
return -EIO;
}
bio_put(bio);
ee_len -= done;
ee_pblock += done << (blkbits - 9);
}
return 0;
return ret;
}

#define EXT4_EXT_ZERO_LEN 7
Expand Down

0 comments on commit d215a21

Please sign in to comment.