linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] f2fs: move all the bio initialization into __bio_alloc
@ 2013-12-18 10:29 Gu Zheng
  2013-12-19  1:23 ` Chao Yu
  0 siblings, 1 reply; 4+ messages in thread
From: Gu Zheng @ 2013-12-18 10:29 UTC (permalink / raw)
  To: Kim; +Cc: fsdevel, linux-kernel, f2fs

Move all the bio initialization into __bio_alloc, and some minor cleanups are
also added.

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 fs/f2fs/data.c |   93 ++++++++++++++++++++++++++------------------------------
 1 files changed, 43 insertions(+), 50 deletions(-)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 9bdacc6..da5c52d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -24,20 +24,6 @@
 #include "segment.h"
 #include <trace/events/f2fs.h>
 
-/*
- * Low-level block read/write IO operations.
- */
-static struct bio *__bio_alloc(struct block_device *bdev, int npages)
-{
-	struct bio *bio;
-
-	/* No failure on bio allocation */
-	bio = bio_alloc(GFP_NOIO, npages);
-	bio->bi_bdev = bdev;
-	bio->bi_private = NULL;
-	return bio;
-}
-
 static void f2fs_read_end_io(struct bio *bio, int err)
 {
 	const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
@@ -93,6 +79,25 @@ static void f2fs_write_end_io(struct bio *bio, int err)
 	bio_put(bio);
 }
 
+/*
+ * Low-level block read/write IO operations.
+ */
+static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
+				int npages, int rw)
+{
+	struct bio *bio;
+
+	/* No failure on bio allocation */
+	bio = bio_alloc(GFP_NOIO, npages);
+
+	bio->bi_bdev = sbi->sb->s_bdev;
+	bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
+	bio->bi_end_io = rw ? f2fs_read_end_io : f2fs_write_end_io;
+	bio->bi_private = NULL;
+
+	return bio;
+}
+
 static void __submit_merged_bio(struct f2fs_bio_info *io)
 {
 	struct f2fs_io_info *fio = &io->fio;
@@ -104,25 +109,26 @@ static void __submit_merged_bio(struct f2fs_bio_info *io)
 	rw = fio->rw | fio->rw_flag;
 
 	if (is_read_io(rw)) {
-		trace_f2fs_submit_read_bio(io->sbi->sb, rw, fio->type, io->bio);
-		submit_bio(rw, io->bio);
-		io->bio = NULL;
-		return;
-	}
-	trace_f2fs_submit_write_bio(io->sbi->sb, rw, fio->type, io->bio);
-
-	/*
-	 * META_FLUSH is only from the checkpoint procedure, and we should wait
-	 * this metadata bio for FS consistency.
-	 */
-	if (fio->type == META_FLUSH) {
-		DECLARE_COMPLETION_ONSTACK(wait);
-		io->bio->bi_private = &wait;
+		trace_f2fs_submit_read_bio(io->sbi->sb, rw,
+						fio->type, io->bio);
 		submit_bio(rw, io->bio);
-		wait_for_completion(&wait);
 	} else {
-		submit_bio(rw, io->bio);
+		trace_f2fs_submit_write_bio(io->sbi->sb, rw,
+						fio->type, io->bio);
+		/*
+		 * META_FLUSH is only from the checkpoint procedure, and we
+		 * should wait this metadata bio for FS consistency.
+		 */
+		if (fio->type == META_FLUSH) {
+			DECLARE_COMPLETION_ONSTACK(wait);
+			io->bio->bi_private = &wait;
+			submit_bio(rw, io->bio);
+			wait_for_completion(&wait);
+		} else {
+			submit_bio(rw, io->bio);
+		}
 	}
+
 	io->bio = NULL;
 }
 
@@ -152,17 +158,12 @@ void f2fs_submit_merged_bio(struct f2fs_sb_info *sbi,
 int f2fs_submit_page_bio(struct f2fs_sb_info *sbi, struct page *page,
 					block_t blk_addr, int rw)
 {
-	struct block_device *bdev = sbi->sb->s_bdev;
 	struct bio *bio;
 
 	trace_f2fs_submit_page_bio(page, blk_addr, rw);
 
 	/* Allocate a new bio */
-	bio = __bio_alloc(bdev, 1);
-
-	/* Initialize the bio */
-	bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
-	bio->bi_end_io = is_read_io(rw) ? f2fs_read_end_io : f2fs_write_end_io;
+	bio = __bio_alloc(sbi, blk_addr, 1, is_read_io(rw));
 
 	if (bio_add_page(bio, page, PAGE_CACHE_SIZE, 0) < PAGE_CACHE_SIZE) {
 		bio_put(bio);
@@ -178,17 +179,16 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
 			block_t blk_addr, struct f2fs_io_info *fio)
 {
 	enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
-	struct block_device *bdev = sbi->sb->s_bdev;
 	struct f2fs_bio_info *io;
-	int bio_blocks;
+	int rw = is_read_io(fio->rw);
 
-	io = is_read_io(fio->rw) ? &sbi->read_io : &sbi->write_io[btype];
+	io = rw ? &sbi->read_io : &sbi->write_io[btype];
 
 	verify_block_addr(sbi, blk_addr);
 
 	mutex_lock(&io->io_mutex);
 
-	if (!is_read_io(fio->rw))
+	if (!rw)
 		inc_page_count(sbi, F2FS_WRITEBACK);
 
 	if (io->bio && (io->last_block_in_bio != blk_addr - 1 ||
@@ -196,17 +196,10 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
 		__submit_merged_bio(io);
 alloc_new:
 	if (io->bio == NULL) {
-		bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
-		io->bio = __bio_alloc(bdev, bio_blocks);
-		io->bio->bi_sector = SECTOR_FROM_BLOCK(sbi, blk_addr);
-		io->bio->bi_end_io = is_read_io(fio->rw) ? f2fs_read_end_io :
-							f2fs_write_end_io;
+		int bio_blocks = MAX_BIO_BLOCKS(max_hw_blocks(sbi));
+
+		io->bio = __bio_alloc(sbi, blk_addr, bio_blocks, rw);
 		io->fio = *fio;
-		/*
-		 * The end_io will be assigned at the sumbission phase.
-		 * Until then, let bio_add_page() merge consecutive IOs as much
-		 * as possible.
-		 */
 	}
 
 	if (bio_add_page(io->bio, page, PAGE_CACHE_SIZE, 0) <
-- 
1.7.7


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk

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

* Re: [PATCH] f2fs: move all the bio initialization into __bio_alloc
  2013-12-18 10:29 [PATCH] f2fs: move all the bio initialization into __bio_alloc Gu Zheng
@ 2013-12-19  1:23 ` Chao Yu
  2013-12-19  8:59   ` Jaegeuk Kim
  0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2013-12-19  1:23 UTC (permalink / raw)
  To: 'Gu Zheng', 'Kim'
  Cc: 'fsdevel', 'linux-kernel', 'f2fs'

Hi Gu,

> -----Original Message-----
> From: Gu Zheng [mailto:guz.fnst@cn.fujitsu.com]
> Sent: Wednesday, December 18, 2013 6:29 PM
> To: Kim
> Cc: fsdevel; linux-kernel; f2fs
> Subject: [f2fs-dev] [PATCH] f2fs: move all the bio initialization into __bio_alloc
> 
> Move all the bio initialization into __bio_alloc, and some minor cleanups are
> also added.

Looks more neat!

> @@ -178,17 +179,16 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
>  			block_t blk_addr, struct f2fs_io_info *fio)
>  {
>  	enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
> -	struct block_device *bdev = sbi->sb->s_bdev;
>  	struct f2fs_bio_info *io;
> -	int bio_blocks;
> +	int rw = is_read_io(fio->rw);

Maybe it's more neat to use 'is_read' to instead of 'rw'.

Thanks


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk

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

* Re: [PATCH] f2fs: move all the bio initialization into __bio_alloc
  2013-12-19  1:23 ` Chao Yu
