xfs: remove iomap_target

Instead of using the iomap_target field in struct xfs_iomap
and the IOMAP_REALTIME flag just use the already existing
xfs_find_bdev_for_inode helper.  There's some fallout as we
need to pass the inode in a few more places, which we also
use to sanitize some calling conventions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
This commit is contained in:
Christoph Hellwig 2010-04-28 12:28:52 +00:00 committed by Alex Elder
parent 826bf0adce
commit 046f1685bb
3 changed files with 18 additions and 29 deletions

View file

@ -103,8 +103,9 @@ xfs_count_page_state(
STATIC struct block_device * STATIC struct block_device *
xfs_find_bdev_for_inode( xfs_find_bdev_for_inode(
struct xfs_inode *ip) struct inode *inode)
{ {
struct xfs_inode *ip = XFS_I(inode);
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
if (XFS_IS_REALTIME_INODE(ip)) if (XFS_IS_REALTIME_INODE(ip))
@ -554,19 +555,19 @@ xfs_add_to_ioend(
STATIC void STATIC void
xfs_map_buffer( xfs_map_buffer(
struct inode *inode,
struct buffer_head *bh, struct buffer_head *bh,
xfs_iomap_t *mp, xfs_iomap_t *mp,
xfs_off_t offset, xfs_off_t offset)
uint block_bits)
{ {
sector_t bn; sector_t bn;
ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL); ASSERT(mp->iomap_bn != IOMAP_DADDR_NULL);
bn = (mp->iomap_bn >> (block_bits - BBSHIFT)) + bn = (mp->iomap_bn >> (inode->i_blkbits - BBSHIFT)) +
((offset - mp->iomap_offset) >> block_bits); ((offset - mp->iomap_offset) >> inode->i_blkbits);
ASSERT(bn || (mp->iomap_flags & IOMAP_REALTIME)); ASSERT(bn || XFS_IS_REALTIME_INODE(XFS_I(inode)));
bh->b_blocknr = bn; bh->b_blocknr = bn;
set_buffer_mapped(bh); set_buffer_mapped(bh);
@ -574,17 +575,17 @@ xfs_map_buffer(
STATIC void STATIC void
xfs_map_at_offset( xfs_map_at_offset(
struct inode *inode,
struct buffer_head *bh, struct buffer_head *bh,
loff_t offset, xfs_iomap_t *iomapp,
int block_bits, xfs_off_t offset)
xfs_iomap_t *iomapp)
{ {
ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE)); ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY)); ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
lock_buffer(bh); lock_buffer(bh);
xfs_map_buffer(bh, iomapp, offset, block_bits); xfs_map_buffer(inode, bh, iomapp, offset);
bh->b_bdev = iomapp->iomap_target->bt_bdev; bh->b_bdev = xfs_find_bdev_for_inode(inode);
set_buffer_mapped(bh); set_buffer_mapped(bh);
clear_buffer_delay(bh); clear_buffer_delay(bh);
clear_buffer_unwritten(bh); clear_buffer_unwritten(bh);
@ -750,7 +751,6 @@ xfs_convert_page(
xfs_off_t end_offset; xfs_off_t end_offset;
unsigned long p_offset; unsigned long p_offset;
unsigned int type; unsigned int type;
int bbits = inode->i_blkbits;
int len, page_dirty; int len, page_dirty;
int count = 0, done = 0, uptodate = 1; int count = 0, done = 0, uptodate = 1;
xfs_off_t offset = page_offset(page); xfs_off_t offset = page_offset(page);
@ -814,7 +814,7 @@ xfs_convert_page(
ASSERT(!(mp->iomap_flags & IOMAP_HOLE)); ASSERT(!(mp->iomap_flags & IOMAP_HOLE));
ASSERT(!(mp->iomap_flags & IOMAP_DELAY)); ASSERT(!(mp->iomap_flags & IOMAP_DELAY));
xfs_map_at_offset(bh, offset, bbits, mp); xfs_map_at_offset(inode, bh, mp, offset);
if (startio) { if (startio) {
xfs_add_to_ioend(inode, bh, offset, xfs_add_to_ioend(inode, bh, offset,
type, ioendp, done); type, ioendp, done);
@ -1174,8 +1174,7 @@ xfs_page_state_convert(
iomap_valid = xfs_iomap_valid(&iomap, offset); iomap_valid = xfs_iomap_valid(&iomap, offset);
} }
if (iomap_valid) { if (iomap_valid) {
xfs_map_at_offset(bh, offset, xfs_map_at_offset(inode, bh, &iomap, offset);
inode->i_blkbits, &iomap);
if (startio) { if (startio) {
xfs_add_to_ioend(inode, bh, offset, xfs_add_to_ioend(inode, bh, offset,
type, &ioend, type, &ioend,
@ -1473,10 +1472,8 @@ __xfs_get_blocks(
* For unwritten extents do not report a disk address on * For unwritten extents do not report a disk address on
* the read case (treat as if we're reading into a hole). * the read case (treat as if we're reading into a hole).
*/ */
if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN)) { if (create || !(iomap.iomap_flags & IOMAP_UNWRITTEN))
xfs_map_buffer(bh_result, &iomap, offset, xfs_map_buffer(inode, bh_result, &iomap, offset);
inode->i_blkbits);
}
if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) { if (create && (iomap.iomap_flags & IOMAP_UNWRITTEN)) {
if (direct) if (direct)
bh_result->b_private = inode; bh_result->b_private = inode;
@ -1488,7 +1485,7 @@ __xfs_get_blocks(
* If this is a realtime file, data may be on a different device. * If this is a realtime file, data may be on a different device.
* to that pointed to from the buffer_head b_bdev currently. * to that pointed to from the buffer_head b_bdev currently.
*/ */
bh_result->b_bdev = iomap.iomap_target->bt_bdev; bh_result->b_bdev = xfs_find_bdev_for_inode(inode);
/* /*
* If we previously allocated a block out beyond eof and we are now * If we previously allocated a block out beyond eof and we are now
@ -1612,7 +1609,7 @@ xfs_vm_direct_IO(
struct block_device *bdev; struct block_device *bdev;
ssize_t ret; ssize_t ret;
bdev = xfs_find_bdev_for_inode(XFS_I(inode)); bdev = xfs_find_bdev_for_inode(inode);
iocb->private = xfs_alloc_ioend(inode, rw == WRITE ? iocb->private = xfs_alloc_ioend(inode, rw == WRITE ?
IOMAP_UNWRITTEN : IOMAP_READ); IOMAP_UNWRITTEN : IOMAP_READ);

View file

@ -72,12 +72,6 @@ xfs_imap_to_bmap(
iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
iomapp->iomap_flags = flags; iomapp->iomap_flags = flags;
if (XFS_IS_REALTIME_INODE(ip)) {
iomapp->iomap_flags |= IOMAP_REALTIME;
iomapp->iomap_target = mp->m_rtdev_targp;
} else {
iomapp->iomap_target = mp->m_ddev_targp;
}
start_block = imap->br_startblock; start_block = imap->br_startblock;
if (start_block == HOLESTARTBLOCK) { if (start_block == HOLESTARTBLOCK) {
iomapp->iomap_bn = IOMAP_DADDR_NULL; iomapp->iomap_bn = IOMAP_DADDR_NULL;

View file

@ -25,7 +25,6 @@ typedef enum { /* iomap_flags values */
IOMAP_READ = 0, /* mapping for a read */ IOMAP_READ = 0, /* mapping for a read */
IOMAP_HOLE = 0x02, /* mapping covers a hole */ IOMAP_HOLE = 0x02, /* mapping covers a hole */
IOMAP_DELAY = 0x04, /* mapping covers delalloc region */ IOMAP_DELAY = 0x04, /* mapping covers delalloc region */
IOMAP_REALTIME = 0x10, /* mapping on the realtime device */
IOMAP_UNWRITTEN = 0x20, /* mapping covers allocated */ IOMAP_UNWRITTEN = 0x20, /* mapping covers allocated */
/* but uninitialized file data */ /* but uninitialized file data */
IOMAP_NEW = 0x40 /* just allocate */ IOMAP_NEW = 0x40 /* just allocate */
@ -71,7 +70,6 @@ typedef enum {
typedef struct xfs_iomap { typedef struct xfs_iomap {
xfs_daddr_t iomap_bn; /* first 512B blk of mapping */ xfs_daddr_t iomap_bn; /* first 512B blk of mapping */
xfs_buftarg_t *iomap_target;
xfs_off_t iomap_offset; /* offset of mapping, bytes */ xfs_off_t iomap_offset; /* offset of mapping, bytes */
xfs_off_t iomap_bsize; /* size of mapping, bytes */ xfs_off_t iomap_bsize; /* size of mapping, bytes */
xfs_off_t iomap_delta; /* offset into mapping, bytes */ xfs_off_t iomap_delta; /* offset into mapping, bytes */