Skip to content

Commit

Permalink
[XFS] kill xfs_iocore_t
Browse files Browse the repository at this point in the history
xfs_iocore_t is a structure embedded in xfs_inode. Except for one field it
just duplicates fields already in xfs_inode, and there is nothing this
abstraction buys us on XFS/Linux. This patch removes it and shrinks source
and binary size of xfs aswell as shrinking the size of xfs_inode by 60/44
bytes in debug/non-debug builds.

SGI-PV: 970852
SGI-Modid: xfs-linux-melb:xfs-kern:29754a

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Lachlan McIlroy <[email protected]>
Signed-off-by: Tim Shimmin <[email protected]>
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Feb 7, 2008
1 parent 007c61c commit 613d704
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 211 deletions.
1 change: 0 additions & 1 deletion fs/xfs/Makefile-linux-2.6
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ xfs-y += xfs_alloc.o \
xfs_iget.o \
xfs_inode.o \
xfs_inode_item.o \
xfs_iocore.o \
xfs_iomap.o \
xfs_itable.o \
xfs_dfrag.o \
Expand Down
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 @@ -163,7 +163,7 @@ xfs_destroy_ioend(
/*
* Update on-disk file size now that data has been written to disk.
* The current in-memory file size is i_size. If a write is beyond
* eof io_new_size will be the intended file size until i_size is
* eof i_new_size will be the intended file size until i_size is
* updated. If this write does not extend all the way to the valid
* file size then restrict this update to the end of the write.
*/
Expand All @@ -185,7 +185,7 @@ xfs_setfilesize(

xfs_ilock(ip, XFS_ILOCK_EXCL);

isize = MAX(ip->i_size, ip->i_iocore.io_new_size);
isize = MAX(ip->i_size, ip->i_new_size);
isize = MIN(isize, bsize);

if (ip->i_d.di_size < isize) {
Expand Down
55 changes: 24 additions & 31 deletions fs/xfs/linux-2.6/xfs_lrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,12 @@
void
xfs_rw_enter_trace(
int tag,
xfs_iocore_t *io,
xfs_inode_t *ip,
void *data,
size_t segs,
loff_t offset,
int ioflags)
{
xfs_inode_t *ip = XFS_IO_INODE(io);

if (ip->i_rwtrace == NULL)
return;
ktrace_enter(ip->i_rwtrace,
Expand All @@ -78,8 +76,8 @@ xfs_rw_enter_trace(
(void *)((unsigned long)((offset >> 32) & 0xffffffff)),
(void *)((unsigned long)(offset & 0xffffffff)),
(void *)((unsigned long)ioflags),
(void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
(void *)((unsigned long)(io->io_new_size & 0xffffffff)),
(void *)((unsigned long)((ip->i_new_size >> 32) & 0xffffffff)),
(void *)((unsigned long)(ip->i_new_size & 0xffffffff)),
(void *)((unsigned long)current_pid()),
(void *)NULL,
(void *)NULL,
Expand All @@ -89,13 +87,12 @@ xfs_rw_enter_trace(

void
xfs_inval_cached_trace(
xfs_iocore_t *io,
xfs_inode_t *ip,
xfs_off_t offset,
xfs_off_t len,
xfs_off_t first,
xfs_off_t last)
{
xfs_inode_t *ip = XFS_IO_INODE(io);

if (ip->i_rwtrace == NULL)
return;
Expand Down Expand Up @@ -256,7 +253,7 @@ xfs_read(
}
}

xfs_rw_enter_trace(XFS_READ_ENTER, &ip->i_iocore,
xfs_rw_enter_trace(XFS_READ_ENTER, ip,
(void *)iovp, segs, *offset, ioflags);

iocb->ki_pos = *offset;
Expand Down Expand Up @@ -301,7 +298,7 @@ xfs_splice_read(
return -error;
}
}
xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, &ip->i_iocore,
xfs_rw_enter_trace(XFS_SPLICE_READ_ENTER, ip,
pipe, count, *ppos, ioflags);
ret = generic_file_splice_read(infilp, ppos, pipe, count, flags);
if (ret > 0)
Expand All @@ -323,7 +320,6 @@ xfs_splice_write(
{
bhv_vnode_t *vp = XFS_ITOV(ip);
xfs_mount_t *mp = ip->i_mount;
xfs_iocore_t *io = &ip->i_iocore;
ssize_t ret;
struct inode *inode = outfilp->f_mapping->host;
xfs_fsize_t isize, new_size;
Expand All @@ -350,10 +346,10 @@ xfs_splice_write(

xfs_ilock(ip, XFS_ILOCK_EXCL);
if (new_size > ip->i_size)
io->io_new_size = new_size;
ip->i_new_size = new_size;
xfs_iunlock(ip, XFS_ILOCK_EXCL);

xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, &ip->i_iocore,
xfs_rw_enter_trace(XFS_SPLICE_WRITE_ENTER, ip,
pipe, count, *ppos, ioflags);
ret = generic_file_splice_write(pipe, outfilp, ppos, count, flags);
if (ret > 0)
Expand All @@ -370,9 +366,9 @@ xfs_splice_write(
xfs_iunlock(ip, XFS_ILOCK_EXCL);
}

if (io->io_new_size) {
if (ip->i_new_size) {
xfs_ilock(ip, XFS_ILOCK_EXCL);
io->io_new_size = 0;
ip->i_new_size = 0;
if (ip->i_d.di_size > ip->i_size)
ip->i_d.di_size = ip->i_size;
xfs_iunlock(ip, XFS_ILOCK_EXCL);
Expand Down Expand Up @@ -461,20 +457,19 @@ xfs_zero_eof(
xfs_off_t offset, /* starting I/O offset */
xfs_fsize_t isize) /* current inode size */
{
xfs_iocore_t *io = &ip->i_iocore;
xfs_mount_t *mp = ip->i_mount;
xfs_fileoff_t start_zero_fsb;
xfs_fileoff_t end_zero_fsb;
xfs_fileoff_t zero_count_fsb;
xfs_fileoff_t last_fsb;
xfs_fileoff_t zero_off;
xfs_fsize_t zero_len;
xfs_mount_t *mp = io->io_mount;
int nimaps;
int error = 0;
xfs_bmbt_irec_t imap;

ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
ASSERT(offset > isize);

/*
Expand All @@ -483,8 +478,8 @@ xfs_zero_eof(
*/
error = xfs_zero_last_block(ip, offset, isize);
if (error) {
ASSERT(ismrlocked(io->io_lock, MR_UPDATE));
ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
return error;
}

Expand Down Expand Up @@ -515,8 +510,8 @@ xfs_zero_eof(
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));
ASSERT(ismrlocked(io->io_iolock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_lock, MR_UPDATE));
ASSERT(ismrlocked(&ip->i_iolock, MR_UPDATE));
return error;
}
ASSERT(nimaps > 0);
Expand Down Expand Up @@ -584,7 +579,6 @@ xfs_write(
xfs_mount_t *mp;
ssize_t ret = 0, error = 0;
xfs_fsize_t isize, new_size;
xfs_iocore_t *io;
int iolock;
int eventsent = 0;
bhv_vrwlock_t locktype;
Expand All @@ -604,8 +598,7 @@ xfs_write(
if (count == 0)
return 0;

io = &xip->i_iocore;
mp = io->io_mount;
mp = xip->i_mount;

xfs_wait_for_freeze(mp, SB_FREEZE_WRITE);

Expand Down Expand Up @@ -685,7 +678,7 @@ xfs_write(

new_size = pos + count;
if (new_size > xip->i_size)
io->io_new_size = new_size;
xip->i_new_size = new_size;

if (likely(!(ioflags & IO_INVIS))) {
file_update_time(file);
Expand Down Expand Up @@ -737,7 +730,7 @@ xfs_write(
if ((ioflags & IO_ISDIRECT)) {
if (VN_CACHED(vp)) {
WARN_ON(need_i_mutex == 0);
xfs_inval_cached_trace(io, pos, -1,
xfs_inval_cached_trace(xip, pos, -1,
ctooff(offtoct(pos)), -1);
error = xfs_flushinval_pages(xip,
ctooff(offtoct(pos)),
Expand All @@ -756,7 +749,7 @@ xfs_write(
need_i_mutex = 0;
}

xfs_rw_enter_trace(XFS_DIOWR_ENTER, io, (void *)iovp, segs,
xfs_rw_enter_trace(XFS_DIOWR_ENTER, xip, (void *)iovp, segs,
*offset, ioflags);
ret = generic_file_direct_write(iocb, iovp,
&segs, pos, offset, count, ocount);
Expand All @@ -776,7 +769,7 @@ xfs_write(
goto relock;
}
} else {
xfs_rw_enter_trace(XFS_WRITE_ENTER, io, (void *)iovp, segs,
xfs_rw_enter_trace(XFS_WRITE_ENTER, xip, (void *)iovp, segs,
*offset, ioflags);
ret = generic_file_buffered_write(iocb, iovp, segs,
pos, offset, count, ret);
Expand Down Expand Up @@ -840,9 +833,9 @@ xfs_write(
}

out_unlock_internal:
if (io->io_new_size) {
if (xip->i_new_size) {
xfs_ilock(xip, XFS_ILOCK_EXCL);
io->io_new_size = 0;
xip->i_new_size = 0;
/*
* If this was a direct or synchronous I/O that failed (such
* as ENOSPC) then part of the I/O may have been written to
Expand Down
13 changes: 6 additions & 7 deletions fs/xfs/linux-2.6/xfs_lrw.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#define __XFS_LRW_H__

struct xfs_mount;
struct xfs_iocore;
struct xfs_inode;
struct xfs_bmbt_irec;
struct xfs_buf;
Expand Down Expand Up @@ -60,13 +59,13 @@ struct xfs_iomap;
#define XFS_IOMAP_UNWRITTEN 27
#define XFS_SPLICE_READ_ENTER 28
#define XFS_SPLICE_WRITE_ENTER 29
extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
void *, size_t, loff_t, int);
extern void xfs_inval_cached_trace(struct xfs_iocore *,
xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
extern void xfs_rw_enter_trace(int, struct xfs_inode *,
void *, size_t, loff_t, int);
extern void xfs_inval_cached_trace(struct xfs_inode *,
xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
#else
#define xfs_rw_enter_trace(tag, io, data, size, offset, ioflags)
#define xfs_inval_cached_trace(io, offset, len, first, last)
#define xfs_rw_enter_trace(tag, ip, data, size, offset, ioflags)
#define xfs_inval_cached_trace(ip, offset, len, first, last)
#endif

extern int xfsbdstrat(struct xfs_mount *, struct xfs_buf *);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_dfrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ xfs_swap_extents(
}

if (VN_CACHED(tvp) != 0) {
xfs_inval_cached_trace(&tip->i_iocore, 0, -1, 0, -1);
xfs_inval_cached_trace(tip, 0, -1, 0, -1);
error = xfs_flushinval_pages(tip, 0, -1,
FI_REMAPF_LOCKED);
if (error)
Expand Down
13 changes: 3 additions & 10 deletions fs/xfs/xfs_iget.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,9 @@ xfs_iget_core(
XFS_STATS_INC(xs_ig_found);

finish_inode:
if (ip->i_d.di_mode == 0) {
if (!(flags & XFS_IGET_CREATE)) {
xfs_put_perag(mp, pag);
return ENOENT;
}
xfs_iocore_inode_reinit(ip);
if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) {
xfs_put_perag(mp, pag);
return ENOENT;
}

if (lock_flags != 0)
Expand Down Expand Up @@ -235,7 +232,6 @@ xfs_iget_core(
xfs_itrace_exit_tag(ip, "xfs_iget.alloc");

xfs_inode_lock_init(ip, vp);
xfs_iocore_inode_init(ip);
if (lock_flags)
xfs_ilock(ip, lock_flags);

Expand Down Expand Up @@ -331,9 +327,6 @@ xfs_iget_core(
ASSERT(ip->i_df.if_ext_max ==
XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t));

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

xfs_iflags_set(ip, XFS_IMODIFIED);
*ipp = ip;

Expand Down
4 changes: 1 addition & 3 deletions fs/xfs/xfs_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1220,10 +1220,8 @@ xfs_ialloc(
ip->i_d.di_extsize = pip->i_d.di_extsize;
}
} else if ((mode & S_IFMT) == S_IFREG) {
if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
di_flags |= XFS_DIFLAG_REALTIME;
ip->i_iocore.io_flags |= XFS_IOCORE_RT;
}
if (pip->i_d.di_flags & XFS_DIFLAG_EXTSZINHERIT) {
di_flags |= XFS_DIFLAG_EXTSIZE;
ip->i_d.di_extsize = pip->i_d.di_extsize;
Expand Down
43 changes: 1 addition & 42 deletions fs/xfs/xfs_inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,45 +132,6 @@ typedef struct dm_attrs_s {
__uint16_t da_pad; /* DMIG extra padding */
} dm_attrs_t;

typedef struct xfs_iocore {
void *io_obj; /* pointer to container
* inode or dcxvn structure */
struct xfs_mount *io_mount; /* fs mount struct ptr */
#ifdef DEBUG
mrlock_t *io_lock; /* inode IO lock */
mrlock_t *io_iolock; /* inode IO lock */
#endif

/* I/O state */
xfs_fsize_t io_new_size; /* sz when write completes */

/* Miscellaneous state. */
unsigned int io_flags; /* IO related flags */

/* DMAPI state */
dm_attrs_t io_dmattrs;

} xfs_iocore_t;

#define io_dmevmask io_dmattrs.da_dmevmask
#define io_dmstate io_dmattrs.da_dmstate

#define XFS_IO_INODE(io) ((xfs_inode_t *) ((io)->io_obj))
#define XFS_IO_DCXVN(io) ((dcxvn_t *) ((io)->io_obj))

/*
* Flags in the flags field
*/

#define XFS_IOCORE_RT 0x1

/*
* xfs_iocore prototypes
*/

extern void xfs_iocore_inode_init(struct xfs_inode *);
extern void xfs_iocore_inode_reinit(struct xfs_inode *);

/*
* This is the xfs inode cluster structure. This structure is used by
* xfs_iflush to find inodes that share a cluster and can be flushed to disk at
Expand Down Expand Up @@ -283,9 +244,6 @@ typedef struct xfs_inode {
struct xfs_inode **i_refcache; /* ptr to entry in ref cache */
struct xfs_inode *i_release; /* inode to unref */
#endif
/* I/O state */
xfs_iocore_t i_iocore; /* I/O core */

/* Miscellaneous state. */
unsigned short i_flags; /* see defined flags below */
unsigned char i_update_core; /* timestamps/size is dirty */
Expand All @@ -298,6 +256,7 @@ typedef struct xfs_inode {
struct hlist_node i_cnode; /* cluster link node */

xfs_fsize_t i_size; /* in-memory size */
xfs_fsize_t i_new_size; /* size when write completes */
atomic_t i_iocount; /* outstanding I/O count */
/* Trace buffers per inode. */
#ifdef XFS_INODE_TRACE
Expand Down
Loading

0 comments on commit 613d704

Please sign in to comment.