@ 2013-12-19  8:59   ` Jaegeuk Kim
  2013-12-19  9:22     ` Gu Zheng
  0 siblings, 1 reply; 4+ messages in thread
From: Jaegeuk Kim @ 2013-12-19  8:59 UTC (permalink / raw)
  To: Chao Yu
  Cc: 'Gu Zheng', 'fsdevel', 'linux-kernel',
	'f2fs'

Hi Gu,

I agreed with Chao.
It is more readable to use something like "is_read" instead of "rw".
Thanks,

2013-12-19 (목), 09:23 +0800, Chao Yu:
> Hi Gu,
> 
> > -----Original Message-----
> > From: Gu Zheng [mailto:guz.fnst@cn.fujitsu.com]
> > Sent: Wednesday, December 18, 2013 6:29 PM
> > To: Kim
> > Cc: fsdevel; linux-kernel; f2fs
> > Subject: [f2fs-dev] [PATCH] f2fs: move all the bio initialization into __bio_alloc
> > 
> > Move all the bio initialization into __bio_alloc, and some minor cleanups are
> > also added.
> 
> Looks more neat!
> 
> > @@ -178,17 +179,16 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
> >  			block_t blk_addr, struct f2fs_io_info *fio)
> >  {
> >  	enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
> > -	struct block_device *bdev = sbi->sb->s_bdev;
> >  	struct f2fs_bio_info *io;
> > -	int bio_blocks;
> > +	int rw = is_read_io(fio->rw);
> 
> Maybe it's more neat to use 'is_read' to instead of 'rw'.
> 
> Thanks
> 

-- 
Jaegeuk Kim
Samsung



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

* Re: [PATCH] f2fs: move all the bio initialization into __bio_alloc
  2013-12-19  8:59   ` Jaegeuk Kim
@ 2013-12-19  9:22     ` Gu Zheng
  0 siblings, 0 replies; 4+ messages in thread
From: Gu Zheng @ 2013-12-19  9:22 UTC (permalink / raw)
  To: jaegeuk.kim; +Cc: 'fsdevel', 'linux-kernel', 'f2fs'

Hi Kim, Yu,
Thanks for your review!

On 12/19/2013 04:59 PM, Jaegeuk Kim wrote:

> Hi Gu,
> 
> I agreed with Chao.
> It is more readable to use something like "is_read" instead of "rw".

Agree. I'll follow it.

Regards,
Gu

> Thanks,
> 
> 2013-12-19 (목), 09:23 +0800, Chao Yu:
>> Hi Gu,
>>
>>> -----Original Message-----
>>> From: Gu Zheng [mailto:guz.fnst@cn.fujitsu.com]
>>> Sent: Wednesday, December 18, 2013 6:29 PM
>>> To: Kim
>>> Cc: fsdevel; linux-kernel; f2fs
>>> Subject: [f2fs-dev] [PATCH] f2fs: move all the bio initialization into __bio_alloc
>>>
>>> Move all the bio initialization into __bio_alloc, and some minor cleanups are
>>> also added.
>>
>> Looks more neat!
>>
>>> @@ -178,17 +179,16 @@ void f2fs_submit_page_mbio(struct f2fs_sb_info *sbi, struct page *page,
>>>  			block_t blk_addr, struct f2fs_io_info *fio)
>>>  {
>>>  	enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
>>> -	struct block_device *bdev = sbi->sb->s_bdev;
>>>  	struct f2fs_bio_info *io;
>>> -	int bio_blocks;
>>> +	int rw = is_read_io(fio->rw);
>>
>> Maybe it's more neat to use 'is_read' to instead of 'rw'.
>>
>> Thanks
>>
> 



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

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

end of thread, other threads:[~2013-12-19  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 10:29 [PATCH] f2fs: move all the bio initialization into __bio_alloc Gu Zheng
2013-12-19  1:23 ` Chao Yu
2013-12-19  8:59   ` Jaegeuk Kim
2013-12-19  9:22     ` Gu Zheng

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