[PATCH 12/16] Unionfs: reintroduce a bmap method

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Erez Zadok
Date: Monday, November 26, 2007 - 9:44 am

This is needed for swapon(2) files in the union.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
---
 fs/unionfs/mmap.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c
index 3f65e52..fa358ef 100644
--- a/fs/unionfs/mmap.c
+++ b/fs/unionfs/mmap.c
@@ -304,10 +304,33 @@ out:
 	return err;		/* assume all is ok */
 }
 
+/*
+ * Although unionfs isn't a block-based file system, it may stack on one.
+ * ->bmap is needed, for example, to swapon(2) files.
+ */
+sector_t unionfs_bmap(struct address_space *mapping, sector_t block)
+{
+	int err = -EINVAL;
+	struct inode *inode, *lower_inode;
+	sector_t (*bmap)(struct address_space *, sector_t);
+
+	inode = (struct inode *)mapping->host;
+	lower_inode = unionfs_lower_inode(inode);
+	if (!lower_inode)
+		goto out;
+	bmap = lower_inode->i_mapping->a_ops->bmap;
+	if (bmap)
+		err = bmap(lower_inode->i_mapping, block);
+out:
+	return err;
+}
+
+
 struct address_space_operations unionfs_aops = {
 	.writepage	= unionfs_writepage,
 	.writepages	= unionfs_writepages,
 	.readpage	= unionfs_readpage,
 	.prepare_write	= unionfs_prepare_write,
 	.commit_write	= unionfs_commit_write,
+	.bmap		= unionfs_bmap,
 };
-- 
1.5.2.2

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PULL -mm] 00/16 Unionfs updates/fixes/cleanups, Erez Zadok, (Mon Nov 26, 9:43 am)
[PATCH 02/16] Unionfs: minor cleanup in writepage, Erez Zadok, (Mon Nov 26, 9:43 am)
[PATCH 11/16] Unionfs: update times in setattr, Erez Zadok, (Mon Nov 26, 9:44 am)
[PATCH 12/16] Unionfs: reintroduce a bmap method, Erez Zadok, (Mon Nov 26, 9:44 am)
[PATCH 13/16] Unionfs: support splice(2), Erez Zadok, (Mon Nov 26, 9:44 am)