Linux-EROFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 1/4] erofs: avoid unnecessary variable `err'
@ 2020-09-18 13:54 Gao Xiang
  2020-09-18 13:54 ` [PATCH 2/4] erofs: fold in should_decompress_synchronously() Gao Xiang
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Gao Xiang @ 2020-09-18 13:54 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: LKML

variable `err' in z_erofs_submit_queue() isn't useful
here, remove it instead.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 fs/erofs/zdata.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index 6c939def00f9..df6fa691097f 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1193,7 +1193,6 @@ static void z_erofs_submit_queue(struct super_block *sb,
 
 		do {
 			struct page *page;
-			int err;
 
 			page = pickup_page_for_submission(pcl, i++, pagepool,
 							  MNGD_MAPPING(sbi),
@@ -1219,8 +1218,7 @@ static void z_erofs_submit_queue(struct super_block *sb,
 				++nr_bios;
 			}
 
-			err = bio_add_page(bio, page, PAGE_SIZE, 0);
-			if (err < PAGE_SIZE)
+			if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE)
 				goto submit_bio_retry;
 
 			last_index = cur;
-- 
2.18.1


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

* [PATCH 2/4] erofs: fold in should_decompress_synchronously()
  2020-09-18 13:54 [PATCH 1/4] erofs: avoid unnecessary variable `err' Gao Xiang
