Skip to content

Commit

Permalink
[XFS] kill unnessecary ioops indirection
Browse files Browse the repository at this point in the history
Currently there is an indirection called ioops in the XFS data I/O path.
Various functions are called by functions pointers, but there is no
coherence in what this is for, and of course for XFS itself it's entirely
unused. This patch removes it instead and significantly reduces source and
binary size of XFS while making maintaince easier.

SGI-PV: 970841
SGI-Modid: xfs-linux-melb:xfs-kern:29737a

Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
  • Loading branch information
Lachlan McIlroy authored and Lachlan McIlroy committed Feb 7, 2008
1 parent 21a6254 commit 541d7d3
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 249 deletions.
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_aops.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ xfs_map_blocks(
xfs_inode_t *ip = XFS_I(inode);
int error, nmaps = 1;

error = xfs_bmap(ip, offset, count,
error = xfs_iomap(ip, offset, count,
flags, mapp, &nmaps);
if (!error && (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)))
xfs_iflags_set(ip, XFS_IMODIFIED);
Expand Down Expand Up @@ -1336,7 +1336,7 @@ __xfs_get_blocks(
offset = (xfs_off_t)iblock << inode->i_blkbits;
ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
size = bh_result->b_size;
error = xfs_bmap(XFS_I(inode), offset, size,
error = xfs_iomap(XFS_I(inode), offset, size,
create ? flags : BMAPI_READ, &iomap, &niomap);
if (error)
return -error;
Expand Down
56 changes: 17 additions & 39 deletions fs/xfs/linux-2.6/xfs_lrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,15 @@ xfs_inval_cached_trace(
*/
STATIC int
xfs_iozero(
struct inode *ip, /* inode */
struct xfs_inode *ip, /* inode */
loff_t pos, /* offset in file */
size_t count) /* size of data to zero */
{
struct page *page;
struct address_space *mapping;
int status;

mapping = ip->i_mapping;
mapping = ip->i_vnode->i_mapping;
do {
unsigned offset, bytes;
void *fsdata;
Expand Down Expand Up @@ -389,20 +389,19 @@ xfs_splice_write(
*/
STATIC int /* error (positive) */
xfs_zero_last_block(
struct inode *ip,
xfs_iocore_t *io,
xfs_inode_t *ip,
xfs_fsize_t offset,
xfs_fsize_t isize)
{
xfs_fileoff_t last_fsb;
xfs_mount_t *mp = io->io_mount;
xfs_mount_t *mp = ip->i_mount;
int nimaps;
int zero_offset;
int zero_len;
int error = 0;
xfs_bmbt_irec_t imap;

ASSERT(ismrlocked(io->io_lock, MR_UPDATE) != 0);
ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE) != 0);

zero_offset = XFS_B_FSB_OFFSET(mp, isize);
if (zero_offset == 0) {
Expand All @@ -415,7 +414,7 @@ xfs_zero_last_block(

last_fsb = XFS_B_TO_FSBT(mp, isize);
nimaps = 1;
error = XFS_BMAPI(mp, NULL, io, last_fsb, 1, 0, NULL, 0, &imap,
error = xfs_bmapi(NULL, ip, last_fsb, 1, 0, NULL, 0, &imap,
&nimaps, NULL, NULL);
if (error) {
return error;
Expand All @@ -433,14 +432,14 @@ xfs_zero_last_block(
* out sync. We need to drop the ilock while we do this so we
* don't deadlock when the buffer cache calls back to us.
*/
XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);
xfs_iunlock(ip, XFS_ILOCK_EXCL| XFS_EXTSIZE_RD);

zero_len = mp->m_sb.sb_blocksize - zero_offset;
if (isize + zero_len > offset)
zero_len = offset - isize;
error = xfs_iozero(ip, isize, zero_len);

XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
ASSERT(error >= 0);
return error;
}
Expand All @@ -458,12 +457,11 @@ xfs_zero_last_block(

int /* error (positive) */
xfs_zero_eof(
bhv_vnode_t *vp,
xfs_iocore_t *io,
xfs_inode_t *ip,
xfs_off_t offset, /* starting I/O offset */
xfs_fsize_t isize) /* current inode size */
{
struct inode *ip = vn_to_inode(vp);
xfs_iocore_t *io = &ip->i_iocore;
xfs_fileoff_t start_zero_fsb;
xfs_fileoff_t end_zero_fsb;
xfs_fileoff_t zero_count_fsb;
Expand All @@ -483,7 +481,7 @@ xfs_zero_eof(
* First handle zeroing the block on which isize resides.
* We only zero a part of that block so it is handled specially.
*/
error = xfs_zero_last_block(ip, io, offset, isize);
error = xfs_zero_last_block(ip, offset, isize);
if (error) {
ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
Expand Down Expand Up @@ -514,7 +512,7 @@ xfs_zero_eof(
while (start_zero_fsb <= end_zero_fsb) {
nimaps = 1;
zero_count_fsb = end_zero_fsb - start_zero_fsb + 1;
error = XFS_BMAPI(mp, NULL, io, start_zero_fsb, zero_count_fsb,
error = xfs_bmapi(NULL, ip, start_zero_fsb, zero_count_fsb,
0, NULL, 0, &imap, &nimaps, NULL, NULL);
if (error) {
ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
Expand Down Expand Up @@ -542,7 +540,7 @@ xfs_zero_eof(
* Drop the inode lock while we're doing the I/O.
* We'll still have the iolock to protect us.
*/
XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
xfs_iunlock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);

zero_off = XFS_FSB_TO_B(mp, start_zero_fsb);
zero_len = XFS_FSB_TO_B(mp, imap.br_blockcount);
Expand All @@ -558,14 +556,13 @@ xfs_zero_eof(
start_zero_fsb = imap.br_startoff + imap.br_blockcount;
ASSERT(start_zero_fsb <= (end_zero_fsb + 1));

XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
}

return 0;

out_lock:

XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
xfs_ilock(ip, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
ASSERT(error >= 0);
return error;
}
Expand Down Expand Up @@ -706,7 +703,7 @@ xfs_write(
*/

if (pos > xip->i_size) {
error = xfs_zero_eof(vp, io, pos, xip->i_size);
error = xfs_zero_eof(xip, pos, xip->i_size);
if (error) {
xfs_iunlock(xip, XFS_ILOCK_EXCL);
goto out_unlock_internal;
Expand Down Expand Up @@ -751,7 +748,7 @@ xfs_write(

if (need_i_mutex) {
/* demote the lock now the cached pages are gone */
XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
xfs_ilock_demote(xip, XFS_IOLOCK_EXCL);
mutex_unlock(&inode->i_mutex);

iolock = XFS_IOLOCK_SHARED;
Expand Down Expand Up @@ -894,25 +891,6 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
}
}


int
xfs_bmap(
xfs_inode_t *ip,
xfs_off_t offset,
ssize_t count,
int flags,
xfs_iomap_t *iomapp,
int *niomaps)
{
xfs_iocore_t *io = &ip->i_iocore;

ASSERT((ip->i_d.di_mode & S_IFMT) == S_IFREG);
ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));

return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
}

/*
* Wrapper around bdstrat so that we can stop data
* from going to disk in case we are shutting down the filesystem.
Expand Down
3 changes: 1 addition & 2 deletions fs/xfs/linux-2.6/xfs_lrw.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
extern int xfs_bdstrat_cb(struct xfs_buf *);
extern int xfs_dev_is_read_only(struct xfs_mount *, char *);

extern int xfs_zero_eof(struct inode *, struct xfs_iocore *, xfs_off_t,
xfs_fsize_t);
extern int xfs_zero_eof(struct xfs_inode *, xfs_off_t, xfs_fsize_t);

#endif /* __XFS_LRW_H__ */
2 changes: 1 addition & 1 deletion fs/xfs/xfs_dfrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ xfs_swapext(
goto error0;
}

error = XFS_SWAP_EXTENTS(mp, &ip->i_iocore, &tip->i_iocore, sxp);
error = xfs_swap_extents(ip, tip, sxp);

error0:
if (fp != NULL)
Expand Down
8 changes: 2 additions & 6 deletions fs/xfs/xfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@ xfs_itruncate_finish(
* runs.
*/
XFS_BMAP_INIT(&free_list, &first_block);
error = XFS_BUNMAPI(mp, ntp, &ip->i_iocore,
error = xfs_bunmapi(ntp, ip,
first_unmap_block, unmap_len,
XFS_BMAPI_AFLAG(fork) |
(sync ? 0 : XFS_BMAPI_ASYNC),
Expand Down Expand Up @@ -1844,8 +1844,6 @@ xfs_igrow_start(
xfs_fsize_t new_size,
cred_t *credp)
{
int error;

ASSERT(ismrlocked(&(ip->i_lock), MR_UPDATE) != 0);
ASSERT(ismrlocked(&(ip->i_iolock), MR_UPDATE) != 0);
ASSERT(new_size > ip->i_size);
Expand All @@ -1855,9 +1853,7 @@ xfs_igrow_start(
* xfs_write_file() beyond the end of the file
* and any blocks between the old and new file sizes.
*/
error = xfs_zero_eof(XFS_ITOV(ip), &ip->i_iocore, new_size,
ip->i_size);
return error;
return xfs_zero_eof(ip, new_size, ip->i_size);
}

/*
Expand Down
40 changes: 0 additions & 40 deletions fs/xfs/xfs_iocore.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,46 +47,6 @@
#include "xfs_trans_space.h"
#include "xfs_iomap.h"


STATIC xfs_fsize_t
xfs_size_fn(
xfs_inode_t *ip)
{
return XFS_ISIZE(ip);
}

STATIC int
xfs_ioinit(
struct xfs_mount *mp,
struct xfs_mount_args *mntargs,
int flags)
{
return xfs_mountfs(mp, flags);
}

xfs_ioops_t xfs_iocore_xfs = {
.xfs_ioinit = (xfs_ioinit_t) xfs_ioinit,
.xfs_bmapi_func = (xfs_bmapi_t) xfs_bmapi,
.xfs_bunmapi_func = (xfs_bunmapi_t) xfs_bunmapi,
.xfs_bmap_eof_func = (xfs_bmap_eof_t) xfs_bmap_eof,
.xfs_iomap_write_direct =
(xfs_iomap_write_direct_t) xfs_iomap_write_direct,
.xfs_iomap_write_delay =
(xfs_iomap_write_delay_t) xfs_iomap_write_delay,
.xfs_iomap_write_allocate =
(xfs_iomap_write_allocate_t) xfs_iomap_write_allocate,
.xfs_iomap_write_unwritten =
(xfs_iomap_write_unwritten_t) xfs_iomap_write_unwritten,
.xfs_ilock = (xfs_lock_t) xfs_ilock,
.xfs_lck_map_shared = (xfs_lck_map_shared_t) xfs_ilock_map_shared,
.xfs_ilock_demote = (xfs_lock_demote_t) xfs_ilock_demote,
.xfs_ilock_nowait = (xfs_lock_nowait_t) xfs_ilock_nowait,
.xfs_unlock = (xfs_unlk_t) xfs_iunlock,
.xfs_size_func = (xfs_size_t) xfs_size_fn,
.xfs_iodone = (xfs_iodone_t) fs_noerr,
.xfs_swap_extents_func = (xfs_swap_extents_t) xfs_swap_extents,
};

void
xfs_iocore_inode_reinit(
xfs_inode_t *ip)
Expand Down
Loading

0 comments on commit 541d7d3

Please sign in to comment.