[RFC PATCH 9/9] jfs: Convert buffered IO paths to iomap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use the iomap helper functions and remove jfs_get_block().

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
---
 fs/jfs/inode.c        | 70 ++++++++-----------------------------------
 fs/jfs/jfs_inode.h    |  1 -
 fs/jfs/jfs_logmgr.c   |  1 -
 fs/jfs/jfs_metapage.c |  1 -
 4 files changed, 12 insertions(+), 61 deletions(-)

diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 19c091d9c20e..f1d4c308e047 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -7,7 +7,6 @@
 #include <linux/fs.h>
 #include <linux/iomap.h>
 #include <linux/mpage.h>
-#include <linux/buffer_head.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
 #include <linux/uio.h>
@@ -298,69 +297,25 @@ const struct iomap_ops jfs_iomap_ops = {
 	.iomap_begin =  jfs_iomap_begin,
 };
 
-int jfs_get_block(struct inode *ip, sector_t lblock,
-		  struct buffer_head *bh_result, int create)
-{
-	struct iomap iomap = { };
-	int ret;
-
-	ret = jfs_iomap_begin(ip, lblock << ip->i_blkbits, bh_result->b_size,
-			create ? IOMAP_WRITE : 0, &iomap, NULL);
-	if (ret)
-		return ret;
-
-	bh_result->b_size = iomap.length;
-	if (iomap.type == IOMAP_HOLE)
-		return 0;
-
-	map_bh(bh_result, ip->i_sb, iomap.addr >> ip->i_blkbits);
-	if (iomap.flags & IOMAP_F_NEW)
-		set_buffer_new(bh_result);
-	return 0;
-}
-
-static int jfs_writepage(struct page *page, struct writeback_control *wbc)
-{
-	return block_write_full_page(page, jfs_get_block, wbc);
-}
+static const struct iomap_writeback_ops jfs_writeback_ops = {
+};
 
 static int jfs_writepages(struct address_space *mapping,
 			struct writeback_control *wbc)
 {
-	return mpage_writepages(mapping, wbc, jfs_get_block);
+	struct iomap_writepage_ctx wpc = { };
+
+	return iomap_writepages(mapping, wbc, &wpc, &jfs_writeback_ops);
 }
 
 static int jfs_read_folio(struct file *file, struct folio *folio)
 {
-	return mpage_read_folio(folio, jfs_get_block);
+	return iomap_read_folio(folio, &jfs_iomap_ops);
 }
 
 static void jfs_readahead(struct readahead_control *rac)
 {
-	mpage_readahead(rac, jfs_get_block);
-}
-
-static void jfs_write_failed(struct address_space *mapping, loff_t to)
-{
-	struct inode *inode = mapping->host;
-
-	if (to > inode->i_size) {
-		truncate_pagecache(inode, inode->i_size);
-		jfs_truncate(inode);
-	}
-}
-
-static int jfs_write_begin(struct file *file, struct address_space *mapping,
-				loff_t pos, unsigned len,
-				struct page **pagep, void **fsdata)
-{
-	int ret;
-
-	ret = nobh_write_begin(mapping, pos, len, pagep, fsdata, jfs_get_block);
-	if (unlikely(ret))
-		jfs_write_failed(mapping, pos + len);
-
-	return ret;
+	iomap_readahead(rac, &jfs_iomap_ops);
 }
 
 static sector_t jfs_bmap(struct address_space *mapping, sector_t block)
@@ -369,14 +324,11 @@ static sector_t jfs_bmap(struct address_space *mapping, sector_t block)
 }
 
 const struct address_space_operations jfs_aops = {
-	.dirty_folio	= block_dirty_folio,
-	.invalidate_folio = block_invalidate_folio,
+	.dirty_folio	= filemap_dirty_folio,
+	.invalidate_folio = iomap_invalidate_folio,
 	.read_folio	= jfs_read_folio,
 	.readahead	= jfs_readahead,
-	.writepage	= jfs_writepage,
 	.writepages	= jfs_writepages,
-	.write_begin	= jfs_write_begin,
-	.write_end	= nobh_write_end,
 	.bmap		= jfs_bmap,
 	.direct_IO	= noop_direct_IO,
 };
@@ -427,9 +379,11 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
 
 void jfs_truncate(struct inode *ip)
 {
+	bool did_zero;
+
 	jfs_info("jfs_truncate: size = 0x%lx", (ulong) ip->i_size);
 
-	nobh_truncate_page(ip->i_mapping, ip->i_size, jfs_get_block);
+	iomap_truncate_page(ip, i_size_read(ip), &did_zero, &jfs_iomap_ops);
 
 	IWRITE_LOCK(ip, RDWRLOCK_NORMAL);
 	jfs_truncate_nolock(ip, ip->i_size);
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index afd12de3c341..b1d3816a1a5c 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -27,7 +27,6 @@ extern struct dentry *jfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
 extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
 	int fh_len, int fh_type);
 extern void jfs_set_inode_flags(struct inode *);
-extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
 extern int jfs_setattr(struct user_namespace *, struct dentry *, struct iattr *);
 
 extern const struct iomap_ops jfs_iomap_ops;
diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c
index 997c81fcea34..466105331735 100644
--- a/fs/jfs/jfs_logmgr.c
+++ b/fs/jfs/jfs_logmgr.c
@@ -51,7 +51,6 @@
 #include <linux/interrupt.h>
 #include <linux/completion.h>
 #include <linux/kthread.h>
-#include <linux/buffer_head.h>		/* for sync_blockdev() */
 #include <linux/bio.h>
 #include <linux/freezer.h>
 #include <linux/export.h>
diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c
index 5b4f0cd8d276..dd9b855092fd 100644
--- a/fs/jfs/jfs_metapage.c
+++ b/fs/jfs/jfs_metapage.c
@@ -10,7 +10,6 @@
 #include <linux/bio.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/buffer_head.h>
 #include <linux/mempool.h>
 #include <linux/seq_file.h>
 #include <linux/writeback.h>
-- 
2.34.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux