From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH v3 15/18] xfs_copy: genericize write helper to facilitate separate log buf
Date: Fri, 2 Oct 2015 14:19:52 -0400 [thread overview]
Message-ID: <1443809995-20395-16-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1443809995-20395-1-git-send-email-bfoster@redhat.com>
xfs_copy uses a fixed write buffer throughout the code for the various
targets. This is a global buffer and is assumed to be the write source
in the do_write() helper used by the log clearing code.
v5 superblock log formatting will require a larger, independent buffer
to format the log. Therefore, update do_write() to accept a write buffer
parameter to optionally override the global write buffer. This patch
does not change current behavior.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
copy/xfs_copy.c | 34 ++++++++++++++++++++--------------
1 file changed, 20 insertions(+), 14 deletions(-)
diff --git a/copy/xfs_copy.c b/copy/xfs_copy.c
index f3e5288..0481ece 100644
--- a/copy/xfs_copy.c
+++ b/copy/xfs_copy.c
@@ -170,20 +170,26 @@ check_errors(void)
* are taken care of when the buffer's read in
*/
int
-do_write(thread_args *args)
+do_write(
+ thread_args *args,
+ wbuf *buf)
{
- int res, error = 0;
+ int res;
+ int error = 0;
- if (target[args->id].position != w_buf.position) {
- if (lseek64(args->fd, w_buf.position, SEEK_SET) < 0) {
+ if (!buf)
+ buf = &w_buf;
+
+ if (target[args->id].position != buf->position) {
+ if (lseek64(args->fd, buf->position, SEEK_SET) < 0) {
error = target[args->id].err_type = 1;
} else {
- target[args->id].position = w_buf.position;
+ target[args->id].position = buf->position;
}
}
- if ((res = write(target[args->id].fd, w_buf.data,
- w_buf.length)) == w_buf.length) {
+ if ((res = write(target[args->id].fd, buf->data,
+ buf->length)) == buf->length) {
target[args->id].position += res;
} else {
error = 2;
@@ -191,7 +197,7 @@ do_write(thread_args *args)
if (error) {
target[args->id].error = errno;
- target[args->id].position = w_buf.position;
+ target[args->id].position = buf->position;
}
return error;
}
@@ -203,7 +209,7 @@ begin_reader(void *arg)
for (;;) {
pthread_mutex_lock(&args->wait);
- if (do_write(args))
+ if (do_write(args, NULL))
goto handle_error;
pthread_mutex_lock(&glob_masks.mutex);
if (--glob_masks.num_working == 0)
@@ -1168,7 +1174,7 @@ main(int argc, char **argv)
memset(w_buf.data, 0, w_buf.length);
while (w_buf.position < end_pos) {
- do_write(tcarg);
+ do_write(tcarg, NULL);
w_buf.position += w_buf.length;
}
tcarg++;
@@ -1190,7 +1196,7 @@ main(int argc, char **argv)
for (j = 0, tcarg = targ; j < num_targets; j++) {
sb_update_uuid(sb, &ag_hdr, tcarg);
- do_write(tcarg);
+ do_write(tcarg, NULL);
tcarg++;
}
}
@@ -1212,7 +1218,7 @@ next_log_chunk(char *p, int offset, void *private)
if (buf->length < (int)(p - buf->data) + offset) {
/* need to flush this one, then start afresh */
- do_write(buf->owner);
+ do_write(buf->owner, NULL);
memset(buf->data, 0, buf->length);
return buf->data;
}
@@ -1247,7 +1253,7 @@ write_log_header(int fd, wbuf *buf, xfs_mount_t *mp)
xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
mp->m_sb.sb_logsunit, XLOG_FMT, NULLCOMMITLSN,
NULLCOMMITLSN, next_log_chunk, buf);
- do_write(buf->owner);
+ do_write(buf->owner, NULL);
return roundup(logstart + offset, buf->length);
}
@@ -1272,7 +1278,7 @@ write_log_trailer(int fd, wbuf *buf, xfs_mount_t *mp)
read_wbuf(fd, buf, mp);
offset = (int)(logend - buf->position);
memset(buf->data, 0, offset);
- do_write(buf->owner);
+ do_write(buf->owner, NULL);
}
return buf->position;
--
2.1.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-10-02 18:20 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 18:19 [PATCH v3 00/18] xfsprogs: format the log correctly on v5 supers Brian Foster
2015-10-02 18:19 ` [PATCH v3 01/18] libxfs: validate metadata LSNs against log on v5 superblocks Brian Foster
2015-10-02 18:19 ` [PATCH v3 02/18] libxfs: track largest metadata LSN in use via verifiers Brian Foster
2015-10-02 18:19 ` [PATCH v3 03/18] libxfs: don't hardcode cycle 1 into unmount op header Brian Foster
2015-10-02 18:19 ` [PATCH v3 04/18] libxfs: pass lsn param to log clear and record header logging helpers Brian Foster
2015-10-02 18:19 ` [PATCH v3 05/18] libxfs: add ability to clear log to arbitrary log cycle Brian Foster
2015-10-02 18:19 ` [PATCH v3 06/18] libxlog: pull struct xlog out of xlog_is_dirty() Brian Foster
2015-10-02 18:19 ` [PATCH v3 07/18] xfs_repair: track log state throughout all recovery phases Brian Foster
2015-10-02 18:19 ` [PATCH v3 08/18] xfs_repair: process the log in no_modify mode Brian Foster
2015-10-02 18:19 ` [PATCH v3 09/18] xfs_repair: format the log with forward cycle number on v5 supers Brian Foster
2015-10-02 18:19 ` [PATCH v3 10/18] xfs_repair: don't clear the log by default Brian Foster
2015-10-02 18:19 ` [PATCH v3 11/18] xfs_repair: seed the max lsn from log state in phase 2 Brian Foster
2015-10-02 18:19 ` [PATCH v3 12/18] xfs_db: do not reset current lsn from uuid command on v5 supers Brian Foster
2015-10-02 18:19 ` [PATCH v3 13/18] db/metadump: bump lsn when log is cleared " Brian Foster
2015-10-02 18:19 ` [PATCH v3 14/18] xfs_copy: check for dirty log on non-duplicate copies Brian Foster
2015-10-02 18:19 ` Brian Foster [this message]
2015-10-02 18:19 ` [PATCH v3 16/18] xfs_copy: store data buf alignment in buf data structure Brian Foster
2015-10-02 18:19 ` [PATCH v3 17/18] xfs_copy: refactor log format code into new helper Brian Foster
2015-10-02 18:19 ` [PATCH v3 18/18] xfs_copy: format v5 sb logs correctly Brian Foster
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=1443809995-20395-16-git-send-email-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=xfs@oss.sgi.com \
/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