From: Lukas Czerner <lczerner@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, rwheeler@redhat.com, sandeen@redhat.com,
adilger@dilger.ca, lczerner@redhat.com
Subject: [PATCH 5/6] Use sb_issue_discard in ext4_ext_zeroout
Date: Wed, 15 Sep 2010 18:36:07 +0200 [thread overview]
Message-ID: <1284568568-13637-6-git-send-email-lczerner@redhat.com> (raw)
In-Reply-To: <1284568568-13637-1-git-send-email-lczerner@redhat.com>
Change ext4_ext4_zeroout to use sb_issue_discard instead of its
own approach to zero out extents.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
fs/ext4/extents.c | 68 ++++------------------------------------------------
1 files changed, 6 insertions(+), 62 deletions(-)
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 377309c..c426d9e 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2536,77 +2536,21 @@ 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);
+ 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
--
1.7.2.2
next prev parent reply other threads:[~2010-09-15 16:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-15 16:36 [PATCH 0/6 v3] Lazy itable initialization for Ext4 Lukas Czerner
2010-09-15 16:36 ` [PATCH 1/6] Add helper function for blkdev_issue_zeroout Lukas Czerner
2010-09-15 20:33 ` Mike Snitzer
2010-09-15 16:36 ` [PATCH 2/6] Add inititable/noinititable mount options for ext4 Lukas Czerner
2010-09-15 16:36 ` [PATCH 3/6] Add inode table initialization code for Ext4 Lukas Czerner
2010-09-15 16:46 ` Lukas Czerner
2010-09-15 16:36 ` [PATCH 4/6] Use sb_issue_zeroout in setup_new_group_blocks Lukas Czerner
2010-09-15 16:36 ` Lukas Czerner [this message]
2010-09-15 20:19 ` [PATCH 5/6] Use sb_issue_discard in ext4_ext_zeroout Mike Snitzer
2010-09-15 16:36 ` [PATCH 6/6] Add interface to advertise ext4 features in sysfs Lukas Czerner
2011-01-10 23:08 ` Eric Sandeen
2011-01-11 12:55 ` 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=1284568568-13637-6-git-send-email-lczerner@redhat.com \
--to=lczerner@redhat.com \
--cc=adilger@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=rwheeler@redhat.com \
--cc=sandeen@redhat.com \
--cc=tytso@mit.edu \
/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).