All of lore.kernel.org
 help / color / mirror / Atom feed
From: gaoxiang25@huawei.com (Gao Xiang)
Subject: [WIP] [NOMERGE] [RFC PATCH v0.7 05/10] erofs: globalize prepare_bio and __submit_bio
Date: Tue, 10 Jul 2018 03:17:14 +0800	[thread overview]
Message-ID: <1531163839-29830-6-git-send-email-gaoxiang25@huawei.com> (raw)
In-Reply-To: <1531163839-29830-1-git-send-email-gaoxiang25@huawei.com>

Signed-off-by: Gao Xiang <gaoxiang25 at huawei.com>
---
 fs/erofs/data.c     | 41 +++++++++--------------------------------
 fs/erofs/internal.h | 41 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index de99217..2efe69f 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -47,33 +47,6 @@ static inline void read_endio(struct bio *bio)
 	bio_put(bio);
 }
 
-static void __submit_bio(struct bio *bio, unsigned op, unsigned op_flags)
-{
-	bio_set_op_attrs(bio, op, op_flags);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
-	submit_bio(0, bio);
-#else
-	submit_bio(bio);
-#endif
-}
-
-static struct bio *prepare_bio(struct super_block *sb,
-	erofs_blk_t blkaddr, unsigned nr_pages)
-{
-	struct bio *bio = bio_alloc(GFP_NOIO | __GFP_NOFAIL, nr_pages);
-
-	BUG_ON(bio == NULL);
-
-	bio->bi_end_io = read_endio;
-	bio_set_dev(bio, sb->s_bdev);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
-	bio->bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK;
-#else
-	bio->bi_iter.bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK;
-#endif
-	return bio;
-}
-
 /* prio -- true is used for dir */
 struct page *erofs_get_meta_page(struct super_block *sb,
 	erofs_blk_t blkaddr, bool prio)