@ 2020-09-18 13:54 ` Gao Xiang
  2020-09-19  6:12   ` Chao Yu
  2020-09-18 13:54 ` [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios Gao Xiang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Gao Xiang @ 2020-09-18 13:54 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: LKML

should_decompress_synchronously() has one single condition
for now, so fold it instead.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 fs/erofs/zdata.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index df6fa691097f..d483e9fee41c 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1297,24 +1297,18 @@ static int z_erofs_readpage(struct file *file, struct page *page)
 	return err;
 }
 
-static bool should_decompress_synchronously(struct erofs_sb_info *sbi,
-					    unsigned int nr)
-{
-	return nr <= sbi->ctx.max_sync_decompress_pages;
-}
-
 static void z_erofs_readahead(struct readahead_control *rac)
 {
 	struct inode *const inode = rac->mapping->host;
 	struct erofs_sb_info *const sbi = EROFS_I_SB(inode);
 
-	bool sync = should_decompress_synchronously(sbi, readahead_count(rac));
+	unsigned int nr_pages = readahead_count(rac);
+	bool sync = (nr_pages <= sbi->ctx.max_sync_decompress_pages);
 	struct z_erofs_decompress_frontend f = DECOMPRESS_FRONTEND_INIT(inode);
 	struct page *page, *head = NULL;
 	LIST_HEAD(pagepool);
 
-	trace_erofs_readpages(inode, readahead_index(rac),
-			readahead_count(rac), false);
+	trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
 
 	f.headoffset = readahead_pos(rac);
 
-- 
2.18.1


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

* [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios
  2020-09-18 13:54 [PATCH 1/4] erofs: avoid unnecessary variable `err' Gao Xiang
  2020-09-18 13:54 ` [PATCH 2/4] erofs: fold in should_decompress_synchronously() Gao Xiang
@ 2020-09-18 13:54 ` Gao Xiang
  2020-09-19  4:50   ` Gao Xiang
  2020-09-18 13:54 ` [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests Gao Xiang
  2020-09-19  6:12 ` [PATCH 1/4] erofs: avoid unnecessary variable `err' Chao Yu
  3 siblings, 1 reply; 8+ messages in thread
From: Gao Xiang @ 2020-09-18 13:54 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: LKML

Use more accurate compressed page count
instead of BIO_MAX_PAGES unconditionally.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 fs/erofs/zdata.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index d483e9fee41c..bb20f73f10e0 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -135,6 +135,8 @@ struct z_erofs_decompress_frontend {
 	struct z_erofs_collector clt;
 	struct erofs_map_blocks map;
 
+	unsigned int compressedblock_total;
+
 	/* used for applying cache strategy on the fly */
 	bool backmost;
 	erofs_off_t headoffset;
@@ -622,6 +624,7 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 
 	preload_compressed_pages(clt, MNGD_MAPPING(sbi),
 				 cache_strategy, pagepool);
+	fe->compressedblock_total += BIT(clt->pcl->clusterbits);
 
 hitted:
 	/*
@@ -1151,7 +1154,7 @@ static void move_to_bypass_jobqueue(struct z_erofs_pcluster *pcl,
 }
 
 static void z_erofs_submit_queue(struct super_block *sb,
-				 z_erofs_next_pcluster_t owned_head,
+				 struct z_erofs_decompress_frontend *f,
 				 struct list_head *pagepool,
 				 struct z_erofs_decompressqueue *fgq,
 				 bool *force_fg)
@@ -1160,10 +1163,12 @@ static void z_erofs_submit_queue(struct super_block *sb,
 	z_erofs_next_pcluster_t qtail[NR_JOBQUEUES];
 	struct z_erofs_decompressqueue *q[NR_JOBQUEUES];
 	void *bi_private;
+	z_erofs_next_pcluster_t owned_head = f->clt.owned_head;
 	/* since bio will be NULL, no need to initialize last_index */
 	pgoff_t last_index;
 	unsigned int nr_bios = 0;
 	struct bio *bio = NULL;
+	int cblks = f->compressedblock_total;
 
 	bi_private = jobqueueset_init(sb, q, fgq, force_fg);
 	qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head;
@@ -1207,8 +1212,8 @@ static void z_erofs_submit_queue(struct super_block *sb,
 			}
 
 			if (!bio) {
-				bio = bio_alloc(GFP_NOIO, BIO_MAX_PAGES);
-
+				bio = bio_alloc(GFP_NOIO,
+						min(cblks, BIO_MAX_PAGES));
 				bio->bi_end_io = z_erofs_decompressqueue_endio;
 				bio_set_dev(bio, sb->s_bdev);
 				bio->bi_iter.bi_sector = (sector_t)cur <<
@@ -1221,6 +1226,7 @@ static void z_erofs_submit_queue(struct super_block *sb,
 			if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE)
 				goto submit_bio_retry;
 
+			--cblks;
 			last_index = cur;
 			bypass = false;
 		} while (++cur < end);
@@ -1234,6 +1240,8 @@ static void z_erofs_submit_queue(struct super_block *sb,
 	if (bio)
 		submit_bio(bio);
 
+	DBG_BUGON(cblks);
+
 	/*
 	 * although background is preferred, no one is pending for submission.
 	 * don't issue workqueue for decompression but drop it directly instead.
@@ -1246,14 +1254,14 @@ static void z_erofs_submit_queue(struct super_block *sb,
 }
 
 static void z_erofs_runqueue(struct super_block *sb,
-			     struct z_erofs_collector *clt,
+			     struct z_erofs_decompress_frontend *f,
 			     struct list_head *pagepool, bool force_fg)
 {
 	struct z_erofs_decompressqueue io[NR_JOBQUEUES];
 
-	if (clt->owned_head == Z_EROFS_PCLUSTER_TAIL)
+	if (f->clt.owned_head == Z_EROFS_PCLUSTER_TAIL)
 		return;
-	z_erofs_submit_queue(sb, clt->owned_head, pagepool, io, &force_fg);
+	z_erofs_submit_queue(sb, f, pagepool, io, &force_fg);
 
 	/* handle bypass queue (no i/o pclusters) immediately */
 	z_erofs_decompress_queue(&io[JQ_BYPASS], pagepool);
@@ -1284,7 +1292,7 @@ static int z_erofs_readpage(struct file *file, struct page *page)
 	(void)z_erofs_collector_end(&f.clt);
 
 	/* if some compressed cluster ready, need submit them anyway */
-	z_erofs_runqueue(inode->i_sb, &f.clt, &pagepool, true);
+	z_erofs_runqueue(inode->i_sb, &f, &pagepool, true);
 
 	if (err)
 		erofs_err(inode->i_sb, "failed to read, err [%d]", err);
@@ -1343,7 +1351,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
 
 	(void)z_erofs_collector_end(&f.clt);
 
-	z_erofs_runqueue(inode->i_sb, &f.clt, &pagepool, sync);
+	z_erofs_runqueue(inode->i_sb, &f, &pagepool, sync);
 
 	if (f.map.mpage)
 		put_page(f.map.mpage);
-- 
2.18.1


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

* [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests
  2020-09-18 13:54 [PATCH 1/4] erofs: avoid unnecessary variable `err' Gao Xiang
  2020-09-18 13:54 ` [PATCH 2/4] erofs: fold in should_decompress_synchronously() Gao Xiang
  2020-09-18 13:54 ` [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios Gao Xiang
@ 2020-09-18 13:54 ` Gao Xiang
  2020-09-19  6:20   ` Chao Yu
  2020-09-19  6:12 ` [PATCH 1/4] erofs: avoid unnecessary variable `err' Chao Yu
  3 siblings, 1 reply; 8+ messages in thread
From: Gao Xiang @ 2020-09-18 13:54 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: LKML

Let's add REQ_RAHEAD flag so it'd be easier to identify
readahead I/O requests in blktrace.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
---
 fs/erofs/data.c  | 2 +-
 fs/erofs/zdata.c | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 459ecb42cbd3..347be146884c 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -224,7 +224,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
 		bio_set_dev(bio, sb->s_bdev);
 		bio->bi_iter.bi_sector = (sector_t)blknr <<
 			LOG_SECTORS_PER_BLOCK;
-		bio->bi_opf = REQ_OP_READ;
+		bio->bi_opf = REQ_OP_READ | (ra ? REQ_RAHEAD : 0);
 	}
 
 	err = bio_add_page(bio, page, PAGE_SIZE, 0);
diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index bb20f73f10e0..23940edf16ce 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -136,6 +136,7 @@ struct z_erofs_decompress_frontend {
 	struct erofs_map_blocks map;
 
 	unsigned int compressedblock_total;
+	bool readahead;
 
 	/* used for applying cache strategy on the fly */
 	bool backmost;
@@ -1220,6 +1221,8 @@ static void z_erofs_submit_queue(struct super_block *sb,
 					LOG_SECTORS_PER_BLOCK;
 				bio->bi_private = bi_private;
 				bio->bi_opf = REQ_OP_READ;
+				if (f->readahead)
+					bio->bi_opf |= REQ_RAHEAD;
 				++nr_bios;
 			}
 
@@ -1318,6 +1321,7 @@ static void z_erofs_readahead(struct readahead_control *rac)
 
 	trace_erofs_readpages(inode, readahead_index(rac), nr_pages, false);
 
+	f.readahead = true;
 	f.headoffset = readahead_pos(rac);
 
 	while ((page = readahead_page(rac))) {
-- 
2.18.1


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

* Re: [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios
  2020-09-18 13:54 ` [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios Gao Xiang
@ 2020-09-19  4:50   ` Gao Xiang
  0 siblings, 0 replies; 8+ messages in thread
From: Gao Xiang @ 2020-09-19  4:50 UTC (permalink / raw)
  To: linux-erofs, Chao Yu; +Cc: LKML

On Fri, Sep 18, 2020 at 09:54:35PM +0800, Gao Xiang wrote:
> Use more accurate compressed page count
> instead of BIO_MAX_PAGES unconditionally.
> 
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

Found by ro_fsstress, the submission chain could be extended
by other threads, so this patch wouldn't work with the tail
merging strategy. Please ignore this and I will drop it and
send the next version instead.

Thanks,
Gao Xiang


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

* Re: [PATCH 1/4] erofs: avoid unnecessary variable `err'
  2020-09-18 13:54 [PATCH 1/4] erofs: avoid unnecessary variable `err' Gao Xiang
                   ` (2 preceding siblings ...)
  2020-09-18 13:54 ` [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests Gao Xiang
@ 2020-09-19  6:12 ` Chao Yu
  3 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2020-09-19  6:12 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: LKML

On 2020/9/18 21:54, Gao Xiang wrote:
> variable `err' in z_erofs_submit_queue() isn't useful
> here, remove it instead.
> 
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 2/4] erofs: fold in should_decompress_synchronously()
  2020-09-18 13:54 ` [PATCH 2/4] erofs: fold in should_decompress_synchronously() Gao Xiang
@ 2020-09-19  6:12   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2020-09-19  6:12 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: LKML

On 2020/9/18 21:54, Gao Xiang wrote:
> should_decompress_synchronously() has one single condition
> for now, so fold it instead.
> 
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

* Re: [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests
  2020-09-18 13:54 ` [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests Gao Xiang
@ 2020-09-19  6:20   ` Chao Yu
  0 siblings, 0 replies; 8+ messages in thread
From: Chao Yu @ 2020-09-19  6:20 UTC (permalink / raw)
  To: Gao Xiang, linux-erofs; +Cc: LKML

On 2020/9/18 21:54, Gao Xiang wrote:
> Let's add REQ_RAHEAD flag so it'd be easier to identify
> readahead I/O requests in blktrace.
> 
> Signed-off-by: Gao Xiang <hsiangkao@redhat.com>

Reviewed-by: Chao Yu <yuchao0@huawei.com>

Thanks,

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

end of thread, back to index

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-18 13:54 [PATCH 1/4] erofs: avoid unnecessary variable `err' Gao Xiang
2020-09-18 13:54 ` [PATCH 2/4] erofs: fold in should_decompress_synchronously() Gao Xiang
2020-09-19  6:12   ` Chao Yu
2020-09-18 13:54 ` [PATCH 3/4] erofs: specify accurate nr_iovecs for compressed bios Gao Xiang
2020-09-19  4:50   ` Gao Xiang
2020-09-18 13:54 ` [PATCH 4/4] erofs: add REQ_RAHEAD flag to readahead requests Gao Xiang
2020-09-19  6:20   ` Chao Yu
2020-09-19  6:12 ` [PATCH 1/4] erofs: avoid unnecessary variable `err' Chao Yu

Linux-EROFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-erofs/0 linux-erofs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-erofs linux-erofs/ https://lore.kernel.org/linux-erofs \
		linux-erofs@lists.ozlabs.org linux-erofs@ozlabs.org
	public-inbox-index linux-erofs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.ozlabs.lists.linux-erofs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git