Commit 421b3a51 authored by Stephen Lord's avatar Stephen Lord Committed by Christoph Hellwig

[XFS] rework iocore infrastructure, remove some code and make it more

orthogonal. In addition, add some of the hooks for unwritten extents.

SGI Modid: 2.5.x-xfs:slinx:134603a
parent 4a725254
...@@ -48,6 +48,9 @@ map_blocks( ...@@ -48,6 +48,9 @@ map_blocks(
vnode_t *vp = LINVFS_GET_VP(inode); vnode_t *vp = LINVFS_GET_VP(inode);
int error, nmaps = 1; int error, nmaps = 1;
if (((flags & (PBF_DIRECT|PBF_SYNC)) == PBF_DIRECT) &&
(offset >= inode->i_size))
count = max(count, XFS_WRITE_IO_LOG);
retry: retry:
VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error); VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error);
if (flags & PBF_WRITE) { if (flags & PBF_WRITE) {
...@@ -515,7 +518,7 @@ linvfs_get_block_core( ...@@ -515,7 +518,7 @@ linvfs_get_block_core(
/* If we are doing writes at the end of the file, /* If we are doing writes at the end of the file,
* allocate in chunks * allocate in chunks
*/ */
if (create && (offset >= inode->i_size) && !(flags & PBF_SYNC)) if (create && (offset >= inode->i_size))
size = 1 << XFS_WRITE_IO_LOG; size = 1 << XFS_WRITE_IO_LOG;
else else
size = 1 << inode->i_blkbits; size = 1 << inode->i_blkbits;
...@@ -534,15 +537,20 @@ linvfs_get_block_core( ...@@ -534,15 +537,20 @@ linvfs_get_block_core(
page_buf_daddr_t bn; page_buf_daddr_t bn;
loff_t delta; loff_t delta;
delta = offset - pbmap.pbm_offset; /* For unwritten extents do not report a disk address on
delta >>= inode->i_blkbits; * the read case.
*/
if (create || ((pbmap.pbm_flags & PBMF_UNWRITTEN) == 0)) {
delta = offset - pbmap.pbm_offset;
delta >>= inode->i_blkbits;
bn = pbmap.pbm_bn >> (inode->i_blkbits - 9); bn = pbmap.pbm_bn >> (inode->i_blkbits - 9);
bn += delta; bn += delta;
bh_result->b_blocknr = bn; bh_result->b_blocknr = bn;
bh_result->b_bdev = pbmap.pbm_target->pbr_bdev; bh_result->b_bdev = pbmap.pbm_target->pbr_bdev;
set_buffer_mapped(bh_result); set_buffer_mapped(bh_result);
}
} }
/* If we previously allocated a block out beyond eof and /* If we previously allocated a block out beyond eof and
......
This diff is collapsed.
...@@ -808,6 +808,25 @@ xfs_bdstrat_cb(struct xfs_buf *bp) ...@@ -808,6 +808,25 @@ xfs_bdstrat_cb(struct xfs_buf *bp)
} }
} }
int
xfs_bmap(bhv_desc_t *bdp,
xfs_off_t offset,
ssize_t count,
int flags,
page_buf_bmap_t *pbmapp,
int *npbmaps)
{
xfs_inode_t *ip = XFS_BHVTOI(bdp);
xfs_iocore_t *io = &ip->i_iocore;
ASSERT((ip->i_d.di_mode & IFMT) == 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, pbmapp, npbmaps);
}
/* /*
* Wrapper around bdstrat so that we can stop data * Wrapper around bdstrat so that we can stop data
* from going to disk in case we are shutting down the filesystem. * from going to disk in case we are shutting down the filesystem.
......
...@@ -36,6 +36,8 @@ struct vnode; ...@@ -36,6 +36,8 @@ struct vnode;
struct bhv_desc; struct bhv_desc;
struct xfs_mount; struct xfs_mount;
struct xfs_iocore; struct xfs_iocore;
struct xfs_inode;
struct xfs_bmbt_irec;
struct page_buf_s; struct page_buf_s;
struct page_buf_bmap_s; struct page_buf_bmap_s;
...@@ -62,6 +64,16 @@ extern ssize_t xfs_sendfile (struct bhv_desc *, struct file *, ...@@ -62,6 +64,16 @@ extern ssize_t xfs_sendfile (struct bhv_desc *, struct file *,
loff_t *, size_t, read_actor_t, loff_t *, size_t, read_actor_t,
void *, struct cred *); void *, struct cred *);
extern int xfs_iomap (struct xfs_iocore *, xfs_off_t, ssize_t, int,
struct page_buf_bmap_s *, int *);
extern int xfs_iomap_write_direct (struct xfs_inode *, loff_t, size_t,
int, struct xfs_bmbt_irec *, int *, int);
extern int xfs_iomap_write_delay (struct xfs_inode *, loff_t, size_t,
int, struct xfs_bmbt_irec *, int *);
extern int xfs_iomap_write_allocate (struct xfs_inode *,
struct xfs_bmbt_irec *, int *);
extern int xfs_iomap_write_unwritten (struct xfs_inode *, loff_t, size_t);
extern int xfs_dev_is_read_only (struct xfs_mount *, char *); extern int xfs_dev_is_read_only (struct xfs_mount *, char *);
extern void XFS_log_write_unmount_ro (struct bhv_desc *); extern void XFS_log_write_unmount_ro (struct bhv_desc *);
......
...@@ -41,14 +41,24 @@ xfs_size_fn( ...@@ -41,14 +41,24 @@ xfs_size_fn(
} }
xfs_ioops_t xfs_iocore_xfs = { xfs_ioops_t xfs_iocore_xfs = {
.xfs_ioinit = (xfs_ioinit_t) fs_noerr,
.xfs_bmapi_func = (xfs_bmapi_t) xfs_bmapi, .xfs_bmapi_func = (xfs_bmapi_t) xfs_bmapi,
.xfs_bmap_eof_func = (xfs_bmap_eof_t) xfs_bmap_eof, .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_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_demote = (xfs_lock_demote_t) xfs_ilock_demote,
.xfs_ilock_nowait = (xfs_lock_nowait_t) xfs_ilock_nowait, .xfs_ilock_nowait = (xfs_lock_nowait_t) xfs_ilock_nowait,
.xfs_unlock = (xfs_unlk_t) xfs_iunlock, .xfs_unlock = (xfs_unlk_t) xfs_iunlock,
.xfs_size_func = (xfs_size_t) xfs_size_fn, .xfs_size_func = (xfs_size_t) xfs_size_fn,
.xfs_lastbyte = (xfs_lastbyte_t) xfs_file_last_byte, .xfs_iodone = (xfs_iodone_t) fs_noerr,
}; };
void void
...@@ -83,4 +93,3 @@ xfs_iocore_inode_init( ...@@ -83,4 +93,3 @@ xfs_iocore_inode_init(
xfs_iocore_inode_reinit(ip); xfs_iocore_inode_reinit(ip);
} }
...@@ -87,41 +87,60 @@ struct xfs_bmap_free; ...@@ -87,41 +87,60 @@ struct xfs_bmap_free;
#define AIL_LOCK(mp,s) s=mutex_spinlock(&(mp)->m_ail_lock) #define AIL_LOCK(mp,s) s=mutex_spinlock(&(mp)->m_ail_lock)
#define AIL_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_ail_lock, s) #define AIL_UNLOCK(mp,s) mutex_spinunlock(&(mp)->m_ail_lock, s)
/*
/* Prototypes and functions for I/O core modularization, a vector * Prototypes and functions for I/O core modularization.
* of functions is used to indirect from xfs/cxfs independent code
* to the xfs/cxfs dependent code.
* The vector is placed in the mount structure so that we can
* minimize the number of memory indirections involved.
*/ */
struct flid;
struct buf;
typedef int (*xfs_ioinit_t)(struct vfs *,
struct xfs_mount_args *, int *);
typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *, typedef int (*xfs_bmapi_t)(struct xfs_trans *, void *,
xfs_fileoff_t, xfs_filblks_t, int, xfs_fileoff_t, xfs_filblks_t, int,
xfs_fsblock_t *, xfs_extlen_t, xfs_fsblock_t *, xfs_extlen_t,
struct xfs_bmbt_irec *, int *, struct xfs_bmbt_irec *, int *,
struct xfs_bmap_free *); struct xfs_bmap_free *);
typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *); typedef int (*xfs_bmap_eof_t)(void *, xfs_fileoff_t, int, int *);
typedef int (*xfs_iomap_write_direct_t)(
void *, loff_t, size_t, int,
struct xfs_bmbt_irec *, int *, int);
typedef int (*xfs_iomap_write_delay_t)(
void *, loff_t, size_t, int,
struct xfs_bmbt_irec *, int *);
typedef int (*xfs_iomap_write_allocate_t)(
void *, struct xfs_bmbt_irec *, int *);
typedef int (*xfs_iomap_write_unwritten_t)(
void *, loff_t, size_t);
typedef uint (*xfs_lck_map_shared_t)(void *);
typedef void (*xfs_lock_t)(void *, uint); typedef void (*xfs_lock_t)(void *, uint);
typedef void (*xfs_lock_demote_t)(void *, uint); typedef void (*xfs_lock_demote_t)(void *, uint);
typedef int (*xfs_lock_nowait_t)(void *, uint); typedef int (*xfs_lock_nowait_t)(void *, uint);
typedef void (*xfs_unlk_t)(void *, unsigned int); typedef void (*xfs_unlk_t)(void *, unsigned int);
typedef void (*xfs_chgtime_t)(void *, int);
typedef xfs_fsize_t (*xfs_size_t)(void *); typedef xfs_fsize_t (*xfs_size_t)(void *);
typedef xfs_fsize_t (*xfs_lastbyte_t)(void *); typedef xfs_fsize_t (*xfs_iodone_t)(struct vfs *);
typedef struct xfs_ioops { typedef struct xfs_ioops {
xfs_bmapi_t xfs_bmapi_func; xfs_ioinit_t xfs_ioinit;
xfs_bmap_eof_t xfs_bmap_eof_func; xfs_bmapi_t xfs_bmapi_func;
xfs_lock_t xfs_ilock; xfs_bmap_eof_t xfs_bmap_eof_func;
xfs_lock_demote_t xfs_ilock_demote; xfs_iomap_write_direct_t xfs_iomap_write_direct;
xfs_lock_nowait_t xfs_ilock_nowait; xfs_iomap_write_delay_t xfs_iomap_write_delay;
xfs_unlk_t xfs_unlock; xfs_iomap_write_allocate_t xfs_iomap_write_allocate;
xfs_chgtime_t xfs_chgtime; xfs_iomap_write_unwritten_t xfs_iomap_write_unwritten;
xfs_size_t xfs_size_func; xfs_lock_t xfs_ilock;
xfs_lastbyte_t xfs_lastbyte; xfs_lck_map_shared_t xfs_lck_map_shared;
xfs_lock_demote_t xfs_ilock_demote;
xfs_lock_nowait_t xfs_ilock_nowait;
xfs_unlk_t xfs_unlock;
xfs_size_t xfs_size_func;
xfs_iodone_t xfs_iodone;
} xfs_ioops_t; } xfs_ioops_t;
#define XFS_IOINIT(vfsp, args, flags) \
(*(mp)->m_io_ops.xfs_ioinit)(vfsp, args, flags)
#define XFS_BMAPI(mp, trans,io,bno,len,f,first,tot,mval,nmap,flist) \ #define XFS_BMAPI(mp, trans,io,bno,len,f,first,tot,mval,nmap,flist) \
(*(mp)->m_io_ops.xfs_bmapi_func) \ (*(mp)->m_io_ops.xfs_bmapi_func) \
(trans,(io)->io_obj,bno,len,f,first,tot,mval,nmap,flist) (trans,(io)->io_obj,bno,len,f,first,tot,mval,nmap,flist)
...@@ -130,9 +149,31 @@ typedef struct xfs_ioops { ...@@ -130,9 +149,31 @@ typedef struct xfs_ioops {
(*(mp)->m_io_ops.xfs_bmap_eof_func) \ (*(mp)->m_io_ops.xfs_bmap_eof_func) \
((io)->io_obj, endoff, whichfork, eof) ((io)->io_obj, endoff, whichfork, eof)
#define XFS_IOMAP_WRITE_DIRECT(mp, io, offset, count, flags, mval, nmap, found)\
(*(mp)->m_io_ops.xfs_iomap_write_direct) \
((io)->io_obj, offset, count, flags, mval, nmap, found)
#define XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, flags, mval, nmap) \
(*(mp)->m_io_ops.xfs_iomap_write_delay) \
((io)->io_obj, offset, count, flags, mval, nmap)
#define XFS_IOMAP_WRITE_ALLOCATE(mp, io, mval, nmap) \
(*(mp)->m_io_ops.xfs_iomap_write_allocate) \
((io)->io_obj, mval, nmap)
#define XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count) \
(*(mp)->m_io_ops.xfs_iomap_write_unwritten) \
((io)->io_obj, offset, count)
#define XFS_LCK_MAP_SHARED(mp, io) \
(*(mp)->m_io_ops.xfs_lck_map_shared)((io)->io_obj)
#define XFS_ILOCK(mp, io, mode) \ #define XFS_ILOCK(mp, io, mode) \
(*(mp)->m_io_ops.xfs_ilock)((io)->io_obj, mode) (*(mp)->m_io_ops.xfs_ilock)((io)->io_obj, mode)
#define XFS_ILOCK_NOWAIT(mp, io, mode) \
(*(mp)->m_io_ops.xfs_ilock_nowait)((io)->io_obj, mode)
#define XFS_IUNLOCK(mp, io, mode) \ #define XFS_IUNLOCK(mp, io, mode) \
(*(mp)->m_io_ops.xfs_unlock)((io)->io_obj, mode) (*(mp)->m_io_ops.xfs_unlock)((io)->io_obj, mode)
...@@ -142,8 +183,13 @@ typedef struct xfs_ioops { ...@@ -142,8 +183,13 @@ typedef struct xfs_ioops {
#define XFS_SIZE(mp, io) \ #define XFS_SIZE(mp, io) \
(*(mp)->m_io_ops.xfs_size_func)((io)->io_obj) (*(mp)->m_io_ops.xfs_size_func)((io)->io_obj)
#define XFS_LASTBYTE(mp, io) \ #define XFS_IODONE(vfsp) \
(*(mp)->m_io_ops.xfs_lastbyte)((io)->io_obj) (*(mp)->m_io_ops.xfs_iodone)(vfsp)
/*
* Prototypes and functions for the XFS realtime subsystem.
*/
typedef struct xfs_mount { typedef struct xfs_mount {
...@@ -303,8 +349,8 @@ typedef struct xfs_mount { ...@@ -303,8 +349,8 @@ typedef struct xfs_mount {
/* /*
* Default minimum read and write sizes. * Default minimum read and write sizes.
*/ */
#define XFS_READIO_LOG_LARGE 12 #define XFS_READIO_LOG_LARGE 16
#define XFS_WRITEIO_LOG_LARGE 12 #define XFS_WRITEIO_LOG_LARGE 16
/* /*
* Default allocation size * Default allocation size
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment