@@ -127,6 +127,9 @@ extern struct cache_operations libxfs_bcache_operations;
/* Exit on buffer read error */
#define LIBXFS_READBUF_FAIL_EXIT (1 << 0)
+/* Exit on buffer write error */
+#define LIBXFS_WRITEBUF_FAIL_EXIT (1 << 0)
+
#ifdef XFS_BUF_TRACING
#define libxfs_readbuf(dev, daddr, len, flags, ops) \
@@ -1177,21 +1177,28 @@ libxfs_writebuf_int(xfs_buf_t *bp, int flags)
}
int
-libxfs_writebuf(xfs_buf_t *bp, int flags)
+libxfs_writebuf(
+ struct xfs_buf *bp,
+ int flags)
{
+ int bflags = LIBXFS_B_DIRTY;
+
#ifdef IO_DEBUG
printf("%lx: %s: dirty blkno=%llu(%llu)\n",
pthread_self(), __FUNCTION__,
(long long)LIBXFS_BBTOOFF64(bp->b_bn),
(long long)bp->b_bn);
#endif
+ if (flags & LIBXFS_WRITEBUF_FAIL_EXIT)
+ bflags |= LIBXFS_B_EXIT;
+
/*
* Clear any error hanging over from reading the buffer. This prevents
* subsequent reads after this write from seeing stale errors.
*/
bp->b_error = 0;
bp->b_flags &= ~LIBXFS_B_STALE;
- bp->b_flags |= (LIBXFS_B_DIRTY | flags);
+ bp->b_flags |= bflags;
libxfs_putbuf(bp);
return 0;
}
@@ -262,7 +262,7 @@ newfile(
if (logit)
libxfs_trans_log_buf(tp, bp, 0, bp->b_bcount - 1);
else
- libxfs_writebuf(bp, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(bp, LIBXFS_WRITEBUF_FAIL_EXIT);
}
ip->i_d.di_size = len;
return flags;
@@ -3447,7 +3447,7 @@ prepare_devices(
buf = libxfs_getbuf(mp->m_ddev_targp, (xi->dsize - whack_blks),
whack_blks);
memset(buf->b_addr, 0, WHACK_SIZE);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
libxfs_purgebuf(buf);
/*
@@ -3458,7 +3458,7 @@ prepare_devices(
*/
buf = libxfs_getbuf(mp->m_ddev_targp, 0, whack_blks);
memset(buf->b_addr, 0, WHACK_SIZE);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
libxfs_purgebuf(buf);
/* OK, now write the superblock... */
@@ -3466,7 +3466,7 @@ prepare_devices(
buf->b_ops = &xfs_sb_buf_ops;
memset(buf->b_addr, 0, cfg->sectorsize);
libxfs_sb_to_disk(buf->b_addr, sbp);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
libxfs_purgebuf(buf);
/* ...and zero the log.... */
@@ -3486,7 +3486,7 @@ prepare_devices(
XFS_FSB_TO_BB(mp, cfg->rtblocks - 1LL),
BTOBB(cfg->blocksize));
memset(buf->b_addr, 0, cfg->blocksize);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
libxfs_purgebuf(buf);
}
@@ -3579,7 +3579,7 @@ rewrite_secondary_superblocks(
XFS_FSS_TO_BB(mp, 1),
LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
/* and one in the middle for luck if there's enough AGs for that */
if (mp->m_sb.sb_agcount <= 2)
@@ -3591,7 +3591,7 @@ rewrite_secondary_superblocks(
XFS_FSS_TO_BB(mp, 1),
LIBXFS_READBUF_FAIL_EXIT, &xfs_sb_buf_ops);
XFS_BUF_TO_SBP(buf)->sb_rootino = cpu_to_be64(mp->m_sb.sb_rootino);
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
}
static void
@@ -3939,7 +3939,7 @@ main(
if (!buf || buf->b_error)
exit(1);
(XFS_BUF_TO_SBP(buf))->sb_inprogress = 0;
- libxfs_writebuf(buf, LIBXFS_EXIT_ON_FAILURE);
+ libxfs_writebuf(buf, LIBXFS_WRITEBUF_FAIL_EXIT);
/* Make sure our new fs made it to stable storage. */
libxfs_flush_devices(mp, &d, &l, &r);