[Cluster-devel] [RFC v2 PATCH 3/5] gfs2: changes to gfs2_log_XXX_bio

Abhi Das adas at redhat.com
Mon Aug 13 04:48:47 UTC 2018


Change gfs2_log_flush_bio to accept a pointer to the struct bio
to be flushed. Change gfs2_log_alloc_bio and gfs2_log_get_bio to
take a struct gfs2_jdesc instead of gfs2_sbd.

Signed-off-by: Abhi Das <adas at redhat.com>
---
 fs/gfs2/log.c  |  4 ++--
 fs/gfs2/lops.c | 32 ++++++++++++++++++--------------
 fs/gfs2/lops.h |  2 +-
 3 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 15a3a8c..87b7d87 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -655,7 +655,7 @@ static void log_write_header(struct gfs2_sbd *sdp, u32 flags)
 
 	sdp->sd_log_idle = (tail == sdp->sd_log_flush_head);
 	gfs2_log_write_page(sdp, page);
-	gfs2_log_flush_bio(sdp, rw);
+	gfs2_log_flush_bio(&sdp->sd_log_bio, rw);
 	log_flush_wait(sdp);
 
 	if (sdp->sd_log_tail != tail)
@@ -699,7 +699,7 @@ void gfs2_log_flush(struct gfs2_sbd *sdp, struct gfs2_glock *gl)
 
 	gfs2_ordered_write(sdp);
 	lops_before_commit(sdp, tr);
-	gfs2_log_flush_bio(sdp, WRITE);
+	gfs2_log_flush_bio(&sdp->sd_log_bio, WRITE);
 
 	if (sdp->sd_log_head != sdp->sd_log_flush_head) {
 		log_flush_wait(sdp);
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index 4da6055..0284648 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -230,25 +230,27 @@ static void gfs2_end_log_write(struct bio *bio, int error)
 
 /**
  * gfs2_log_flush_bio - Submit any pending log bio
- * @sdp: The superblock
+ * @biop: Pointer to the bio we want to flush
  * @rw: The rw flags
  *
  * Submit any pending part-built or full bio to the block device. If
  * there is no pending bio, then this is a no-op.
  */
 
-void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw)
+void gfs2_log_flush_bio(struct bio **biop, int rw)
 {
-	if (sdp->sd_log_bio) {
+	struct bio *bio = *biop;
+	if (bio) {
+		struct gfs2_sbd *sdp = bio->bi_private;
 		atomic_inc(&sdp->sd_log_in_flight);
-		submit_bio(rw, sdp->sd_log_bio);
-		sdp->sd_log_bio = NULL;
+		submit_bio(rw, bio);
+		*biop = NULL;
 	}
 }
 
 /**
  * gfs2_log_alloc_bio - Allocate a new bio for log writing
- * @sdp: The superblock
+ * @jd: The journal descriptor
  * @blkno: The next device block number we want to write to
  *
  * This should never be called when there is a cached bio in the
@@ -259,8 +261,9 @@ void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw)
  * Returns: Newly allocated bio
  */
 
-static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno)
+static struct bio *gfs2_log_alloc_bio(struct gfs2_jdesc *jd, u64 blkno)
 {
+	struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 	struct super_block *sb = sdp->sd_vfs;
 	unsigned nrvecs = bio_get_nr_vecs(sb->s_bdev);
 	struct bio *bio;
@@ -286,7 +289,7 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno)
 
 /**
  * gfs2_log_get_bio - Get cached log bio, or allocate a new one
- * @sdp: The superblock
+ * @jd: The journal descriptor
  * @blkno: The device block number we want to write to
  *
  * If there is a cached bio, then if the next block number is sequential
@@ -297,8 +300,9 @@ static struct bio *gfs2_log_alloc_bio(struct gfs2_sbd *sdp, u64 blkno)
  * Returns: The bio to use for log writes
  */
 
-static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno)
+static struct bio *gfs2_log_get_bio(struct gfs2_jdesc *jd, u64 blkno)
 {
+	struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
 	struct bio *bio = sdp->sd_log_bio;
 	u64 nblk;
 
@@ -307,10 +311,10 @@ static struct bio *gfs2_log_get_bio(struct gfs2_sbd *sdp, u64 blkno)
 		nblk >>= sdp->sd_fsb2bb_shift;
 		if (blkno == nblk)
 			return bio;
-		gfs2_log_flush_bio(sdp, WRITE);
+		gfs2_log_flush_bio(&sdp->sd_log_bio, WRITE);
 	}
 
-	return gfs2_log_alloc_bio(sdp, blkno);
+	return gfs2_log_alloc_bio(sdp->sd_jdesc, blkno);
 }
 
 
@@ -333,11 +337,11 @@ static void gfs2_log_write(struct gfs2_sbd *sdp, struct page *page,
 	struct bio *bio;
 	int ret;
 
-	bio = gfs2_log_get_bio(sdp, blkno);
+	bio = gfs2_log_get_bio(sdp->sd_jdesc, blkno);
 	ret = bio_add_page(bio, page, size, offset);
 	if (ret == 0) {
-		gfs2_log_flush_bio(sdp, WRITE);
-		bio = gfs2_log_alloc_bio(sdp, blkno);
+		gfs2_log_flush_bio(&sdp->sd_log_bio, WRITE);
+		bio = gfs2_log_alloc_bio(sdp->sd_jdesc, blkno);
 		ret = bio_add_page(bio, page, size, offset);
 		WARN_ON(ret == 0);
 	}
diff --git a/fs/gfs2/lops.h b/fs/gfs2/lops.h
index 06793e3..3044347 100644
--- a/fs/gfs2/lops.h
+++ b/fs/gfs2/lops.h
@@ -28,7 +28,7 @@ extern const struct gfs2_log_operations gfs2_databuf_lops;
 
 extern const struct gfs2_log_operations *gfs2_log_ops[];
 extern void gfs2_log_write_page(struct gfs2_sbd *sdp, struct page *page);
-extern void gfs2_log_flush_bio(struct gfs2_sbd *sdp, int rw);
+extern void gfs2_log_flush_bio(struct bio **biop, int rw);
 extern void gfs2_pin(struct gfs2_sbd *sdp, struct buffer_head *bh);
 
 static inline unsigned int buf_limit(struct gfs2_sbd *sdp)
-- 
2.4.11




More information about the Cluster-devel mailing list