linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: make discard command directly
@ 2017-01-12  0:48 Jaegeuk Kim
  2017-01-12 14:10 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Jaegeuk Kim @ 2017-01-12  0:48 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: make discard command directly
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2017-01-12 14:10 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On Wed, Jan 11, 2017 at 04:48:48PM -0800, Jaegeuk Kim wrote:
> This can reduce the backporting efforts.

NAK.  For one that is not a valid excuse for anything, and second
your remove respecting the granularity.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] f2fs: make discard command directly
  2017-01-12 14:10 ` Christoph Hellwig
@ 2017-01-12 18:39   ` Jaegeuk Kim
  0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2017-01-12 18:39 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On 01/12, Christoph Hellwig wrote:
> On Wed, Jan 11, 2017 at 04:48:48PM -0800, Jaegeuk Kim wrote:
> > This can reduce the backporting efforts.
> 
> NAK.  For one that is not a valid excuse for anything, and second
> your remove respecting the granularity.

Okay, I'll try from backporting side without this. :)

Thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-12 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

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).