From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH] f2fs: make discard command directly
Date: Wed, 11 Jan 2017 16:48:48 -0800 [thread overview]
Message-ID: <20170112004848.37202-1-jaegeuk@kernel.org> (raw)
This can reduce the backporting efforts.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/segment.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0738f48293cc..ebfd5cd7619e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -673,8 +673,8 @@ static void f2fs_submit_bio_wait_endio(struct bio *bio)
static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
struct block_device *bdev, block_t blkstart, block_t blklen)
{
+ struct bio_entry *be;
struct bio *bio = NULL;
- int err;
trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
@@ -683,20 +683,24 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
blkstart -= FDEV(devi).start_blk;
}
- err = __blkdev_issue_discard(bdev,
- SECTOR_FROM_BLOCK(blkstart),
- SECTOR_FROM_BLOCK(blklen),
- GFP_NOFS, 0, &bio);
- if (!err && bio) {
- struct bio_entry *be = __add_bio_entry(sbi, bio);
- bio->bi_private = be;
- bio->bi_end_io = f2fs_submit_bio_wait_endio;
- bio->bi_opf |= REQ_SYNC;
- submit_bio(bio);
- }
+ if (!blk_queue_discard(bdev_get_queue(bdev)))
+ return 0;
- return err;
+ /* we always submit 4KB-aligned discard commands. */
+ bio = f2fs_bio_alloc(0);
+ bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blkstart);
+ bio->bi_bdev = bdev;
+ bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
+ bio->bi_iter.bi_size = SECTOR_FROM_BLOCK(blklen) << 9;
+ bio->bi_end_io = f2fs_submit_bio_wait_endio;
+
+ be = __add_bio_entry(sbi, bio);
+
+ bio->bi_private = be;
+ bio->bi_opf |= REQ_SYNC;
+ submit_bio(bio);
+ return 0;
}
#ifdef CONFIG_BLK_DEV_ZONED
--
2.11.0
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH] f2fs: make discard command directly
Date: Wed, 11 Jan 2017 16:48:48 -0800 [thread overview]
Message-ID: <20170112004848.37202-1-jaegeuk@kernel.org> (raw)
This can reduce the backporting efforts.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
fs/f2fs/segment.c | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 0738f48293cc..ebfd5cd7619e 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -673,8 +673,8 @@ static void f2fs_submit_bio_wait_endio(struct bio *bio)
static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
struct block_device *bdev, block_t blkstart, block_t blklen)
{
+ struct bio_entry *be;
struct bio *bio = NULL;
- int err;
trace_f2fs_issue_discard(sbi->sb, blkstart, blklen);
@@ -683,20 +683,24 @@ static int __f2fs_issue_discard_async(struct f2fs_sb_info *sbi,
blkstart -= FDEV(devi).start_blk;
}
- err = __blkdev_issue_discard(bdev,
- SECTOR_FROM_BLOCK(blkstart),
- SECTOR_FROM_BLOCK(blklen),
- GFP_NOFS, 0, &bio);
- if (!err && bio) {
- struct bio_entry *be = __add_bio_entry(sbi, bio);
- bio->bi_private = be;
- bio->bi_end_io = f2fs_submit_bio_wait_endio;
- bio->bi_opf |= REQ_SYNC;
- submit_bio(bio);
- }
+ if (!blk_queue_discard(bdev_get_queue(bdev)))
+ return 0;
- return err;
+ /* we always submit 4KB-aligned discard commands. */
+ bio = f2fs_bio_alloc(0);
+ bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blkstart);
+ bio->bi_bdev = bdev;
+ bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
+ bio->bi_iter.bi_size = SECTOR_FROM_BLOCK(blklen) << 9;
+ bio->bi_end_io = f2fs_submit_bio_wait_endio;
+
+ be = __add_bio_entry(sbi, bio);
+
+ bio->bi_private = be;
+ bio->bi_opf |= REQ_SYNC;
+ submit_bio(bio);
+ return 0;
}
#ifdef CONFIG_BLK_DEV_ZONED
--
2.11.0
next reply other threads:[~2017-01-12 0:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-12 0:48 Jaegeuk Kim [this message]
2017-01-12 0:48 ` [PATCH] f2fs: make discard command directly Jaegeuk Kim
2017-01-12 14:10 ` Christoph Hellwig
2017-01-12 18:39 ` Jaegeuk Kim
2017-01-12 18:39 ` Jaegeuk Kim
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=20170112004848.37202-1-jaegeuk@kernel.org \
--to=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.