From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/20] xfs: factor out log buffer writing from xlog_sync
Date: Fri, 24 May 2019 09:04:45 +1000 [thread overview]
Message-ID: <20190523230445.GT29573@dread.disaster.area> (raw)
In-Reply-To: <20190523173742.15551-8-hch@lst.de>
On Thu, May 23, 2019 at 07:37:29PM +0200, Christoph Hellwig wrote:
> Replace the not very useful xlog_bdstrat wrapper with a new version that
> that takes care of all the common logic for writing log buffers. Use
> the opportunity to avoid overloading the buffer address with the log
> relative address, and to shed the unused return value.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Some minor things
> @@ -1765,28 +1761,34 @@ xlog_cksum(
> return xfs_end_cksum(crc);
> }
>
> -/*
> - * The bdstrat callback function for log bufs. This gives us a central
> - * place to trap bufs in case we get hit by a log I/O error and need to
> - * shutdown. Actually, in practice, even when we didn't get a log error,
> - * we transition the iclogs to IOERROR state *after* flushing all existing
> - * iclogs to disk. This is because we don't want anymore new transactions to be
> - * started or completed afterwards.
> - *
> - * We lock the iclogbufs here so that we can serialise against IO completion
> - * during unmount. We might be processing a shutdown triggered during unmount,
> - * and that can occur asynchronously to the unmount thread, and hence we need to
> - * ensure that completes before tearing down the iclogbufs. Hence we need to
> - * hold the buffer lock across the log IO to acheive that.
> - */
> -STATIC int
> -xlog_bdstrat(
> - struct xfs_buf *bp)
> +STATIC void
> +xlog_write_iclog(
> + struct xlog *log,
> + struct xlog_in_core *iclog,
> + struct xfs_buf *bp,
> + uint64_t bno,
> + bool flush)
Can you rename this to need_flush here and in xlog_sync()? I kept
having to check whether it meant "we need a flush" or "we've
already done a flush" while reading the patch.
> {
> - struct xlog_in_core *iclog = bp->b_log_item;
> + ASSERT(bno < log->l_logBBsize);
> + ASSERT(bno + bp->b_io_length <= log->l_logBBsize);
>
> + bp->b_maps[0].bm_bn = log->l_logBBstart + bno;
> + bp->b_log_item = iclog;
> + bp->b_flags &= ~XBF_FLUSH;
> + bp->b_flags |= (XBF_ASYNC | XBF_SYNCIO | XBF_WRITE | XBF_FUA);
> + if (flush)
> + bp->b_flags |= XBF_FLUSH;
> +
> + /*
> + * We lock the iclogbufs here so that we can serialise against I/O
> + * completion during unmount. We might be processing a shutdown
> + * triggered during unmount, and that can occur asynchronously to the
> + * unmount thread, and hence we need to ensure that completes before
> + * tearing down the iclogbufs. Hence we need to hold the buffer lock
> + * across the log IO to archive that.
^^^^^^^ achieve
> + */
....
> - ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
> + iclog->ic_bp->b_io_length = BTOBB(count);
>
> xlog_verify_iclog(log, iclog, count, true);
> + xlog_write_iclog(log, iclog, iclog->ic_bp, bno, flush);
Ok, so we set the io length of the buffer before we call
xlog_write_iclog(), avoiding needing to pass the size into it.
> - /* account for log which doesn't start at block #0 */
> - XFS_BUF_SET_ADDR(bp, XFS_BUF_ADDR(bp) + log->l_logBBstart);
> -
> - /*
> - * Don't call xfs_bwrite here. We do log-syncs even when the filesystem
> - * is shutting down.
> - */
> - error = xlog_bdstrat(bp);
> - if (error) {
> - xfs_buf_ioerror_alert(bp, "xlog_sync");
> - return error;
> - }
> if (split) {
> - bp = iclog->ic_log->l_xbuf;
> - XFS_BUF_SET_ADDR(bp, 0); /* logical 0 */
> - xfs_buf_associate_memory(bp,
> + xfs_buf_associate_memory(iclog->ic_log->l_xbuf,
> (char *)&iclog->ic_header + count, split);
> - bp->b_log_item = iclog;
> - bp->b_flags &= ~XBF_FLUSH;
> - bp->b_flags |= (XBF_ASYNC | XBF_SYNCIO | XBF_WRITE | XBF_FUA);
> -
> - ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1);
> - ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
> -
> - /* account for internal log which doesn't start at block #0 */
> - XFS_BUF_SET_ADDR(bp, XFS_BUF_ADDR(bp) + log->l_logBBstart);
> - error = xlog_bdstrat(bp);
> - if (error) {
> - xfs_buf_ioerror_alert(bp, "xlog_sync (split)");
> - return error;
> - }
> + xlog_write_iclog(log, iclog, iclog->ic_log->l_xbuf, 0, false);
But on the extra buffer, we don't set it's I/O length at all....
Oh, the setting of the IO length is hidden inside
xfs_buf_associate_memory(). Can you add a comment indicating that
this is why we omit the setting of the io length for the extra
buffer?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2019-05-23 23:04 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 17:37 use bios directly in the log code v2 Christoph Hellwig
2019-05-23 17:37 ` [PATCH 01/20] xfs: remove the no-op spinlock_destroy stub Christoph Hellwig
2019-05-23 22:31 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 02/20] xfs: remove the never used _XBF_COMPOUND flag Christoph Hellwig
2019-05-23 22:31 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 03/20] xfs: renumber XBF_WRITE_FAIL Christoph Hellwig
2019-05-23 22:32 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 04/20] xfs: make mem_to_page available outside of xfs_buf.c Christoph Hellwig
2019-05-23 22:33 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 05/20] xfs: reformat xlog_get_lowest_lsn Christoph Hellwig
2019-05-23 22:34 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 06/20] xfs: don't use REQ_PREFLUSH for split log writes Christoph Hellwig
2019-05-23 22:39 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 07/20] xfs: factor out log buffer writing from xlog_sync Christoph Hellwig
2019-05-23 23:04 ` Dave Chinner [this message]
2019-05-24 6:14 ` Christoph Hellwig
2019-05-23 17:37 ` [PATCH 08/20] xfs: factor out splitting of an iclog " Christoph Hellwig
2019-05-23 23:17 ` Dave Chinner
2019-05-24 6:16 ` Christoph Hellwig
2019-05-23 17:37 ` [PATCH 09/20] xfs: factor out iclog size calculation " Christoph Hellwig
2019-05-23 23:25 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 10/20] xfs: update both stat counters together in xlog_sync Christoph Hellwig
2019-05-23 23:25 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 11/20] xfs: remove the syncing argument from xlog_verify_iclog Christoph Hellwig
2019-05-23 23:27 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 12/20] xfs: make use of the l_targ field in struct xlog Christoph Hellwig
2019-05-23 23:31 ` Dave Chinner
2019-05-23 17:37 ` [PATCH 13/20] xfs: use bios directly to write log buffers Christoph Hellwig
2019-05-23 17:37 ` [PATCH 14/20] xfs: move the log ioend workqueue to struct xlog Christoph Hellwig
2019-05-23 17:37 ` [PATCH 15/20] xfs: return an offset instead of a pointer from xlog_align Christoph Hellwig
2019-05-23 17:37 ` [PATCH 16/20] xfs: use bios directly to read and write the log recovery buffers Christoph Hellwig
2019-05-23 17:37 ` [PATCH 17/20] xfs: stop using bp naming for " Christoph Hellwig
2019-05-23 17:37 ` [PATCH 18/20] xfs: remove unused buffer cache APIs Christoph Hellwig
2019-05-23 17:37 ` [PATCH 19/20] xfs: properly type the b_log_item field in struct xfs_buf Christoph Hellwig
2019-05-23 17:37 ` [PATCH 20/20] xfs: remove the b_io_length " Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2019-06-03 17:29 use bios directly in the log code v2 Christoph Hellwig
2019-06-03 17:29 ` [PATCH 07/20] xfs: factor out log buffer writing from xlog_sync Christoph Hellwig
2019-06-04 2:20 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190523230445.GT29573@dread.disaster.area \
--to=david@fromorbit.com \
--cc=hch@lst.de \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox