Commit 0fb91f05 authored by Nathan Scott's avatar Nathan Scott

[XFS] Fix error code sign on forced shutdown in iomap; sync iomap code up...

[XFS] Fix error code sign on forced shutdown in iomap; sync iomap code up between 2.4 and 2.6 versions.

SGI Modid: 2.5.x-xfs:slinx:161902a
parent 73cf7321
...@@ -74,14 +74,14 @@ ...@@ -74,14 +74,14 @@
#define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP #define XFS_WRITE_IMAPS XFS_BMAP_MAX_NMAP
STATIC int STATIC int
_xfs_imap_to_bmap( xfs_imap_to_bmap(
xfs_iocore_t *io, xfs_iocore_t *io,
xfs_off_t offset, xfs_off_t offset,
int new,
xfs_bmbt_irec_t *imap, xfs_bmbt_irec_t *imap,
page_buf_bmap_t *pbmapp, page_buf_bmap_t *pbmapp,
int imaps, /* Number of imap entries */ int imaps, /* Number of imap entries */
int pbmaps) /* Number of pbmap entries */ int bmaps, /* Number of bmap entries */
int flags)
{ {
xfs_mount_t *mp; xfs_mount_t *mp;
xfs_fsize_t nisize; xfs_fsize_t nisize;
...@@ -93,13 +93,13 @@ _xfs_imap_to_bmap( ...@@ -93,13 +93,13 @@ _xfs_imap_to_bmap(
if (io->io_new_size > nisize) if (io->io_new_size > nisize)
nisize = io->io_new_size; nisize = io->io_new_size;
for (pbm = 0; imaps && pbm < pbmaps; imaps--, pbmapp++, imap++, pbm++) { for (pbm = 0; imaps && pbm < bmaps; imaps--, pbmapp++, imap++, pbm++) {
pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ? pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ?
mp->m_rtdev_targp : mp->m_ddev_targp; mp->m_rtdev_targp : mp->m_ddev_targp;
pbmapp->pbm_offset = XFS_FSB_TO_B(mp, imap->br_startoff); pbmapp->pbm_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
pbmapp->pbm_delta = offset - pbmapp->pbm_offset; pbmapp->pbm_delta = offset - pbmapp->pbm_offset;
pbmapp->pbm_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount); pbmapp->pbm_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
pbmapp->pbm_flags = 0; pbmapp->pbm_flags = flags;
start_block = imap->br_startblock; start_block = imap->br_startblock;
if (start_block == HOLESTARTBLOCK) { if (start_block == HOLESTARTBLOCK) {
...@@ -118,9 +118,6 @@ _xfs_imap_to_bmap( ...@@ -118,9 +118,6 @@ _xfs_imap_to_bmap(
pbmapp->pbm_flags |= PBMF_EOF; pbmapp->pbm_flags |= PBMF_EOF;
} }
if (new)
pbmapp->pbm_flags |= PBMF_NEW;
offset += pbmapp->pbm_bsize - pbmapp->pbm_delta; offset += pbmapp->pbm_bsize - pbmapp->pbm_delta;
} }
return pbm; /* Return the number filled */ return pbm; /* Return the number filled */
...@@ -138,32 +135,32 @@ xfs_iomap( ...@@ -138,32 +135,32 @@ xfs_iomap(
xfs_mount_t *mp = io->io_mount; xfs_mount_t *mp = io->io_mount;
xfs_fileoff_t offset_fsb, end_fsb; xfs_fileoff_t offset_fsb, end_fsb;
int error = 0; int error = 0;
int new = 0;
int lockmode = 0; int lockmode = 0;
xfs_bmbt_irec_t imap; xfs_bmbt_irec_t imap;
int nimaps = 1; int nimaps = 1;
int bmap_flags = 0; int bmapi_flags = 0;
int bmapv_flags = 0;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -XFS_ERROR(EIO); return XFS_ERROR(EIO);
switch (flags & switch (flags &
(BMAP_READ | BMAP_WRITE | BMAP_ALLOCATE | (BMAP_READ | BMAP_WRITE | BMAP_ALLOCATE |
BMAP_UNWRITTEN | BMAP_DEVICE)) { BMAP_UNWRITTEN | BMAP_DEVICE)) {
case BMAP_READ: case BMAP_READ:
lockmode = XFS_LCK_MAP_SHARED(mp, io); lockmode = XFS_LCK_MAP_SHARED(mp, io);
bmap_flags = XFS_BMAPI_ENTIRE; bmapi_flags = XFS_BMAPI_ENTIRE;
if (flags & BMAP_IGNSTATE) if (flags & BMAP_IGNSTATE)
bmap_flags |= XFS_BMAPI_IGSTATE; bmapi_flags |= XFS_BMAPI_IGSTATE;
break; break;
case BMAP_WRITE: case BMAP_WRITE:
lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR; lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR;
bmap_flags = 0; bmapi_flags = 0;
XFS_ILOCK(mp, io, lockmode); XFS_ILOCK(mp, io, lockmode);
break; break;
case BMAP_ALLOCATE: case BMAP_ALLOCATE:
lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD; lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD;
bmap_flags = XFS_BMAPI_ENTIRE; bmapi_flags = XFS_BMAPI_ENTIRE;
/* Attempt non-blocking lock */ /* Attempt non-blocking lock */
if (flags & BMAP_TRYLOCK) { if (flags & BMAP_TRYLOCK) {
if (!XFS_ILOCK_NOWAIT(mp, io, lockmode)) if (!XFS_ILOCK_NOWAIT(mp, io, lockmode))
...@@ -192,8 +189,8 @@ xfs_iomap( ...@@ -192,8 +189,8 @@ xfs_iomap(
offset_fsb = XFS_B_TO_FSBT(mp, offset); offset_fsb = XFS_B_TO_FSBT(mp, offset);
error = XFS_BMAPI(mp, NULL, io, offset_fsb, error = XFS_BMAPI(mp, NULL, io, offset_fsb,
(xfs_filblks_t)(end_fsb - offset_fsb) , (xfs_filblks_t)(end_fsb - offset_fsb),
bmap_flags, NULL, 0, &imap, bmapi_flags, NULL, 0, &imap,
&nimaps, NULL); &nimaps, NULL);
if (error) if (error)
...@@ -213,7 +210,7 @@ xfs_iomap( ...@@ -213,7 +210,7 @@ xfs_iomap(
error = XFS_IOMAP_WRITE_DELAY(mp, io, offset, count, error = XFS_IOMAP_WRITE_DELAY(mp, io, offset, count,
flags, &imap, &nimaps); flags, &imap, &nimaps);
} }
new = 1; bmapv_flags = PBMF_NEW;
break; break;
case BMAP_ALLOCATE: case BMAP_ALLOCATE:
/* If we found an extent, return it */ /* If we found an extent, return it */
...@@ -233,8 +230,8 @@ xfs_iomap( ...@@ -233,8 +230,8 @@ xfs_iomap(
} }
if (nimaps) { if (nimaps) {
*npbmaps = _xfs_imap_to_bmap(io, offset, new, &imap, *npbmaps = xfs_imap_to_bmap(io, offset, &imap,
pbmapp, nimaps, *npbmaps); pbmapp, nimaps, *npbmaps, bmapv_flags);
} else if (npbmaps) { } else if (npbmaps) {
*npbmaps = 0; *npbmaps = 0;
} }
...@@ -251,13 +248,11 @@ xfs_flush_space( ...@@ -251,13 +248,11 @@ xfs_flush_space(
int *fsynced, int *fsynced,
int *ioflags) int *ioflags)
{ {
vnode_t *vp = XFS_ITOV(ip);
switch (*fsynced) { switch (*fsynced) {
case 0: case 0:
if (ip->i_delayed_blks) { if (ip->i_delayed_blks) {
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping); xfs_flush_inode(ip);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
*fsynced = 1; *fsynced = 1;
} else { } else {
...@@ -271,9 +266,7 @@ xfs_flush_space( ...@@ -271,9 +266,7 @@ xfs_flush_space(
return 0; return 0;
case 2: case 2:
xfs_iunlock(ip, XFS_ILOCK_EXCL); xfs_iunlock(ip, XFS_ILOCK_EXCL);
sync_blockdev(vp->v_vfsp->vfs_super->s_bdev); xfs_flush_device(ip);
xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
XFS_LOG_FORCE|XFS_LOG_SYNC);
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
*fsynced = 3; *fsynced = 3;
return 0; return 0;
......
...@@ -241,6 +241,23 @@ xfs_initialize_vnode( ...@@ -241,6 +241,23 @@ xfs_initialize_vnode(
} }
} }
void
xfs_flush_inode(
xfs_inode_t *ip)
{
struct inode *inode = LINVFS_GET_IP(XFS_ITOV(ip));
filemap_fdatawrite(inode->i_mapping);
}
void
xfs_flush_device(
xfs_inode_t *ip)
{
sync_blockdev(XFS_ITOV(ip)->v_vfsp->vfs_super->s_bdev);
xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
}
int int
xfs_blkdev_get( xfs_blkdev_get(
xfs_mount_t *mp, xfs_mount_t *mp,
......
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
#define LINVFS_SET_VFS(s, vfsp) \ #define LINVFS_SET_VFS(s, vfsp) \
((s)->s_fs_info = vfsp) ((s)->s_fs_info = vfsp)
struct xfs_inode;
struct xfs_mount; struct xfs_mount;
struct pb_target; struct pb_target;
struct block_device; struct block_device;
...@@ -107,6 +108,9 @@ extern __uint64_t xfs_max_file_offset(unsigned int); ...@@ -107,6 +108,9 @@ extern __uint64_t xfs_max_file_offset(unsigned int);
extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int); extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
extern void xfs_flush_inode(struct xfs_inode *);
extern void xfs_flush_device(struct xfs_inode *);
extern int xfs_blkdev_get(struct xfs_mount *, const char *, extern int xfs_blkdev_get(struct xfs_mount *, const char *,
struct block_device **); struct block_device **);
extern void xfs_blkdev_put(struct block_device *); extern void xfs_blkdev_put(struct block_device *);
......
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