@@ -96,7 +69,7 @@ struct page *erofs_get_meta_page(struct super_block *sb,
 		struct bio *bio;
 		int err;
 
-		bio = prepare_bio(sb, blkaddr, 1);
+		bio = prepare_bio(sb, blkaddr, 1, read_endio);
 		err = bio_add_page(bio, page, PAGE_SIZE, 0);
 		BUG_ON(err != PAGE_SIZE);
 
@@ -237,6 +210,8 @@ static inline struct bio *erofs_read_raw_page(
 		struct erofs_map_blocks map = {
 			.m_la = blknr_to_addr(current_block),
 		};
+		erofs_blk_t blknr;
+		unsigned blkoff;
 
 		err = erofs_map_blocks(inode, &map, EROFS_GET_BLOCKS_RAW);
 		if (unlikely(err))
@@ -254,6 +229,9 @@ static inline struct bio *erofs_read_raw_page(
 		/* for RAW access mode, m_plen must be equal to m_llen */
 		BUG_ON(map.m_plen != map.m_llen);
 
+		blknr = erofs_blknr(map.m_pa);
+		blkoff = erofs_blkoff(map.m_pa);
+
 		/* deal with inline page */
 		if (map.m_flags & EROFS_MAP_META) {
 			void *vsrc, *vto;
@@ -261,8 +239,7 @@ static inline struct bio *erofs_read_raw_page(
 
 			BUG_ON(map.m_plen > PAGE_SIZE);
 
-			ipage = erofs_get_meta_page(inode->i_sb,
-				erofs_blknr(map.m_pa), 0);
+			ipage = erofs_get_meta_page(inode->i_sb, blknr, 0);
 
 			if (IS_ERR(ipage)) {
 				err = PTR_ERR(ipage);
@@ -271,7 +248,7 @@ static inline struct bio *erofs_read_raw_page(
 
 			vsrc = kmap_atomic(ipage);
 			vto = kmap_atomic(page);
-			memcpy(vto, vsrc + erofs_blkoff(map.m_pa), map.m_plen);
+			memcpy(vto, vsrc + blkoff, map.m_plen);
 			memset(vto + map.m_plen, 0, PAGE_SIZE - map.m_plen);
 			kunmap_atomic(vto);
 			kunmap_atomic(vsrc);
@@ -295,7 +272,7 @@ static inline struct bio *erofs_read_raw_page(
 		if (nblocks > BIO_MAX_PAGES)
 			nblocks = BIO_MAX_PAGES;
 
-		bio = prepare_bio(inode->i_sb, erofs_blknr(map.m_pa), nblocks);
+		bio = prepare_bio(inode->i_sb, blknr, nblocks, read_endio);
 	}
 
 	err = bio_add_page(bio, page, PAGE_SIZE, 0);
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 07bab28..e60f535 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -291,6 +291,47 @@ struct erofs_map_blocks {
 #define EROFS_GET_BLOCKS_RAW    0x0001
 
 /* data.c */
+static inline struct bio *prepare_bio(
+	struct super_block *sb,
+	erofs_blk_t blkaddr, unsigned nr_pages,
+	bio_end_io_t endio)
+{
+	gfp_t gfp = GFP_NOIO;
+	struct bio *bio = bio_alloc(gfp, nr_pages);
+
+	if (unlikely(bio == NULL) &&
+		(current->flags & PF_MEMALLOC)) {
+		do {
+			nr_pages /= 2;
+			if (unlikely(!nr_pages)) {
+				bio = bio_alloc(gfp | __GFP_NOFAIL, 1);
+				BUG_ON(bio == NULL);
+				break;
+			}
+			bio = bio_alloc(gfp, nr_pages);
+		} while (bio == NULL);
+	}
+
+	bio->bi_end_io = endio;
+	bio_set_dev(bio, sb->s_bdev);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 14, 0))
+	bio->bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK;
+#else
+	bio->bi_iter.bi_sector = blkaddr << LOG_SECTORS_PER_BLOCK;
+#endif
+	return bio;
+}
+
+static inline void __submit_bio(struct bio *bio, unsigned op, unsigned op_flags)
+{
+	bio_set_op_attrs(bio, op, op_flags);
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
+	submit_bio(0, bio);
+#else
+	submit_bio(bio);
+#endif
+}
+
 extern struct page *erofs_get_meta_page(struct super_block *sb,
 	erofs_blk_t blkaddr, bool prio);
 extern int erofs_map_blocks(struct inode *, struct erofs_map_blocks *, int);
-- 
1.9.1

  parent reply	other threads:[~2018-07-09 19:17 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27 14:20 [WIP] [NOMERGE] [RFC PATCH v0] erofs: introduce the new unzip subsystem Gao Xiang
2018-06-29 23:45 ` Chao Yu
2018-06-30  0:25   ` Gao Xiang
2018-06-30  9:18 ` [WIP] [NOMERGE] [RFC PATCH v0.2 1/2] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-06-30  9:18   ` [WIP] [NOMERGE] [RFC PATCH v0.2 2/2] erofs: introduce the new VLE unzip subsystem Gao Xiang
2018-06-30 15:17 ` [WIP] [NOMERGE] [RFC PATCH v0.3 1/6] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-06-30 15:17   ` [WIP] [NOMERGE] [RFC PATCH v0.3 2/6] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-06-30 15:17   ` [WIP] [NOMERGE] [RFC PATCH v0.3 3/6] erofs: introduce erofs_map_blocks_iter Gao Xiang
2018-07-01  3:56     ` Chao Yu
2018-07-01  4:17       ` Gao Xiang
2018-07-01  4:26         ` Gao Xiang
2018-07-02  1:47           ` Chao Yu
2018-07-02  2:48             ` Gao Xiang
2018-07-02  3:36               ` Chao Yu
2018-07-02  3:47                 ` Gao Xiang
2018-07-02 10:48                   ` Chao Yu
2018-07-02 11:53                     ` Gao Xiang
2018-06-30 15:17   ` [WIP] [NOMERGE] [RFC PATCH v0.3 4/6] erofs: add erofs_allocpage Gao Xiang
2018-06-30 15:17   ` [WIP] [NOMERGE] [RFC PATCH v0.3 5/6] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-06-30 15:17   ` [WIP] [NOMERGE] [RFC PATCH v0.3 6/6] erofs: introduce VLE decompression subsystem Gao Xiang
2018-07-02 14:53 ` [WIP] [NOMERGE] [RFC PATCH v0.4 0/7] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 1/7] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-02 14:53     ` Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 2/7] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 3/7] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 4/7] erofs: add erofs_allocpage Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 5/7] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 6/7] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-02 14:53   ` [WIP] [NOMERGE] [RFC PATCH v0.4 7/7] erofs: introduce VLE decompression subsystem Gao Xiang
2018-07-03 16:12 ` [WIP] [NOMERGE] [RFC PATCH v0.4 0/7] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-03 16:13 ` [WIP] [NOMERGE] [RFC PATCH v0.4 RESEND " Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 1/7] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 2/7] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 3/7] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 4/7] erofs: add erofs_allocpage Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 5/7] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 6/7] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-03 16:13   ` [WIP] [NOMERGE] [RFC PATCH RESEND v0.4 7/7] erofs: introduce VLE decompression subsystem Gao Xiang
2018-07-05  8:41 ` [WIP] [NOMERGE] [RFC PATCH v0.5 00/10] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-05  8:41   ` [WIP] [NOMERGE] [RFC PATCH v0.5 01/10] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-05  8:41   ` [WIP] [NOMERGE] [RFC PATCH v0.5 02/10] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-05  8:41   ` [WIP] [NOMERGE] [RFC PATCH v0.5 03/10] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-05  8:41   ` [WIP] [NOMERGE] [RFC PATCH v0.5 04/10] erofs: add erofs_allocpage Gao Xiang
2018-07-05  8:44   ` [WIP] [NOMERGE] [RFC PATCH v0.5 05/10] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-05  8:44     ` [WIP] [NOMERGE] [RFC PATCH v0.5 06/10] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-05  8:44     ` [WIP] [NOMERGE] [RFC PATCH v0.5 07/10] erofs: introduce superblock registration Gao Xiang
2018-07-05  8:44     ` [WIP] [NOMERGE] [RFC PATCH v0.5 08/10] erofs: introduce erofs shrinker Gao Xiang
2018-07-05  9:09       ` [WIP] [NOMERGE] [RFC PATCH v0.5 RESEND " Gao Xiang
2018-07-05  8:44     ` [WIP] [NOMERGE] [RFC PATCH v0.5 09/10] erofs: introduce workstation for decompression Gao Xiang
2018-07-05  8:44     ` [WIP] [NOMERGE] [RFC PATCH v0.5 10/10] erofs: introduce VLE decompression support Gao Xiang
2018-07-05  9:37       ` [WIP] [NOMERGE] [RFC PATCH v0.5 RESEND " Gao Xiang
2018-07-06 16:50 ` [WIP] [NOMERGE] [RFC PATCH v0.6 00/10] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 01/10] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 02/10] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 03/10] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 04/10] erofs: add erofs_allocpage Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 05/10] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 06/10] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 07/10] erofs: introduce superblock registration Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 08/10] erofs: introduce erofs shrinker Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 09/10] erofs: introduce workstation for decompression Gao Xiang
2018-07-06 16:50   ` [WIP] [NOMERGE] [RFC PATCH v0.6 10/10] erofs: introduce VLE decompression support Gao Xiang
2018-07-09 19:17 ` [WIP] [NOMERGE] [RFC PATCH v0.7 00/10] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 01/10] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 02/10] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 03/10] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 04/10] erofs: add erofs_allocpage Gao Xiang
2018-07-09 19:17   ` Gao Xiang [this message]
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 06/10] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 07/10] erofs: introduce superblock registration Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 08/10] erofs: introduce erofs shrinker Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 09/10] erofs: introduce workstation for decompression Gao Xiang
2018-07-09 19:17   ` [WIP] [NOMERGE] [RFC PATCH v0.7 10/10] erofs: introduce VLE decompression support Gao Xiang
2018-07-13 13:17     ` [PATCH 1/2] temp commit 1 Gao Xiang
2018-07-13 13:17       ` [PATCH 2/2] temp commit 2 Gao Xiang
2018-07-17 14:18 ` [RFC PATCH v1 00/11] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 01/11] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 02/11] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 03/11] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 04/11] erofs: add erofs_allocpage Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 05/11] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 06/11] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 07/11] erofs: introduce superblock registration Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 08/11] erofs: introduce erofs shrinker Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 09/11] erofs: introduce workstation for decompression Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 10/11] erofs: introduce VLE decompression support Gao Xiang
2018-07-17 14:18   ` [RFC PATCH v1 11/11] erofs: introduce cached decompression Gao Xiang
2018-07-20  2:52 ` [RFC PATCH v2 00/11] erofs: introduce the new unzip subsystem Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 01/11] <linux/tagptr.h>: Introduce tagged pointer Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 02/11] erofs: introduce pagevec for unzip subsystem Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 03/11] erofs: add erofs_map_blocks_iter Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 04/11] erofs: add erofs_allocpage Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 05/11] erofs: globalize prepare_bio and __submit_bio Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 06/11] erofs: add a generic z_erofs VLE decompressor Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 07/11] erofs: introduce superblock registration Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 08/11] erofs: introduce erofs shrinker Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 09/11] erofs: introduce workstation for decompression Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 10/11] erofs: introduce VLE decompression support Gao Xiang
2018-07-20 16:55     ` [RFC PATCH v3 " Gao Xiang
2018-07-20 16:55       ` [RFC PATCH v3 11/11] erofs: introduce cached decompression Gao Xiang
2018-07-20 17:29       ` [RFC PATCH v3 RESEND 10/11] erofs: introduce VLE decompression support Gao Xiang
2018-07-20  2:52   ` [RFC PATCH v2 11/11] erofs: introduce cached decompression Gao Xiang

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=1531163839-29830-6-git-send-email-gaoxiang25@huawei.com \
    --to=gaoxiang25@huawei.com \
    /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.