wbuf *
wbuf_init(wbuf *buf, int data_size, int data_align, int min_io_size, int id)
{
- buf->id = id;
- if ((buf->data = memalign(data_align, data_size)) == NULL)
- return NULL;
+ ASSERT(data_size % BBSIZE == 0);
+ while ((buf->data = memalign(data_align, data_size)) == NULL) {
+ data_size >>= 1;
+ if (data_size < min_io_size)
+ return NULL;
+ }
ASSERT(min_io_size % BBSIZE == 0);
buf->min_io_size = min_io_size;
- buf->size = MAX(data_size, 2*min_io_size);
+ buf->size = data_size;
+ buf->id = id;
return buf;
}
off = XFS_AG_DADDR(mp, agno, XFS_SB_DADDR);
buf->position = (xfs_off_t) off * (xfs_off_t) BBSIZE;
length = buf->length = first_agbno * blocksize;
-
+
/* handle alignment stuff */
newpos = rounddown(buf->position, (xfs_off_t) buf->min_io_size);
}
wbuf_align = d.d_mem;
- wbuf_size = d.d_maxiosz;
+ wbuf_size = MIN(d.d_maxiosz, 1 * 1024 * 1024);
wbuf_miniosize = d.d_miniosz;
} else {
/* set arbitrary I/O params, miniosize at least 1 disk block */
- wbuf_align = 4096*4;
- wbuf_size = 1024 * 4000;
+ wbuf_align = getpagesize();
+ wbuf_size = 1 * 1024 * 1024;
wbuf_miniosize = -1; /* set after mounting source fs */
}
for (i = 0; i < num_targets; i++) {
int write_last_block = 0;
-
+
if (stat64(target[i].name, &statbuf) < 0) {
/* ok, assume it's a file and create it */
exit(1);
}
/* need to start out blocking */
- pthread_mutex_lock(&mainwait);
+ pthread_mutex_lock(&mainwait);
/* set up sigchild signal handler */
exit(1);
}
/* need to start out blocking */
- pthread_mutex_lock(&tcarg->wait);
+ pthread_mutex_lock(&tcarg->wait);
}
for (i = 0, tcarg = targ; i < num_targets; i++, tcarg++) {
check_errors();
killall();
- pthread_exit(NULL);
+ pthread_exit(NULL);
/*NOTREACHED*/
return 0;
}
/*
* Writes a log header at the start of the log (with the real
* filesystem UUID embedded into it), and writes to all targets.
- *
+ *
* Returns the next buffer-length-aligned disk address.
*/
xfs_off_t
next_log_chunk, buf);
do_write(buf->owner);
- return logstart + roundup(offset, buf->length);
+ return roundup(logstart + offset, buf->length);
}
/*